summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--xc/programs/Xserver/dbe/Imakefile26
-rw-r--r--xc/programs/Xserver/dbe/midbe.c7
-rw-r--r--xc/programs/Xserver/dbe/module/Imakefile33
-rw-r--r--xc/programs/Xserver/dix/dispatch.c34
-rw-r--r--xc/programs/Xserver/dix/dixfonts.c119
-rw-r--r--xc/programs/Xserver/dix/events.c222
-rw-r--r--xc/programs/Xserver/dix/main.c7
-rw-r--r--xc/programs/Xserver/fb/Imakefile16
-rw-r--r--xc/programs/Xserver/fb/fb.h120
-rw-r--r--xc/programs/Xserver/fb/fb24_32.c616
-rw-r--r--xc/programs/Xserver/fb/fb24_32.h49
-rw-r--r--xc/programs/Xserver/fb/fballpriv.c31
-rw-r--r--xc/programs/Xserver/fb/fbarc.c5
-rw-r--r--xc/programs/Xserver/fb/fbbltone.c7
-rw-r--r--xc/programs/Xserver/fb/fbcopy.c15
-rw-r--r--xc/programs/Xserver/fb/fbgc.c28
-rw-r--r--xc/programs/Xserver/fb/fbgetsp.c10
-rw-r--r--xc/programs/Xserver/fb/fbimage.c41
-rw-r--r--xc/programs/Xserver/fb/fboverlay.c192
-rw-r--r--xc/programs/Xserver/fb/fboverlay.h91
-rw-r--r--xc/programs/Xserver/fb/fbpixmap.c24
-rw-r--r--xc/programs/Xserver/fb/fbscreen.c46
-rw-r--r--xc/programs/Xserver/fb/fbsetsp.c9
-rw-r--r--xc/programs/Xserver/fb/fbwindow.c32
-rw-r--r--xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c36
-rw-r--r--xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h6
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/Imakefile14
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igs.c665
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igs.h329
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igscmap.c61
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igscurs.c344
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igsdraw.c1532
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igsdraw.h260
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igsreg.c968
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igsreg.h70
-rw-r--r--xc/programs/Xserver/hw/kdrive/igs/igsstub.c63
-rw-r--r--xc/programs/Xserver/hw/kdrive/kcmap.c127
-rw-r--r--xc/programs/Xserver/hw/kdrive/kcurscol.c31
-rw-r--r--xc/programs/Xserver/hw/kdrive/kdrive.c130
-rw-r--r--xc/programs/Xserver/hw/kdrive/kdrive.h43
-rw-r--r--xc/programs/Xserver/hw/kdrive/kinput.c5
-rw-r--r--xc/programs/Xserver/hw/kdrive/kmode.c16
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3.c834
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3.h199
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3clock.c12
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3cmap.c15
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3curs.c51
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3draw.c991
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3draw.h18
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3reg.c62
-rw-r--r--xc/programs/Xserver/hw/kdrive/savage/s3reg.h14
-rw-r--r--xc/programs/Xserver/hw/kdrive/sis530/sis.c100
-rw-r--r--xc/programs/Xserver/hw/kdrive/sis530/sis.h6
-rw-r--r--xc/programs/Xserver/hw/kdrive/sis530/siscmap.c6
-rw-r--r--xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c6
-rw-r--r--xc/programs/Xserver/hw/kdrive/trident/trident.c4
-rw-r--r--xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c6
-rw-r--r--xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c6
-rw-r--r--xc/programs/Xserver/hw/kdrive/trio/s3.c108
-rw-r--r--xc/programs/Xserver/hw/kdrive/trio/s3.h19
-rw-r--r--xc/programs/Xserver/hw/kdrive/trio/s3cmap.c6
-rw-r--r--xc/programs/Xserver/hw/kdrive/trio/s3curs.c6
-rw-r--r--xc/programs/Xserver/hw/kdrive/vga.c7
-rw-r--r--xc/programs/Xserver/hw/kdrive/vga.h4
-rw-r--r--xc/programs/Xserver/hw/sun/Imakefile6
-rw-r--r--xc/programs/Xserver/hw/sun/kbd_mode.c4
-rw-r--r--xc/programs/Xserver/hw/sun/sun.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/CHANGELOG790
-rw-r--r--xc/programs/Xserver/hw/xfree86/DebuggingHints192
-rw-r--r--xc/programs/Xserver/hw/xfree86/Imakefile16
-rw-r--r--xc/programs/Xserver/hw/xfree86/RAC.Notes19
-rw-r--r--xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c17
-rw-r--r--xc/programs/Xserver/hw/xfree86/XF86Config.cpp286
-rw-r--r--xc/programs/Xserver/hw/xfree86/XF98Conf.cpp16
-rw-r--r--xc/programs/Xserver/hw/xfree86/XFree86.cpp8
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/Imakefile15
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/compiler.h295
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/fourcc.h89
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86.h76
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Bus.c392
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Bus.h16
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Config.c57
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Configure.c165
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86DGA.c80
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Events.c16
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Helper.c279
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Init.c21
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Io.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c74
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Mode.c73
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Module.h8
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Option.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h155
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Priv.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Resources.h14
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86XKB.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c48
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86cmap.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86cmap.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86fbman.c599
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86fbman.h31
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c152
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c725
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.h88
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86str.h27
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86xv.c197
-rw-r--r--xc/programs/Xserver/hw/xfree86/common/xf86xv.h13
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/edid.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/print_edid.c364
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/vdif.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/DESIGN268
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/Imakefile5
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/Install224
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/Japanese/README98164
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/read98.sgml138
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/LICENSE2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/OS2.Notes24
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README214
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.DECtga6
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.DRI379
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp417
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.LynxOS35
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.NetBSD38
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD41
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.SiS2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.apm2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.ati208
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.chips47
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.cyrix2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.fonts2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.i7402
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.i8102
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.isc2
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.mouse4
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.r1288
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.rendition35
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/README.s3virge4
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/RELNOTES403
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/Status169
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/VideoBoard9868
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml240
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml463
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml490
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml16
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile23
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml212
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml7
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml11
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml17
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml20
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml188
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml339
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml20
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml161
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml34
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent14
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/index.post16
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre5
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/mdefs.cpp14
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml6
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml28
-rw-r--r--xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml19
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c49
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c17
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c154
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c14
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile18
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp22
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c285
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c68
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h71
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c48
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c342
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h33
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c24
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c821
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h23
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c11
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c493
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c98
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h33
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c52
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h49
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h6
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c76
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h16
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp76
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c267
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h25
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c1121
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c22
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c244
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c106
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile16
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h34
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c178
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c252
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c54
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c116
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp25
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c60
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile17
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm355
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c133
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c28
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c41
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c85
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp67
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h63
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c294
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c125
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c1291
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h68
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c3109
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c1778
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c596
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/sx_accel.c926
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c22
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c106
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i740/i740_accel.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c120
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile21
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h59
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c16
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c292
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c420
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h43
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c164
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_io.c26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c63
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile52
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h63
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c143
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c1292
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h215
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp56
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h71
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c1087
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h127
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c180
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h16
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c390
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c620
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c198
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.h8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile11
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h22
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c292
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c220
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile5
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp36
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c66
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c54
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile24
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/README4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h170
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c129
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c117
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c378
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c1289
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h116
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h54
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c920
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h769
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h77
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c253
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c234
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp42
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c134
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c93
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c18
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c14
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h6
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c87
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h34
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c205
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h12
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c104
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h14
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile3
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/README4
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES26
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c27
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c196
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c27
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c27
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp50
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile40
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h71
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c7
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c53
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c62
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c601
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c292
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c250
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c180
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.h121
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c184
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.h158
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c664
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunbw2/Imakefile38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2.h50
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c588
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg14/Imakefile38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14.h71
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c673
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg3/Imakefile38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3.h50
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c592
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg6/Imakefile38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6.h97
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_cursor.c121
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c665
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_regs.h194
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile126
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/VISmoveImage.s2710
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h317
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c951
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_asm.s349
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_attr.c256
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c561
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_checks.c288
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_circle.c210
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.c103
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.h49
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cplane.c393
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cursor.c139
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.c491
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.h363
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dbe.c901
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_ddc.c195
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c280
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dri.c488
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_drishare.h53
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c1090
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fifo.h69
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_frect.c709
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fspans.c121
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c752
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.h151
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_glyph.c380
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gspans.c130
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_line.c195
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_loops.h212
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_plygon.c167
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_point.c108
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h333
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rect.c207
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h509
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_seg.c196
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_sspans.c166
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.c64
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.h36
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stubs.c544
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c461
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wline.c897
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_zeroarc.c536
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/Imakefile42
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h106
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c195
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_bcopy.c178
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_checks.c180
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_cursor.c155
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c690
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frect.c233
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frectsp.c276
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspans.c127
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspanssp.c166
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c590
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.h81
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_glyph.c325
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_regs.h198
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_stubs.c104
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suntcx/Imakefile38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp30
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx.h69
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_cursor.c156
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c769
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_regs.h56
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile23
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h55
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c98
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c14
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c350
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c574
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c54
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c75
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c769
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h183
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h38
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c293
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c472
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h111
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c44
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c448
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c97
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp24
-rw-r--r--xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c11
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh183
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar33
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def8
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-excl10
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list60
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/dir1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-dir1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/fsrv-list2
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-excl14
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-list2
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-excl3
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/mod-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/nest-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-excl5
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-list3
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prt-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list5
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-dir1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/vfb-list1
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/xserv-list2
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/bindist/os2/host.def7
-rw-r--r--xc/programs/Xserver/hw/xfree86/etc/scanpci.c123
-rw-r--r--xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c55
-rw-r--r--xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp4
-rw-r--r--xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c37
-rw-r--r--xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp23
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile7
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp40
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp38
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp23
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c79
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp59
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h29
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mouse/mousePriv.h27
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile7
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp40
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/void/void.cpp20
-rw-r--r--xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp23
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/Imakefile14
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/generic.c294
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/helper_exec.c26
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/helper_mem.c50
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/xf86int10.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/xf86int10.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/dixsym.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/elfloader.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/extsym.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/loader.c23
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/loadmod.c39
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/misym.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/os2funcs.c217
-rw-r--r--xc/programs/Xserver/hw/xfree86/loader/xf86sym.c91
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/Imakefile11
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile28
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile41
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c56
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile31
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Makefile.bsd5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h362
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/Makefile16
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/agpsupport.c270
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/auth.c168
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/bufs.c500
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/context.c297
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ctxbitmap.c85
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/dma.c543
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drawable.c50
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drmstat.c418
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/fops.c261
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/init.c100
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ioctl.c120
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lists.c258
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lock.c220
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/memory.c458
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/proc.c568
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/sysctl.c554
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/vm.c104
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h723
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/Makefile15
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_dma.c824
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.c629
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.h48
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h188
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/Makefile16
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_bufs.c604
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_context.c196
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_dma.c1106
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.c714
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.h420
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_state.c1074
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h269
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h111
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/Makefile15
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_context.c204
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.c738
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.h45
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drm.c1108
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c435
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c86
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c116
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c198
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c219
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c490
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile18
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c44
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h15
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c581
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h40
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile13
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h1
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile17
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel22
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux85
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c22
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c15
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c17
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c28
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h96
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h142
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c16
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c35
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c66
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c416
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c205
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c1572
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h188
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c159
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h166
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c156
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c437
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c66
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c1495
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h269
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c135
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h359
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c1139
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c15
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c308
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c213
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c922
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h111
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c737
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h226
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c26
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c55
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h6
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c36
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c276
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c87
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c117
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c197
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c38
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c16
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c5
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c90
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c56
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c27
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile12
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile110
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c451
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c38
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c17
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c469
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c21
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c178
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c34
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile10
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c20
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile16
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile14
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h96
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c36
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c43
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c15
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile9
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile7
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile9
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile25
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/vbe/module/Imakefile31
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c44
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h17
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h40
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h6
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h67
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drmI810.h46
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h147
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h80
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Configint.h8
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/DRI.c19
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Device.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Flags.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Layout.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Module.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Monitor.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/Screen.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/read.c4
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/scan.c20
-rw-r--r--xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h6
-rw-r--r--xc/programs/Xserver/hw/xfree86/ramdac/TI.c329
-rw-r--r--xc/programs/Xserver/hw/xfree86/ramdac/TI.h7
-rw-r--r--xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h5
-rw-r--r--xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c12
-rw-r--r--xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h11
-rw-r--r--xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c11
-rw-r--r--xc/programs/Xserver/hw/xfree86/scanpci/Imakefile24
-rw-r--r--xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile33
-rw-r--r--xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c11
-rw-r--r--xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c11
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/Imakefile6
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP7
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO15
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaa.h15
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c57
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c70
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c42
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c2
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c6
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c87
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c25
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c341
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c19
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c10
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c3
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaStateChange.c1628
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c252
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c42
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h10
-rw-r--r--xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h163
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h3
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c16
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c14
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86Version.h8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile76
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad1291
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c687
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c316
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.h44
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/card.xbm59
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/card.xpm81
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c462
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/cards.h73
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/computer.xpm91
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/config.c291
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/config.h195
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/down.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/help.c1785
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/help.h42
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c1861
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c814
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.h74
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xbm59
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xpm66
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/left.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c448
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h44
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xbm59
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xpm79
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c431
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.h44
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xbm59
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xpm76
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/narrower.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/options.c284
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/options.h38
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/right.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c439
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.h44
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c978
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h51
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/shorter.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c119
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/taller.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/up.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c1236
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.h63
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/wider.xbm8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man121
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c595
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h69
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86config/Cards280
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86config/Imakefile8
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c60
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cmd99
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c23
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32wid/Imakefile33
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32wid.h93
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32widmodule.c46
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbscrinit.c382
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwid.c147
-rw-r--r--xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwindow.c285
-rw-r--r--xc/programs/Xserver/hw/xnest/Display.h4
-rw-r--r--xc/programs/Xserver/hw/xnest/Imakefile8
-rw-r--r--xc/programs/Xserver/include/dix.h32
-rw-r--r--xc/programs/Xserver/include/dixstruct.h7
-rw-r--r--xc/programs/Xserver/include/globals.h4
-rw-r--r--xc/programs/Xserver/include/os.h28
-rw-r--r--xc/programs/Xserver/include/scrnintstr.h6
-rw-r--r--xc/programs/Xserver/include/servermd.h17
-rw-r--r--xc/programs/Xserver/include/site.h10
-rw-r--r--xc/programs/Xserver/lbx/lbxcmap.c122
-rw-r--r--xc/programs/Xserver/lbx/lbxdix.c112
-rw-r--r--xc/programs/Xserver/lbx/lbxexts.c58
-rw-r--r--xc/programs/Xserver/lbx/lbxgfx.c119
-rw-r--r--xc/programs/Xserver/lbx/lbxmain.c260
-rw-r--r--xc/programs/Xserver/lbx/lbxopts.c212
-rw-r--r--xc/programs/Xserver/lbx/lbxprop.c48
-rw-r--r--xc/programs/Xserver/lbx/lbxserve.h199
-rw-r--r--xc/programs/Xserver/lbx/lbxsquish.c6
-rw-r--r--xc/programs/Xserver/lbx/lbxsrvopts.h43
-rw-r--r--xc/programs/Xserver/lbx/lbxswap.c138
-rw-r--r--xc/programs/Xserver/lbx/lbxtables.c8
-rw-r--r--xc/programs/Xserver/lbx/lbxtags.c59
-rw-r--r--xc/programs/Xserver/lbx/lbxtags.h57
-rw-r--r--xc/programs/Xserver/lbx/lbxzerorep.c8
-rw-r--r--xc/programs/Xserver/mi/Imakefile3
-rw-r--r--xc/programs/Xserver/mi/miinitext.c6
-rw-r--r--xc/programs/Xserver/mi/mioverlay.c14
-rw-r--r--xc/programs/Xserver/os/Imakefile11
-rw-r--r--xc/programs/Xserver/os/WaitFor.c43
-rw-r--r--xc/programs/Xserver/os/connection.c41
-rw-r--r--xc/programs/Xserver/os/io.c4
-rw-r--r--xc/programs/Xserver/os/lbxio.c4
-rw-r--r--xc/programs/Xserver/os/secauth.c12
-rw-r--r--xc/programs/Xserver/os/utils.c270
-rw-r--r--xc/programs/Xserver/os/xalloc.c4
-rw-r--r--xc/programs/Xserver/record/Imakefile22
-rw-r--r--xc/programs/Xserver/record/module/Imakefile33
-rw-r--r--xc/programs/Xserver/xkb/Imakefile5
-rw-r--r--xc/programs/Xserver/xkb/ddxFakeMtn.c92
-rw-r--r--xc/programs/Xserver/xkb/ddxLoad.c14
-rw-r--r--xc/programs/Xserver/xkb/xkb.c8
-rw-r--r--xc/programs/Xserver/xkb/xkbActions.c11
-rw-r--r--xc/programs/Xserver/xkb/xkbEvents.c26
-rw-r--r--xc/programs/Xserver/xkb/xkbInit.c55
-rw-r--r--xc/programs/Xserver/xkb/xkbPrKeyEv.c52
-rw-r--r--xc/util/memleak/fmalloc.c15
868 files changed, 115141 insertions, 16525 deletions
diff --git a/xc/programs/Xserver/dbe/Imakefile b/xc/programs/Xserver/dbe/Imakefile
index 6e09449d9..7d171eed5 100644
--- a/xc/programs/Xserver/dbe/Imakefile
+++ b/xc/programs/Xserver/dbe/Imakefile
@@ -3,30 +3,34 @@ XCOMM $XConsortium: Imakefile /main/2 1996/09/28 17:06:40 rws $
-XCOMM $XFree86: xc/programs/Xserver/dbe/Imakefile,v 3.7 1999/08/14 10:49:27 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/dbe/Imakefile,v 3.9 2000/04/06 14:47:46 dawes Exp $
+
+#if DoLoadableServer
+#define IHaveSubdirs
+#endif
-#define IHaveModules
#include <Server.tmpl>
#if DoLoadableServer
- MSRCS = dbemodule.c
- MOBJS = dbemodule.o
+ SUBDIRS = module
#endif
- SRCS = dbe.c midbe.c $(MSRCS)
- OBJS = dbe.o midbe.o $(MOBJS)
- INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(EXTRAINCLUDES)
+ SRCS = dbe.c midbe.c
+ OBJS = dbe.o midbe.o
+ INCLUDES = -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(EXTRAINCLUDES)
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
-ModuleObjectRule()
+NormalLibraryObjectRule()
-LibraryModuleTarget(dbe,$(OBJS))
+NormalLibraryTarget(dbe,$(OBJS))
LintLibraryTarget(dbe,$(SRCS))
NormalLintTarget($(SRCS))
-InstallLibraryModule(dbe,$(MODULEDIR),extensions)
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
DependTarget()
-InstallDriverSDKLibraryModule(dbe,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/xc/programs/Xserver/dbe/midbe.c b/xc/programs/Xserver/dbe/midbe.c
index 20b14baa3..c6b812d48 100644
--- a/xc/programs/Xserver/dbe/midbe.c
+++ b/xc/programs/Xserver/dbe/midbe.c
@@ -30,13 +30,13 @@
* Machine-independent DBE code
*
*****************************************************************************/
+/* $XFree86: xc/programs/Xserver/dbe/midbe.c,v 3.2 2000/04/06 14:47:46 dawes Exp $ */
/* INCLUDES */
#define NEED_REPLIES
#define NEED_EVENTS
-#include <stdio.h>
#include "X.h"
#include "Xproto.h"
#include "misc.h"
@@ -54,6 +54,11 @@
#include "gcstruct.h"
#include "inputstr.h"
+#ifndef IN_MODULE
+#include <stdio.h>
+#else
+#include "xf86_ansic.h"
+#endif
/* DEFINES */
diff --git a/xc/programs/Xserver/dbe/module/Imakefile b/xc/programs/Xserver/dbe/module/Imakefile
new file mode 100644
index 000000000..cf7d38dde
--- /dev/null
+++ b/xc/programs/Xserver/dbe/module/Imakefile
@@ -0,0 +1,33 @@
+XCOMM $XConsortium: Imakefile /main/2 1996/09/28 17:06:40 rws $
+
+XCOMM $XFree86: xc/programs/Xserver/dbe/module/Imakefile,v 1.1 2000/04/06 15:35:03 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ MSRCS = dbemodule.c
+ MOBJS = dbemodule.o
+#endif
+
+ SRCS = dbe.c midbe.c $(MSRCS)
+ OBJS = dbe.o midbe.o $(MOBJS)
+ INCLUDES = -I.. -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(EXTRAINCLUDES)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln
+
+LinkSourceFile(dbemodule.c,..)
+LinkSourceFile(midbe.c,..)
+LinkSourceFile(dbe.c,..)
+
+ModuleObjectRule()
+
+LibraryModuleTarget(dbe,$(OBJS))
+
+LintLibraryTarget(dbe,$(SRCS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(dbe,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(dbe,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/xc/programs/Xserver/dix/dispatch.c b/xc/programs/Xserver/dix/dispatch.c
index 9250a65ab..92942edd7 100644
--- a/xc/programs/Xserver/dix/dispatch.c
+++ b/xc/programs/Xserver/dix/dispatch.c
@@ -64,7 +64,7 @@ SOFTWARE.
* *
*****************************************************************/
-/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.18 2000/02/12 03:39:39 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/dispatch.c,v 3.19 2000/05/05 17:53:46 keithp Exp $ */
#ifdef PANORAMIX_DEBUG
#include <stdio.h>
@@ -253,17 +253,18 @@ FlushClientCaches(id)
}
#ifdef SMART_SCHEDULE
+#undef SMART_DEBUG
+
#define SMART_SCHEDULE_DEFAULT_INTERVAL 20 /* ms */
#define SMART_SCHEDULE_MAX_SLICE 200 /* ms */
Bool SmartScheduleDisable;
-int SmartMaxPriority = 20;
-int SmartMinPriority = -20;
long SmartScheduleSlice = SMART_SCHEDULE_DEFAULT_INTERVAL;
long SmartScheduleInterval = SMART_SCHEDULE_DEFAULT_INTERVAL;
+long SmartScheduleMaxSlice = SMART_SCHEDULE_MAX_SLICE;
long SmartScheduleTime;
ClientPtr SmartLastClient;
-int SmartLastIndex;
+int SmartLastIndex[SMART_MAX_PRIORITY-SMART_MIN_PRIORITY+1];
#ifdef SMART_DEBUG
long SmartLastPrint;
@@ -283,20 +284,21 @@ SmartScheduleClient (int *clientReady, int nready)
bestPrio = -0x7fffffff;
bestRobin = 0;
- idle = nready * 2 * SmartScheduleSlice;
+ idle = 2 * SmartScheduleSlice;
for (i = 0; i < nready; i++)
{
client = clientReady[i];
pClient = clients[client];
/* Praise clients which are idle */
- if ((now - pClient->smart_stop_tick) >= idle)
+ if ((now - pClient->smart_check_tick) >= idle)
{
if (pClient->smart_priority < 0)
pClient->smart_priority++;
}
+ pClient->smart_check_tick = now;
/* check priority to select best client */
- robin = (pClient->index - SmartLastIndex) & 0xff;
+ robin = (pClient->index - SmartLastIndex[pClient->smart_priority-SMART_MIN_PRIORITY]) & 0xff;
if (pClient->smart_priority > bestPrio ||
(pClient->smart_priority == bestPrio && robin > bestRobin))
{
@@ -316,14 +318,15 @@ SmartScheduleClient (int *clientReady, int nready)
SmartLastPrint = now;
}
#endif
+ pClient = clients[best];
+ SmartLastIndex[bestPrio-SMART_MIN_PRIORITY] = pClient->index;
/*
* Set current client pointer
*/
- if (SmartLastClient != clients[best])
+ if (SmartLastClient != pClient)
{
- SmartLastClient = clients[best];
- SmartLastIndex = SmartLastClient->index;
- SmartLastClient->smart_start_tick = now;
+ pClient->smart_start_tick = now;
+ SmartLastClient = pClient;
}
/*
* Adjust slice
@@ -335,10 +338,10 @@ SmartScheduleClient (int *clientReady, int nready)
* has run, bump the slice up to get maximal
* performance from a single client
*/
- if ((now - SmartLastClient->smart_start_tick) > 1000 &&
- SmartScheduleSlice < SMART_SCHEDULE_MAX_SLICE)
+ if ((now - pClient->smart_start_tick) > 1000 &&
+ SmartScheduleSlice < SmartScheduleMaxSlice)
{
- SmartScheduleSlice += 20;
+ SmartScheduleSlice += SmartScheduleInterval;
}
}
else
@@ -425,7 +428,7 @@ Dispatch()
(SmartScheduleTime - start_tick) >= SmartScheduleSlice)
{
/* Penalize clients which consume ticks */
- if (client->smart_priority > SmartMinPriority)
+ if (client->smart_priority > SMART_MIN_PRIORITY)
client->smart_priority--;
break;
}
@@ -3697,6 +3700,7 @@ void InitClient(client, i, ospriv)
client->smart_priority = 0;
client->smart_start_tick = SmartScheduleTime;
client->smart_stop_tick = SmartScheduleTime;
+ client->smart_check_tick = SmartScheduleTime;
#endif
}
diff --git a/xc/programs/Xserver/dix/dixfonts.c b/xc/programs/Xserver/dix/dixfonts.c
index 18e22c9fc..f780bc07b 100644
--- a/xc/programs/Xserver/dix/dixfonts.c
+++ b/xc/programs/Xserver/dix/dixfonts.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.22 2000/02/08 17:18:54 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/dixfonts.c,v 3.23 2000/04/04 19:24:47 dawes Exp $ */
/************************************************************************
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
@@ -1732,12 +1732,13 @@ find_existing_fpe(list, num, name, len)
static int
#if NeedFunctionPrototypes
-SetFontPathElements(int npaths, unsigned char *paths, int *bad)
+SetFontPathElements(int npaths, unsigned char *paths, int *bad, Bool persist)
#else
-SetFontPathElements(npaths, paths, bad)
+SetFontPathElements(npaths, paths, bad, persist)
int npaths;
unsigned char *paths;
int *bad;
+ Bool persist;
#endif
{
int i,
@@ -1758,71 +1759,83 @@ SetFontPathElements(npaths, paths, bad)
if (fpe_functions[i].set_path_hook)
(*fpe_functions[i].set_path_hook) ();
}
- for (i = 0; i < npaths; i++) {
+ for (i = 0; i < npaths; i++)
+ {
len = (unsigned int) (*cp++);
- if (len) {
+ if (len == 0)
+ {
+ if (persist)
+ ErrorF ("Removing empty element from the valid list of fontpaths\n");
+ err = BadValue;
+ }
+ else
+ {
/* if it's already in our active list, just reset it */
/*
* note that this can miss FPE's in limbo -- may be worth catching
* them, though it'd muck up refcounting
*/
fpe = find_existing_fpe(font_path_elements, num_fpes, cp, len);
- if (fpe) {
+ if (fpe)
+ {
err = (*fpe_functions[fpe->type].reset_fpe) (fpe);
- if (err == Successful) {
+ if (err == Successful)
+ {
UseFPE(fpe);/* since it'll be decref'd later when freed
* from the old list */
- fplist[valid_paths++] = fpe;
- cp += len;
- continue;
}
- /* if error or can't do it, act like it's a new one */
- }
- fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
- if (!fpe) {
- err = BadAlloc;
- goto bail;
- }
- fpe->name = (char *) xalloc(len + 1);
- if (!fpe->name) {
- xfree(fpe);
- err = BadAlloc;
- goto bail;
- }
- fpe->refcount = 1;
-
- strncpy(fpe->name, (char *) cp, (int) len);
- cp += len;
- fpe->name[len] = '\0';
- fpe->name_length = len;
- fpe->type = DetermineFPEType(fpe->name);
- if (fpe->type == -1) {
- xfree(fpe->name);
- xfree(fpe);
- err = BadValue;
- goto bail;
+ else
+ fpe = 0;
}
- err = (*fpe_functions[fpe->type].init_fpe) (fpe);
- if (!loadableFonts) {
- if (err != Successful) {
- xfree(fpe->name);
+ /* if error or can't do it, act like it's a new one */
+ if (!fpe)
+ {
+ fpe = (FontPathElementPtr) xalloc(sizeof(FontPathElementRec));
+ if (!fpe)
+ {
+ err = BadAlloc;
+ goto bail;
+ }
+ fpe->name = (char *) xalloc(len + 1);
+ if (!fpe->name)
+ {
xfree(fpe);
- err = BadValue;
+ err = BadAlloc;
goto bail;
}
- fplist[valid_paths++] = fpe;
- } else {
- if (err == Successful) /* a successful font, add it to list */
- fplist[valid_paths++] = fpe;
+ fpe->refcount = 1;
+
+ strncpy(fpe->name, (char *) cp, (int) len);
+ fpe->name[len] = '\0';
+ fpe->name_length = len;
+ fpe->type = DetermineFPEType(fpe->name);
+ if (fpe->type == -1)
+ err = BadValue;
else
- ErrorF("Removing %s from the valid list of fontpaths\n",
- fpe->name);
+ err = (*fpe_functions[fpe->type].init_fpe) (fpe);
+ if (err != Successful)
+ {
+ if (persist)
+ {
+ ErrorF("Could not init font path element %s, removing from list!\n",
+ fpe->name);
+ }
+ xfree (fpe->name);
+ xfree (fpe);
+ }
}
- } else {
- err = BadValue;
- goto bail;
}
+ if (err != Successful)
+ {
+ if (!persist)
+ goto bail;
+ }
+ else
+ {
+ fplist[valid_paths++] = fpe;
+ }
+ cp += len;
}
FreeFontPath(font_path_elements, num_fpes, FALSE);
@@ -1834,8 +1847,8 @@ SetFontPathElements(npaths, paths, bad)
return Success;
bail:
*bad = i;
- while (--i >= 0)
- FreeFPE(fplist[i]);
+ while (--valid_paths >= 0)
+ FreeFPE(fplist[valid_paths]);
xfree(fplist);
return err;
}
@@ -1854,7 +1867,7 @@ SetFontPath(client, npaths, paths, error)
if (SetDefaultFontPath(defaultFontPath) != Success)
return BadName;
} else {
- err = SetFontPathElements(npaths, paths, error);
+ err = SetFontPathElements(npaths, paths, error, FALSE);
}
return err;
}
@@ -1894,7 +1907,7 @@ SetDefaultFontPath(path)
}
*nump = (unsigned char) size;
- err = SetFontPathElements(num, newpath, &bad);
+ err = SetFontPathElements(num, newpath, &bad, TRUE);
DEALLOCATE_LOCAL(newpath);
diff --git a/xc/programs/Xserver/dix/events.c b/xc/programs/Xserver/dix/events.c
index 44f5bb255..5b5c264ff 100644
--- a/xc/programs/Xserver/dix/events.c
+++ b/xc/programs/Xserver/dix/events.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.29 2000/02/21 01:16:28 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/events.c,v 3.34 2000/05/05 17:53:48 keithp Exp $ */
/************************************************************
Copyright 1987, 1998 The Open Group
@@ -282,7 +282,7 @@ static Mask filters[128] =
static CARD8 criticalEvents[32] =
{
- 0x3c /* key and button events */
+ 0x7c /* key and button events */
};
#ifdef PANORAMIX
@@ -1584,9 +1584,7 @@ TryClientEvents (client, pEvents, count, mask, filter, grab)
if (BitIsOn(criticalEvents, type))
{
#ifdef SMART_SCHEDULE
- extern int SmartMaxPriority;
-
- if (client->smart_priority < SmartMaxPriority)
+ if (client->smart_priority < SMART_MAX_PRIORITY)
client->smart_priority++;
#endif
SetCriticalOutputPending();
@@ -1821,16 +1819,6 @@ FixUpEventFromWindow(xE, pWin, child, calcChild)
XE_KBPTR.rootX - pWin->drawable.x;
XE_KBPTR.eventY =
XE_KBPTR.rootY - pWin->drawable.y;
-#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
- XE_KBPTR.rootX += panoramiXdataPtr[0].x;
- XE_KBPTR.rootY += panoramiXdataPtr[0].y;
- if(pWin == WindowTable[0]) {
- XE_KBPTR.eventX += panoramiXdataPtr[0].x;
- XE_KBPTR.eventY += panoramiXdataPtr[0].y;
- }
- }
-#endif
}
else
{
@@ -2186,6 +2174,117 @@ NewCurrentScreen(newScreen, x, y)
if (newScreen != sprite.hotPhys.pScreen)
ConfineCursorToWindow(WindowTable[newScreen->myNum], TRUE, FALSE);
}
+
+#ifdef PANORAMIX
+
+static Bool
+PanoramiXPointInWindowIsVisible(
+ WindowPtr pWin,
+ int x,
+ int y
+)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ BoxRec box;
+ int i, xoff, yoff;
+
+ if (!pWin->realized) return FALSE;
+
+ if (POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+ return TRUE;
+
+ if(!PanoramiXSetWindowPntrs(pWin)) return FALSE;
+
+ xoff = x + panoramiXdataPtr[0].x;
+ yoff = y + panoramiXdataPtr[0].y;
+
+ for(i = 1; i < PanoramiXNumScreens; i++) {
+ pWin = sprite.windows[i];
+ pScreen = pWin->drawable.pScreen;
+ x = xoff - panoramiXdataPtr[i].x;
+ y = yoff - panoramiXdataPtr[i].y;
+
+ if(POINT_IN_REGION(pScreen, &pWin->borderClip, x, y, &box))
+ return TRUE;
+
+ }
+
+ return FALSE;
+}
+
+static int
+PanoramiXWarpPointer(ClientPtr client)
+{
+ WindowPtr dest = NULL;
+ int x, y;
+
+ REQUEST(xWarpPointerReq);
+
+
+ if (stuff->dstWid != None)
+ {
+ dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
+ if (!dest)
+ return BadWindow;
+ }
+ x = sprite.hotPhys.x;
+ y = sprite.hotPhys.y;
+
+ if (stuff->srcWid != None)
+ {
+ int winX, winY;
+ XID winID = stuff->srcWid;
+ WindowPtr source;
+
+ source = SecurityLookupWindow(winID, client, SecurityReadAccess);
+ if (!source) return BadWindow;
+
+ winX = source->drawable.x;
+ winY = source->drawable.y;
+ if(source == WindowTable[0]) {
+ winX -= panoramiXdataPtr[0].x;
+ winY -= panoramiXdataPtr[0].y;
+ }
+ if (x < winX + stuff->srcX ||
+ y < winY + stuff->srcY ||
+ (stuff->srcWidth != 0 &&
+ winX + stuff->srcX + (int)stuff->srcWidth < x) ||
+ (stuff->srcHeight != 0 &&
+ winY + stuff->srcY + (int)stuff->srcHeight < y) ||
+ !PanoramiXPointInWindowIsVisible(source, x, y))
+ return Success;
+ }
+ if (dest) {
+ x = dest->drawable.x;
+ y = dest->drawable.y;
+ if(dest == WindowTable[0]) {
+ x -= panoramiXdataPtr[0].x;
+ y -= panoramiXdataPtr[0].y;
+ }
+ }
+
+ x += stuff->dstX;
+ y += stuff->dstY;
+
+ if (x < sprite.physLimits.x1)
+ x = sprite.physLimits.x1;
+ else if (x >= sprite.physLimits.x2)
+ x = sprite.physLimits.x2 - 1;
+ if (y < sprite.physLimits.y1)
+ y = sprite.physLimits.y1;
+ else if (y >= sprite.physLimits.y2)
+ y = sprite.physLimits.y2 - 1;
+ if (sprite.hotShape)
+ ConfineToShape(sprite.hotShape, &x, &y);
+
+ PanoramiXSetCursorPosition(x, y, TRUE);
+
+ return Success;
+}
+
+#endif
+
+
int
ProcWarpPointer(client)
ClientPtr client;
@@ -2197,6 +2296,12 @@ ProcWarpPointer(client)
REQUEST(xWarpPointerReq);
REQUEST_SIZE_MATCH(xWarpPointerReq);
+
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension)
+ return PanoramiXWarpPointer(client);
+#endif
+
if (stuff->dstWid != None)
{
dest = SecurityLookupWindow(stuff->dstWid, client, SecurityReadAccess);
@@ -2227,7 +2332,8 @@ ProcWarpPointer(client)
!PointInWindowIsVisible(source, x, y))
return Success;
}
- if (dest) {
+ if (dest)
+ {
x = dest->drawable.x;
y = dest->drawable.y;
newScreen = dest->drawable.pScreen;
@@ -2237,19 +2343,14 @@ ProcWarpPointer(client)
x += stuff->dstX;
y += stuff->dstY;
-#ifdef PANORAMIX
- if(noPanoramiXExtension) /* Clip to the SLS not Screen 0 */
-#endif
- {
- if (x < 0)
- x = 0;
- else if (x >= newScreen->width)
- x = newScreen->width - 1;
- if (y < 0)
- y = 0;
- else if (y >= newScreen->height)
- y = newScreen->height - 1;
- }
+ if (x < 0)
+ x = 0;
+ else if (x >= newScreen->width)
+ x = newScreen->width - 1;
+ if (y < 0)
+ y = 0;
+ else if (y >= newScreen->height)
+ y = newScreen->height - 1;
if (newScreen == sprite.hotPhys.pScreen)
{
@@ -2261,15 +2362,10 @@ ProcWarpPointer(client)
y = sprite.physLimits.y1;
else if (y >= sprite.physLimits.y2)
y = sprite.physLimits.y2 - 1;
-#if defined(SHAPE) || defined(PANORAMIX)
+#if defined(SHAPE)
if (sprite.hotShape)
ConfineToShape(sprite.hotShape, &x, &y);
#endif
-#ifdef PANORAMIX
- if(!noPanoramiXExtension)
- PanoramiXSetCursorPosition(x, y, TRUE);
- else
-#endif
(*newScreen->SetCursorPosition)(newScreen, x, y, TRUE);
}
else if (!PointerConfinedToScreen())
@@ -3856,18 +3952,12 @@ ProcQueryPointer(client)
rep.root = (ROOT)->drawable.id;
rep.rootX = sprite.hot.x;
rep.rootY = sprite.hot.y;
-#ifdef PANORAMIX
- if(!noPanoramiXExtension) {
- rep.rootX += panoramiXdataPtr[0].x;
- rep.rootY += panoramiXdataPtr[0].y;
- }
-#endif
rep.child = None;
if (sprite.hot.pScreen == pWin->drawable.pScreen)
{
rep.sameScreen = xTrue;
rep.winX = sprite.hot.x - pWin->drawable.x;
- rep.winY =sprite.hot.y - pWin->drawable.y;
+ rep.winY = sprite.hot.y - pWin->drawable.y;
for (t = sprite.win; t; t = t->parent)
if (t->parent == pWin)
{
@@ -3882,6 +3972,17 @@ ProcQueryPointer(client)
rep.winY = 0;
}
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension) {
+ rep.rootX += panoramiXdataPtr[0].x;
+ rep.rootY += panoramiXdataPtr[0].y;
+ if(stuff->id == rep.root) {
+ rep.winX += panoramiXdataPtr[0].x;
+ rep.winY += panoramiXdataPtr[0].y;
+ }
+ }
+#endif
+
WriteReplyToClient(client, sizeof(xQueryPointerReply), &rep);
return(Success);
@@ -4409,6 +4510,9 @@ WriteEventsToClient(pClient, count, events)
int count;
xEvent *events;
{
+#ifdef PANORAMIX
+ xEvent eventCopy;
+#endif
xEvent eventTo, *eventFrom;
int i;
@@ -4417,6 +4521,40 @@ WriteEventsToClient(pClient, count, events)
return;
#endif
+#ifdef PANORAMIX
+ if(!noPanoramiXExtension &&
+ (panoramiXdataPtr[0].x || panoramiXdataPtr[0].y))
+ {
+ switch(events->u.u.type) {
+ case MotionNotify:
+ case ButtonPress:
+ case ButtonRelease:
+ case KeyPress:
+ case KeyRelease:
+ case EnterNotify:
+ case LeaveNotify:
+ /*
+ When multiple clients want the same event DeliverEventsToWindow
+ passes the same event structure multiple times so we can't
+ modify the one passed to us
+ */
+ count = 1; /* should always be 1 */
+ memcpy(&eventCopy, events, sizeof(xEvent));
+ eventCopy.u.keyButtonPointer.rootX += panoramiXdataPtr[0].x;
+ eventCopy.u.keyButtonPointer.rootY += panoramiXdataPtr[0].y;
+ if(eventCopy.u.keyButtonPointer.event ==
+ eventCopy.u.keyButtonPointer.root)
+ {
+ eventCopy.u.keyButtonPointer.eventX += panoramiXdataPtr[0].x;
+ eventCopy.u.keyButtonPointer.eventY += panoramiXdataPtr[0].y;
+ }
+ events = &eventCopy;
+ break;
+ default: break;
+ }
+ }
+#endif
+
if (EventCallback)
{
EventInfoRec eventinfo;
diff --git a/xc/programs/Xserver/dix/main.c b/xc/programs/Xserver/dix/main.c
index 93c9a652f..f212cfd9b 100644
--- a/xc/programs/Xserver/dix/main.c
+++ b/xc/programs/Xserver/dix/main.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.28 2000/02/12 03:39:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/dix/main.c,v 3.29 2000/06/16 01:50:19 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -250,9 +250,10 @@ static int indexForScanlinePad[ 65 ] = {
#endif
int
-main(argc, argv)
+main(argc, argv, envp)
int argc;
char *argv[];
+ char *envp[];
{
int i, j, k, error;
HWEventQueueType alwaysCheckForInput[2];
@@ -264,6 +265,8 @@ main(argc, argv)
else
restart = 1;
+ CheckUserParameters(argc, argv, envp);
+
#ifdef COMMANDLINE_CHALLENGED_OPERATING_SYSTEMS
ExpandCommandLine(&argc, &argv);
#endif
diff --git a/xc/programs/Xserver/fb/Imakefile b/xc/programs/Xserver/fb/Imakefile
index 7b6a8f2a2..5157e6fb8 100644
--- a/xc/programs/Xserver/fb/Imakefile
+++ b/xc/programs/Xserver/fb/Imakefile
@@ -1,8 +1,9 @@
-XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.4 2000/02/23 20:29:40 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/fb/Imakefile,v 1.8 2000/05/06 21:09:29 keithp Exp $
XCOMM
XCOMM
XCOMM Id: Imakefile,v 1.1 1999/11/02 03:54:44 keithp Exp $
-#define IHaveModule
+
+#define IHaveModules
#include <Server.tmpl>
#ifdef FbNoPixelAddrCode
@@ -32,6 +33,7 @@ SRCS = $(XFMODSRC) \
fbglyph.c \
fbimage.c \
fbline.c \
+ fboverlay.c \
fbpixmap.c \
fbpoint.c \
fbpush.c \
@@ -42,7 +44,8 @@ SRCS = $(XFMODSRC) \
fbstipple.c \
fbtile.c \
fbutil.c \
- fbwindow.c
+ fbwindow.c \
+ fb24_32.c
OBJS = $(XFMODOBJ) \
fbarc.o \
@@ -61,6 +64,7 @@ OBJS = $(XFMODOBJ) \
fbglyph.o \
fbimage.o \
fbline.o \
+ fboverlay.o \
fbpixmap.o \
fbpoint.o \
fbpush.o \
@@ -71,7 +75,8 @@ OBJS = $(XFMODOBJ) \
fbstipple.o \
fbtile.o \
fbutil.o \
- fbwindow.o
+ fbwindow.o \
+ fb24_32.o
INCLUDES = -I. -I../mi -I../include -I$(XINCLUDESRC) \
-I$(FONTINCSRC) -I$(XF86SRC)/common $(EXTRAINCLUDES)
@@ -90,3 +95,6 @@ InstallLibraryModule(fb,$(MODULEDIR),.)
DependTarget()
#endif
+InstallDriverSDKLibraryModule(fb,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKNonExecFile(fb.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(fbrop.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/fb/fb.h b/xc/programs/Xserver/fb/fb.h
index 4a508f0ab..047f1f175 100644
--- a/xc/programs/Xserver/fb/fb.h
+++ b/xc/programs/Xserver/fb/fb.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fb.h,v 1.13 2000/03/01 00:25:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fb.h,v 1.16 2000/05/06 21:09:30 keithp Exp $ */
#ifndef _FB_H_
#define _FB_H_
@@ -77,6 +77,17 @@
#undef FB_24BIT
#endif
+/*
+ * Unless otherwise instructed, fb includes code to advertise 24bpp
+ * windows with 32bpp image format for application compatibility
+ */
+
+#ifdef FB_24BIT
+#ifndef FBNO24_32
+#define FB_24_32BIT
+#endif
+#endif
+
#define FB_STIP_SHIFT LOG2_BITMAP_PAD
#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
#define FB_STIP_MASK (FB_STIP_UNIT - 1)
@@ -204,10 +215,10 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data);
#ifdef FBNOPIXADDR
#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
- *dst = FbDoRRop(*dst,and,xor,l);
+ *dst = FbDoMaskRRop(*dst,and,xor,l); \
}
#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
- *dst = FbDoRRop(*dst,and,xor,r);
+ *dst = FbDoMaskRRop(*dst,and,xor,r); \
}
#else
@@ -502,6 +513,9 @@ extern void fbSetBits (FbStip *bits, int stride, FbStip data);
#define FbCheck24Pix(p) ((p) == FbNext24Pix(p))
extern int fbGCPrivateIndex;
+#ifndef FB_NO_WINDOW_PIXMAPS
+extern int fbWinPrivateIndex;
+#endif
extern const GCOps fbGCOps;
extern const GCFuncs fbGCFuncs;
@@ -514,6 +528,23 @@ extern const GCFuncs fbGCFuncs;
extern WindowPtr *WindowTable;
#endif
+#ifdef FB_24_32BIT
+#define FB_SCREEN_PRIVATE
+#endif
+
+#ifdef FB_SCREEN_PRIVATE
+extern int fbScreenPrivateIndex;
+
+/* private field of a screen */
+typedef struct {
+ unsigned char win32bpp; /* window bpp for 32-bpp images */
+ unsigned char pix32bpp; /* pixmap bpp for 32-bpp images */
+} FbScreenPrivRec, *FbScreenPrivPtr;
+
+#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
+ (pScreen)->devPrivates[fbScreenPrivateIndex].ptr)
+#endif
+
/* private field of GC */
typedef struct {
#ifdef FB_OLD_GC
@@ -529,8 +560,9 @@ typedef struct {
FbBits bgand, bgxor; /* for stipples */
FbBits fg, bg, pm; /* expanded and filled */
unsigned int dashLength; /* total of all dash elements */
- Bool oneRect; /* clip list is single rectangle */
- Bool evenStipple; /* stipple is even */
+ unsigned char oneRect; /* clip list is single rectangle */
+ unsigned char evenStipple; /* stipple is even */
+ unsigned char bpp; /* current drawable bpp */
} FbGCPrivRec, *FbGCPrivPtr;
#define fbGetGCPrivate(pGC) ((FbGCPrivPtr)\
@@ -549,7 +581,12 @@ typedef struct {
#endif
#define fbGetScreenPixmap(s) ((PixmapPtr) (s)->devPrivate)
+#ifdef FB_NO_WINDOW_PIXMAPS
#define fbGetWindowPixmap(d) fbGetScreenPixmap((d)->pScreen)
+#else
+#define fbGetWindowPixmap(pWin) ((PixmapPtr)\
+ ((WindowPtr) (pWin))->devPrivates[fbWinPrivateIndex].ptr)
+#endif
#define fbGetDrawable(pDrawable, pointer, stride, bpp) { \
PixmapPtr _pPix; \
@@ -604,6 +641,76 @@ typedef struct {
#define FbEvenStip(w,bpp) ((w) * (bpp) <= FB_UNIT && FbPowerOfTwo(w) && FbPowerOfTwo(bpp))
/*
+ * fb24_32.c
+ */
+void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart);
+
+void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted);
+
+void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride);
+
+void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d);
+
+void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure);
+
+PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel);
+
+Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen);
+
+Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData);
+
+/*
* fballpriv.c
*/
Bool
@@ -1387,6 +1494,9 @@ fbPolySegment (DrawablePtr pDrawable,
*/
PixmapPtr
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp);
+
+PixmapPtr
fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth);
Bool
diff --git a/xc/programs/Xserver/fb/fb24_32.c b/xc/programs/Xserver/fb/fb24_32.c
new file mode 100644
index 000000000..cfcf368ba
--- /dev/null
+++ b/xc/programs/Xserver/fb/fb24_32.c
@@ -0,0 +1,616 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fb24_32.c,v 1.3 2000/05/06 21:09:31 keithp Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#endif
+
+#include "fb.h"
+
+/* X apps don't like 24bpp images, this code exposes 32bpp images */
+
+/*
+ * These two functions do a full CopyArea while reformatting
+ * the data between 24 and 32bpp. They try to go a bit faster
+ * by reading/writing aligned CARD32s where it's easy
+ */
+
+#define Get8(a) ((CARD32) *(a))
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Get24(a) ((Get8(a) << 16) | (Get8((a)+1) << 8) | Get8((a)+2))
+#define Put24(a,p) (((a)[0] = (CARD8) ((p) >> 16)), \
+ ((a)[1] = (CARD8) ((p) >> 8)), \
+ ((a)[2] = (CARD8) (p)))
+#else
+#define Get24(a) (Get8(a) | (Get8((a)+1) << 8) | (Get8((a)+2)<<16))
+#define Put24(a,p) (((a)[0] = (CARD8) (p)), \
+ ((a)[1] = (CARD8) ((p) >> 8)), \
+ ((a)[2] = (CARD8) ((p) >> 16)))
+#endif
+
+typedef void (*fb24_32BltFunc) (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm);
+
+static void
+fb24_32BltDown (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ CARD32 *src;
+ CARD8 *dst;
+ int w;
+ Bool destInvarient;
+ CARD32 pixel, dpixel;
+ FbDeclareMergeRop ();
+
+ srcLine += srcX * 4;
+ dstLine += dstX * 3;
+
+ FbInitializeMergeRop(alu, (pm | ~(FbBits) 0xffffff));
+ destInvarient = FbDestInvarientMergeRop();
+
+ while (height--)
+ {
+ src = (CARD32 *) srcLine;
+ dst = dstLine;
+ srcLine += srcStride;
+ dstLine += dstStride;
+ w = width;
+ if (destInvarient)
+ {
+ while (((long) dst & 3) && w)
+ {
+ w--;
+ pixel = *src++;
+ pixel = FbDoDestInvarientMergeRop(pixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4)
+ {
+ CARD32 s0, s1;
+ s0 = *src++;
+ s0 = FbDoDestInvarientMergeRop(s0);
+ s1 = *src++;
+ s1 = FbDoDestInvarientMergeRop(s1);
+#if BITMAP_BIT_ORDER == LSBFirst
+ *(CARD32 *)(dst) = (s0 & 0xffffff) | (s1 << 24);
+#else
+ *(CARD32 *)(dst) = (s0 << 8) | ((s1 & 0xffffff) >> 16);
+#endif
+ s0 = *src++;
+ s0 = FbDoDestInvarientMergeRop(s0);
+#if BITMAP_BIT_ORDER == LSBFirst
+ *(CARD32 *)(dst+4) = ((s1 & 0xffffff) >> 8) | (s0 << 16);
+#else
+ *(CARD32 *)(dst+4) = (s1 << 16) | ((s0 & 0xffffff) >> 8);
+#endif
+ s1 = *src++;
+ s1 = FbDoDestInvarientMergeRop(s1);
+#if BITMAP_BIT_ORDER == LSBFirst
+ *(CARD32 *)(dst+8) = ((s0 & 0xffffff) >> 16) | (s1 << 8);
+#else
+ *(CARD32 *)(dst+8) = (s0 << 24) | (s1 & 0xffffff);
+#endif
+ dst += 12;
+ w -= 4;
+ }
+ while (w--)
+ {
+ pixel = *src++;
+ pixel = FbDoDestInvarientMergeRop(pixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ }
+ else
+ {
+ while (w--)
+ {
+ pixel = *src++;
+ dpixel = Get24 (dst);
+ pixel = FbDoMergeRop(pixel, dpixel);
+ Put24 (dst, pixel);
+ dst += 3;
+ }
+ }
+ }
+}
+
+static void
+fb24_32BltUp (CARD8 *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ CARD8 *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ CARD8 *src;
+ CARD32 *dst;
+ int w;
+ Bool destInvarient;
+ CARD32 pixel;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop(alu, (pm | (~(FbBits) 0xffffff)));
+ destInvarient = FbDestInvarientMergeRop();
+
+ srcLine += srcX * 3;
+ dstLine += dstX * 4;
+
+ while (height--)
+ {
+ w = width;
+ src = srcLine;
+ dst = (CARD32 *) dstLine;
+ srcLine += srcStride;
+ dstLine += dstStride;
+ if (destInvarient)
+ {
+ while (((long) src & 3) && w)
+ {
+ w--;
+ pixel = Get24(src);
+ src += 3;
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ }
+ /* Do four aligned pixels at a time */
+ while (w >= 4)
+ {
+ CARD32 s0, s1;
+
+ s0 = *(CARD32 *)(src);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = s0 & 0xffffff;
+#else
+ pixel = s0 >> 8;
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ s1 = *(CARD32 *)(src+4);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = (s0 >> 24) | ((s1 << 8) & 0xffffff);
+#else
+ pixel = ((s0 << 16) & 0xffffff) | (s1 >> 16);
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ s0 = *(CARD32 *)(src+8);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = (s1 >> 16) | ((s0 << 16) & 0xffffff);
+#else
+ pixel = ((s1 << 8) & 0xffffff) | (s0 >> 24);
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+#if BITMAP_BIT_ORDER == LSBFirst
+ pixel = s0 >> 8;
+#else
+ pixel = s0 & 0xffffff;
+#endif
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ src += 12;
+ w -= 4;
+ }
+ while (w)
+ {
+ w--;
+ pixel = Get24(src);
+ src += 3;
+ *dst++ = FbDoDestInvarientMergeRop(pixel);
+ }
+ }
+ else
+ {
+ while (w--)
+ {
+ pixel = Get24(src);
+ src += 3;
+ *dst = FbDoMergeRop(pixel, *dst);
+ dst++;
+ }
+ }
+ }
+}
+
+/*
+ * Spans functions; probably unused.
+ */
+void
+fb24_32GetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart)
+{
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ CARD8 *dst;
+
+ fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+
+ while (nspans--)
+ {
+ dst = (CARD8 *) pchardstStart;
+ fb24_32BltUp (src + ppt->y * srcStride, srcStride,
+ ppt->x,
+
+ dst,
+ 1,
+ 0,
+
+ *pwidth,
+ 1,
+
+ GXcopy,
+ FB_ALLONES);
+
+ pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+}
+
+void
+fb24_32SetSpans (DrawablePtr pDrawable,
+ GCPtr pGC,
+ char *src,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ int fSorted)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate (pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ FbBits *dstBits;
+ CARD8 *dst, *d, *s;
+ FbStride dstStride;
+ int dstBpp;
+ BoxPtr pbox;
+ int n;
+ int x1, x2;
+
+ fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp);
+ dst = (CARD8 *) dstBits;
+ dstStride *= sizeof (FbBits);
+ while (nspans--)
+ {
+ d = dst + ppt->y * dstStride;
+ s = (CARD8 *) src;
+ n = REGION_NUM_RECTS(pClip);
+ pbox = REGION_RECTS (pClip);
+ while (n--)
+ {
+ if (pbox->y1 > ppt->y)
+ break;
+ if (pbox->y2 > ppt->y)
+ {
+ x1 = ppt->x;
+ x2 = x1 + *pwidth;
+ if (pbox->x1 > x1)
+ x1 = pbox->x1;
+ if (pbox->x2 < x2)
+ x2 = pbox->x2;
+ if (x1 < x2)
+ fb24_32BltDown (s,
+ 0,
+ (x1 - ppt->x),
+ d,
+ dstStride,
+ x1,
+
+ (x2 - x1),
+ 1,
+ pGC->alu,
+ pPriv->pm);
+ }
+ }
+ src += PixmapBytePad (*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+}
+
+/*
+ * Clip and put 32bpp Z-format images to a 24bpp drawable
+ */
+void
+fb24_32PutZImage (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int alu,
+ FbBits pm,
+ int x,
+ int y,
+ int width,
+ int height,
+ CARD8 *src,
+ FbStride srcStride)
+{
+ FbBits *dstBits;
+ CARD8 *dst;
+ FbStride dstStride;
+ int dstBpp;
+ int nbox;
+ BoxPtr pbox;
+ int x1, y1, x2, y2;
+
+ fbGetDrawable (pDrawable, dstBits, dstStride, dstBpp);
+ dstStride *= sizeof(FbBits);
+ dst = (CARD8 *) dstBits;
+
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ x1 = x;
+ y1 = y;
+ x2 = x + width;
+ y2 = y + height;
+ if (x1 < pbox->x1)
+ x1 = pbox->x1;
+ if (y1 < pbox->y1)
+ y1 = pbox->y1;
+ if (x2 > pbox->x2)
+ x2 = pbox->x2;
+ if (y2 > pbox->y2)
+ y2 = pbox->y2;
+ if (x1 >= x2 || y1 >= y2)
+ continue;
+ fb24_32BltDown (src + (y1 - y) * srcStride,
+ srcStride,
+ (x1 - x),
+
+ dst + y1 * dstStride,
+ dstStride,
+ x1,
+
+ (x2 - x1),
+ (y2 - y1),
+
+ alu,
+ pm);
+ }
+}
+
+void
+fb24_32GetImage (DrawablePtr pDrawable,
+ int x,
+ int y,
+ int w,
+ int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *d)
+{
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ FbStride dstStride;
+ FbBits pm;
+
+ fbGetDrawable (pDrawable, srcBits, srcStride, srcBpp);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ pm = fbReplicatePixel (planeMask, 32);
+ dstStride = PixmapBytePad(w, pDrawable->depth);
+ if (pm != FB_ALLONES)
+ memset (d, 0, dstStride * h);
+ fb24_32BltUp (src + y * srcStride, srcStride, x,
+ (CARD8 *) d, dstStride, 0,
+ w, h, GXcopy, pm);
+}
+
+void
+fb24_32CopyMtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ FbBits *srcBits;
+ CARD8 *src;
+ FbStride srcStride;
+ int srcBpp;
+ FbBits *dstBits;
+ CARD8 *dst;
+ FbStride dstStride;
+ int dstBpp;
+ fb24_32BltFunc blt;
+
+ fbGetDrawable (pSrcDrawable, srcBits, srcStride, srcBpp);
+ src = (CARD8 *) srcBits;
+ srcStride *= sizeof (FbBits);
+ fbGetDrawable (pDstDrawable, dstBits, dstStride, dstBpp);
+ dst = (CARD8 *) dstBits;
+ dstStride *= sizeof (FbBits);
+ if (srcBpp == 24)
+ blt = fb24_32BltUp;
+ else
+ blt = fb24_32BltDown;
+
+ while (nbox--)
+ {
+ (*blt) (src + (pbox->y1 + dy) * srcStride,
+ srcStride,
+ (pbox->x1 + dx),
+
+ dst + (pbox->y1) * dstStride,
+ dstStride,
+ (pbox->x1),
+
+ (pbox->x2 - pbox->x1),
+ (pbox->y2 - pbox->y1),
+
+ pGC->alu,
+ pPriv->pm);
+ pbox++;
+ }
+}
+
+PixmapPtr
+fb24_32ReformatTile(PixmapPtr pOldTile, int bitsPerPixel)
+{
+ ScreenPtr pScreen = pOldTile->drawable.pScreen;
+ PixmapPtr pNewTile;
+ FbBits *old, *new;
+ FbStride oldStride, newStride;
+ int oldBpp, newBpp;
+ fb24_32BltFunc blt;
+
+ pNewTile = fbCreatePixmapBpp (pScreen,
+ pOldTile->drawable.width,
+ pOldTile->drawable.height,
+ pOldTile->drawable.depth,
+ bitsPerPixel);
+ if (!pNewTile)
+ return 0;
+ fbGetDrawable (&pOldTile->drawable,
+ old, oldStride, oldBpp);
+ fbGetDrawable (&pNewTile->drawable,
+ new, newStride, newBpp);
+ if (oldBpp == 24)
+ blt = fb24_32BltUp;
+ else
+ blt = fb24_32BltDown;
+
+ (*blt) ((CARD8 *) old,
+ oldStride * sizeof (FbBits),
+ 0,
+
+ (CARD8 *) new,
+ newStride * sizeof (FbBits),
+ 0,
+
+ pOldTile->drawable.width,
+ pOldTile->drawable.height,
+
+ GXcopy,
+ FB_ALLONES);
+
+ (*pScreen->DestroyPixmap) (pOldTile);
+ return pNewTile;
+}
+
+typedef struct {
+ pointer pbits;
+ int width;
+} miScreenInitParmsRec, *miScreenInitParmsPtr;
+
+Bool
+fb24_32CreateScreenResources(ScreenPtr pScreen)
+{
+ miScreenInitParmsPtr pScrInitParms;
+ int pitch;
+ Bool retval;
+
+ /* get the pitch before mi destroys it */
+ pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
+ pitch = BitmapBytePad(pScrInitParms->width * 24);
+
+ if((retval = miCreateScreenResources(pScreen))) {
+ /* fix the screen pixmap */
+ PixmapPtr pPix = (PixmapPtr)pScreen->devPrivate;
+ pPix->drawable.bitsPerPixel = 24;
+ pPix->devKind = pitch;
+ }
+
+ return retval;
+}
+
+Bool
+fb24_32ModifyPixmapHeader (PixmapPtr pPixmap,
+ int width,
+ int height,
+ int depth,
+ int bitsPerPixel,
+ int devKind,
+ pointer pPixData)
+{
+ int bpp, w;
+
+ if (!pPixmap)
+ return FALSE;
+ bpp = bitsPerPixel;
+ if (bpp <= 0)
+ bpp = pPixmap->drawable.bitsPerPixel;
+ if (bpp == 24)
+ {
+ if (devKind < 0)
+ {
+ w = width;
+ if (w <= 0)
+ w = pPixmap->drawable.width;
+ devKind = BitmapBytePad(w * 24);
+ }
+ }
+ return miModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel,
+ devKind, pPixData);
+}
diff --git a/xc/programs/Xserver/fb/fb24_32.h b/xc/programs/Xserver/fb/fb24_32.h
new file mode 100644
index 000000000..d0a0acb97
--- /dev/null
+++ b/xc/programs/Xserver/fb/fb24_32.h
@@ -0,0 +1,49 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fb24_32.h,v 1.1 2000/04/04 19:24:49 dawes Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _FB24_32_H_
+#define _FB24_32_H_
+
+Bool
+fb24_32FinishScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+Bool
+fb24_32ScreenInit(ScreenPtr pScreen,
+ pointer pbits,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width,
+ int bpp);
+
+#endif
diff --git a/xc/programs/Xserver/fb/fballpriv.c b/xc/programs/Xserver/fb/fballpriv.c
index e1ae7b663..687de493a 100644
--- a/xc/programs/Xserver/fb/fballpriv.c
+++ b/xc/programs/Xserver/fb/fballpriv.c
@@ -21,11 +21,17 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fballpriv.c,v 1.3 2000/02/23 20:29:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fballpriv.c,v 1.4 2000/05/06 21:09:31 keithp Exp $ */
#include "fb.h"
+#ifdef FB_SCREEN_PRIVATE
+int fbScreenPrivateIndex;
+#endif
int fbGCPrivateIndex;
+#ifndef FB_NO_WINDOW_PIXMAPS
+int fbWinPrivateIndex;
+#endif
int fbGeneration;
#ifdef FB_OLD_SCREEN
@@ -38,11 +44,34 @@ fbAllocatePrivates(ScreenPtr pScreen, int *pGCIndex)
if (fbGeneration != serverGeneration)
{
fbGCPrivateIndex = miAllocateGCPrivateIndex ();
+#ifndef FB_NO_WINDOW_PIXMAPS
+ fbWinPrivateIndex = AllocateWindowPrivateIndex();
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ fbScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (fbScreenPrivateIndex == -1)
+ return FALSE;
+#endif
+
fbGeneration = serverGeneration;
}
if (pGCIndex)
*pGCIndex = fbGCPrivateIndex;
if (!AllocateGCPrivate(pScreen, fbGCPrivateIndex, sizeof(FbGCPrivRec)))
return FALSE;
+#ifndef FB_NO_WINDOW_PIXMAPS
+ if (!AllocateWindowPrivate(pScreen, fbWinPrivateIndex, 0))
+ return FALSE;
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ {
+ FbScreenPrivPtr pScreenPriv;
+
+ pScreenPriv = (FbScreenPrivPtr) xalloc (sizeof (FbScreenPrivRec));
+ if (!pScreenPriv)
+ return FALSE;
+ pScreen->devPrivates[fbScreenPrivateIndex].ptr = (pointer) pScreenPriv;
+ }
+#endif
return TRUE;
}
diff --git a/xc/programs/Xserver/fb/fbarc.c b/xc/programs/Xserver/fb/fbarc.c
index 1ceebbf0f..ab31be772 100644
--- a/xc/programs/Xserver/fb/fbarc.c
+++ b/xc/programs/Xserver/fb/fbarc.c
@@ -21,10 +21,13 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbarc.c,v 1.3 2000/02/23 20:29:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbarc.c,v 1.5 2000/04/06 15:27:24 dawes Exp $ */
#include "fb.h"
#include "mizerarc.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
typedef void (*FbArc) (FbBits *dst,
FbStride dstStride,
diff --git a/xc/programs/Xserver/fb/fbbltone.c b/xc/programs/Xserver/fb/fbbltone.c
index 169aec4cc..7463be439 100644
--- a/xc/programs/Xserver/fb/fbbltone.c
+++ b/xc/programs/Xserver/fb/fbbltone.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbbltone.c,v 1.7 2000/02/23 20:29:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbbltone.c,v 1.9 2000/05/06 21:09:32 keithp Exp $ */
#include "fb.h"
@@ -823,7 +823,10 @@ fbBltPlane (FbBits *src,
if (srcBits & srcMask)
dstBits |= dstMask;
dstUnion |= dstMask;
- srcMask = FbScrRight(srcMask,srcBpp);
+ if (srcBpp == FB_UNIT)
+ srcMask = 0;
+ else
+ srcMask = FbScrRight(srcMask,srcBpp);
dstMask = FbStipRight(dstMask,1);
}
if (dstUnion)
diff --git a/xc/programs/Xserver/fb/fbcopy.c b/xc/programs/Xserver/fb/fbcopy.c
index 9a34455fb..d25fe0f94 100644
--- a/xc/programs/Xserver/fb/fbcopy.c
+++ b/xc/programs/Xserver/fb/fbcopy.c
@@ -21,9 +21,12 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbcopy.c,v 1.4 2000/02/23 20:29:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbcopy.c,v 1.7 2000/05/06 21:09:32 keithp Exp $ */
#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
void
fbCopyNtoN (DrawablePtr pSrcDrawable,
@@ -599,8 +602,16 @@ fbCopyArea (DrawablePtr pSrcDrawable,
int xOut,
int yOut)
{
+ fbCopyProc copy;
+
+#ifdef FB_24_32BIT
+ if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
+ copy = fb24_32CopyMtoN;
+ else
+#endif
+ copy = fbCopyNtoN;
return fbDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
- widthSrc, heightSrc, xOut, yOut, fbCopyNtoN, 0, 0);
+ widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
}
RegionPtr
diff --git a/xc/programs/Xserver/fb/fbgc.c b/xc/programs/Xserver/fb/fbgc.c
index 7cd14833b..83d94e5b0 100644
--- a/xc/programs/Xserver/fb/fbgc.c
+++ b/xc/programs/Xserver/fb/fbgc.c
@@ -21,9 +21,12 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.6 2000/02/23 20:29:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbgc.c,v 1.9 2000/05/06 21:09:32 keithp Exp $ */
#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
const GCFuncs fbGCFuncs = {
fbValidateGC,
@@ -77,6 +80,7 @@ fbCreateGC(GCPtr pGC)
fbGetExpose(pGC) = 1;
fbGetFreeCompClip(pGC) = 0;
fbGetCompositeClip(pGC) = 0;
+ fbGetGCPrivate(pGC)->bpp = BitsPerPixel (pGC->depth);
return TRUE;
}
@@ -204,6 +208,28 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
pPriv->oneRect = REGION_NUM_RECTS(fbGetCompositeClip(pGC)) == 1;
}
+#ifdef FB_24_32BIT
+ if (pPriv->bpp != pDrawable->bitsPerPixel)
+ {
+ changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
+ pPriv->bpp = pDrawable->bitsPerPixel;
+ }
+ if (pGC->fillStyle == FillTiled)
+ {
+ PixmapPtr pOldTile, pNewTile;
+
+ pOldTile = pGC->tile.pixmap;
+ if (pOldTile->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pNewTile = fb24_32ReformatTile (pOldTile, pDrawable->bitsPerPixel);
+ if (pNewTile)
+ {
+ pGC->tile.pixmap = pNewTile;
+ changes |= GCTile;
+ }
+ }
+ }
+#endif
if (changes & GCTile)
{
if (!pGC->tileIsPixel &&
diff --git a/xc/programs/Xserver/fb/fbgetsp.c b/xc/programs/Xserver/fb/fbgetsp.c
index 80299d3ab..3331e00bf 100644
--- a/xc/programs/Xserver/fb/fbgetsp.c
+++ b/xc/programs/Xserver/fb/fbgetsp.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbgetsp.c,v 1.4 2000/02/23 20:29:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbgetsp.c,v 1.5 2000/05/06 21:09:33 keithp Exp $ */
#include "fb.h"
@@ -45,6 +45,14 @@ fbGetSpans(DrawablePtr pDrawable,
if (!fbDrawableEnabled(pDrawable))
return;
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
+ return;
+ }
+#endif
+
fbGetDrawable (pDrawable, src, srcStride, srcBpp);
while (nspans--)
diff --git a/xc/programs/Xserver/fb/fbimage.c b/xc/programs/Xserver/fb/fbimage.c
index d9a467f38..d88df7c04 100644
--- a/xc/programs/Xserver/fb/fbimage.c
+++ b/xc/programs/Xserver/fb/fbimage.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbimage.c,v 1.5 2000/02/23 20:29:45 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbimage.c,v 1.6 2000/05/06 21:09:33 keithp Exp $ */
#include "fb.h"
#ifdef XFree86LOADER
@@ -88,13 +88,29 @@ fbPutImage (DrawablePtr pDrawable,
}
break;
case ZPixmap:
- srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
- fbPutZImage (pDrawable,
- fbGetCompositeClip(pGC),
- pGC->alu,
- pPriv->pm,
- x, y, w, h,
- src, srcStride);
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth);
+ fb24_32PutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ (FbBits) pGC->planemask,
+ x, y, w, h,
+ (CARD8 *) pImage,
+ srcStride);
+ }
+ else
+#endif
+ {
+ srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
+ fbPutZImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pGC->alu,
+ pPriv->pm,
+ x, y, w, h,
+ src, srcStride);
+ }
}
}
@@ -284,6 +300,15 @@ fbGetImage (DrawablePtr pDrawable,
if (!fbDrawableEnabled(pDrawable))
return;
+#ifdef FB_24_32BIT
+ if (format == ZPixmap &&
+ pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
+ {
+ fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
+ return;
+ }
+#endif
+
fbGetDrawable (pDrawable, src, srcStride, srcBpp);
x += pDrawable->x;
diff --git a/xc/programs/Xserver/fb/fboverlay.c b/xc/programs/Xserver/fb/fboverlay.c
new file mode 100644
index 000000000..548419fdc
--- /dev/null
+++ b/xc/programs/Xserver/fb/fboverlay.c
@@ -0,0 +1,192 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.c,v 1.2 2000/05/11 18:14:13 tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#include "fb.h"
+#include "fboverlay.h"
+
+int fbOverlayGeneration;
+int fbOverlayScreenPrivateIndex;
+
+/*
+ * Replace this if you want something supporting
+ * multiple overlays with the same depth
+ */
+Bool
+fbOverlayCreateWindow(WindowPtr pWin)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pWin->drawable.pScreen);
+ int i;
+
+ if (pWin->drawable.class != InputOutput)
+ return TRUE;
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ if (pWin->drawable.depth == pScrPriv->pLayer[i]->drawable.depth)
+ {
+ pWin->devPrivates[fbWinPrivateIndex].ptr = (pointer) pScrPriv->pLayer[i];
+ return TRUE;
+ }
+ return FALSE;
+}
+
+Bool
+fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen)
+{
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int i;
+
+ for (i = 0; i < pScrPriv->nlayers; i++)
+ (*pScreen->DestroyPixmap)(pScrPriv->pLayer[i]);
+ return TRUE;
+}
+
+Bool
+fbOverlayCreateScreenResources(ScreenPtr pScreen)
+{
+ int i;
+ FbOverlayScrInitPtr pInit = (FbOverlayScrInitPtr) (pScreen)->devPrivates[fbOverlayScreenPrivateIndex].ptr;
+ FbOverlayScrPrivPtr pScrPriv;
+ PixmapPtr pPixmap;
+ FbOverlayInitPtr overlay;
+
+ if (!miCreateScreenResources(pScreen))
+ return FALSE;
+
+ pScrPriv = xalloc (sizeof (FbOverlayScrPrivRec));
+ if (!pScrPriv)
+ return FALSE;
+
+ for (i = 0; i < pInit->nlayers; i++)
+ {
+ overlay = &pInit->init[i];
+ pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, overlay->depth);
+ if (!pPixmap)
+ return FALSE;
+ if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
+ pScreen->height, overlay->depth,
+ BitsPerPixel(overlay->depth),
+ PixmapBytePad(overlay->width, overlay->depth),
+ overlay->pbits))
+ return FALSE;
+ pScrPriv->pLayer[i] = pPixmap;
+ }
+ pScrPriv->nlayers = pInit->nlayers;
+ xfree (pInit);
+ (pScreen)->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pScrPriv;
+ pScreen->devPrivate = pScrPriv->pLayer[0];
+ return TRUE;
+}
+
+Bool
+fbOverlaySetupScreen(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2)
+{
+ return fbSetupScreen (pScreen,
+ pbits1,
+ xsize,
+ ysize,
+ dpix,
+ dpiy,
+ width1,
+ bpp1);
+}
+
+Bool
+fbOverlayFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2,
+ int depth1,
+ int depth2)
+{
+ VisualPtr visuals;
+ DepthPtr depths;
+ int nvisuals;
+ int ndepths;
+ VisualID defaultVisual;
+ FbOverlayScrInitPtr pInit;
+
+ if (fbOverlayGeneration != serverGeneration)
+ {
+ fbOverlayScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ fbOverlayGeneration = serverGeneration;
+ }
+
+ pInit = xalloc (sizeof (FbOverlayScrInitRec));
+ if (!pInit)
+ return FALSE;
+
+
+ if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
+ &defaultVisual, ((unsigned long)1<<(bpp1-1)) |
+ ((unsigned long)1<<(bpp2-1)), 8))
+ return FALSE;
+ if (! miScreenInit(pScreen, 0, xsize, ysize, dpix, dpiy, 0,
+ depth1, ndepths, depths,
+ defaultVisual, nvisuals, visuals
+#ifdef FB_OLD_SCREEN
+ , (miBSFuncPtr) 0
+#endif
+ ))
+ return FALSE;
+ /* MI thinks there's no frame buffer */
+#ifdef MITSHM
+ ShmRegisterFbFuncs(pScreen);
+#endif
+ pScreen->minInstalledCmaps = 1;
+ pScreen->maxInstalledCmaps = 2;
+
+ pInit->nlayers = 2;
+ pInit->init[0].pbits = pbits1;
+ pInit->init[0].width = width1;
+ pInit->init[0].depth = depth1;
+
+ pInit->init[1].pbits = pbits2;
+ pInit->init[1].width = width2;
+ pInit->init[1].depth = depth2;
+
+ pScreen->devPrivates[fbOverlayScreenPrivateIndex].ptr = (pointer) pInit;
+
+ /* overwrite miCloseScreen with our own */
+ pScreen->CloseScreen = fbOverlayCloseScreen;
+ pScreen->CreateScreenResources = fbOverlayCreateScreenResources;
+ pScreen->CreateWindow = fbOverlayCreateWindow;
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/fb/fboverlay.h b/xc/programs/Xserver/fb/fboverlay.h
new file mode 100644
index 000000000..d45f16e8a
--- /dev/null
+++ b/xc/programs/Xserver/fb/fboverlay.h
@@ -0,0 +1,91 @@
+/*
+ * $XFree86: xc/programs/Xserver/fb/fboverlay.h,v 1.2 2000/05/11 18:14:13 tsi Exp $
+ *
+ * Copyright © 2000 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _FBOVERLAY_H_
+#define _FBOVERLAY_H_
+
+extern int fbOverlayGeneration;
+extern int fbOverlayScreenPrivateIndex;
+
+#define FB_OVERLAY_MAX 3
+
+typedef struct _fbOverlayScrPriv {
+ int nlayers;
+ PixmapPtr pLayer[FB_OVERLAY_MAX];
+} FbOverlayScrPrivRec, *FbOverlayScrPrivPtr;
+
+#define fbOverlayGetScrPriv(s) ((FbOverlayScrPrivPtr) \
+ (s)->devPrivates[fbOverlayScreenPrivateIndex].ptr)
+
+typedef struct _fbOverlayInit {
+ pointer pbits;
+ int width;
+ int depth;
+} FbOverlayInitRec, *FbOverlayInitPtr;
+
+typedef struct _fbOverlayScrInit {
+ int nlayers;
+ FbOverlayInitRec init[FB_OVERLAY_MAX];
+} FbOverlayScrInitRec, *FbOverlayScrInitPtr;
+
+Bool
+fbOverlayCreateWindow(WindowPtr pWin);
+
+Bool
+fbOverlayCloseScreen (int iScreen, ScreenPtr pScreen);
+
+Bool
+fbOverlayCreateScreenResources(ScreenPtr pScreen);
+
+
+Bool
+fbOverlaySetupScreen(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2);
+
+Bool
+fbOverlayFinishScreenInit(ScreenPtr pScreen,
+ pointer pbits1,
+ pointer pbits2,
+ int xsize,
+ int ysize,
+ int dpix,
+ int dpiy,
+ int width1,
+ int width2,
+ int bpp1,
+ int bpp2,
+ int depth1,
+ int depth2);
+
+#endif /* _FBOVERLAY_H_ */
diff --git a/xc/programs/Xserver/fb/fbpixmap.c b/xc/programs/Xserver/fb/fbpixmap.c
index eb2fe6949..0ecc58de7 100644
--- a/xc/programs/Xserver/fb/fbpixmap.c
+++ b/xc/programs/Xserver/fb/fbpixmap.c
@@ -21,21 +21,22 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbpixmap.c,v 1.3 2000/02/23 20:29:45 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbpixmap.c,v 1.7 2000/05/06 21:09:34 keithp Exp $ */
#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
PixmapPtr
-fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth)
+fbCreatePixmapBpp (ScreenPtr pScreen, int width, int height, int depth, int bpp)
{
PixmapPtr pPixmap;
int datasize;
int paddedWidth;
- int bpp;
int adjust;
int base;
- bpp = BitsPerPixel(depth);
paddedWidth = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (FbBits);
datasize = height * paddedWidth;
#ifdef PIXPRIV
@@ -74,6 +75,19 @@ fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth)
return pPixmap;
}
+PixmapPtr
+fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth)
+{
+ int bpp;
+
+ bpp = BitsPerPixel (depth);
+#ifdef FB_SCREEN_PRIVATE
+ if (bpp == 32)
+ bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
+#endif
+ return fbCreatePixmapBpp (pScreen, width, height, depth, bpp);
+}
+
Bool
fbDestroyPixmap (PixmapPtr pPixmap)
{
@@ -130,7 +144,7 @@ fbPixmapToRegion(PixmapPtr pPix)
register FbBits mask0 = FB_ALLONES & ~FbScrRight(FB_ALLONES, 1);
FbBits *pwLine;
int nWidth;
-
+
pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
if(!pReg)
return NullRegion;
diff --git a/xc/programs/Xserver/fb/fbscreen.c b/xc/programs/Xserver/fb/fbscreen.c
index 90e812e1e..ffcd2620f 100644
--- a/xc/programs/Xserver/fb/fbscreen.c
+++ b/xc/programs/Xserver/fb/fbscreen.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.8 2000/02/23 20:29:46 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbscreen.c,v 1.9 2000/05/06 21:09:34 keithp Exp $ */
#include "fb.h"
@@ -146,6 +146,7 @@ fbFinishScreenInit(ScreenPtr pScreen,
int ndepths;
int rootdepth;
VisualID defaultVisual;
+ int imagebpp = bpp;
#ifdef FB_DEBUG
int stride;
@@ -158,9 +159,43 @@ fbFinishScreenInit(ScreenPtr pScreen,
fbSetBits ((FbStip *) ((char *) pbits + stride * ysize),
stride / sizeof (FbStip), FB_TAIL_BITS);
#endif
+ /*
+ * By default, a 24bpp screen will use 32bpp images, this avoids
+ * problems with many applications which just can't handle packed
+ * pixels. If you want real 24bit images, include a 24bpp
+ * format in the pixmap formats
+ */
+#ifdef FB_24_32BIT
+ if (bpp == 24)
+ {
+ int f;
+
+ imagebpp = 32;
+ /*
+ * Check to see if we're advertising a 24bpp image format,
+ * in which case windows will use it in preference to a 32 bit
+ * format.
+ */
+ for (f = 0; f < screenInfo.numPixmapFormats; f++)
+ {
+ if (screenInfo.formats[f].bitsPerPixel == 24)
+ {
+ imagebpp = 24;
+ break;
+ }
+ }
+ }
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ if (imagebpp == 32)
+ {
+ fbGetScreenPrivate(pScreen)->win32bpp = bpp;
+ fbGetScreenPrivate(pScreen)->pix32bpp = bpp;
+ }
+#endif
rootdepth = 0;
if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
- &defaultVisual,((unsigned long)1<<(bpp-1)), 8))
+ &defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
return FALSE;
if (! miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
rootdepth, ndepths, depths,
@@ -172,6 +207,13 @@ fbFinishScreenInit(ScreenPtr pScreen,
return FALSE;
/* overwrite miCloseScreen with our own */
pScreen->CloseScreen = fbCloseScreen;
+#ifdef FB_24_32BIT
+ if (bpp == 24 && imagebpp == 32)
+ {
+ pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
+ pScreen->CreateScreenResources = fb24_32CreateScreenResources;
+ }
+#endif
#if 0
/* leave backing store initialization to the enclosing code so
* it can choose the correct order of wrappers
diff --git a/xc/programs/Xserver/fb/fbsetsp.c b/xc/programs/Xserver/fb/fbsetsp.c
index 4bddf8560..d2490e891 100644
--- a/xc/programs/Xserver/fb/fbsetsp.c
+++ b/xc/programs/Xserver/fb/fbsetsp.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbsetsp.c,v 1.3 2000/02/23 20:29:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbsetsp.c,v 1.4 2000/05/06 21:09:34 keithp Exp $ */
#include "fb.h"
@@ -44,6 +44,13 @@ fbSetSpans (DrawablePtr pDrawable,
int xoff;
int x1, x2;
+#ifdef FB_24_32BIT
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
+ return;
+ }
+#endif
fbGetDrawable (pDrawable, dst, dstStride, dstBpp);
while (nspans--)
{
diff --git a/xc/programs/Xserver/fb/fbwindow.c b/xc/programs/Xserver/fb/fbwindow.c
index 79090a55d..9f5bb0980 100644
--- a/xc/programs/Xserver/fb/fbwindow.c
+++ b/xc/programs/Xserver/fb/fbwindow.c
@@ -21,13 +21,24 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/fb/fbwindow.c,v 1.3 2000/02/23 20:29:48 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/fb/fbwindow.c,v 1.6 2000/05/06 21:09:34 keithp Exp $ */
#include "fb.h"
+#ifdef IN_MODULE
+#include "xf86_ansic.h"
+#endif
Bool
fbCreateWindow(WindowPtr pWin)
{
+#ifndef FB_NO_WINDOW_PIXMAPS
+ pWin->devPrivates[fbWinPrivateIndex].ptr =
+ (pointer) fbGetScreenPixmap(pWin->drawable.pScreen);
+#endif
+#ifdef FB_SCREEN_PRIVATE
+ if (pWin->drawable.bitsPerPixel == 32)
+ pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
+#endif
return TRUE;
}
@@ -140,6 +151,15 @@ fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (pWin->backgroundState == BackgroundPixmap)
{
pPixmap = pWin->background.pixmap;
+#ifdef FB_24_32BIT
+ if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap,
+ pWin->drawable.bitsPerPixel);
+ if (pPixmap)
+ pWin->background.pixmap = pPixmap;
+ }
+#endif
if (FbEvenTile (pPixmap->drawable.width *
pPixmap->drawable.bitsPerPixel))
fbPadPixmap (pPixmap);
@@ -150,6 +170,16 @@ fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (pWin->borderIsPixel == FALSE)
{
pPixmap = pWin->border.pixmap;
+#ifdef FB_24_32BIT
+ if (pPixmap->drawable.bitsPerPixel !=
+ pWin->drawable.bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap,
+ pWin->drawable.bitsPerPixel);
+ if (pPixmap)
+ pWin->border.pixmap = pPixmap;
+ }
+#endif
if (FbEvenTile (pPixmap->drawable.width *
pPixmap->drawable.bitsPerPixel))
fbPadPixmap (pPixmap);
diff --git a/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c b/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c
index 8e55df245..fb533f916 100644
--- a/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c
+++ b/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.3 2000/02/23 20:29:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.c,v 1.4 2000/05/06 22:17:41 keithp Exp $ */
#include "fbdev.h"
@@ -88,40 +88,40 @@ fbdevScreenInit (KdScreenInfo *screen)
screen->width = priv->var.xres;
screen->height = priv->var.yres;
- screen->depth = priv->var.bits_per_pixel;
- screen->bitsPerPixel = priv->var.bits_per_pixel;
- screen->byteStride = priv->fix.line_length;
- screen->pixelStride = (priv->fix.line_length * 8 /
+ screen->fb[0].depth = priv->var.bits_per_pixel;
+ screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
+ screen->fb[0].byteStride = priv->fix.line_length;
+ screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
priv->var.bits_per_pixel);
switch (priv->fix.visual) {
case FB_VISUAL_PSEUDOCOLOR:
- screen->visuals = ((1 << StaticGray) |
+ screen->fb[0].visuals = ((1 << StaticGray) |
(1 << GrayScale) |
(1 << StaticColor) |
(1 << PseudoColor) |
(1 << TrueColor) |
(1 << DirectColor));
- screen->blueMask = 0x00;
- screen->greenMask = 0x00;
- screen->redMask = 0x00;
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
break;
case FB_VISUAL_TRUECOLOR:
- screen->visuals = (1 << TrueColor);
- screen->redMask = FbStipMask (priv->var.red.offset, priv->var.red.length);
- screen->greenMask = FbStipMask (priv->var.green.offset, priv->var.green.length);
- screen->blueMask = FbStipMask (priv->var.blue.offset, priv->var.blue.length);
- allbits = screen->redMask | screen->greenMask | screen->blueMask;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].redMask = FbStipMask (priv->var.red.offset, priv->var.red.length);
+ screen->fb[0].greenMask = FbStipMask (priv->var.green.offset, priv->var.green.length);
+ screen->fb[0].blueMask = FbStipMask (priv->var.blue.offset, priv->var.blue.length);
+ allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask;
depth = 32;
while (depth && !(allbits & (1 << (depth - 1))))
depth--;
- screen->depth = depth;
+ screen->fb[0].depth = depth;
break;
default:
return FALSE;
break;
}
screen->rate = 72;
- screen->frameBuffer = (CARD8 *) (priv->fb);
+ screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
return TRUE;
}
@@ -191,7 +191,7 @@ fbdevCardFini (KdCardInfo *card)
}
void
-fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
+fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
FbdevPriv *priv = pScreenPriv->card->driver;
@@ -232,7 +232,7 @@ fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
}
void
-fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs)
+fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
FbdevPriv *priv = pScreenPriv->card->driver;
diff --git a/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h b/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h
index 052539bcc..795fa8dce 100644
--- a/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h
+++ b/xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.3 2000/02/23 20:29:58 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/fbdev/fbdev.h,v 1.4 2000/05/06 22:17:42 keithp Exp $ */
#ifndef _FBDEV_H_
#define _FBDEV_H_
@@ -75,10 +75,10 @@ void
fbdevCardFini (KdCardInfo *card);
void
-fbdevGetColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+fbdevGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
void
-fbdevPutColors (ScreenPtr pScreen, int n, xColorItem *pdefs);
+fbdevPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
#endif /* _FBDEV_H_ */
diff --git a/xc/programs/Xserver/hw/kdrive/igs/Imakefile b/xc/programs/Xserver/hw/kdrive/igs/Imakefile
new file mode 100644
index 000000000..cf18d0efe
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/Imakefile
@@ -0,0 +1,14 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/igs/Imakefile,v 1.2 2000/05/24 23:52:47 keithp Exp $
+#include <Server.tmpl>
+
+SRCS = igs.c igscmap.c igscurs.c igsdraw.c igsreg.c igsstub.c
+
+OBJS = igs.o igscmap.o igscurs.o igsdraw.o igsreg.o igsstub.o
+
+INCLUDES = -I.. -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
+ -I../../../fb -I../../../mi -I../../../include -I../../../os \
+ -I$(EXTINCSRC) -I$(XINCLUDESRC)
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(igs,$(OBJS))
+DependTarget()
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igs.c b/xc/programs/Xserver/hw/kdrive/igs/igs.c
new file mode 100644
index 000000000..a526b774e
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igs.c
@@ -0,0 +1,665 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igs.c,v 1.2 2000/05/24 23:52:47 keithp Exp $
+ *
+ * Copyright © 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#include "igs.h"
+
+Bool
+igsCardInit (KdCardInfo *card)
+{
+ int k;
+ char *pixels;
+ IgsCardInfo *igsc;
+
+ igsc = (IgsCardInfo *) xalloc (sizeof (IgsCardInfo));
+ if (!igsc)
+ return FALSE;
+
+ memset (igsc, '\0', sizeof (IgsCardInfo));
+
+ igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0] +
+ IGS_FB,
+ IGS_MEM);
+
+ igsc->vga = (VOL8 *) KdMapDevice (card->attr.address[0] +
+ IGS_VGA,
+ 64 * 1024);
+
+ igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] +
+ IGS_COP_OFFSET,
+ sizeof (Cop5xxx));
+
+ igsc->copData = (VOL32 *) KdMapDevice (card->attr.address[0] +
+ IGS_COP_DATA,
+ IGS_COP_DATA_LEN);
+
+ igsRegInit (&igsc->igsvga, igsc->vga);
+
+ card->driver = igsc;
+
+ return TRUE;
+}
+
+Bool
+igsModeSupported (KdScreenInfo *screen,
+ const KdMonitorTiming *t)
+{
+ /* make sure the clock isn't too fast */
+ if (t->clock > IGS_MAX_CLOCK)
+ return FALSE;
+ /* width must be a multiple of 16 */
+ if (t->horizontal & 0xf)
+ return FALSE;
+ return TRUE;
+}
+
+Bool
+igsModeUsable (KdScreenInfo *screen)
+{
+ KdCardInfo *card = screen->card;
+ int screen_size;
+ int pixel_width;
+ int byte_width;
+ int fb = 0;
+
+ screen_size = 0;
+ if (screen->fb[fb].depth >= 24)
+ {
+ screen->fb[fb].depth = 24;
+ if (screen->fb[fb].bitsPerPixel != 24)
+ screen->fb[fb].bitsPerPixel = 32;
+ }
+ else if (screen->fb[fb].depth >= 16)
+ {
+ screen->fb[fb].depth = 16;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else if (screen->fb[fb].depth >= 15)
+ {
+ screen->fb[fb].depth = 15;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else if (screen->fb[fb].depth >= 12)
+ {
+ screen->fb[fb].depth = 12;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->fb[fb].depth = 8;
+ screen->fb[fb].bitsPerPixel = 8;
+ }
+
+ byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
+ pixel_width = screen->width;
+ screen->fb[fb].pixelStride = pixel_width;
+ screen->fb[fb].byteStride = byte_width;
+ screen_size += byte_width * screen->height;
+
+ return TRUE;
+}
+
+Bool
+igsScreenInit (KdScreenInfo *screen)
+{
+ IgsCardInfo *igsc = screen->card->driver;
+ int fb = 0;
+ IgsScreenInfo *igss;
+ int screen_size, memory;
+ int pattern_size;
+ int tile_size;
+ int stipple_size;
+ int poffset, boffset;
+ const KdMonitorTiming *t;
+
+ if (!screen->width || !screen->height)
+ {
+ screen->width = 800;
+ screen->height = 600;
+ screen->rate = 72;
+ }
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 8;
+
+ t = KdFindMode (screen, igsModeSupported);
+
+ screen->rate = t->rate;
+ screen->width = t->horizontal;
+ screen->height = t->vertical;
+
+ if (!KdTuneMode (screen, igsModeUsable, igsModeSupported))
+ {
+ return FALSE;
+ }
+
+ igss = (IgsScreenInfo *) xalloc (sizeof (IgsScreenInfo));
+ if (!igss)
+ return FALSE;
+
+ memset (igss, '\0', sizeof (IgsScreenInfo));
+
+ screen_size = screen->fb[fb].byteStride * screen->height;
+ memory = IGS_MEM;
+ memory -= screen_size;
+ if (memory >= 1024)
+ {
+ igss->cursor_offset = memory - 1024;
+#if BITMAP_BIT_ORDER == MSBFirst
+ igss->cursor_base = (CARD8 *) KdMapDevice (card->attr.address[0] +
+ igss->cursor_offset,
+ 1024);
+#else
+ igss->cursor_base = igsc->frameBuffer + igss->cursor_offset;
+#endif
+ memory -= 1024;
+ }
+ else
+ igss->cursor_base = 0;
+
+ tile_size = IgsTileSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
+ stipple_size = IgsStippleSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
+ pattern_size = tile_size + stipple_size;
+ if (memory >= pattern_size)
+ {
+ boffset = screen_size;
+ poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
+ igss->tile.offset = poffset;
+ igss->tile.base = igsc->frameBuffer + boffset;
+
+ boffset = screen_size + tile_size;
+ poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
+ igss->stipple.offset = poffset;
+ igss->stipple.base = igsc->frameBuffer + boffset;
+
+ memory -= pattern_size;
+ }
+ else
+ {
+ igss->tile.base = 0;
+ igss->stipple.base = 0;
+ }
+
+ switch (screen->fb[fb].depth) {
+ case 8:
+ screen->fb[fb].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ screen->fb[fb].blueMask = 0x00;
+ screen->fb[fb].greenMask = 0x00;
+ screen->fb[fb].redMask = 0x00;
+ break;
+ case 15:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x001f;
+ screen->fb[fb].greenMask = 0x03e0;
+ screen->fb[fb].redMask = 0x7c00;
+ break;
+ case 16:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x001f;
+ screen->fb[fb].greenMask = 0x07e0;
+ screen->fb[fb].redMask = 0xf800;
+ break;
+ case 24:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x0000ff;
+ screen->fb[fb].greenMask = 0x00ff00;
+ screen->fb[fb].redMask = 0xff0000;
+ break;
+ }
+
+ screen->fb[fb].pixelStride = screen->width;
+ screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
+ screen->fb[fb].frameBuffer = igsc->frameBuffer;
+ if (!igsc->cop)
+ screen->dumb = TRUE;
+ screen->driver = igss;
+ return TRUE;
+}
+
+Bool
+igsInitScreen(ScreenPtr pScreen)
+{
+ return TRUE;
+}
+
+void
+igsPreserve (KdCardInfo *card)
+{
+ IgsCardInfo *igsc = card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+
+ igsSave (igsvga);
+}
+
+void
+igsSetBlank (IgsVga *igsvga, Bool blank)
+{
+ igsSetImm(igsvga, igs_screen_off, blank ? 1 : 0);
+}
+
+void
+igsSetSync (IgsCardInfo *igsc, int hsync, int vsync)
+{
+ IgsVga *igsvga = &igsc->igsvga;
+
+ igsSet (igsvga, igs_mexhsyn, hsync);
+ igsSet (igsvga, igs_mexvsyn, vsync);
+ VgaFlush (&igsvga->card);
+}
+
+
+/*
+ * Clock synthesis:
+ *
+ * scale = p ? (2 * p) : 1
+ * f_out = f_ref * ((M + 1) / ((N + 1) * scale))
+ *
+ * Constraints:
+ *
+ * 1. 115MHz <= f_ref * ((M + 1) / (N + 1)) <= 260 MHz
+ * 2. N >= 1
+ *
+ * Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
+ * Horizontal refresh rate = clock / (hsize + hblank)
+ */
+
+/* all in kHz */
+
+void
+igsGetClock (int target, int *Mp, int *Np, int *Pp, int maxM, int maxN, int maxP, int minVco)
+{
+ int M, N, P, bestM, bestN;
+ int f_vco, f_out;
+ int err, abserr, besterr;
+
+ /*
+ * Compute correct P value to keep VCO in range
+ */
+ for (P = 0; P <= maxP; P++)
+ {
+ f_vco = target * IGS_SCALE(P);
+ if (f_vco >= minVco)
+ break;
+ }
+
+ /* M = f_out / f_ref * ((N + 1) * IGS_SCALE(P)); */
+ besterr = target;
+ for (N = 1; N <= maxN; N++)
+ {
+ M = ((target * (N + 1) * IGS_SCALE(P) + (IGS_CLOCK_REF/2)) + IGS_CLOCK_REF/2) / IGS_CLOCK_REF - 1;
+ if (0 <= M && M <= maxM)
+ {
+ f_out = IGS_CLOCK(M,N,P);
+ err = target - f_out;
+ if (err < 0)
+ err = -err;
+ if (err < besterr)
+ {
+ besterr = err;
+ bestM = M;
+ bestN = N;
+ }
+ }
+ }
+ *Mp = bestM;
+ *Np = bestN;
+ *Pp = P;
+}
+
+void
+igsEnable (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ IgsCardInfo *igsc = card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+ const KdMonitorTiming *t;
+ int hactive, hblank, hfp, hbp;
+ int vactive, vblank, vfp, vbp;
+ int hsize;
+ int fb = 0;
+ int m, n, r;
+ int h_total;
+ int h_display_end;
+ int h_blank_start;
+ int h_blank_end;
+ int h_sync_start;
+ int h_sync_end;
+ int h_screen_off;
+ int v_total;
+ int v_retrace_start;
+ int v_retrace_end;
+ int v_display_end;
+ int v_blank_start;
+ int v_blank_end;
+ int offset;
+ int num_fetch;
+ int m_m, m_n, m_r;
+
+
+ igsSetBlank (igsvga, TRUE);
+
+ t = KdFindMode (screen, igsModeSupported);
+
+ igsGetClock (t->clock, &m, &n, &r, 2047, 255, 7, IGS_MIN_VCO);
+
+ /*
+ * Set the chip so that 0x400000 is a big-endian frame buffer
+ * with the correct byte swapping enabled
+ */
+ igsSet (igsvga, igs_biga22force, 0);
+ igsSet (igsvga, igs_biga22en, 1);
+ igsSet (igsvga, igs_biga24en, 1);
+ /*
+ * Enable 8-bit DACs
+ */
+ igsSet (igsvga, igs_rampwdn, 0);
+ igsSet (igsvga, igs_dac6_8, 1);
+ igsSet (igsvga, igs_dacpwdn, 0);
+ /*
+ * Set overscan to black
+ */
+ igsSet (igsvga, igs_overscan_red, 0x00);
+ igsSet (igsvga, igs_overscan_green, 0x00);
+ igsSet (igsvga, igs_overscan_blue, 0x00);
+ /*
+ * Enable PCI retries
+ */
+ igsSet (igsvga, igs_iow_retry, 1);
+ igsSet (igsvga, igs_mw_retry, 1);
+ igsSet (igsvga, igs_mr_retry, 1);
+ igsSet (igsvga, igs_pci_burst_write, 1);
+ igsSet (igsvga, igs_pci_burst_read, 1);
+ /*
+ * Set FIFO
+ */
+ igsSet (igsvga, igs_memgopg, 1);
+ igsSet (igsvga, igs_memr2wpg, 0);
+ igsSet (igsvga, igs_crtff16, 0);
+ igsSet (igsvga, igs_fifomust, 0xff);
+ igsSet (igsvga, igs_fifogen, 0xff);
+ /*
+ * Enable CRT reg access
+ */
+ igsSetImm (igsvga, igs_ena_vr_access, 1);
+ igsSetImm (igsvga, igs_crt_protect, 0);
+
+ hfp = t->hfp;
+ hbp = t->hbp;
+ hblank = t->hblank;
+ hactive = t->horizontal;
+ offset = screen->fb[0].byteStride;
+
+ vfp = t->vfp;
+ vbp = t->vbp;
+ vblank = t->vblank;
+ vactive = t->vertical;
+
+ /*
+ * Compute character lengths for horizontal timing values
+ */
+ hactive = screen->width / 8;
+ hblank /= 8;
+ hfp /= 8;
+ hbp /= 8;
+ offset /= 8;
+
+ switch (screen->fb[fb].bitsPerPixel) {
+ case 8:
+ igsSet (igsvga, igs_overscan_red, pScreen->blackPixel);
+ igsSet (igsvga, igs_overscan_green, pScreen->blackPixel);
+ igsSet (igsvga, igs_overscan_blue, pScreen->blackPixel);
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_8);
+ igsSet (igsvga, igs_ramdacbypass, 0);
+ break;
+ case 16:
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_16);
+ igsSet (igsvga, igs_ramdacbypass, 1);
+ switch (screen->fb[fb].depth) {
+ case 12:
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_4444);
+ break;
+ case 15:
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_5551);
+ break;
+ case 16:
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_565);
+ break;
+ }
+ break;
+ case 24:
+ igsSet (igsvga, igs_ramdacbypass, 1);
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_888);
+ break;
+ case 32:
+ igsSet (igsvga, igs_ramdacbypass, 1);
+ igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_32);
+ igsSet (igsvga, igs_mode_sel, IGS_MODE_8888);
+ break;
+ }
+
+ /*
+ * Compute horizontal register values from timings
+ */
+ h_total = hactive + hblank - 5;
+ h_display_end = hactive - 1;
+
+ h_sync_start = hactive + hfp;
+ h_sync_end = hactive + hblank - hbp;
+ /*
+ * pad the blank values narrow a bit and use the border_select to
+ * eliminate the remaining border; don't know why, but it doesn't
+ * work in the documented fashion
+ */
+ h_blank_start = hactive - 1;
+ h_blank_end = hactive + hblank - 1 - 1;
+
+ num_fetch = (t->horizontal * screen->fb[fb].bitsPerPixel / 64) + 1;
+
+ v_total = vactive + vblank - 2;
+ v_display_end = vactive - 1;
+
+ v_blank_start = vactive - 1;
+ v_blank_end = v_blank_start + vblank - 1;
+
+ v_retrace_start = vactive + vfp;
+ v_retrace_end = vactive + vblank - vbp;
+
+#if 0
+#define chk(a,b,c) fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", a, igsGet(igsvga, b), c);
+
+ chk("h_total", igs_h_total, h_total);
+ chk("h_display_end", igs_h_de_end, h_display_end);
+ chk("h_sync_start", igs_h_rstart, h_sync_start);
+ chk("h_sync_end", igs_h_rend, h_sync_end&0x1f);
+ chk("h_blank_start", igs_h_bstart, h_blank_start);
+ chk("h_blank_end", igs_h_bend, h_blank_end&0x3f);
+ chk("offset", igs_offset, offset);
+ chk("num_fetch", igs_num_fetch, num_fetch);
+
+ chk("v_total", igs_v_total, v_total);
+ chk("v_display_end", igs_v_de_end, v_display_end);
+ chk("v_blank_start", igs_v_bstart, v_blank_start);
+ chk("v_blank_end", igs_v_bend, v_blank_end&0xf);
+ chk("v_retrace_start", igs_v_rstart, v_retrace_start);
+ chk("v_retrace_end", igs_v_rend, v_retrace_end&0xf);
+ chk("vclk_m", igs_vclk_m, m);
+ chk("vclk_n", igs_vclk_n, n);
+ chk("vclk_p", igs_vclk_p, r);
+
+ fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", "vclk",
+ IGS_CLOCK(igsGet(igsvga,igs_vclk_m),
+ igsGet(igsvga,igs_vclk_n),
+ igsGet(igsvga,igs_vclk_p)),
+ IGS_CLOCK(m,n,r));
+#endif
+ igsSet (igsvga, igs_h_total, h_total);
+ igsSet (igsvga, igs_h_de_end, h_display_end);
+ igsSet (igsvga, igs_h_rstart, h_sync_start);
+ igsSet (igsvga, igs_h_rend, h_sync_end);
+ igsSet (igsvga, igs_h_bstart, h_blank_start);
+ igsSet (igsvga, igs_h_bend, h_blank_end);
+ igsSet (igsvga, igs_offset, offset);
+ igsSet (igsvga, igs_num_fetch, num_fetch);
+
+ igsSet (igsvga, igs_v_total, v_total);
+ igsSet (igsvga, igs_v_de_end, v_display_end);
+ igsSet (igsvga, igs_v_bstart, v_blank_start);
+ igsSet (igsvga, igs_v_bend, v_blank_end&0xf);
+ igsSet (igsvga, igs_v_rstart, v_retrace_start);
+ igsSet (igsvga, igs_v_rend, v_retrace_end&0xf);
+
+ igsSet (igsvga, igs_vclk_m, m);
+ igsSet (igsvga, igs_vclk_n, n);
+ igsSet (igsvga, igs_vclk_p, r);
+ igsSet (igsvga, igs_vfsel, IGS_CLOCK(m, n, 0) >= 180000);
+ VgaFlush (&igsvga->card);
+
+ igsSetImm (igsvga, igs_frqlat, 0);
+ igsSetImm (igsvga, igs_frqlat, 1);
+ igsSetImm (igsvga, igs_frqlat, 0);
+
+ igsSetBlank (igsvga, FALSE);
+#if 0
+#define dbg(a,b) fprintf(stderr, "%20.20s = 0x%x\n", a, igsGet(igsvga,b))
+
+#include "reg.dbg"
+
+ {
+ VGA16 reg;
+ char buf[128];
+
+ for (reg = 0; reg < IGS_NREG; reg++)
+ fprintf(stderr, "%20.20s = 0x%02x\n", igsRegName(buf, reg),
+ VgaFetch (&igsvga->card, reg));
+ }
+#endif
+}
+
+Bool
+igsDPMS (ScreenPtr pScreen, int mode)
+{
+ KdScreenPriv(pScreen);
+ IgsCardInfo *igsc = pScreenPriv->card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+
+ switch (mode) {
+ case KD_DPMS_NORMAL:
+ igsSetSync (igsc, 0, 0);
+ igsSetBlank (igsvga, FALSE);
+ break;
+ case KD_DPMS_STANDBY:
+ igsSetBlank (igsvga, TRUE);
+ igsSetSync (igsc, 1, 0);
+ break;
+ case KD_DPMS_SUSPEND:
+ igsSetBlank (igsvga, TRUE);
+ igsSetSync (igsc, 0, 1);
+ break;
+ case KD_DPMS_POWERDOWN:
+ igsSetBlank (igsvga, TRUE);
+ igsSetSync (igsc, 1, 1);
+ break;
+ }
+ return TRUE;
+}
+
+void
+igsDisable (ScreenPtr pScreen)
+{
+}
+
+void
+igsRestore (KdCardInfo *card)
+{
+ IgsCardInfo *igsc = card->driver;
+ IgsVga *igsvga = &igsc->igsvga;
+
+ igsReset (igsvga);
+}
+
+void
+igsScreenFini (KdScreenInfo *screen)
+{
+ IgsScreenInfo *igss = (IgsScreenInfo *) screen->driver;
+
+#if BITMAP_BIT_ORDER == MSBFirst
+ if (igss->cursor_base)
+ KdUnmapDevice ((void *) igss->cursor_base, 1024);
+#endif
+ xfree (igss);
+ screen->driver = 0;
+}
+
+void
+igsCardFini (KdCardInfo *card)
+{
+ IgsCardInfo *igsc = card->driver;
+
+ if (igsc->copData)
+ KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN);
+ if (igsc->cop)
+ KdUnmapDevice ((void *) igsc->cop, sizeof (Cop5xxx));
+ if (igsc->vga)
+ KdUnmapDevice ((void *) igsc->vga, 64 * 1024);
+ if (igsc->frameBuffer)
+ KdUnmapDevice (igsc->frameBuffer, IGS_MEM);
+ xfree (igsc);
+ card->driver = 0;
+}
+
+KdCardFuncs igsFuncs = {
+ igsCardInit, /* cardinit */
+ igsScreenInit, /* scrinit */
+ igsInitScreen,
+ igsPreserve, /* preserve */
+ igsEnable, /* enable */
+ igsDPMS, /* dpms */
+ igsDisable, /* disable */
+ igsRestore, /* restore */
+ igsScreenFini, /* scrfini */
+ igsCardFini, /* cardfini */
+
+ igsCursorInit, /* initCursor */
+ igsCursorEnable, /* enableCursor */
+ igsCursorDisable, /* disableCursor */
+ igsCursorFini, /* finiCursor */
+ 0, /* recolorCursor */
+
+ igsDrawInit, /* initAccel */
+ igsDrawEnable, /* enableAccel */
+ igsDrawSync, /* drawSync */
+ igsDrawDisable, /* disableAccel */
+ igsDrawFini, /* finiAccel */
+
+ igsGetColors, /* getColors */
+ igsPutColors, /* putColors */
+};
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igs.h b/xc/programs/Xserver/hw/kdrive/igs/igs.h
new file mode 100644
index 000000000..9ca757d8a
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igs.h
@@ -0,0 +1,329 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igs.h,v 1.2 2000/05/24 23:52:47 keithp Exp $
+ *
+ * Copyright © 1999 SuSE, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of SuSE not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. SuSE makes no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
+ * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
+ * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Keith Packard, SuSE, Inc.
+ */
+
+#ifndef _IGS_H_
+#define _IGS_H_
+
+#include "kdrive.h"
+#include "igsreg.h"
+
+extern KdCardFuncs igsFuncs;
+
+/*
+ * FB 0x00000000
+ * VGA 0x00800000
+ * Blt window 0x008a0000
+ * Coprocessor 0x008bf000
+ */
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define IGS_FB 0x00400000
+#else
+#define IGS_FB 0x00000000
+#endif
+#define IGS_VGA 0x00800000
+#define IGS_COP_DATA 0x008a0000
+#define IGS_COP_DATA_LEN 0x00010000
+#define IGS_COP_OFFSET 0x008bf000
+/* give audio 1/2 meg at end */
+#if 1
+#define IGS_MEM ((4096-512)*1024)
+#else
+#define IGS_MEM ((4096)*1024)
+#endif
+
+#define IGS_CLOCK_REF 24576 /* KHz */
+
+#define IGS_SCALE(p) ((p) ? (2 * (p)) : 1)
+
+#define IGS_CLOCK(m,n,p) ((IGS_CLOCK_REF * ((m) + 1)) / (((n) + 1) * IGS_SCALE(p)))
+
+#define IGS_MAX_CLOCK 260000
+
+#define IGS_MIN_VCO 115000
+
+typedef volatile CARD8 VOL8;
+typedef volatile CARD16 VOL16;
+typedef volatile CARD32 VOL32;
+
+typedef struct _Cop5xxx {
+ VOL8 pad000[0x10]; /* 0x000 */
+
+ VOL32 control; /* 0x010 */
+#define IGS_CONTROL_HBLTW_RDYZ 0x0100
+#define IGS_CONTROL_MALLWBEPTZ 0x0200
+#define IGS_CONTROL_CMDFF 0x0400
+#define IGS_CONTROL_SOP 0x0800
+#define IGS_CONTROL_OPS 0x1000
+#define IGS_CONTROL_TER 0x2000
+#define IGS_CONTROL_HBACKZ 0x4000
+#define IGS_CONTROL_BUSY 0x8000
+
+ VOL8 pad014[0x04]; /* 0x014 */
+
+ VOL32 src1_stride; /* 0x018 */
+
+ VOL32 format; /* 0x01c */
+
+#define IGS_FORMAT_8BPP 0
+#define IGS_FORMAT_16BPP 1
+#define IGS_FORMAT_24BPP 2
+#define IGS_FORMAT_32BPP 3
+
+ VOL32 bres_error; /* 0x020 */
+ VOL32 bres_k1; /* 0x024 */
+ VOL32 bres_k2; /* 0x028 */
+ VOL8 pad02c[0x1c]; /* 0x02c */
+
+ VOL32 mix; /* 0x048 */
+#define IGS_MIX_FG 0x00ff
+#define IGS_MIX_BG 0xff00
+#define IGS_MAKE_MIX(fg,bg) ((fg) | ((bg) << 8))
+
+#define IGS_MIX_ZERO 0x0
+#define IGS_MIX_SRC_AND_DST 0x1
+#define IGS_MIX_SRC_AND_NOT_DST 0x2
+#define IGS_MIX_SRC 0x3
+#define IGS_MIX_NOT_SRC_AND_DST 0x4
+#define IGS_MIX_DST 0x5
+#define IGS_MIX_SRC_XOR_DST 0x6
+#define IGS_MIX_SRC_OR_DST 0x7
+#define IGS_MIX_NOT_SRC_AND_NOT_DST 0x8
+#define IGS_MIX_SRC_XOR_NOT_DST 0x9
+#define IGS_MIX_NOT_DST 0xa
+#define IGS_MIX_SRC_OR_NOT_DST 0xb
+#define IGS_MIX_NOT_SRC 0xc
+#define IGS_MIX_NOT_SRC_OR_DST 0xd
+#define IGS_MIX_NOT_SRC_OR_NOT_DST 0xe
+#define IGS_MIX_ONE 0xf
+
+ VOL32 colorComp; /* 0x04c */
+ VOL32 planemask; /* 0x050 */
+
+ VOL8 pad054[0x4]; /* 0x054 */
+
+ VOL32 fg; /* 0x058 */
+ VOL32 bg; /* 0x05c */
+ VOL32 dim; /* 0x060 */
+#define IGS_MAKE_DIM(w,h) ((w) | ((h) << 16))
+ VOL8 pad5[0x0c]; /* 0x064 */
+
+ VOL32 src1_base_address; /* 0x070 */
+ VOL8 pad074[0x04]; /* 0x074 */
+
+ VOL32 rotate; /* 0x078 */
+#define IGS_MAKE_ROTATE(x,y) ((x) | ((y) << 16))
+ VOL32 operation; /* 0x07c */
+
+/* OCT[2:0] */
+#define IGS_DRAW_X_MAJOR 0x00000000
+#define IGS_DRAW_Y_MAJOR 0x00000001
+#define IGS_DRAW_T_B 0x00000000
+#define IGS_DRAW_B_T 0x00000002
+#define IGS_DRAW_L_R 0x00000000
+#define IGS_DRAW_R_L 0x00000004
+
+/* Draw_Mode[1:0] */
+#define IGS_DRAW_ALL 0x00000000
+#define IGS_DRAW_NOT_FIRST 0x00000010
+#define IGS_DRAW_NOT_LAST 0x00000020
+#define IGS_DRAW_NOT_FIRST_LAST 0x00000030
+
+/* TRPS[1:0] */
+#define IGS_TRANS_SRC1 0x00000000
+#define IGS_TRANS_SRC2 0x00000100
+#define IGS_TRANS_DST 0x00000200
+/* TRPS2 Transparent Invert */
+#define IGS_TRANS_INVERT 0x00000400
+/* TRPS3, Transparent Enable */
+#define IGS_TRANS_ENABLE 0x00000800
+
+/* PPS[3:0], Pattern Pixel Select */
+#define IGS_PIXEL_TEXT_OPAQUE 0x00001000
+#define IGS_PIXEL_STIP_OPAQUE 0x00002000
+#define IGS_PIXEL_LINE_OPAQUE 0x00003000
+#define IGS_PIXEL_TEXT_TRANS 0x00005000
+#define IGS_PIXEL_STIP_TRANS 0x00006000
+#define IGS_PIXEL_LINE_TRANS 0x00007000
+#define IGS_PIXEL_FG 0x00008000
+#define IGS_PIXEL_TILE 0x00009000
+#define IGS_PIXEL_TILE_OPAQUE 0x0000d000
+
+/* HostBltEnable[1:0] */
+#define IGS_HBLT_DISABLE 0x00000000
+#define IGS_HBLT_READ 0x00010000
+#define IGS_HBLT_WRITE_1 0x00020000
+#define IGS_HBLT_WRITE_2 0x00030000
+
+/* Src2MapSelect[2:0], Src2 map select mode */
+#define IGS_SRC2_NORMAL 0x00000000
+#define IGS_SRC2_MONO_OPAQUE 0x00100000
+#define IGS_SRC2_FG 0x00200000
+#define IGS_SRC2_MONO_TRANS 0x00500000
+
+/* StepFunction[3:0], Step function select */
+#define IGS_STEP_DRAW_AND_STEP 0x04000000
+#define IGS_STEP_LINE_DRAW 0x05000000
+#define IGS_STEP_PXBLT 0x08000000
+#define IGS_STEP_INVERT_PXBLT 0x09000000
+#define IGS_STEP_TERNARY_PXBLT 0x0b000000
+
+/* FGS */
+#define IGS_FGS_FG 0x00000000
+#define IGS_FGS_SRC 0x20000000
+
+/* BGS */
+#define IGS_BGS_BG 0x00000000
+#define IGS_BGS_SRC 0x80000000
+ VOL8 pad080[0x90]; /* 0x080 */
+
+ VOL32 debug_control; /* 0x110 */
+ VOL8 pad114[0x04]; /* 0x114 */
+
+ VOL32 src2_stride; /* 0x118 */
+ VOL8 pad11c[0x14]; /* 0x11c */
+
+ VOL32 extension; /* 0x130 */
+
+#define IGS_BURST_ENABLE 0x01
+#define IGS_STYLE_LINE 0x02
+#define IGS_ADDITIONAL_WAIT 0x04
+#define IGS_BLOCK_COP_REG 0x08
+#define IGS_TURBO_MONO 0x10
+#define IGS_SELECT_SAMPLE 0x40
+#define IGS_MDSBL_RD_B_WR 0x80
+#define IGS_WRMRSTZ 0x100
+#define IGS_TEST_MTST 0x200
+
+ VOL32 style_line; /* 0x134 */
+#define IGS_MAKE_STILE_LINE(roll_over,inc,pattern,accumulator) \
+ ((roll_over) | \
+ ((style_line_inc) << 8) | \
+ ((style_line_patern) << 16) | \
+ ((style_line_accumullator) << 24))
+ VOL32 style_line_pattern_index; /* 0x138 */
+
+ VOL32 mono_burst_total; /* 0x13c */
+ VOL8 pad140[0x10]; /* 0x140 */
+
+ VOL32 pat_x_rotate; /* 0x150 */
+ VOL8 pad154[0x1c]; /* 0x154 */
+
+ VOL32 src1_start; /* 0x170 */
+ VOL32 src2_start; /* 0x174 */
+ VOL32 dst_start; /* 0x178 */
+ VOL8 pad17c[0x9c]; /* 0x17c */
+
+ VOL32 dst_stride; /* 0x218 */
+} Cop5xxx;
+
+typedef struct _igsCardInfo {
+ Cop5xxx *cop;
+ VOL8 *vga;
+ VOL32 *copData;
+ CARD8 *frameBuffer;
+ IgsVga igsvga;
+} IgsCardInfo;
+
+#define getIgsCardInfo(kd) ((IgsCardInfo *) ((kd)->card->driver))
+#define igsCardInfo(kd) IgsCardInfo *igsc = getIgsCardInfo(kd)
+
+typedef struct _igsCursor {
+ int width, height;
+ int xhot, yhot;
+ Bool has_cursor;
+ CursorPtr pCursor;
+ Pixel source, mask;
+} IgsCursor;
+
+#define IGS_CURSOR_WIDTH 64
+#define IGS_CURSOR_HEIGHT 64
+
+typedef struct _igsPattern {
+ INT32 xrot, yrot;
+ CARD32 serial_number;
+ CARD8 *base;
+ CARD32 offset;
+} IgsPattern;
+
+#define IGS_NUM_PATTERN 8
+#define IGS_PATTERN_WIDTH 8
+#define IGS_PATTERN_HEIGHT 8
+
+typedef struct _igsPatternCache {
+ CARD8 *base;
+ CARD32 offset;
+ IgsPattern pattern[IGS_NUM_PATTERN];
+ int next;
+} IgsPatternCache;
+
+typedef struct _igsScreenInfo {
+ CARD8 *cursor_base;
+ CARD32 cursor_offset;
+ IgsCursor cursor;
+ IgsPatternCache tile;
+ IgsPatternCache stipple;
+} IgsScreenInfo;
+
+#define IgsTileSize(bpp) (IGS_PATTERN_WIDTH*(bpp)/8*IGS_PATTERN_HEIGHT)
+#define IgsStippleSize(bpp) (IGS_PATTERN_WIDTH/8*IGS_PATTERN_HEIGHT)
+
+#define getIgsScreenInfo(kd) ((IgsScreenInfo *) ((kd)->screen->driver))
+#define igsScreenInfo(kd) IgsScreenInfo *igss = getIgsScreenInfo(kd)
+
+Bool
+igsDrawInit (ScreenPtr pScreen);
+
+void
+igsDrawEnable (ScreenPtr pScreen);
+
+void
+igsDrawDisable (ScreenPtr pScreen);
+
+void
+igsDrawSync (ScreenPtr pScreen);
+
+void
+igsDrawFini (ScreenPtr pScreen);
+
+void
+igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+
+void
+igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+
+Bool
+igsCursorInit (ScreenPtr pScreen);
+
+void
+igsCursorEnable (ScreenPtr pScreen);
+
+void
+igsCursorDisable (ScreenPtr pScreen);
+
+void
+igsCursorFini (ScreenPtr pScreen);
+
+#endif /* _IGS_H_ */
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igscmap.c b/xc/programs/Xserver/hw/kdrive/igs/igscmap.c
new file mode 100644
index 000000000..dcebe264d
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igscmap.c
@@ -0,0 +1,61 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igscmap.c,v 1.1 2000/05/24 23:52:48 keithp Exp $
+ *
+ * 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.
+ */
+
+#include "igs.h"
+
+#define IGS_DAC_SHIFT 8
+void
+igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ IgsVga *igsvga = &igsc->igsvga;
+
+ while (ndef--)
+ {
+ igsSetImm (igsvga, igs_dac_read_index, pdefs->pixel);
+ pdefs->red = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
+ pdefs->green = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
+ pdefs->blue = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
+ pdefs++;
+ }
+}
+
+void
+igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ IgsVga *igsvga = &igsc->igsvga;
+
+ while (ndef--)
+ {
+ igsSetImm (igsvga, igs_dac_write_index, pdefs->pixel);
+ igsSetImm (igsvga, igs_dac_data, pdefs->red >> IGS_DAC_SHIFT);
+ igsSetImm (igsvga, igs_dac_data, pdefs->green >> IGS_DAC_SHIFT);
+ igsSetImm (igsvga, igs_dac_data, pdefs->blue >> IGS_DAC_SHIFT);
+ pdefs++;
+ }
+}
+
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igscurs.c b/xc/programs/Xserver/hw/kdrive/igs/igscurs.c
new file mode 100644
index 000000000..6e856eedc
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igscurs.c
@@ -0,0 +1,344 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igscurs.c,v 1.1 2000/05/24 23:52:48 keithp Exp $
+ *
+ * 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.
+ */
+
+#include "igs.h"
+#include "cursorstr.h"
+
+#define SetupCursor(s) KdScreenPriv(s); \
+ igsCardInfo(pScreenPriv); \
+ igsScreenInfo(pScreenPriv); \
+ IgsCursor *pCurPriv = &igss->cursor; \
+ IgsVga *igsvga = &igsc->igsvga
+
+static void
+_igsMoveCursor (ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor(pScreen);
+ CARD8 xoff, yoff;
+
+ x -= pCurPriv->xhot;
+ xoff = 0;
+ if (x < 0)
+ {
+ xoff = -x;
+ x = 0;
+ }
+ y -= pCurPriv->yhot;
+ yoff = 0;
+ if (y < 0)
+ {
+ yoff = -y;
+ y = 0;
+ }
+
+ igsSet (igsvga, igs_sprite_x, x);
+ igsSet (igsvga, igs_sprite_preset_x, xoff);
+ igsSet (igsvga, igs_sprite_y, y);
+ igsSet (igsvga, igs_sprite_preset_y, yoff);
+}
+
+static void
+igsMoveCursor (ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor (pScreen);
+
+ if (!pCurPriv->has_cursor)
+ return;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ _igsMoveCursor (pScreen, x, y);
+ VgaFlush (&igsvga->card);
+}
+
+
+static void
+igsSetCursorColors (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+ CursorPtr pCursor = pCurPriv->pCursor;
+
+ igsSetImm (igsvga, igs_cursor_write_index, 0);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8);
+ igsSetImm (igsvga, igs_cursor_write_index, 1);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8);
+ igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8);
+}
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define IgsAdjustCursor(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+ v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \
+ v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \
+}
+#else
+#define IgsAdjustCursor(v)
+#endif
+
+#define ExplodeBits2(v) (((v) & 1) | (((v) & 2) << 1))
+#define ExplodeBits4(v) ((ExplodeBits2((v) >> 2) << 4) | \
+ (ExplodeBits2((v) & 0x3)))
+#define ExplodeBits8(v) ((ExplodeBits4((v) >> 4) << 8) | \
+ (ExplodeBits4((v) & 0xf)))
+#define ExplodeBits16(v) ((ExplodeBits8((v) >> 8) << 16) | \
+ (ExplodeBits8((v) & 0xff)))
+static void
+igsLoadCursor (ScreenPtr pScreen, int x, int y)
+{
+ SetupCursor(pScreen);
+ CursorPtr pCursor = pCurPriv->pCursor;
+ CursorBitsPtr bits = pCursor->bits;
+ int w, h;
+ CARD32 *ram, *msk, *mskLine, *src, *srcLine;
+ int i, j;
+ int cursor_address;
+ int lwsrc;
+ unsigned char ramdac_control_;
+ CARD32 offset;
+ CARD32 b0, b1;
+
+ pCurPriv->pCursor = pCursor;
+ pCurPriv->xhot = pCursor->bits->xhot;
+ pCurPriv->yhot = pCursor->bits->yhot;
+
+ /*
+ * Stick new image into cursor memory
+ */
+ ram = (CARD32 *) igss->cursor_base;
+ mskLine = (CARD32 *) bits->mask;
+ srcLine = (CARD32 *) bits->source;
+
+ h = bits->height;
+ if (h > IGS_CURSOR_HEIGHT)
+ h = IGS_CURSOR_HEIGHT;
+
+ lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
+
+ for (i = 0; i < IGS_CURSOR_HEIGHT; i++) {
+ msk = mskLine;
+ src = srcLine;
+ mskLine += lwsrc;
+ srcLine += lwsrc;
+ for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) {
+
+ CARD32 m, s;
+
+ if (i < h && j < lwsrc)
+ {
+ m = *msk++;
+ s = *src++;
+ IgsAdjustCursor(m);
+ IgsAdjustCursor(s);
+ }
+ else
+ {
+ m = 0;
+ s = 0;
+ }
+ s &= m;
+ m = ~m;
+ b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1);
+ b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1);
+ *ram++ = b0;
+ *ram++ = b1;
+ }
+ }
+
+ /* Set new color */
+ igsSetCursorColors (pScreen);
+
+ /* Set address for cursor bits */
+ offset = igss->cursor_offset;
+ offset >>= 10;
+ igsSet (igsvga, igs_sprite_addr, offset);
+
+ /* Assume TV interpolation off */
+ igsSet (igsvga, igs_hcshf, 3);
+ /* Enable the cursor */
+ igsSet (igsvga, igs_sprite_visible, 1);
+ igsSet (igsvga, igs_sprite_64x64, 1);
+ /* Move to new position */
+ _igsMoveCursor (pScreen, x, y);
+
+ VgaFlush (&igsvga->card);
+}
+
+static void
+igsUnloadCursor (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ /* Disable cursor */
+ igsSet (igsvga, igs_sprite_visible, 0);
+ VgaFlush (&igsvga->card);
+}
+
+static Bool
+igsRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ SetupCursor(pScreen);
+
+ if (!pScreenPriv->enabled)
+ return TRUE;
+
+ /* miRecolorCursor does this */
+ if (pCurPriv->pCursor == pCursor)
+ {
+ if (pCursor)
+ {
+ int x, y;
+
+ miPointerPosition (&x, &y);
+ igsLoadCursor (pScreen, x, y);
+ }
+ }
+ return TRUE;
+}
+
+static Bool
+igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
+{
+ return TRUE;
+}
+
+static void
+igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
+{
+ SetupCursor(pScreen);
+
+ pCurPriv->pCursor = pCursor;
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCursor)
+ igsLoadCursor (pScreen, x, y);
+ else
+ igsUnloadCursor (pScreen);
+}
+
+miPointerSpriteFuncRec igsPointerSpriteFuncs = {
+ igsRealizeCursor,
+ igsUnrealizeCursor,
+ igsSetCursor,
+ igsMoveCursor,
+};
+
+static void
+igsQueryBestSize (int class,
+ unsigned short *pwidth, unsigned short *pheight,
+ ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ switch (class)
+ {
+ case CursorShape:
+ if (*pwidth > pCurPriv->width)
+ *pwidth = pCurPriv->width;
+ if (*pheight > pCurPriv->height)
+ *pheight = pCurPriv->height;
+ if (*pwidth > pScreen->width)
+ *pwidth = pScreen->width;
+ if (*pheight > pScreen->height)
+ *pheight = pScreen->height;
+ break;
+ default:
+ fbQueryBestSize (class, pwidth, pheight, pScreen);
+ break;
+ }
+}
+
+Bool
+igsCursorInit (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ if (!igss->cursor_base)
+ {
+ pCurPriv->has_cursor = FALSE;
+ return FALSE;
+ }
+
+ pCurPriv->width = IGS_CURSOR_WIDTH;
+ pCurPriv->height= IGS_CURSOR_HEIGHT;
+ pScreen->QueryBestSize = igsQueryBestSize;
+ miPointerInitialize (pScreen,
+ &igsPointerSpriteFuncs,
+ &kdPointerScreenFuncs,
+ FALSE);
+ pCurPriv->has_cursor = TRUE;
+ pCurPriv->pCursor = NULL;
+ return TRUE;
+}
+
+void
+igsCursorEnable (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ if (pCurPriv->has_cursor)
+ {
+ if (pCurPriv->pCursor)
+ {
+ int x, y;
+
+ miPointerPosition (&x, &y);
+ igsLoadCursor (pScreen, x, y);
+ }
+ else
+ igsUnloadCursor (pScreen);
+ }
+}
+
+void
+igsCursorDisable (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ if (!pScreenPriv->enabled)
+ return;
+
+ if (pCurPriv->has_cursor)
+ {
+ if (pCurPriv->pCursor)
+ {
+ igsUnloadCursor (pScreen);
+ }
+ }
+}
+
+void
+igsCursorFini (ScreenPtr pScreen)
+{
+ SetupCursor (pScreen);
+
+ pCurPriv->pCursor = NULL;
+}
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igsdraw.c b/xc/programs/Xserver/hw/kdrive/igs/igsdraw.c
new file mode 100644
index 000000000..a93c0b248
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igsdraw.c
@@ -0,0 +1,1532 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsdraw.c,v 1.2 2000/05/24 23:52:48 keithp Exp $
+ *
+ * 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.
+ */
+
+#include "igs.h"
+#include "igsdraw.h"
+
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "fb.h"
+#include "migc.h"
+#include "miline.h"
+
+CARD8 igsPatRop[16] = {
+ /* GXclear */ 0x00, /* 0 */
+ /* GXand */ 0xa0, /* src AND dst */
+ /* GXandReverse */ 0x50, /* src AND NOT dst */
+ /* GXcopy */ 0xf0, /* src */
+ /* GXandInverted*/ 0x0a, /* NOT src AND dst */
+ /* GXnoop */ 0xaa, /* dst */
+ /* GXxor */ 0x5a, /* src XOR dst */
+ /* GXor */ 0xfa, /* src OR dst */
+ /* GXnor */ 0x05, /* NOT src AND NOT dst */
+ /* GXequiv */ 0xa5, /* NOT src XOR dst */
+ /* GXinvert */ 0x55, /* NOT dst */
+ /* GXorReverse */ 0xf5, /* src OR NOT dst */
+ /* GXcopyInverted*/ 0x0f, /* NOT src */
+ /* GXorInverted */ 0xaf, /* NOT src OR dst */
+ /* GXnand */ 0x5f, /* NOT src OR NOT dst */
+ /* GXset */ 0xff, /* 1 */
+};
+
+/*
+ * Handle pixel transfers
+ */
+
+#define BURST
+#ifdef BURST
+#define PixTransDeclare VOL32 *pix_trans_base = igsc->copData,\
+ *pix_trans = pix_trans_base
+#define PixTransStart(n) if (pix_trans + (n) > pix_trans_base + 16384) pix_trans = pix_trans_base
+#define PixTransStore(t) *pix_trans++ = (t)
+#else
+#define PixTransDeclare VOL32 *pix_trans = igsc->copData
+#define PixTransStart(n)
+#define PixTransStore(t) *pix_trans = (t)
+#endif
+
+static IgsPattern *
+igsSetPattern (ScreenPtr pScreen,
+ PixmapPtr pPixmap,
+ CARD8 fillStyle,
+ INT32 xrot,
+ INT32 yrot)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ igsScreenInfo(pScreenPriv);
+ int i;
+ IgsPatternCache *c;
+ IgsPattern *p;
+
+ if (fillStyle == FillTiled)
+ c = &igss->tile;
+ else
+ c = &igss->stipple;
+ for (i = 0; i < IGS_NUM_PATTERN; i++)
+ {
+ p = &c->pattern[i];
+ if (p->serial_number == pPixmap->drawable.serialNumber &&
+ p->xrot == xrot &&
+ p->yrot == yrot)
+ {
+ return p;
+ }
+ }
+ p = &c->pattern[c->next];
+ if (++c->next == IGS_NUM_PATTERN)
+ c->next = 0;
+ p->serial_number = pPixmap->drawable.serialNumber;
+ p->xrot = xrot;
+ p->yrot = yrot;
+
+ if (fillStyle != FillTiled)
+ {
+ FbStip *pix;
+ FbStride pixStride;
+ int pixBpp;
+ CARD8 tmp[8];
+ CARD32 *pat;
+ int stipX, stipY;
+ int y;
+ FbStip bits;
+
+ modulus (-yrot, pPixmap->drawable.height, stipY);
+ modulus (-xrot, FB_UNIT, stipX);
+
+ pat = (CARD32 *) p->base;
+
+ fbGetStipDrawable (&pPixmap->drawable, pix, pixStride, pixBpp);
+
+ for (y = 0; y < 8; y++)
+ {
+ bits = pix[stipY * pixStride];
+ FbRotLeft (bits, stipX);
+ tmp[y] = (CARD8) bits;
+ stipY++;
+ if (stipY == pPixmap->drawable.height)
+ stipY = 0;
+ }
+ for (i = 0; i < 2; i++)
+ {
+ bits = (tmp[i*4+0] |
+ (tmp[i*4+1] << 8) |
+ (tmp[i*4+2] << 16) |
+ (tmp[i*4+3] << 24));
+ IgsAdjustBits32 (bits);
+ *pat++ = bits;
+ }
+ }
+ else
+ {
+ FbBits *pix;
+ FbStride pixStride;
+ int pixBpp;
+ FbBits *pat;
+ FbStride patStride;
+ int patBpp;
+
+ fbGetDrawable (&pPixmap->drawable, pix, pixStride, pixBpp);
+
+ pat = (FbBits *) p->base;
+ patBpp = pixBpp;
+ patStride = (patBpp * IGS_PATTERN_WIDTH) / (8 * sizeof (FbBits));
+
+ fbTile (pat, patStride, 0,
+ patBpp * IGS_PATTERN_WIDTH, IGS_PATTERN_HEIGHT,
+
+ pix, pixStride,
+ pPixmap->drawable.width * pixBpp,
+ pPixmap->drawable.height,
+ GXcopy, FB_ALLONES, pixBpp,
+ xrot * pixBpp, yrot);
+ }
+ return p;
+}
+
+void
+igsFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
+ unsigned long pixel, int alu, unsigned long planemask)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+
+ _igsSetSolidRect(cop,alu,planemask,pixel,cmd);
+ while (nBox--)
+ {
+ _igsRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
+ pBox++;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+void
+igsFillBoxTiled (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
+ PixmapPtr pPixmap, int xrot, int yrot, int alu)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ IgsPattern *p = igsSetPattern (pDrawable->pScreen,
+ pPixmap,
+ FillTiled,
+ xrot, yrot);
+
+ _igsSetTiledRect(cop,alu,planemask,p->offset,cmd);
+ while (nBox--)
+ {
+ _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
+ pBox++;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+void
+igsFillBoxStippled (DrawablePtr pDrawable, GCPtr pGC,
+ int nBox, BoxPtr pBox)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int xrot = pGC->patOrg.x + pDrawable->x;
+ int yrot = pGC->patOrg.y + pDrawable->y;
+ IgsPattern *p = igsSetPattern (pDrawable->pScreen,
+ pGC->stipple,
+ pGC->fillStyle,
+ xrot, yrot);
+ if (pGC->fillStyle == FillStippled)
+ {
+ _igsSetStippledRect (cop,pGC->alu,planemask,pGC->fgPixel,p->offset,cmd);
+ }
+ else
+ {
+ _igsSetOpaqueStippledRect (cop,pGC->alu,planemask,
+ pGC->fgPixel,pGC->bgPixel,p->offset,cmd);
+ }
+ while (nBox--)
+ {
+ _igsPatRect(cop,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1,cmd);
+ pBox++;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+
+void
+igsStipple (ScreenPtr pScreen,
+ CARD32 cmd,
+ FbStip *psrcBase,
+ FbStride widthSrc,
+ int srcx,
+ int srcy,
+ int dstx,
+ int dsty,
+ int width,
+ int height)
+{
+ SetupIgs(pScreen);
+ FbStip *psrcLine, *psrc;
+ FbStride widthRest;
+ FbStip bits, tmp, lastTmp;
+ int leftShift, rightShift;
+ int nl, nlMiddle;
+ int r;
+ PixTransDeclare;
+
+ /* Compute blt address and parameters */
+ psrc = psrcBase + srcy * widthSrc + (srcx >> 5);
+ nlMiddle = (width + 31) >> 5;
+ leftShift = srcx & 0x1f;
+ rightShift = 32 - leftShift;
+ widthRest = widthSrc - nlMiddle;
+
+ _igsPlaneBlt(cop,dstx,dsty,width,height,cmd);
+
+ if (leftShift == 0)
+ {
+ while (height--)
+ {
+ nl = nlMiddle;
+ PixTransStart(nl);
+ while (nl--)
+ {
+ tmp = *psrc++;
+ IgsAdjustBits32 (tmp);
+ PixTransStore (tmp);
+ }
+ psrc += widthRest;
+ }
+ }
+ else
+ {
+ widthRest--;
+ while (height--)
+ {
+ bits = *psrc++;
+ nl = nlMiddle;
+ PixTransStart(nl);
+ while (nl--)
+ {
+ tmp = FbStipLeft(bits, leftShift);
+ bits = *psrc++;
+ tmp |= FbStipRight(bits, rightShift);
+ IgsAdjustBits32(tmp);
+ PixTransStore (tmp);
+ }
+ psrc += widthRest;
+ }
+ }
+}
+
+void
+igsCopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ SetupIgs(pDstDrawable->pScreen);
+ int srcX, srcY, dstX, dstY;
+ int w, h;
+ CARD32 flags;
+ CARD32 cmd;
+ CARD8 alu;
+
+ if (pGC)
+ {
+ alu = pGC->alu;
+ if (sourceInvarient (pGC->alu))
+ {
+ igsFillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask);
+ return;
+ }
+ }
+ else
+ alu = GXcopy;
+
+ _igsSetBlt(cop,alu,pGC->planemask,reverse,upsidedown,cmd);
+ while (nbox--)
+ {
+ w = pbox->x2 - pbox->x1;
+ h = pbox->y2 - pbox->y1;
+ if (reverse)
+ dstX = pbox->x2 - 1;
+ else
+ dstX = pbox->x1;
+ srcX = dstX + dx;
+
+ if (upsidedown)
+ dstY = pbox->y2 - 1;
+ else
+ dstY = pbox->y1;
+
+ srcY = dstY + dy;
+
+ _igsBlt (cop, srcX, srcY, dstX, dstY, w, h, cmd);
+ pbox++;
+ }
+ KdMarkSync (pDstDrawable->pScreen);
+}
+
+RegionPtr
+igsCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ KdScreenPriv(pDstDrawable->pScreen);
+ FbBits depthMask;
+
+ depthMask = FbFullMask (pDstDrawable->depth);
+ if ((pGC->planemask & depthMask) == depthMask &&
+ pSrcDrawable->type == DRAWABLE_WINDOW &&
+ pDstDrawable->type == DRAWABLE_WINDOW)
+ {
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, igsCopyNtoN, 0, 0);
+ }
+ return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty);
+}
+
+typedef struct _igs1toNargs {
+ unsigned long copyPlaneFG, copyPlaneBG;
+ Bool opaque;
+} igs1toNargs;
+
+void
+igsCopy1toN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ SetupIgs(pDstDrawable->pScreen);
+
+ igs1toNargs *args = closure;
+ int dstx, dsty;
+ FbStip *psrcBase;
+ FbStride widthSrc;
+ int srcBpp;
+ CARD32 cmd;
+
+ if (args->opaque && sourceInvarient (pGC->alu))
+ {
+ igsFillBoxSolid (pDstDrawable, nbox, pbox,
+ pGC->bgPixel, pGC->alu, pGC->planemask);
+ return;
+ }
+
+ fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp);
+
+ if (args->opaque)
+ {
+ _igsSetOpaquePlaneBlt (cop, pGC->alu, pGC->planemask, args->copyPlaneFG,
+ args->copyPlaneBG, cmd);
+ }
+ else
+ {
+ _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask,
+ args->copyPlaneFG, cmd);
+ }
+
+ while (nbox--)
+ {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+
+ igsStipple (pDstDrawable->pScreen, cmd,
+ psrcBase, widthSrc,
+ dstx + dx, dsty + dy,
+ dstx, dsty,
+ pbox->x2 - dstx, pbox->y2 - dsty);
+ pbox++;
+ }
+ KdMarkSync (pDstDrawable->pScreen);
+}
+
+RegionPtr
+igsCopyPlane (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ int srcx,
+ int srcy,
+ int width,
+ int height,
+ int dstx,
+ int dsty,
+ unsigned long bitPlane)
+{
+ RegionPtr ret;
+ igs1toNargs args;
+ FbBits depthMask;
+
+ depthMask = FbFullMask (pDstDrawable->depth);
+ if ((pGC->planemask & depthMask) == depthMask &&
+ pDstDrawable->type == DRAWABLE_WINDOW &&
+ pSrcDrawable->depth == 1)
+ {
+ args.copyPlaneFG = pGC->fgPixel;
+ args.copyPlaneBG = pGC->bgPixel;
+ args.opaque = TRUE;
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, igsCopy1toN, bitPlane, &args);
+ }
+ return KdCheckCopyPlane(pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+}
+
+#if 0
+/* would you believe this is slower than fb? */
+void
+igsPushPixels (GCPtr pGC,
+ PixmapPtr pBitmap,
+ DrawablePtr pDrawable,
+ int w,
+ int h,
+ int x,
+ int y)
+{
+ igs1toNargs args;
+ FbBits depthMask;
+
+ depthMask = FbFullMask (pDstDrawable->depth);
+ if ((pGC->planemask & depthMask) == depthMask &&
+ pDrawable->type == DRAWABLE_WINDOW &&
+ pGC->fillStyle == FillSolid)
+ {
+ args.opaque = FALSE;
+ args.copyPlaneFG = pGC->fgPixel;
+ (void) fbDoCopy ((DrawablePtr) pBitmap, pDrawable, pGC,
+ 0, 0, w, h, x, y, igsCopy1toN, 1, &args);
+ }
+ else
+ {
+ KdCheckPushPixels (pGC, pBitmap, pDrawable, w, h, x, y);
+ }
+}
+#else
+#define igsPushPixels KdCheckPushPixels
+#endif
+
+BOOL
+igsFillOk (GCPtr pGC)
+{
+ FbBits depthMask;
+
+ depthMask = FbFullMask(pGC->depth);
+ if ((pGC->planemask & depthMask) != depthMask)
+ return FALSE;
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ return TRUE;
+ case FillTiled:
+ return (igsPatternDimOk (pGC->tile.pixmap->drawable.width) &&
+ igsPatternDimOk (pGC->tile.pixmap->drawable.height));
+ case FillStippled:
+ case FillOpaqueStippled:
+ return (igsPatternDimOk (pGC->stipple->drawable.width) &&
+ igsPatternDimOk (pGC->stipple->drawable.height));
+ }
+ return FALSE;
+}
+
+void
+igsFillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ SetupIgs(pDrawable->pScreen);
+ DDXPointPtr pptFree;
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+ int *pwidthFree;/* copies of the pointers to free */
+ CARD32 cmd;
+ int nTmp;
+ INT16 x, y;
+ int width;
+ IgsPattern *p;
+
+ if (!igsFillOk (pGC))
+ {
+ KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
+ return;
+ }
+ nTmp = n * miFindMaxBand(fbGetCompositeClip(pGC));
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(fbGetCompositeClip(pGC),
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ _igsSetSolidRect(cop,pGC->alu,pGC->planemask,pGC->fgPixel,cmd);
+ break;
+ case FillTiled:
+ p = igsSetPattern (pDrawable->pScreen,
+ pGC->tile.pixmap,
+ FillTiled,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y);
+ _igsSetTiledRect (cop,pGC->alu,pGC->planemask,p->offset,cmd);
+ break;
+ default:
+ p = igsSetPattern (pDrawable->pScreen,
+ pGC->stipple,
+ pGC->fillStyle,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y);
+ if (pGC->fillStyle == FillStippled)
+ {
+ _igsSetStippledRect (cop,pGC->alu,pGC->planemask,
+ pGC->fgPixel,p->offset,cmd);
+ }
+ else
+ {
+ _igsSetOpaqueStippledRect (cop,pGC->alu,pGC->planemask,
+ pGC->fgPixel,pGC->bgPixel,p->offset,cmd);
+ }
+ break;
+ }
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ width = *pwidth++;
+ if (width)
+ {
+ _igsPatRect(cop,x,y,width,1,cmd);
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ KdMarkSync (pDrawable->pScreen);
+}
+
+#define NUM_STACK_RECTS 1024
+
+void
+igsPolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ SetupIgs(pDrawable->pScreen);
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC);
+ int numRects;
+ int n;
+ int xorg, yorg;
+ int x, y;
+
+ if (!igsFillOk (pGC))
+ {
+ KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
+ return;
+ }
+ prgnClip = fbGetCompositeClip (pGC);
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ }
+ else
+ pboxClippedBase = stackRects;
+
+ pboxClipped = pboxClippedBase;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1)
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ if ((pboxClipped->x1 = prect->x) < x1)
+ pboxClipped->x1 = x1;
+
+ if ((pboxClipped->y1 = prect->y) < y1)
+ pboxClipped->y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ pboxClipped->x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ pboxClipped->y2 = by2;
+
+ prect++;
+ if ((pboxClipped->x1 < pboxClipped->x2) &&
+ (pboxClipped->y1 < pboxClipped->y2))
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ else
+ {
+ int x1, y1, x2, y2, bx2, by2;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--)
+ {
+ BoxRec box;
+
+ if ((box.x1 = prect->x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = prect->y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ prect++;
+
+ if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ continue;
+
+ n = REGION_NUM_RECTS (prgnClip);
+ pbox = REGION_RECTS(prgnClip);
+
+ /* clip the rectangle to each box in the clip region
+ this is logically equivalent to calling Intersect()
+ */
+ while(n--)
+ {
+ pboxClipped->x1 = max(box.x1, pbox->x1);
+ pboxClipped->y1 = max(box.y1, pbox->y1);
+ pboxClipped->x2 = min(box.x2, pbox->x2);
+ pboxClipped->y2 = min(box.y2, pbox->y2);
+ pbox++;
+
+ /* see if clipping left anything */
+ if(pboxClipped->x1 < pboxClipped->x2 &&
+ pboxClipped->y1 < pboxClipped->y2)
+ {
+ pboxClipped++;
+ }
+ }
+ }
+ }
+ if (pboxClipped != pboxClippedBase)
+ {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ igsFillBoxSolid(pDrawable,
+ pboxClipped-pboxClippedBase, pboxClippedBase,
+ pGC->fgPixel, pGC->alu, pGC->planemask);
+ break;
+ case FillTiled:
+ igsFillBoxTiled(pDrawable,
+ pboxClipped-pboxClippedBase, pboxClippedBase,
+ pGC->tile.pixmap,
+ pGC->patOrg.x + pDrawable->x,
+ pGC->patOrg.y + pDrawable->y,
+ pGC->alu);
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ igsFillBoxStippled (pDrawable, pGC,
+ pboxClipped-pboxClippedBase, pboxClippedBase);
+ break;
+ }
+ }
+ if (pboxClippedBase != stackRects)
+ xfree(pboxClippedBase);
+}
+
+int
+igsTextInRegion (GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci)
+{
+ int w;
+ FontPtr pfont = pGC->font;
+ BoxRec bbox;
+
+ if (FONTCONSTMETRICS(pfont))
+ w = FONTMAXBOUNDS(pfont,characterWidth) * nglyph;
+ else
+ {
+ w = 0;
+ while (nglyph--)
+ w += (*ppci++)->metrics.characterWidth;
+ }
+ if (w < 0)
+ {
+ bbox.x1 = x + w;
+ bbox.x2 = x;
+ }
+ else
+ {
+ bbox.x1 = x;
+ bbox.x2 = x + w;
+ }
+ w = FONTMINBOUNDS(pfont,leftSideBearing);
+ if (w < 0)
+ bbox.x1 += w;
+ w = FONTMAXBOUNDS(pfont, rightSideBearing) - FONTMINBOUNDS(pfont, characterWidth);
+ if (w > 0)
+ bbox.x2 += w;
+ bbox.y1 = y - FONTMAXBOUNDS(pfont,ascent);
+ bbox.y2 = y + FONTMAXBOUNDS(pfont,descent);
+
+ return RECT_IN_REGION(pGC->pScreen, fbGetCompositeClip(pGC), &bbox);
+}
+
+void
+igsGlyphBltClipped (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ Bool image)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int h;
+ int w;
+ int xBack, yBack;
+ int hBack, wBack;
+ int lw;
+ FontPtr pfont = pGC->font;
+ CharInfoPtr pci;
+ unsigned long *bits;
+ BoxPtr extents;
+ BoxRec bbox;
+ CARD32 b;
+ CharInfoPtr *ppci;
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+ RegionPtr pClip = fbGetCompositeClip(pGC);
+ BoxPtr pBox;
+ int nbox;
+ int x1, y1, x2, y2;
+ unsigned char alu;
+ Bool set;
+ PixTransDeclare;
+
+ if (image)
+ {
+ xBack = x;
+ yBack = y - FONTASCENT(pGC->font);
+ wBack = 0;
+ hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ if (hBack)
+ {
+ h = nglyph;
+ ppci = ppciInit;
+ while (h--)
+ wBack += (*ppci++)->metrics.characterWidth;
+ }
+ if (wBack < 0)
+ {
+ xBack = xBack + wBack;
+ wBack = -wBack;
+ }
+ if (hBack < 0)
+ {
+ yBack = yBack + hBack;
+ hBack = -hBack;
+ }
+ alu = GXcopy;
+ if (wBack)
+ {
+ _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd);
+ for (nbox = REGION_NUM_RECTS (pClip),
+ pBox = REGION_RECTS (pClip);
+ nbox--;
+ pBox++)
+ {
+ x1 = xBack;
+ x2 = xBack + wBack;
+ y1 = yBack;
+ y2 = yBack + hBack;
+ if (x1 < pBox->x1) x1 = pBox->x1;
+ if (x2 > pBox->x2) x2 = pBox->x2;
+ if (y1 < pBox->y1) y1 = pBox->y1;
+ if (y2 > pBox->y2) y2 = pBox->y2;
+ if (x1 < x2 && y1 < y2)
+ {
+ _igsRect (cop, x1, y1, x2 - x1, y2 - y1, cmd);
+ }
+ }
+ KdMarkSync (pDrawable->pScreen);
+ }
+ }
+ else
+ {
+ wBack = 0;
+ alu = pGC->alu;
+ }
+
+ ppci = ppciInit;
+ set = FALSE;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ x1 = x + pci->metrics.leftSideBearing;
+ y1 = y - pci->metrics.ascent;
+ bbox.x1 = x1;
+ bbox.y1 = y1;
+ bbox.x2 = x1 + w;
+ bbox.y2 = y1 + h;
+ switch (RECT_IN_REGION(pGC->pScreen, pClip, &bbox))
+ {
+ case rgnIN:
+ lw = h * ((w + 31) >> 5);
+ if (lw)
+ {
+ if (!set)
+ {
+ _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd);
+ set = TRUE;
+ }
+ _igsPlaneBlt(cop,
+ x + pci->metrics.leftSideBearing,
+ y - pci->metrics.ascent,
+ w, h, cmd);
+ bits = (unsigned long *) pci->bits;
+ PixTransStart (lw);
+ while (lw--)
+ {
+ b = *bits++;
+ IgsAdjustBits32 (b);
+ PixTransStore(b);
+ }
+ KdMarkSync (pDrawable->pScreen);
+ }
+ break;
+ case rgnPART:
+ set = FALSE;
+ KdCheckSync (pDrawable->pScreen);
+ fbPutXYImage (pDrawable,
+ pClip,
+ fbPriv->fg,
+ fbPriv->bg,
+ fbPriv->pm,
+ alu,
+ FALSE,
+ x1, y1,
+ w, h,
+ (FbStip *) pci->bits,
+ (w + 31) >> 5,
+ 0);
+ break;
+ case rgnOUT:
+ break;
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+void
+igsGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ Bool image)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int h;
+ int w;
+ int xBack, yBack;
+ int hBack, wBack;
+ int lw;
+ FontPtr pfont = pGC->font;
+ CharInfoPtr pci;
+ unsigned long *bits;
+ BoxPtr extents;
+ BoxRec bbox;
+ CARD32 b;
+ CharInfoPtr *ppci;
+ unsigned char alu;
+ PixTransDeclare;
+
+ /*
+ * Paint background for image text
+ */
+ if (image)
+ {
+ xBack = x;
+ yBack = y - FONTASCENT(pGC->font);
+ wBack = 0;
+ hBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ if (hBack)
+ {
+ h = nglyph;
+ ppci = ppciInit;
+ while (h--)
+ wBack += (*ppci++)->metrics.characterWidth;
+ }
+ if (wBack < 0)
+ {
+ xBack = xBack + wBack;
+ wBack = -wBack;
+ }
+ if (hBack < 0)
+ {
+ yBack = yBack + hBack;
+ hBack = -hBack;
+ }
+ alu = GXcopy;
+ if (wBack)
+ {
+ _igsSetSolidRect (cop, GXcopy, pGC->planemask, pGC->bgPixel, cmd);
+ _igsRect (cop, xBack, yBack, wBack, hBack, cmd);
+ }
+ }
+ else
+ {
+ wBack = 0;
+ alu = pGC->alu;
+ }
+
+ _igsSetTransparentPlaneBlt (cop, alu, pGC->planemask, pGC->fgPixel, cmd);
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ h = pci->metrics.ascent + pci->metrics.descent;
+ w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ lw = h * ((w + 31) >> 5);
+ if (lw)
+ {
+ _igsPlaneBlt(cop,
+ x + pci->metrics.leftSideBearing,
+ y - pci->metrics.ascent,
+ w, h, cmd);
+ bits = (unsigned long *) pci->bits;
+ PixTransStart(lw);
+ while (lw--)
+ {
+ b = *bits++;
+ IgsAdjustBits32 (b);
+ PixTransStore(b);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+void
+igsTEGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int xInit,
+ int yInit,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ Bool image)
+{
+ SetupIgs(pDrawable->pScreen);
+ CARD32 cmd;
+ int x, y;
+ int h, lw, lwTmp;
+ int w;
+ FontPtr pfont = pGC->font;
+ unsigned long *char1, *char2, *char3, *char4;
+ int widthGlyphs, widthGlyph;
+ BoxRec bbox;
+ CARD32 tmp;
+ PixTransDeclare;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ if (!widthGlyph)
+ return;
+
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ if (!h)
+ return;
+
+ x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing);
+ y = yInit - FONTASCENT(pfont);
+
+ if (image)
+ {
+ _igsSetOpaquePlaneBlt (cop, GXcopy, pGC->planemask, pGC->fgPixel, pGC->bgPixel, cmd);
+ }
+ else
+ {
+ _igsSetTransparentPlaneBlt (cop, pGC->alu, pGC->planemask, pGC->fgPixel, cmd);
+ }
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define SHIFT <<
+#else
+#define SHIFT >>
+#endif
+
+#define LoopIt(count, w, loadup, fetch) \
+ while (nglyph >= count) \
+ { \
+ nglyph -= count; \
+ _igsPlaneBlt (cop, x, y, w, h, cmd); \
+ x += w; \
+ loadup \
+ lwTmp = h; \
+ PixTransStart(h); \
+ while (lwTmp--) { \
+ tmp = fetch; \
+ IgsAdjustBits32(tmp); \
+ PixTransStore(tmp); \
+ } \
+ }
+
+ if (widthGlyph <= 8)
+ {
+ widthGlyphs = widthGlyph << 2;
+ LoopIt(4, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;
+ char3 = (unsigned long *) (*ppci++)->bits;
+ char4 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | ((*char3++ | (*char4++
+ SHIFT widthGlyph))
+ SHIFT widthGlyph))
+ SHIFT widthGlyph)))
+ }
+ else if (widthGlyph <= 10)
+ {
+ widthGlyphs = (widthGlyph << 1) + widthGlyph;
+ LoopIt(3, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;
+ char3 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | (*char3++ SHIFT widthGlyph)) SHIFT widthGlyph)))
+ }
+ else if (widthGlyph <= 16)
+ {
+ widthGlyphs = widthGlyph << 1;
+ LoopIt(2, widthGlyphs,
+ char1 = (unsigned long *) (*ppci++)->bits;
+ char2 = (unsigned long *) (*ppci++)->bits;,
+ (*char1++ | (*char2++ SHIFT widthGlyph)))
+ }
+ lw = h * ((widthGlyph + 31) >> 5);
+ while (nglyph--)
+ {
+ _igsPlaneBlt (cop, x, y, widthGlyph, h, cmd);
+ x += widthGlyph;
+ char1 = (unsigned long *) (*ppci++)->bits;
+ lwTmp = lw;
+ PixTransStart(lw);
+ while (lwTmp--)
+ {
+ tmp = *char1++;
+ IgsAdjustBits32(tmp);
+ PixTransStore(tmp);
+ }
+ }
+ KdMarkSync (pDrawable->pScreen);
+}
+
+/*
+ * Blt glyphs using image transfer window
+ */
+
+void
+igsPolyGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ if (pGC->fillStyle != FillSolid ||
+ fbGetGCPrivate(pGC)->pm != FB_ALLONES)
+ {
+ KdCheckPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return;
+ }
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) {
+ case rgnIN:
+ if (TERMINALFONT(pGC->font))
+ igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
+ else
+ igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
+ break;
+ case rgnPART:
+ igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, FALSE);
+ break;
+ case rgnOUT:
+ break;
+ }
+}
+
+void
+igsImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x, int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ if (fbGetGCPrivate(pGC)->pm != FB_ALLONES)
+ {
+ KdCheckImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ return;
+ }
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ switch (igsTextInRegion (pGC, x, y, nglyph, ppci)) {
+ case rgnIN:
+ if (TERMINALFONT(pGC->font))
+ igsTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
+ else
+ igsGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
+ break;
+ case rgnPART:
+ igsGlyphBltClipped (pDrawable, pGC, x, y, nglyph, ppci, TRUE);
+ break;
+ case rgnOUT:
+ break;
+ }
+}
+
+static void
+igsInvalidatePattern (IgsPatternCache *c,
+ PixmapPtr pPixmap)
+{
+ int i;
+
+ if (c->base)
+ {
+ for (i = 0; i < IGS_NUM_PATTERN; i++)
+ {
+ if (c->pattern[i].serial_number == pPixmap->drawable.serialNumber)
+ c->pattern[i].serial_number = ~0;
+ }
+ }
+}
+
+static void
+igsInitPattern (IgsPatternCache *c, int bsize, int psize)
+{
+ int i;
+ int boffset;
+ int poffset;
+
+ for (i = 0; i < IGS_NUM_PATTERN; i++)
+ {
+ boffset = i * bsize;
+ poffset = i * psize;
+ c->pattern[i].xrot = -1;
+ c->pattern[i].yrot = -1;
+ c->pattern[i].serial_number = ~0;
+ c->pattern[i].offset = c->offset + poffset;
+ c->pattern[i].base = c->base + boffset;
+ }
+ c->next = 0;
+}
+
+static const GCOps igsOps = {
+ igsFillSpans,
+ KdCheckSetSpans,
+ KdCheckPutImage,
+ igsCopyArea,
+ igsCopyPlane,
+ KdCheckPolyPoint,
+ KdCheckPolylines,
+ KdCheckPolySegment,
+ miPolyRectangle,
+ KdCheckPolyArc,
+ miFillPolygon,
+ igsPolyFillRect,
+ KdCheckPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ igsImageGlyphBlt,
+ igsPolyGlyphBlt,
+ igsPushPixels,
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+void
+igsValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
+{
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+
+ fbValidateGC (pGC, changes, pDrawable);
+
+ if (pDrawable->type == DRAWABLE_WINDOW)
+ pGC->ops = (GCOps *) &igsOps;
+ else
+ pGC->ops = (GCOps *) &fbGCOps;
+}
+
+GCFuncs igsGCFuncs = {
+ igsValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+int
+igsCreateGC (GCPtr pGC)
+{
+ if (!fbCreateGC (pGC))
+ return FALSE;
+
+ if (pGC->depth != 1)
+ pGC->funcs = &igsGCFuncs;
+
+ return TRUE;
+}
+
+void
+igsCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ RegionRec rgnDst;
+ int dx, dy;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ 0,
+ &rgnDst, dx, dy, igsCopyNtoN, 0, 0);
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+}
+
+void
+igsPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ KdScreenPriv(pWin->drawable.pScreen);
+ PixmapPtr pTile;
+
+ if (!REGION_NUM_RECTS(pRegion))
+ return;
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+ case BackgroundPixmap:
+ pTile = pWin->background.pixmap;
+ if (igsPatternDimOk (pTile->drawable.width) &&
+ igsPatternDimOk (pTile->drawable.height))
+ {
+ igsFillBoxTiled ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pTile,
+ pWin->drawable.x, pWin->drawable.y, GXcopy);
+ return;
+ }
+ break;
+ case BackgroundPixel:
+ igsFillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel, GXcopy, ~0);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel)
+ {
+ igsFillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel, GXcopy, ~0);
+ return;
+ }
+ else
+ {
+ pTile = pWin->border.pixmap;
+ if (igsPatternDimOk (pTile->drawable.width) &&
+ igsPatternDimOk (pTile->drawable.height))
+ {
+ igsFillBoxTiled ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pTile,
+ pWin->drawable.x, pWin->drawable.y, GXcopy);
+ return;
+ }
+ }
+ break;
+ }
+ KdCheckPaintWindow (pWin, pRegion, what);
+}
+
+Bool
+igsDrawInit (ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ igsCardInfo(pScreenPriv);
+ igsScreenInfo(pScreenPriv);
+ int i;
+ int pattern_size;
+ int boffset, poffset;
+
+ KdScreenInitAsync (pScreen);
+
+ /*
+ * Replace various fb screen functions
+ */
+ pScreen->CreateGC = igsCreateGC;
+ pScreen->CopyWindow = igsCopyWindow;
+ pScreen->PaintWindowBackground = igsPaintWindow;
+ pScreen->PaintWindowBorder = igsPaintWindow;
+
+ /*
+ * Initialize patterns
+ */
+ if (igss->tile.base)
+ {
+ pattern_size = IgsTileSize(pScreenPriv->screen->fb[0].bitsPerPixel);
+ igsInitPattern (&igss->tile,
+ pattern_size,
+ pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel);
+ pattern_size = IgsStippleSize(pScreenPriv->screen->fb[0].bitsPerPixel);
+ igsInitPattern (&igss->stipple,
+ pattern_size,
+ pattern_size * 8 / pScreenPriv->screen->fb[0].bitsPerPixel);
+ }
+ return TRUE;
+}
+
+void
+igsDrawEnable (ScreenPtr pScreen)
+{
+ SetupIgs(pScreen);
+ CARD32 cmd;
+ CARD32 base;
+ CARD16 stride;
+ CARD32 format;
+
+ stride = pScreenPriv->screen->fb[0].pixelStride;
+ _igsWaitIdleEmpty(cop);
+ _igsReset(cop);
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 8:
+ format = IGS_FORMAT_8BPP;
+ break;
+ case 16:
+ format = IGS_FORMAT_16BPP;
+ break;
+ case 24:
+ format = IGS_FORMAT_24BPP;
+ break;
+ case 32:
+ format = IGS_FORMAT_32BPP;
+ break;
+ }
+ cop->format = format;
+ cop->dst_stride = stride - 1;
+ cop->src1_stride = stride - 1;
+ cop->src2_stride = stride - 1;
+ cop->src1_start = 0;
+ cop->src2_start = 0;
+ cop->extension |= IGS_BLOCK_COP_REG | IGS_BURST_ENABLE;
+
+ _igsSetSolidRect(cop, GXcopy, ~0, pScreen->blackPixel, cmd);
+ _igsRect (cop, 0, 0,
+ pScreenPriv->screen->width, pScreenPriv->screen->height,
+ cmd);
+ _igsWaitIdleEmpty (cop);
+}
+
+void
+igsDrawDisable (ScreenPtr pScreen)
+{
+}
+
+void
+igsDrawFini (ScreenPtr pScreen)
+{
+}
+
+void
+igsDrawSync (ScreenPtr pScreen)
+{
+ SetupIgs(pScreen);
+
+ _igsWaitIdleEmpty(cop);
+}
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igsdraw.h b/xc/programs/Xserver/hw/kdrive/igs/igsdraw.h
new file mode 100644
index 000000000..38001fef2
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igsdraw.h
@@ -0,0 +1,260 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsdraw.h,v 1.2 2000/05/24 23:52:48 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _IGSDRAW_H_
+#define _IGSDRAW_H_
+
+extern CARD8 igsPatRop[];
+
+#define SetupIgs(s) KdScreenPriv(s); \
+ igsCardInfo(pScreenPriv); \
+ Cop5xxx *cop = igsc->cop; \
+ int cop_stride = pScreenPriv->screen->fb[0].pixelStride
+
+#define _igsWaitLoop(cop,mask,value) { \
+ int __loop = 1000000; \
+ while (((cop)->control & (mask)) != (value)) { \
+ if (--__loop <= 0) { \
+ FatalError("Warning: igsWaitLoop 0x%x 0x%x failed\n", mask, value); \
+ } \
+ } \
+}
+
+#define _igsWaitDone(cop) _igsWaitLoop(cop, \
+ (IGS_CONTROL_BUSY| \
+ IGS_CONTROL_MALLWBEPTZ), \
+ 0)
+
+#if 1
+#define _igsWaitFull(cop) _igsWaitLoop(cop, \
+ IGS_CONTROL_CMDFF, \
+ 0)
+#else
+#define _igsWaitFull(cop) _igsWaitDone(cop)
+#endif
+
+#define _igsWaitIdleEmpty(cop) _igsWaitDone(cop)
+#define _igsWaitHostBltAck(cop) _igsWaitLoop(cop, \
+ (IGS_CONTROL_HBACKZ| \
+ IGS_CONTROL_CMDFF), \
+ 0)
+
+#define _igsReset(cop) ((cop)->control = 0)
+
+#define IgsInvertBits32(v) { \
+ v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
+ v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
+ v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
+}
+
+#define IgsInvertBits16(v) { \
+ v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
+ v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
+ v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
+}
+
+#define IgsInvertBits8(v) { \
+ v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
+ v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
+ v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
+}
+
+#define IgsByteSwap32(x) ((x) = (((x) >> 24) | \
+ (((x) >> 8) & 0xff00) | \
+ (((x) << 8) & 0xff0000) | \
+ ((x) << 24)))
+
+#define IgsByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8))
+
+#define igsPatternDimOk(d) ((d) <= IGS_PATTERN_WIDTH && (((d) & ((d) - 1)) == 0))
+
+#if BITMAP_BIT_ORDER == LSBFirst
+#define IgsAdjustBits32(b) IgsInvertBits32(b)
+#define IgsAdjustBits16(x) IgsInvertBits16(x)
+#else
+#define IgsAdjustBits32(x) IgsByteSwap32(x)
+#define IgsAdjustBits16(x) IgsByteSwap16(x)
+#endif
+
+#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->fg = (pix); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetTiledRect(cop,alu,pm,base,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_stride = IGS_PATTERN_WIDTH - 1; \
+ (cop)->src1_start = (base); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_TILE | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_SRC | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetStippledRect(cop,alu,pm,pix,base,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_start = (base); \
+ (cop)->fg = (pix); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_STIP_TRANS | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetOpaqueStippledRect(cop,alu,pm,_fg,_bg,base,cmd) {\
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_start = (base); \
+ (cop)->fg = (_fg); \
+ (cop)->bg = (_bg); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_STIP_OPAQUE | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsRect(cop,x,y,w,h,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->dst_start = (x) + (y) * (cop_stride); \
+ (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
+ (cop)->operation = (cmd); \
+}
+
+#define _igsPatRect(cop,x,y,w,h,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->dst_start = (x) + (y) * (cop_stride); \
+ (cop)->rotate = IGS_MAKE_ROTATE(x&7,y&7); \
+ (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
+ (cop)->operation = (cmd); \
+}
+
+#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->mix = IGS_MAKE_MIX(alu,alu); \
+ (cop)->src1_stride = cop_stride - 1; \
+ (cmd) = (IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_DISABLE | \
+ IGS_SRC2_NORMAL | \
+ IGS_STEP_PXBLT | \
+ IGS_FGS_SRC | \
+ IGS_BGS_BG); \
+ if (backwards) (cmd) |= IGS_DRAW_R_L; \
+ if (upsidedown) (cmd) |= IGS_DRAW_B_T; \
+}
+
+#if 0
+#define _igsPreparePlaneBlt(cop) { \
+ _igsReset(cop); \
+ (cop)->dst_stride = cop_stride - 1; \
+ (cop)->src1_stride = cop_stride - 1; \
+ (cop)->src2_stride = cop_stride - 1; \
+ (cop)->format = IGS_FORMAT_16BPP; \
+ (cop)->src1_start = 0; \
+ (cop)->src2_start = 0; \
+}
+#else
+#define _igsPreparePlaneBlt(cop)
+#endif
+
+#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \
+ _igsWaitIdleEmpty(cop); \
+ _igsPreparePlaneBlt(cop); \
+ (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
+ (cop)->fg = (fg_pix); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_WRITE_2 | \
+ IGS_SRC2_MONO_TRANS | \
+ IGS_STEP_TERNARY_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsSetOpaquePlaneBlt(cop,alu,pm,fg_pix,bg_pix,cmd) { \
+ _igsWaitIdleEmpty(cop); \
+ _igsPreparePlaneBlt(cop); \
+ (cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
+ (cop)->fg = (fg_pix); \
+ (cop)->bg = (bg_pix); \
+ (cmd) = (IGS_DRAW_T_B | \
+ IGS_DRAW_L_R | \
+ IGS_DRAW_ALL | \
+ IGS_PIXEL_FG | \
+ IGS_HBLT_WRITE_2 | \
+ IGS_SRC2_MONO_OPAQUE | \
+ IGS_STEP_TERNARY_PXBLT | \
+ IGS_FGS_FG | \
+ IGS_BGS_BG); \
+}
+
+#define _igsPlaneBlt(cop,x,y,w,h,cmd) { \
+/* _igsWaitFull(cop); */ \
+ (cop)->dst_start = (x) + (y) * (cop_stride); \
+ (cop)->dim = IGS_MAKE_DIM((w)-1,(h)-1); \
+ (cop)->operation = (cmd); \
+/* _igsWaitHostBltAck(cop); */ \
+}
+
+#define _igsBlt(cop,sx,sy,dx,dy,w,h,cmd) { \
+ _igsWaitFull(cop); \
+ (cop)->dst_start = (dx) + (dy) * cop_stride; \
+ (cop)->src1_start = (sx) + (sy) * cop_stride; \
+ (cop)->src1_stride = cop_stride - 1; \
+ (cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
+ (cop)->operation = (cmd); \
+}
+
+#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
+
+#endif
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igsreg.c b/xc/programs/Xserver/hw/kdrive/igs/igsreg.c
new file mode 100644
index 000000000..c9608ef99
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igsreg.c
@@ -0,0 +1,968 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsreg.c,v 1.1 2000/05/24 23:52:48 keithp Exp $
+ *
+ * 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.
+ */
+
+#include "igsreg.h"
+#include <stdio.h>
+
+#define CR00 IGS_CR+0x00
+#define CR01 IGS_CR+0x01
+#define CR02 IGS_CR+0x02
+#define CR03 IGS_CR+0x03
+#define CR04 IGS_CR+0x04
+#define CR05 IGS_CR+0x05
+#define CR06 IGS_CR+0x06
+#define CR07 IGS_CR+0x07
+#define CR08 IGS_CR+0x08
+#define CR09 IGS_CR+0x09
+#define CR0A IGS_CR+0x0A
+#define CR0B IGS_CR+0x0B
+#define CR0C IGS_CR+0x0C
+#define CR0D IGS_CR+0x0D
+#define CR0E IGS_CR+0x0E
+#define CR0F IGS_CR+0x0F
+#define CR10 IGS_CR+0x10
+#define CR11 IGS_CR+0x11
+#define CR12 IGS_CR+0x12
+#define CR13 IGS_CR+0x13
+#define CR14 IGS_CR+0x14
+#define CR15 IGS_CR+0x15
+#define CR16 IGS_CR+0x16
+#define CR17 IGS_CR+0x17
+#define CR18 IGS_CR+0x18
+#define CR19 IGS_CR+0x19
+#define CR1A IGS_CR+0x1A
+#define CR1B IGS_CR+0x1B
+#define CR1C IGS_CR+0x1C
+#define CR1D IGS_CR+0x1D
+#define CR1E IGS_CR+0x1E
+#define CR1F IGS_CR+0x1F
+#define CR20 IGS_CR+0x20
+#define CR21 IGS_CR+0x21
+#define CR22 IGS_CR+0x22
+#define CR23 IGS_CR+0x23
+#define CR24 IGS_CR+0x24
+#define CR25 IGS_CR+0x25
+#define CR26 IGS_CR+0x26
+#define CR27 IGS_CR+0x27
+#define CR28 IGS_CR+0x28
+#define CR29 IGS_CR+0x29
+#define CR2A IGS_CR+0x2A
+#define CR2B IGS_CR+0x2B
+#define CR2C IGS_CR+0x2C
+#define CR2D IGS_CR+0x2D
+#define CR2E IGS_CR+0x2E
+#define CR2F IGS_CR+0x2F
+#define CR30 IGS_CR+0x30
+#define CR31 IGS_CR+0x31
+#define CR32 IGS_CR+0x32
+#define CR33 IGS_CR+0x33
+#define CR34 IGS_CR+0x34
+#define CR35 IGS_CR+0x35
+#define CR36 IGS_CR+0x36
+#define CR37 IGS_CR+0x37
+#define CR38 IGS_CR+0x38
+#define CR39 IGS_CR+0x39
+#define CR3A IGS_CR+0x3A
+#define CR3B IGS_CR+0x3B
+#define CR3C IGS_CR+0x3C
+#define CR3D IGS_CR+0x3D
+#define CR3E IGS_CR+0x3E
+#define CR3F IGS_CR+0x3F
+#define CR40 IGS_CR+0x40
+#define CR41 IGS_CR+0x41
+#define CR42 IGS_CR+0x42
+#define CR43 IGS_CR+0x43
+#define CR44 IGS_CR+0x44
+#define CR45 IGS_CR+0x45
+#define CR46 IGS_CR+0x46
+#define CR47 IGS_CR+0x47
+#define CR48 IGS_CR+0x48
+
+#define CR_FIRST CR00
+#define CR_LAST CR48
+
+#define SR00 IGS_SR+0x00
+#define SR01 IGS_SR+0x01
+#define SR02 IGS_SR+0x02
+#define SR03 IGS_SR+0x03
+#define SR04 IGS_SR+0x04
+
+#define SR_FIRST SR00
+#define SR_LAST SR04
+
+#define AR00 IGS_AR+0x00
+#define AR01 IGS_AR+0x01
+#define AR02 IGS_AR+0x02
+#define AR03 IGS_AR+0x03
+#define AR04 IGS_AR+0x04
+#define AR05 IGS_AR+0x05
+#define AR06 IGS_AR+0x06
+#define AR07 IGS_AR+0x07
+#define AR08 IGS_AR+0x08
+#define AR09 IGS_AR+0x09
+#define AR0A IGS_AR+0x0A
+#define AR0B IGS_AR+0x0B
+#define AR0C IGS_AR+0x0C
+#define AR0D IGS_AR+0x0D
+#define AR0E IGS_AR+0x0E
+#define AR0F IGS_AR+0x0F
+#define AR10 IGS_AR+0x10
+#define AR11 IGS_AR+0x11
+#define AR12 IGS_AR+0x12
+#define AR13 IGS_AR+0x13
+#define AR14 IGS_AR+0x14
+
+#define AR_FIRST AR00
+#define AR_LAST AR14
+
+#define GR00 IGS_GR+0x00
+#define GR01 IGS_GR+0x01
+#define GR02 IGS_GR+0x02
+#define GR03 IGS_GR+0x03
+#define GR04 IGS_GR+0x04
+#define GR05 IGS_GR+0x05
+#define GR06 IGS_GR+0x06
+#define GR07 IGS_GR+0x07
+#define GR08 IGS_GR+0x08
+#define GR09 IGS_GR+0x09
+#define GR0A IGS_GR+0x0A
+#define GR0B IGS_GR+0x0B
+#define GR0C IGS_GR+0x0C
+#define GR0D IGS_GR+0x0D
+#define GR0E IGS_GR+0x0E
+#define GR0F IGS_GR+0x0F
+#define GR10 IGS_GR+0x10
+#define GR11 IGS_GR+0x11
+#define GR12 IGS_GR+0x12
+#define GR13 IGS_GR+0x13
+#define GR14 IGS_GR+0x14
+#define GR15 IGS_GR+0x15
+#define GR16 IGS_GR+0x16
+#define GR17 IGS_GR+0x17
+#define GR18 IGS_GR+0x18
+#define GR19 IGS_GR+0x19
+#define GR1A IGS_GR+0x1A
+#define GR1B IGS_GR+0x1B
+#define GR1C IGS_GR+0x1C
+#define GR1D IGS_GR+0x1D
+#define GR1E IGS_GR+0x1E
+#define GR1F IGS_GR+0x1F
+#define GR20 IGS_GR+0x20
+#define GR21 IGS_GR+0x21
+#define GR22 IGS_GR+0x22
+#define GR23 IGS_GR+0x23
+#define GR24 IGS_GR+0x24
+#define GR25 IGS_GR+0x25
+#define GR26 IGS_GR+0x26
+#define GR27 IGS_GR+0x27
+#define GR28 IGS_GR+0x28
+#define GR29 IGS_GR+0x29
+#define GR2A IGS_GR+0x2A
+#define GR2B IGS_GR+0x2B
+#define GR2C IGS_GR+0x2C
+#define GR2D IGS_GR+0x2D
+#define GR2E IGS_GR+0x2E
+#define GR2F IGS_GR+0x2F
+#define GR30 IGS_GR+0x30
+#define GR31 IGS_GR+0x31
+#define GR32 IGS_GR+0x32
+#define GR33 IGS_GR+0x33
+#define GR34 IGS_GR+0x34
+#define GR35 IGS_GR+0x35
+#define GR36 IGS_GR+0x36
+#define GR37 IGS_GR+0x37
+#define GR38 IGS_GR+0x38
+#define GR39 IGS_GR+0x39
+#define GR3A IGS_GR+0x3A
+#define GR3B IGS_GR+0x3B
+#define GR3C IGS_GR+0x3C
+#define GR3D IGS_GR+0x3D
+#define GR3E IGS_GR+0x3E
+#define GR3F IGS_GR+0x3F
+#define GR40 IGS_GR+0x40
+#define GR41 IGS_GR+0x41
+#define GR42 IGS_GR+0x42
+#define GR43 IGS_GR+0x43
+#define GR44 IGS_GR+0x44
+#define GR45 IGS_GR+0x45
+#define GR46 IGS_GR+0x46
+#define GR47 IGS_GR+0x47
+#define GR48 IGS_GR+0x48
+#define GR49 IGS_GR+0x49
+#define GR4A IGS_GR+0x4A
+#define GR4B IGS_GR+0x4B
+#define GR4C IGS_GR+0x4C
+#define GR4D IGS_GR+0x4D
+#define GR4E IGS_GR+0x4E
+#define GR4F IGS_GR+0x4F
+#define GR50 IGS_GR+0x50
+#define GR51 IGS_GR+0x51
+#define GR52 IGS_GR+0x52
+#define GR53 IGS_GR+0x53
+#define GR54 IGS_GR+0x54
+#define GR55 IGS_GR+0x55
+#define GR56 IGS_GR+0x56
+#define GR57 IGS_GR+0x57
+#define GR58 IGS_GR+0x58
+#define GR59 IGS_GR+0x59
+#define GR5A IGS_GR+0x5A
+#define GR5B IGS_GR+0x5B
+#define GR5C IGS_GR+0x5C
+#define GR5D IGS_GR+0x5D
+#define GR5E IGS_GR+0x5E
+#define GR5F IGS_GR+0x5F
+#define GR60 IGS_GR+0x60
+#define GR61 IGS_GR+0x61
+#define GR62 IGS_GR+0x62
+#define GR63 IGS_GR+0x63
+#define GR64 IGS_GR+0x64
+#define GR65 IGS_GR+0x65
+#define GR66 IGS_GR+0x66
+#define GR67 IGS_GR+0x67
+#define GR68 IGS_GR+0x68
+#define GR69 IGS_GR+0x69
+#define GR6A IGS_GR+0x6A
+#define GR6B IGS_GR+0x6B
+#define GR6C IGS_GR+0x6C
+#define GR6D IGS_GR+0x6D
+#define GR6E IGS_GR+0x6E
+#define GR6F IGS_GR+0x6F
+#define GR70 IGS_GR+0x70
+#define GR71 IGS_GR+0x71
+#define GR72 IGS_GR+0x72
+#define GR73 IGS_GR+0x73
+#define GR74 IGS_GR+0x74
+#define GR75 IGS_GR+0x75
+#define GR76 IGS_GR+0x76
+#define GR77 IGS_GR+0x77
+#define GR78 IGS_GR+0x78
+#define GR79 IGS_GR+0x79
+#define GR7A IGS_GR+0x7A
+#define GR7B IGS_GR+0x7B
+#define GR7C IGS_GR+0x7C
+#define GR7D IGS_GR+0x7D
+#define GR7E IGS_GR+0x7E
+#define GR7F IGS_GR+0x7F
+#define GR80 IGS_GR+0x80
+#define GR81 IGS_GR+0x81
+#define GR82 IGS_GR+0x82
+#define GR83 IGS_GR+0x83
+#define GR84 IGS_GR+0x84
+#define GR85 IGS_GR+0x85
+#define GR86 IGS_GR+0x86
+#define GR87 IGS_GR+0x87
+#define GR88 IGS_GR+0x88
+#define GR89 IGS_GR+0x89
+#define GR8A IGS_GR+0x8A
+#define GR8B IGS_GR+0x8B
+#define GR8C IGS_GR+0x8C
+#define GR8D IGS_GR+0x8D
+#define GR8E IGS_GR+0x8E
+#define GR8F IGS_GR+0x8F
+#define GR90 IGS_GR+0x90
+#define GR91 IGS_GR+0x91
+#define GR92 IGS_GR+0x92
+#define GR93 IGS_GR+0x93
+#define GR94 IGS_GR+0x94
+#define GR95 IGS_GR+0x95
+#define GR96 IGS_GR+0x96
+#define GR97 IGS_GR+0x97
+#define GR98 IGS_GR+0x98
+#define GR99 IGS_GR+0x99
+#define GR9A IGS_GR+0x9A
+#define GR9B IGS_GR+0x9B
+#define GR9C IGS_GR+0x9C
+#define GR9D IGS_GR+0x9D
+#define GR9E IGS_GR+0x9E
+#define GR9F IGS_GR+0x9F
+#define GRA0 IGS_GR+0xA0
+#define GRA1 IGS_GR+0xA1
+#define GRA2 IGS_GR+0xA2
+#define GRA3 IGS_GR+0xA3
+#define GRA4 IGS_GR+0xA4
+#define GRA5 IGS_GR+0xA5
+#define GRA6 IGS_GR+0xA6
+#define GRA7 IGS_GR+0xA7
+#define GRA8 IGS_GR+0xA8
+#define GRA9 IGS_GR+0xA9
+#define GRAA IGS_GR+0xAA
+#define GRAB IGS_GR+0xAB
+#define GRAC IGS_GR+0xAC
+#define GRAD IGS_GR+0xAD
+#define GRAE IGS_GR+0xAE
+#define GRAF IGS_GR+0xAF
+#define GRB0 IGS_GR+0xB0
+#define GRB1 IGS_GR+0xB1
+#define GRB2 IGS_GR+0xB2
+#define GRB3 IGS_GR+0xB3
+#define GRB4 IGS_GR+0xB4
+#define GRB5 IGS_GR+0xB5
+#define GRB6 IGS_GR+0xB6
+#define GRB7 IGS_GR+0xB7
+#define GRB8 IGS_GR+0xB8
+#define GRB9 IGS_GR+0xB9
+#define GRBA IGS_GR+0xBA
+#define GRBB IGS_GR+0xBB
+#define GRBC IGS_GR+0xBC
+#define GRBD IGS_GR+0xBD
+#define GRBE IGS_GR+0xBE
+#define GRBF IGS_GR+0xBF
+
+#define GR_FIRST GR00
+#define GR_LAST GRBF
+
+#define GREX3C IGS_GREX+(0x3c-IGS_GREXBASE)
+
+VgaReg igs_h_total[] = {
+ CR00, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_de_end[] = {
+ CR01, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_bstart[] = {
+ CR02, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_bend[] = {
+ CR03, 0, 5,
+ CR05, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_de_skew[] = {
+ CR03, 5, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_ena_vr_access[] = {
+ CR03, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_h_rstart[] = {
+ CR04, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_h_rend[] = {
+ CR05, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg igs_h_rdelay[] = {
+ CR05, 5, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_v_total[] = {
+ CR06, 0, 8,
+ CR07, 0, 1,
+ CR07, 5, 1,
+ GR11, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_rstart[] = {
+ CR10, 0, 8,
+ CR07, 2, 1,
+ CR07, 7, 1,
+ GR11, 2, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_rend[] = {
+ CR11, 0, 4,
+ VGA_REG_END
+};
+
+VgaReg igs_clear_v_int[] = {
+ CR11, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_disable_v_int[] = {
+ CR11, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_bandwidth[] = {
+ CR11, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_crt_protect[] = {
+ CR11, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_de_end[] = {
+ CR12, 0, 8,
+ CR07, 1, 1,
+ CR07, 6, 1,
+ GR11, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_offset[] = {
+ CR13, 0, 8,
+ GR15, 4, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_v_bstart[] = {
+ CR15, 0, 8,
+ CR07, 3, 1,
+ CR09, 5, 1,
+ GR11, 3, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_v_bend[] = {
+ CR16, 0, 7,
+ VGA_REG_END
+};
+
+VgaReg igs_linecomp[] = {
+ CR18, 0, 8,
+ CR07, 4, 1,
+ CR09, 6, 1,
+ GR11, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_ivideo[] = {
+ GR11, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_num_fetch[] = {
+ GR14, 0, 8,
+ GR15, 0, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_wcrt0[] = {
+ CR1F, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_wcrt1[] = {
+ CR1F, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_rcrts1[] = {
+ CR1F, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_selwk[] = {
+ CR1F, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_dot_clock_8[] = {
+ SR01, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_screen_off[] = {
+ SR01, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_enable_write_plane[] = {
+ SR02, 0, 4,
+ VGA_REG_END
+};
+
+VgaReg igs_mexhsyn[] = {
+ GR16, 0, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_mexvsyn[] = {
+ GR16, 2, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_pci_burst_write[] = {
+ GR30, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_pci_burst_read[] = {
+ GR30, 7, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_iow_retry[] = {
+ GREX3C, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_mw_retry[] = {
+ GREX3C, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_mr_retry[] = {
+ GREX3C, 2, 1,
+ VGA_REG_END
+};
+
+
+
+VgaReg igs_biga22en[] = {
+ GR3D, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_biga24en[] = {
+ GR3D, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_biga22force[] = {
+ GR3D, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_bigswap[] = {
+ GR3F, 0, 6,
+ VGA_REG_END
+};
+
+/* #define IGS_BIGSWAP_8 0x3f */
+/* #define IGS_BIGSWAP_16 0x2a */
+/* #define IGS_BIGSWAP_32 0x00 */
+
+VgaReg igs_sprite_x[] = {
+ GR50, 0, 8,
+ GR51, 0, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_preset_x[] = {
+ GR52, 0, 6,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_y[] = {
+ GR53, 0, 8,
+ GR54, 0, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_preset_y[] = {
+ GR55, 0, 6,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_visible[] = {
+ GR56, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_sprite_64x64[] = {
+ GR56, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_mgrext[] = {
+ GR57, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_hcshf[] = {
+ GR57, 4, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_mbpfix[] = {
+ GR57, 6, 2,
+ VGA_REG_END
+};
+
+VgaReg igs_overscan_red[] = {
+ GR58, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_overscan_green[] = {
+ GR59, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_overscan_blue[] = {
+ GR5A, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_memgopg[] = {
+ GR73, 2, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_memr2wpg[] = {
+ GR73, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_crtff16[] = {
+ GR73, 3, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_fifomust[] = {
+ GR74, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg igs_fifogen[] = {
+ GR75, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg igs_mode_sel[] = {
+ GR77, 0, 4,
+ VGA_REG_END
+};
+
+/* #define IGS_MODE_TEXT 0 */
+/* #define IGS_MODE_8 1 */
+/* #define IGS_MODE_565 2 */
+/* #define IGS_MODE_5551 6 */
+/* #define IGS_MODE_8888 3 */
+/* #define IGS_MODE_888 4 */
+/* #define IGS_MODE_332 9 */
+/* #define IGS_MODE_4444 10 */
+
+VgaReg igs_sprite_addr[] = {
+ GR7E, 0, 8,
+ GR7F, 0, 4,
+ VGA_REG_END
+};
+
+VgaReg igs_fastmpie[] = {
+ GR9E, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_vclk_m[] = {
+ GRB0, 0, 8,
+ GRBA, 0, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_vclk_n[] = {
+ GRB1, 0, 5,
+ GRBA, 3, 3,
+ VGA_REG_END
+};
+
+VgaReg igs_vfsel[] = {
+ GRB1, 5, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_vclk_p[] = {
+ GRB1, 6, 2,
+ GRBA, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_frqlat[] = {
+ GRB9, 7, 1,
+ VGA_REG_END
+};
+
+
+VgaReg igs_dac_mask[] = {
+ IGS_DAC + 0, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_dac_read_index[] = {
+ IGS_DAC + 1, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_dac_write_index[] = {
+ IGS_DAC + 2, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_dac_data[] = {
+ IGS_DAC + 3, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_rampwdn[] = {
+ IGS_DACEX + 0, 0, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_dac6_8[] = {
+ IGS_DACEX + 0, 1, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_ramdacbypass[] = {
+ IGS_DACEX + 0, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_dacpwdn[] = {
+ IGS_DACEX + 0, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg igs_cursor_read_index[] = {
+ IGS_DACEX + 1, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_cursor_write_index[] = {
+ IGS_DACEX + 2, 0, 8,
+ VGA_REG_END
+};
+
+VgaReg igs_cursor_data[] = {
+ IGS_DACEX + 3, 0, 8,
+ VGA_REG_END
+};
+
+VGA8
+_igsInb (VgaCard *card, VGA16 port)
+{
+ VGAVOL8 *reg;
+
+ if (card->closure)
+ return VgaReadMemb ((VGA32) card->closure + port);
+ else
+ return VgaInb (port);
+}
+
+void
+_igsOutb (VgaCard *card, VGA8 value, VGA16 port)
+{
+ if (card->closure)
+ VgaWriteMemb (value, (VGA32) card->closure + port);
+ else
+ VgaOutb (value, port);
+}
+
+void
+_igsRegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
+{
+ if (reg < IGS_SR + IGS_NSR)
+ {
+ map->access = VgaAccessIndIo;
+ map->port = 0x3c4;
+ map->addr = 0;
+ map->value = 1;
+ map->index = reg - IGS_SR;
+ }
+ else if (reg < IGS_GR + IGS_NGR)
+ {
+ map->access = VgaAccessIndIo;
+ map->port = 0x3ce;
+ map->addr = 0;
+ map->value = 1;
+ map->index = reg - IGS_GR;
+ }
+ else if (reg < IGS_GREX + IGS_NGREX)
+ {
+ VGA8 gr33;
+
+ map->access = VgaAccessDone;
+ _igsOutb (card, 0x33, 0x3ce);
+ gr33 = _igsInb (card, 0x3cf);
+ _igsOutb (card, gr33 | 0x40, 0x3cf);
+ _igsOutb (card, IGS_GREXBASE + reg - IGS_GREX, 0x3ce);
+ if (write)
+ _igsOutb (card, map->value, 0x3cf);
+ else
+ map->value = _igsInb (card, 0x3cf);
+ _igsOutb (card, 0x33, 0x3ce);
+ _igsOutb (card, gr33, 0x3cf);
+ return;
+ }
+ else if (reg < IGS_AR + IGS_NAR)
+ {
+ reg -= IGS_AR;
+ map->access = VgaAccessDone;
+ /* reset AFF to index */
+ (void) _igsInb (card, 0x3da);
+ if (reg >= 16)
+ reg |= 0x20;
+ _igsOutb (card, reg, 0x3c0);
+ if (write)
+ _igsOutb (card, map->value, 0x3c0);
+ else
+ map->value = _igsInb (card, 0x3c1);
+ if (!(reg & 0x20))
+ {
+ /* enable video display again */
+ (void) _igsInb (card, 0x3da);
+ _igsOutb (card, 0x20, 0x3c0);
+ }
+ return;
+ }
+ else if (reg < IGS_CR + IGS_NCR)
+ {
+ map->access = VgaAccessIndIo;
+ map->port = 0x3d4;
+ map->addr = 0;
+ map->value = 1;
+ map->index = reg - IGS_CR;
+ }
+ else if (reg < IGS_DAC + IGS_NDAC)
+ {
+ map->access = VgaAccessIo;
+ map->port = 0x3c6 + reg - IGS_DAC;
+ }
+ else if (reg < IGS_DACEX + IGS_NDACEX)
+ {
+ VGA8 gr56;
+ reg = 0x3c6 + reg - IGS_DACEX;
+ map->access = VgaAccessDone;
+ _igsOutb (card, 0x56, 0x3ce);
+ gr56 = _igsInb (card, 0x3cf);
+ _igsOutb (card, gr56 | 4, 0x3cf);
+ if (write)
+ _igsOutb (card, map->value, reg);
+ else
+ map->value = _igsInb (card, reg);
+ _igsOutb (card, gr56, 0x3cf);
+ return;
+ }
+ else switch (reg) {
+ case IGS_MISC_OUT:
+ map->access = VgaAccessIo;
+ if (write)
+ map->port = 0x3c2;
+ else
+ map->port = 0x3cc;
+ break;
+ case IGS_INPUT_STATUS_1:
+ map->access = VgaAccessIo;
+ map->port = 0x3da;
+ break;
+ }
+ if (card->closure)
+ {
+ map->port = map->port + (VGA32) card->closure;
+ if (map->access == VgaAccessIo)
+ map->access = VgaAccessMem;
+ if (map->access == VgaAccessIndIo)
+ map->access = VgaAccessIndMem;
+ }
+}
+
+VgaSave igsSaves[] = {
+ CR00, CR18,
+ SR01, SR02,
+ GR11, GRBA,
+ IGS_MISC_OUT, IGS_MISC_OUT,
+ VGA_SAVE_END
+};
+
+void
+igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio)
+{
+ igsvga->card.map = _igsRegMap;
+ igsvga->card.closure = (void *) mmio;
+ igsvga->card.max = IGS_NREG;
+ igsvga->card.values = igsvga->values;
+ igsvga->card.saves = igsSaves;
+}
+
+void
+igsSave (IgsVga *igsvga)
+{
+ igsSetImm (igsvga, igs_wcrt0, 1);
+ igsSetImm (igsvga, igs_wcrt1, 1);
+ igsSetImm (igsvga, igs_rcrts1, 1);
+ igsSetImm (igsvga, igs_selwk, 1);
+ VgaPreserve (&igsvga->card);
+}
+
+void
+igsReset (IgsVga *igsvga)
+{
+ VgaRestore (&igsvga->card);
+ igsSetImm (igsvga, igs_frqlat, 0);
+ igsSetImm (igsvga, igs_frqlat, 1);
+ igsSetImm (igsvga, igs_frqlat, 0);
+ VgaFinish (&igsvga->card);
+}
+
+char *
+igsRegName(char *buf, VGA16 reg)
+{
+ if (reg < IGS_SR + IGS_NSR)
+ {
+ sprintf (buf, " SR%02X", reg - IGS_SR);
+ }
+ else if (reg < IGS_GR + IGS_NGR)
+ {
+ sprintf (buf, " GR%02X", reg - IGS_GR);
+ }
+ else if (reg < IGS_GREX + IGS_NGREX)
+ {
+ sprintf (buf, " GRX%02X", reg - IGS_GREX + IGS_GREXBASE);
+ }
+ else if (reg < IGS_AR + IGS_NAR)
+ {
+ sprintf (buf, " AR%02X", reg - IGS_AR);
+ }
+ else if (reg < IGS_CR + IGS_NCR)
+ {
+ sprintf (buf, " CR%02X", reg - IGS_CR);
+ }
+ else if (reg < IGS_DAC + IGS_NDAC)
+ {
+ sprintf (buf, " DAC%02X", reg - IGS_DAC);
+ }
+ else if (reg < IGS_DACEX + IGS_NDACEX)
+ {
+ sprintf (buf, "DACX%02X", reg - IGS_DACEX);
+ }
+ else switch (reg) {
+ case IGS_MISC_OUT:
+ sprintf (buf, "MISC_O");
+ break;
+ case IGS_INPUT_STATUS_1:
+ sprintf (buf, "IN_S_1");
+ break;
+ }
+ return buf;
+}
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igsreg.h b/xc/programs/Xserver/hw/kdrive/igs/igsreg.h
new file mode 100644
index 000000000..85a31d26d
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igsreg.h
@@ -0,0 +1,70 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsreg.h,v 1.1 2000/05/24 23:52:48 keithp Exp $
+ *
+ * Copyright © 2000 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Keith Packard makes no
+ * representations about the suitability of this software for any purpose. It
+ * is provided "as is" without express or implied warranty.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _IGSREG_H_
+#define _IGSREG_H_
+
+#include "vga.h"
+
+#define IGS_SR 0
+#define IGS_NSR 5
+#define IGS_GR (IGS_SR+IGS_NSR)
+#define IGS_NGR 0xC0
+#define IGS_GREX (IGS_GR+IGS_NGR)
+#define IGS_GREXBASE 0x3c
+#define IGS_NGREX 1
+#define IGS_AR (IGS_GREX+IGS_NGREX)
+#define IGS_NAR 0x15
+#define IGS_CR (IGS_AR+IGS_NAR)
+#define IGS_NCR 0x48
+#define IGS_DAC (IGS_CR+IGS_NCR)
+#define IGS_NDAC 4
+#define IGS_DACEX (IGS_DAC+IGS_NDAC)
+#define IGS_NDACEX 4
+#define IGS_MISC_OUT (IGS_DACEX + IGS_NDACEX)
+#define IGS_INPUT_STATUS_1 (IGS_MISC_OUT+1)
+#define IGS_NREG (IGS_INPUT_STATUS_1+1)
+
+#include "igsregs.t"
+
+#define igsGet(sv,r) VgaGet(&(sv)->card, (r))
+#define igsGetImm(sv,r) VgaGetImm(&(sv)->card, (r))
+#define igsSet(sv,r,v) VgaSet(&(sv)->card, (r), (v))
+#define igsSetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v))
+
+typedef struct _igsVga {
+ VgaCard card;
+ VgaValue values[IGS_NREG];
+} IgsVga;
+
+void
+igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio);
+
+void
+igsSave (IgsVga *igsvga);
+
+void
+igsReset (IgsVga *igsvga);
+
+#endif /* _IGSREG_H_ */
diff --git a/xc/programs/Xserver/hw/kdrive/igs/igsstub.c b/xc/programs/Xserver/hw/kdrive/igs/igsstub.c
new file mode 100644
index 000000000..73e999822
--- /dev/null
+++ b/xc/programs/Xserver/hw/kdrive/igs/igsstub.c
@@ -0,0 +1,63 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/kdrive/igs/igsstub.c,v 1.2 2000/05/24 23:52:48 keithp Exp $
+ *
+ * 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.
+ */
+
+#include "igs.h"
+
+void
+InitCard (char *name)
+{
+ KdCardAttr attr;
+ CARD32 count;
+
+ count = 0;
+#ifdef EMBED
+ attr.address[0] = 0x10000000; /* Adomo Wing video base address */
+ attr.io = 0;
+ attr.naddr = 1;
+#else
+ while (LinuxFindPci (0x10ea, 0x5000, count, &attr))
+#endif
+ {
+ KdCardInfoAdd (&igsFuncs, &attr, 0);
+ count++;
+ }
+}
+
+void
+InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+ KdInitOutput (pScreenInfo, argc, argv);
+}
+
+void
+InitInput (int argc, char **argv)
+{
+ KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
+}
+
+int
+ddxProcessArgument (int argc, char **argv, int i)
+{
+ return KdProcessArgument (argc, argv, i);
+}
diff --git a/xc/programs/Xserver/hw/kdrive/kcmap.c b/xc/programs/Xserver/hw/kdrive/kcmap.c
index 934093f4a..e9d80eb3c 100644
--- a/xc/programs/Xserver/hw/kdrive/kcmap.c
+++ b/xc/programs/Xserver/hw/kdrive/kcmap.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kcmap.c,v 1.2 2000/02/23 20:29:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kcmap.c,v 1.4 2000/05/24 23:57:56 keithp Exp $ */
#include "kdrive.h"
@@ -30,10 +30,10 @@
*/
void
-KdSetColormap (ScreenPtr pScreen)
+KdSetColormap (ScreenPtr pScreen, int fb)
{
KdScreenPriv(pScreen);
- ColormapPtr pCmap = pScreenPriv->pInstalledmap;
+ ColormapPtr pCmap = pScreenPriv->pInstalledmap[fb];
Pixel pixels[KD_MAX_PSEUDO_SIZE];
xrgb colors[KD_MAX_PSEUDO_SIZE];
xColorItem defs[KD_MAX_PSEUDO_SIZE];
@@ -41,7 +41,7 @@ KdSetColormap (ScreenPtr pScreen)
if (!pScreenPriv->card->cfuncs->putColors)
return;
- if (pScreenPriv->screen->depth > KD_MAX_PSEUDO_DEPTH)
+ if (pScreenPriv->screen->fb[fb].depth > KD_MAX_PSEUDO_DEPTH)
return;
if (!pScreenPriv->enabled)
@@ -55,12 +55,12 @@ KdSetColormap (ScreenPtr pScreen)
* true/direct as well as pseudo/static visuals
*/
- for (i = 0; i < (1 << pScreenPriv->screen->depth); i++)
+ for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++)
pixels[i] = i;
- QueryColors (pCmap, (1 << pScreenPriv->screen->depth), pixels, colors);
+ QueryColors (pCmap, (1 << pScreenPriv->screen->fb[fb].depth), pixels, colors);
- for (i = 0; i < (1 << pScreenPriv->screen->depth); i++)
+ for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++)
{
defs[i].pixel = i;
defs[i].red = colors[i].red;
@@ -69,9 +69,9 @@ KdSetColormap (ScreenPtr pScreen)
defs[i].flags = DoRed|DoGreen|DoBlue;
}
- (*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen,
- (1 << pScreenPriv->screen->depth),
- defs);
+ (*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, fb,
+ (1 << pScreenPriv->screen->fb[fb].depth),
+ defs);
/* recolor hardware cursor */
if (pScreenPriv->card->cfuncs->recolorCursor)
@@ -87,33 +87,78 @@ KdEnableColormap (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
int i;
+ int fb;
+ Bool done = FALSE;
if (!pScreenPriv->card->cfuncs->putColors)
return;
- if (pScreenPriv->screen->depth <= KD_MAX_PSEUDO_DEPTH)
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
{
- for (i = 0; i < (1 << pScreenPriv->screen->depth); i++)
- pScreenPriv->systemPalette[i].pixel = i;
- (*pScreenPriv->card->cfuncs->getColors) (pScreen,
- (1 << pScreenPriv->screen->depth),
- pScreenPriv->systemPalette);
+ if (pScreenPriv->screen->fb[fb].depth <= KD_MAX_PSEUDO_DEPTH && !done)
+ {
+ for (i = 0; i < (1 << pScreenPriv->screen->fb[fb].depth); i++)
+ pScreenPriv->systemPalette[i].pixel = i;
+ (*pScreenPriv->card->cfuncs->getColors) (pScreen, fb,
+ (1 << pScreenPriv->screen->fb[fb].depth),
+ pScreenPriv->systemPalette);
+ done = TRUE;
+ }
+ KdSetColormap (pScreen, fb);
}
- KdSetColormap (pScreen);
}
void
KdDisableColormap (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
+ int fb;
if (!pScreenPriv->card->cfuncs->putColors)
return;
- if (pScreenPriv->screen->depth > KD_MAX_PSEUDO_DEPTH)
- return;
-
- (*pScreenPriv->card->cfuncs->putColors) (pScreen,
- (1 << pScreenPriv->screen->depth),
- pScreenPriv->systemPalette);
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
+ {
+ if (pScreenPriv->screen->fb[fb].depth <= KD_MAX_PSEUDO_DEPTH)
+ {
+ (*pScreenPriv->card->cfuncs->putColors) (pScreen, fb,
+ (1 << pScreenPriv->screen->fb[fb].depth),
+ pScreenPriv->systemPalette);
+ break;
+ }
+ }
+}
+
+int
+KdColormapFb (ColormapPtr pCmap)
+{
+ ScreenPtr pScreen = pCmap->pScreen;
+ KdScreenPriv (pScreen);
+ KdScreenInfo *screen = pScreenPriv->screen;
+ int d;
+ DepthPtr depth;
+ int v, vi;
+ VisualPtr visual;
+ VisualID vid = pCmap->pVisual->vid;
+ int fb;
+
+ if (screen->fb[1].depth)
+ {
+ for (d = 0; d < pScreen->numDepths; d++)
+ {
+ depth = &pScreen->allowedDepths[d];
+ for (v = 0; v < depth->numVids; v++)
+ {
+ if (depth->vids[v] == vid)
+ {
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ {
+ if (depth->depth == screen->fb[fb].depth)
+ return fb;
+ }
+ }
+ }
+ }
+ }
+ return 0;
}
/*
@@ -129,19 +174,20 @@ void
KdInstallColormap (ColormapPtr pCmap)
{
KdScreenPriv(pCmap->pScreen);
+ int fb = KdColormapFb (pCmap);
- if (pCmap == pScreenPriv->pInstalledmap)
+ if (pCmap == pScreenPriv->pInstalledmap[fb])
return;
/* Tell X clients that the installed colormap is going away. */
- if (pScreenPriv->pInstalledmap)
- WalkTree(pScreenPriv->pInstalledmap->pScreen, TellLostMap,
- (pointer) &(pScreenPriv->pInstalledmap->mid));
+ if (pScreenPriv->pInstalledmap[fb])
+ WalkTree(pScreenPriv->pInstalledmap[fb]->pScreen, TellLostMap,
+ (pointer) &(pScreenPriv->pInstalledmap[fb]->mid));
/* Take note of the new installed colorscreen-> */
- pScreenPriv->pInstalledmap = pCmap;
+ pScreenPriv->pInstalledmap[fb] = pCmap;
- KdSetColormap (pCmap->pScreen);
+ KdSetColormap (pCmap->pScreen, fb);
/* Tell X clients of the new colorscreen-> */
WalkTree(pCmap->pScreen, TellGainedMap, (pointer) &(pCmap->mid));
@@ -157,8 +203,9 @@ void
KdUninstallColormap (ColormapPtr pCmap)
{
KdScreenPriv(pCmap->pScreen);
+ int fb = KdColormapFb (pCmap);
- if (pCmap == pScreenPriv->pInstalledmap)
+ if (pCmap == pScreenPriv->pInstalledmap[0])
{
Colormap defMapID = pCmap->pScreen->defColormap;
@@ -176,13 +223,18 @@ int
KdListInstalledColormaps (ScreenPtr pScreen, Colormap *pCmaps)
{
KdScreenPriv(pScreen);
+ int fb;
+ int n = 0;
- if (pScreenPriv->pInstalledmap)
+ for (fb = 0; fb < KD_MAX_FB && pScreenPriv->screen->fb[fb].depth; fb++)
{
- *pCmaps = pScreenPriv->pInstalledmap->mid;
- return 1;
+ if (pScreenPriv->pInstalledmap[fb])
+ {
+ *pCmaps++ = pScreenPriv->pInstalledmap[fb]->mid;
+ n++;
+ }
}
- return 0;
+ return n;
}
/*
@@ -198,14 +250,15 @@ KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs)
KdScreenPriv(pCmap->pScreen);
VisualPtr pVisual;
xColorItem expanddefs[KD_MAX_PSEUDO_SIZE];
+ int fb = KdColormapFb (pCmap);
- if (pCmap != pScreenPriv->pInstalledmap)
+ if (pCmap != pScreenPriv->pInstalledmap[fb])
return;
if (!pScreenPriv->card->cfuncs->putColors)
return;
- if (pScreenPriv->screen->depth > KD_MAX_PSEUDO_DEPTH)
+ if (pScreenPriv->screen->fb[fb].depth > KD_MAX_PSEUDO_DEPTH)
return;
if (!pScreenPriv->enabled)
@@ -223,7 +276,7 @@ KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs)
pdefs = expanddefs;
}
- (*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, ndef, pdefs);
+ (*pScreenPriv->card->cfuncs->putColors) (pCmap->pScreen, fb, ndef, pdefs);
/* recolor hardware cursor */
if (pScreenPriv->card->cfuncs->recolorCursor)
diff --git a/xc/programs/Xserver/hw/kdrive/kcurscol.c b/xc/programs/Xserver/hw/kdrive/kcurscol.c
index 3327e9044..9a91fb5e9 100644
--- a/xc/programs/Xserver/hw/kdrive/kcurscol.c
+++ b/xc/programs/Xserver/hw/kdrive/kcurscol.c
@@ -1,5 +1,5 @@
/*
- * Id: kcurscol.c,v 1.3 1999/12/21 03:51:56 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kcurscol.c,v 1.4 2000/05/11 18:14:13 tsi Exp $
*
* Copyright © 1999 Keith Packard
*
@@ -45,6 +45,7 @@ KdComputeCmapShift (unsigned long mask)
void
KdAllocateCursorPixels (ScreenPtr pScreen,
+ int fb,
CursorPtr pCursor,
Pixel *source,
Pixel *mask)
@@ -53,18 +54,18 @@ KdAllocateCursorPixels (ScreenPtr pScreen,
int r, g, b;
KdScreenPriv(pScreen);
- if (pScreenPriv->screen->redMask)
+ if (pScreenPriv->screen->fb[fb].redMask)
{
- r = KdComputeCmapShift (pScreenPriv->screen->redMask);
- g = KdComputeCmapShift (pScreenPriv->screen->greenMask);
- b = KdComputeCmapShift (pScreenPriv->screen->blueMask);
- *source = ((Shift(pCursor->foreRed,r) & pScreenPriv->screen->redMask) |
- (Shift(pCursor->foreGreen,g) & pScreenPriv->screen->greenMask) |
- (Shift(pCursor->foreBlue,b) & pScreenPriv->screen->blueMask));
- *mask = ((Shift(pCursor->backRed,r) & pScreenPriv->screen->redMask) |
- (Shift(pCursor->backGreen,g) & pScreenPriv->screen->greenMask) |
- (Shift(pCursor->backBlue,b) & pScreenPriv->screen->blueMask));
+ r = KdComputeCmapShift (pScreenPriv->screen->fb[fb].redMask);
+ g = KdComputeCmapShift (pScreenPriv->screen->fb[fb].greenMask);
+ b = KdComputeCmapShift (pScreenPriv->screen->fb[fb].blueMask);
+ *source = ((Shift(pCursor->foreRed,r) & pScreenPriv->screen->fb[fb].redMask) |
+ (Shift(pCursor->foreGreen,g) & pScreenPriv->screen->fb[fb].greenMask) |
+ (Shift(pCursor->foreBlue,b) & pScreenPriv->screen->fb[fb].blueMask));
+ *mask = ((Shift(pCursor->backRed,r) & pScreenPriv->screen->fb[fb].redMask) |
+ (Shift(pCursor->backGreen,g) & pScreenPriv->screen->fb[fb].greenMask) |
+ (Shift(pCursor->backBlue,b) & pScreenPriv->screen->fb[fb].blueMask));
}
else
{
@@ -79,13 +80,13 @@ KdAllocateCursorPixels (ScreenPtr pScreen,
sourceColor.red = pCursor->foreRed;
sourceColor.green = pCursor->foreGreen;
sourceColor.blue = pCursor->foreBlue;
- FakeAllocColor(pScreenPriv->pInstalledmap, &sourceColor);
+ FakeAllocColor(pScreenPriv->pInstalledmap[fb], &sourceColor);
maskColor.red = pCursor->backRed;
maskColor.green = pCursor->backGreen;
maskColor.blue = pCursor->backBlue;
- FakeAllocColor(pScreenPriv->pInstalledmap, &maskColor);
- FakeFreeColor(pScreenPriv->pInstalledmap, sourceColor.pixel);
- FakeFreeColor(pScreenPriv->pInstalledmap, maskColor.pixel);
+ FakeAllocColor(pScreenPriv->pInstalledmap[fb], &maskColor);
+ FakeFreeColor(pScreenPriv->pInstalledmap[fb], sourceColor.pixel);
+ FakeFreeColor(pScreenPriv->pInstalledmap[fb], maskColor.pixel);
*source = sourceColor.pixel;
*mask = maskColor.pixel;
}
diff --git a/xc/programs/Xserver/hw/kdrive/kdrive.c b/xc/programs/Xserver/hw/kdrive/kdrive.c
index d2e70ce65..83107c2af 100644
--- a/xc/programs/Xserver/hw/kdrive/kdrive.c
+++ b/xc/programs/Xserver/hw/kdrive/kdrive.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.3 2000/02/23 20:29:53 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.c,v 1.5 2000/05/24 23:57:56 keithp Exp $ */
#include "kdrive.h"
#ifdef PSEUDO8
@@ -58,7 +58,7 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable)
#ifndef FB_OLD_SCREEN
WindowPtr pWin = WindowTable[pScreen->myNum];
WindowPtr pChild;
- Bool WasViewable = (Bool)(pWin->viewable);
+ Bool WasViewable;
Bool anyMarked;
RegionPtr pOldClip, bsExposed;
#ifdef DO_SAVE_UNDERS
@@ -67,6 +67,9 @@ KdSetRootClip (ScreenPtr pScreen, BOOL enable)
WindowPtr pLayerWin;
BoxRec box;
+ if (!pWin)
+ return;
+ WasViewable = (Bool)(pWin->viewable);
if (WasViewable)
{
for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib)
@@ -301,10 +304,14 @@ void
KdParseScreen (KdScreenInfo *screen,
char *arg)
{
+ char *bpp;
+ int fb;
+
screen->width = 0;
screen->height = 0;
- screen->depth = 0;
screen->rate = 0;
+ for (fb = 0; fb < KD_MAX_FB; fb++)
+ screen->fb[fb].depth = 0;
if (!arg)
return;
@@ -320,7 +327,27 @@ KdParseScreen (KdScreenInfo *screen,
return;
arg++;
- screen->depth = atoi(arg);
+ fb = 0;
+ while (fb < KD_MAX_FB)
+ {
+ screen->fb[fb].depth = atoi(arg);
+
+ bpp = strchr (arg, '/');
+ if (bpp)
+ {
+ bpp++;
+ screen->fb[fb].bitsPerPixel = atoi(bpp);
+ arg = bpp;
+ }
+ else
+ screen->fb[fb].bitsPerPixel = 0;
+ bpp = strchr (arg, ',');
+ if (!bpp)
+ break;
+ arg = bpp+1;
+ fb++;
+ }
+
arg = strchr (arg, 'x');
if (!arg)
return;
@@ -551,7 +578,7 @@ KdCreateWindow (WindowPtr pWin)
}
}
#endif
- return TRUE;
+ return fbCreateWindow (pWin);
}
/* Pass through AddScreen, which doesn't take any closure */
@@ -563,6 +590,7 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
KdScreenInfo *screen = kdCurrentScreen;
KdCardInfo *card = screen->card;
KdPrivScreenPtr pScreenPriv;
+ int fb;
KdAllocatePrivates (pScreen);
@@ -571,7 +599,8 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
screen->pScreen = pScreen;
pScreenPriv->screen = screen;
pScreenPriv->card = card;
- pScreenPriv->bytesPerPixel = screen->bitsPerPixel >> 3;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ pScreenPriv->bytesPerPixel[fb] = screen->fb[fb].bitsPerPixel >> 3;
pScreenPriv->dpmsState = KD_DPMS_NORMAL;
/*
@@ -580,11 +609,11 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
* backing store
*/
if (!fbSetupScreen (pScreen,
- screen->frameBuffer,
+ screen->fb[0].frameBuffer,
screen->width, screen->height,
screen->dpix, screen->dpiy,
- screen->pixelStride,
- screen->bitsPerPixel))
+ screen->fb[0].pixelStride,
+ screen->fb[0].bitsPerPixel))
{
return FALSE;
}
@@ -608,14 +637,34 @@ KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
pScreenPriv->BackingStoreFuncs.GetSpansPixmap = 0;
#endif
- if (!fbFinishScreenInit (pScreen,
- screen->frameBuffer,
- screen->width, screen->height,
- screen->dpix, screen->dpiy,
- screen->pixelStride,
- screen->bitsPerPixel))
+ if (screen->fb[1].depth)
+ {
+ if (!fbOverlayFinishScreenInit (pScreen,
+ screen->fb[0].frameBuffer,
+ screen->fb[1].frameBuffer,
+ screen->width, screen->height,
+ screen->dpix, screen->dpiy,
+ screen->fb[0].pixelStride,
+ screen->fb[1].pixelStride,
+ screen->fb[0].bitsPerPixel,
+ screen->fb[1].bitsPerPixel,
+ screen->fb[0].depth,
+ screen->fb[1].depth))
+ {
+ return FALSE;
+ }
+ }
+ else
{
- return FALSE;
+ if (!fbFinishScreenInit (pScreen,
+ screen->fb[0].frameBuffer,
+ screen->width, screen->height,
+ screen->dpix, screen->dpiy,
+ screen->fb[0].pixelStride,
+ screen->fb[0].bitsPerPixel))
+ {
+ return FALSE;
+ }
}
/*
@@ -720,6 +769,8 @@ KdSetPixmapFormats (ScreenInfo *pScreenInfo)
KdCardInfo *card;
KdScreenInfo *screen;
int i;
+ int bpp;
+ int fb;
PixmapFormatRec *format;
for (i = 1; i <= 32; i++)
@@ -735,10 +786,16 @@ KdSetPixmapFormats (ScreenInfo *pScreenInfo)
{
for (screen = card->screenList; screen; screen = screen->next)
{
- if (!depthToBpp[screen->depth])
- depthToBpp[screen->depth] = screen->bitsPerPixel;
- else if (depthToBpp[screen->depth] != screen->bitsPerPixel)
- return FALSE;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ {
+ bpp = screen->fb[fb].bitsPerPixel;
+ if (bpp == 24)
+ bpp = 32;
+ if (!depthToBpp[screen->fb[fb].depth])
+ depthToBpp[screen->fb[fb].depth] = bpp;
+ else if (depthToBpp[screen->fb[fb].depth] != bpp)
+ return FALSE;
+ }
}
}
@@ -784,18 +841,20 @@ KdAddScreen (ScreenInfo *pScreenInfo,
{
unsigned long visuals;
Pixel rm, gm, bm;
+ int fb;
- if (pScreenInfo->formats[i].depth == screen->depth)
- {
- visuals = screen->visuals;
- rm = screen->redMask;
- gm = screen->greenMask;
- bm = screen->blueMask;
- }
- else
+ visuals = 0;
+ rm = gm = bm = 0;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
{
- visuals = 0;
- rm = gm = bm = 0;
+ if (pScreenInfo->formats[i].depth == screen->fb[fb].depth)
+ {
+ visuals = screen->fb[fb].visuals;
+ rm = screen->fb[fb].redMask;
+ gm = screen->fb[fb].greenMask;
+ bm = screen->fb[fb].blueMask;
+ break;
+ }
}
fbSetVisualTypesAndMasks (pScreenInfo->formats[i].depth,
visuals,
@@ -808,6 +867,17 @@ KdAddScreen (ScreenInfo *pScreenInfo,
AddScreen (KdScreenInit, argc, argv);
}
+int
+KdDepthToFb (ScreenPtr pScreen, int depth)
+{
+ KdScreenPriv(pScreen);
+ int fb;
+
+ for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb[fb].frameBuffer; fb++)
+ if (pScreenPriv->screen->fb[fb].depth == depth)
+ return fb;
+}
+
void
KdInitOutput (ScreenInfo *pScreenInfo,
int argc,
diff --git a/xc/programs/Xserver/hw/kdrive/kdrive.h b/xc/programs/Xserver/hw/kdrive/kdrive.h
index b5d374e60..cb36f6b74 100644
--- a/xc/programs/Xserver/hw/kdrive/kdrive.h
+++ b/xc/programs/Xserver/hw/kdrive/kdrive.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.4 2000/02/23 20:29:53 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kdrive.h,v 1.5 2000/05/06 22:17:40 keithp Exp $ */
#include <stdio.h>
#include "X.h"
@@ -40,6 +40,7 @@
#include "mi.h"
#include "dix.h"
#include "fb.h"
+#include "fboverlay.h"
extern WindowPtr *WindowTable;
@@ -49,10 +50,18 @@ extern WindowPtr *WindowTable;
#define KD_DPMS_POWERDOWN 3
#define KD_DPMS_MAX KD_DPMS_POWERDOWN
+#ifndef KD_MAX_FB
+#define KD_MAX_FB 2
+#endif
+
+#ifndef KD_MAX_CARD_ADDRESS
+#define KD_MAX_CARD_ADDRESS 8
+#endif
+
/*
* Configuration information per video card
*/
-#define KD_MAX_CARD_ADDRESS 8
+
typedef struct _KdCardAttr {
CARD32 io;
CARD32 address[KD_MAX_CARD_ADDRESS];
@@ -75,25 +84,30 @@ extern KdCardInfo *kdCardInfo;
/*
* Configuration information per X screen
*/
+typedef struct _KdFrameBuffer {
+ CARD8 *frameBuffer;
+ int depth;
+ int bitsPerPixel;
+ int pixelStride;
+ int byteStride;
+ unsigned long visuals;
+ Pixel redMask, greenMask, blueMask;
+ void *closure;
+} KdFrameBuffer;
+
typedef struct _KdScreenInfo {
struct _KdScreenInfo *next;
KdCardInfo *card;
ScreenPtr pScreen;
void *driver;
- CARD8 *frameBuffer;
int width;
int height;
- int depth;
int rate;
- int bitsPerPixel;
- int pixelStride;
- int byteStride;
int dpix, dpiy;
- unsigned long visuals;
- Pixel redMask, greenMask, blueMask;
Bool dumb;
Bool softCursor;
int mynum;
+ KdFrameBuffer fb[KD_MAX_FB];
} KdScreenInfo;
typedef struct _KdCardFuncs {
@@ -120,8 +134,8 @@ typedef struct _KdCardFuncs {
void (*disableAccel) (ScreenPtr);
void (*finiAccel) (ScreenPtr);
- void (*getColors) (ScreenPtr, int, xColorItem *);
- void (*putColors) (ScreenPtr, int, xColorItem *);
+ void (*getColors) (ScreenPtr, int, int, xColorItem *);
+ void (*putColors) (ScreenPtr, int, int, xColorItem *);
} KdCardFuncs;
#define KD_MAX_PSEUDO_DEPTH 8
@@ -133,11 +147,11 @@ typedef struct {
Bool enabled;
Bool closed;
- int bytesPerPixel;
+ int bytesPerPixel[KD_MAX_FB];
int dpmsState;
- ColormapPtr pInstalledmap; /* current colormap */
+ ColormapPtr pInstalledmap[KD_MAX_FB]; /* current colormap */
xColorItem systemPalette[KD_MAX_PSEUDO_SIZE];/* saved windows colors */
CloseScreenProcPtr CloseScreen;
@@ -341,7 +355,7 @@ extern GCOps kdNoopOps;
/* kcmap.c */
void
-KdSetColormap (ScreenPtr pScreen);
+KdSetColormap (ScreenPtr pScreen, int fb);
void
KdEnableColormap (ScreenPtr pScreen);
@@ -364,6 +378,7 @@ KdStoreColors (ColormapPtr pCmap, int ndef, xColorItem *pdefs);
/* kcurscol.c */
void
KdAllocateCursorPixels (ScreenPtr pScreen,
+ int fb,
CursorPtr pCursor,
Pixel *source,
Pixel *mask);
diff --git a/xc/programs/Xserver/hw/kdrive/kinput.c b/xc/programs/Xserver/hw/kdrive/kinput.c
index 545c6660a..f439c2e83 100644
--- a/xc/programs/Xserver/hw/kdrive/kinput.c
+++ b/xc/programs/Xserver/hw/kdrive/kinput.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.3 2000/02/23 20:29:54 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/kinput.c,v 1.4 2000/05/06 22:17:40 keithp Exp $ */
#include "kdrive.h"
#include "inputstr.h"
@@ -137,6 +137,9 @@ KdAddFd (int fd)
memset (&act, '\0', sizeof act);
act.sa_handler = KdSigio;
sigemptyset (&act.sa_mask);
+ sigaddset (&act.sa_mask, SIGIO);
+ sigaddset (&act.sa_mask, SIGALRM);
+ sigaddset (&act.sa_mask, SIGVTALRM);
sigaction (SIGIO, &act, 0);
sigemptyset (&set);
sigprocmask (SIG_SETMASK, &set, 0);
diff --git a/xc/programs/Xserver/hw/kdrive/kmode.c b/xc/programs/Xserver/hw/kdrive/kmode.c
index 73ef282f2..e6cba64e8 100644
--- a/xc/programs/Xserver/hw/kdrive/kmode.c
+++ b/xc/programs/Xserver/hw/kdrive/kmode.c
@@ -1,5 +1,5 @@
/*
- * Id: kmode.c,v 1.2 1999/12/21 03:50:49 keithp Exp $
+ * $XFree86: xc/programs/Xserver/hw/kdrive/kmode.c,v 1.5 2000/05/24 23:57:56 keithp Exp $
*
* Copyright 1999 SuSE, Inc.
*
@@ -56,8 +56,8 @@ const KdMonitorTiming kdMonitorTimings[] = {
1, 20, 24, KdSyncNegative, /* 72.809 */
},
{ 640, 480, 60, 25175, /* VESA */
- 8, 40, 144, KdSyncNegative, /* 31.469 */
- 2, 25, 29, KdSyncNegative, /* 59.940 */
+ 16, 48, 160, KdSyncNegative, /* 31.469 */
+ 10, 33, 45, KdSyncNegative, /* 59.940 */
},
/* 800x600 modes */
@@ -295,10 +295,12 @@ KdTuneMode (KdScreenInfo *screen,
/*
* Fix requested depth and geometry until it works
*/
- if (screen->depth > 16)
- screen->depth = 16;
- else if (screen->depth > 8)
- screen->depth = 8;
+ if (screen->fb[1].depth)
+ screen->fb[1].depth = 0;
+ else if (screen->fb[0].depth > 16)
+ screen->fb[0].depth = 16;
+ else if (screen->fb[0].depth > 8)
+ screen->fb[0].depth = 8;
else
{
t = kdFindPrevSize (KdFindMode (screen, supported));
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3.c b/xc/programs/Xserver/hw/kdrive/savage/s3.c
index d350bfdea..99a34bb08 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3.c
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.3 2000/02/23 20:30:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.c,v 1.4 2000/05/06 22:17:44 keithp Exp $ */
#include "s3.h"
@@ -30,6 +30,8 @@
#define PACKED_OFFSET (0x8100)
#define IOMAP_OFFSET (0x8000)
+#define S3_MIN_CLOCK 250000
+
static void
_s3SetBlank (S3Ptr s3, S3Vga *s3vga, Bool blank)
{
@@ -171,6 +173,15 @@ Bool
s3ModeSupported (KdScreenInfo *screen,
const KdMonitorTiming *t)
{
+ if (screen->fb[1].depth)
+ {
+ /*
+ * Must have at least one true color stream
+ */
+ if (screen->fb[0].depth <= 8 &&
+ screen->fb[1].depth <= 8)
+ return FALSE;
+ }
/* make sure the clock isn't too fast */
if (t->clock > S3_MAX_CLOCK * 2)
return FALSE;
@@ -188,35 +199,40 @@ s3ModeUsable (KdScreenInfo *screen)
int screen_size;
int pixel_width;
int byte_width;
+ int fb;
- if (screen->depth >= 24)
- {
- screen->depth = 24;
- screen->bitsPerPixel = 32;
- }
- else if (screen->depth >= 16)
- {
- screen->depth = 16;
- screen->bitsPerPixel = 16;
- }
- else if (screen->depth >= 15)
- {
- screen->depth = 15;
- screen->bitsPerPixel = 16;
- }
- else
+ screen_size = 0;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
{
- screen->depth = 8;
- screen->bitsPerPixel = 8;
+ if (screen->fb[fb].depth >= 24)
+ {
+ screen->fb[fb].depth = 24;
+ if (screen->fb[fb].bitsPerPixel != 24)
+ screen->fb[fb].bitsPerPixel = 32;
+ }
+ else if (screen->fb[fb].depth >= 16)
+ {
+ screen->fb[fb].depth = 16;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else if (screen->fb[fb].depth >= 15)
+ {
+ screen->fb[fb].depth = 15;
+ screen->fb[fb].bitsPerPixel = 16;
+ }
+ else
+ {
+ screen->fb[fb].depth = 8;
+ screen->fb[fb].bitsPerPixel = 8;
+ }
+
+ byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
+ pixel_width = screen->width;
+ screen->fb[fb].pixelStride = pixel_width;
+ screen->fb[fb].byteStride = byte_width;
+ screen_size += byte_width * screen->height;
}
- byte_width = screen->width * (screen->bitsPerPixel >> 3);
- pixel_width = screen->width;
- screen->pixelStride = pixel_width;
- screen->byteStride = byte_width;
-
- screen_size = byte_width * screen->height;
-
return screen_size <= s3c->memory;
}
@@ -233,6 +249,8 @@ s3ScreenInit (KdScreenInfo *screen)
int i;
const KdMonitorTiming *t;
int screen_size;
+ int fb;
+ int ma;
s3s = (S3ScreenInfo *) xalloc (sizeof (S3ScreenInfo));
if (!s3s)
@@ -252,23 +270,25 @@ s3ScreenInit (KdScreenInfo *screen)
screen->height = 600;
screen->rate = 72;
}
- if (!screen->depth)
- screen->depth = 8;
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 8;
t = KdFindMode (screen, s3ModeSupported);
screen->rate = t->rate;
screen->width = t->horizontal;
screen->height = t->vertical;
- s3GetClock (t->clock, &m, &n, &r, 511, 127, 4);
+ s3GetClock (t->clock, &m, &n, &r, 511, 127, 4, 250000);
#ifdef DEBUG
fprintf (stderr, "computed %d,%d,%d (%d)\n",
m, n, r, S3_CLOCK(m,n,r));
#endif
+#if 0
/*
* Can only operate in pixel-doubled mode at 8 or 16 bits per pixel
*/
if (screen->depth > 16 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
screen->depth = 16;
+#endif
if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported))
{
@@ -276,14 +296,31 @@ s3ScreenInit (KdScreenInfo *screen)
return FALSE;
}
- screen_size = screen->byteStride * screen->height;
+ s3s->fbmap[2] = -1;
+ if (screen->fb[1].depth)
+ {
+ if (screen->fb[0].bitsPerPixel >= 16)
+ {
+ s3s->fbmap[0] = 1;
+ s3s->fbmap[1] = 0;
+ }
+ else
+ {
+ s3s->fbmap[0] = 0;
+ s3s->fbmap[1] = 1;
+ }
+ }
+ else
+ {
+ s3s->fbmap[0] = 0;
+ s3s->fbmap[1] = -1;
+ }
- memory = s3c->memory - screen_size;
+ screen_size = 0;
+ for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++)
+ screen_size += screen->fb[fb].byteStride * screen->height;
- /*
- * Stick frame buffer at start of memory
- */
- screen->frameBuffer = s3c->frameBuffer;
+ memory = s3c->memory - screen_size;
/*
* Stick cursor at end of memory
@@ -296,60 +333,61 @@ s3ScreenInit (KdScreenInfo *screen)
else
s3s->cursor_base = 0;
- /*
- * Use remaining memory for off-screen storage, but only use
- * one piece (either right or bottom).
- */
- if (memory >= screen->byteStride * S3_TILE_SIZE)
- {
- s3s->offscreen = s3c->frameBuffer + screen_size;
- s3s->offscreen_x = 0;
- s3s->offscreen_y = screen_size / screen->byteStride;
- s3s->offscreen_width = screen->pixelStride;
- s3s->offscreen_height = memory / screen->byteStride;
- memory -= s3s->offscreen_height * screen->byteStride;
- }
- else if (screen->pixelStride - screen->width >= S3_TILE_SIZE)
+ screen_size = 0;
+ for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
{
- s3s->offscreen = s3c->frameBuffer + screen->width;
- s3s->offscreen_x = screen->width;
- s3s->offscreen_y = 0;
- s3s->offscreen_width = screen->pixelStride - screen->width;
- s3s->offscreen_height = screen->height;
- }
- else
- s3s->offscreen = 0;
-
- switch (screen->depth) {
- case 8:
- screen->visuals = ((1 << StaticGray) |
- (1 << GrayScale) |
- (1 << StaticColor) |
- (1 << PseudoColor) |
- (1 << TrueColor) |
- (1 << DirectColor));
- screen->blueMask = 0x00;
- screen->greenMask = 0x00;
- screen->redMask = 0x00;
- break;
- case 15:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x001f;
- screen->greenMask = 0x03e0;
- screen->redMask = 0x7c00;
- break;
- case 16:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x001f;
- screen->greenMask = 0x07e0;
- screen->redMask = 0xf800;
- break;
- case 24:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x0000ff;
- screen->greenMask = 0x00ff00;
- screen->redMask = 0xff0000;
- break;
+ fb = s3s->fbmap[ma];
+ screen->fb[fb].frameBuffer = s3c->frameBuffer + screen_size;
+ screen_size += screen->fb[fb].byteStride * screen->height;
+
+ /*
+ * Use remaining memory for off-screen storage, but only use
+ * one piece (either right or bottom).
+ */
+ if (memory >= screen->fb[fb].byteStride * S3_TILE_SIZE)
+ {
+ s3s->fb[ma].offscreen = screen->fb[fb].frameBuffer;
+ s3s->fb[ma].offscreen_x = 0;
+ s3s->fb[ma].offscreen_y = screen->height;
+ s3s->fb[ma].offscreen_width = screen->fb[fb].pixelStride;
+ s3s->fb[ma].offscreen_height = S3_TILE_SIZE;
+ memory -= s3s->fb[ma].offscreen_height * screen->fb[fb].byteStride;
+ screen_size += s3s->fb[ma].offscreen_height * screen->fb[fb].byteStride;
+ }
+ else
+ s3s->fb[ma].offscreen = 0;
+
+ switch (screen->fb[fb].depth) {
+ case 8:
+ screen->fb[fb].visuals = ((1 << StaticGray) |
+ (1 << GrayScale) |
+ (1 << StaticColor) |
+ (1 << PseudoColor) |
+ (1 << TrueColor) |
+ (1 << DirectColor));
+ screen->fb[fb].blueMask = 0x00;
+ screen->fb[fb].greenMask = 0x00;
+ screen->fb[fb].redMask = 0x00;
+ break;
+ case 15:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x001f;
+ screen->fb[fb].greenMask = 0x03e0;
+ screen->fb[fb].redMask = 0x7c00;
+ break;
+ case 16:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x001f;
+ screen->fb[fb].greenMask = 0x07e0;
+ screen->fb[fb].redMask = 0xf800;
+ break;
+ case 24:
+ screen->fb[fb].visuals = (1 << TrueColor);
+ screen->fb[fb].blueMask = 0x0000ff;
+ screen->fb[fb].greenMask = 0x00ff00;
+ screen->fb[fb].redMask = 0xff0000;
+ break;
+ }
}
screen->driver = s3s;
@@ -821,6 +859,7 @@ s3Preserve (KdCardInfo *card)
S3Save *save = &s3c->save;
CARD8 t1, t2;
CARD8 *cursor_base;
+ CARD8 streams_mode;
s3Save (s3vga);
if (!s3c->bios_initialized)
@@ -842,9 +881,30 @@ s3Preserve (KdCardInfo *card)
save->write_mask = s3->write_mask;
save->fg = s3->fg;
save->bg = s3->bg;
+ /*
+ * Preserve streams processor state
+ */
+ streams_mode = s3Get (s3vga, s3_streams_mode);
+ s3SetImm (s3vga, s3_streams_mode, 3);
save->global_bitmap_1 = s3->global_bitmap_1;
save->global_bitmap_2 = s3->global_bitmap_2;
+ save->adv_func_cntl = s3->adv_func_cntl;
save->primary_bitmap_1 = s3->primary_bitmap_1;
+ save->primary_bitmap_2 = s3->primary_bitmap_2;
+ save->secondary_bitmap_1 = s3->secondary_bitmap_1;
+ save->secondary_bitmap_2 = s3->secondary_bitmap_2;
+ save->primary_stream_control = s3->primary_stream_control;
+ save->blend_control = s3->blend_control;
+ save->primary_stream_addr_0 = s3->primary_stream_addr_0;
+ save->primary_stream_addr_1 = s3->primary_stream_addr_1;
+ save->primary_stream_stride = s3->primary_stream_stride;
+ save->primary_stream_xy = s3->primary_stream_xy;
+ save->primary_stream_size = s3->primary_stream_size;
+ save->primary_stream_mem = s3->primary_stream_mem;
+ save->secondary_stream_xy = s3->secondary_stream_xy;
+ save->secondary_stream_size = s3->secondary_stream_size;
+ save->streams_fifo = s3->streams_fifo;
+ s3SetImm (s3vga, s3_streams_mode, streams_mode);
_s3SetBlank (s3, s3vga, FALSE);
}
@@ -855,6 +915,49 @@ s3Preserve (KdCardInfo *card)
int s3CpuTimeout, s3AccelTimeout;
void
+s3SetGlobalBitmap (ScreenPtr pScreen, int ma)
+{
+ KdScreenPriv(pScreen);
+ s3ScreenInfo (pScreenPriv);
+
+ if (s3s->current_ma != ma)
+ {
+ s3CardInfo (pScreenPriv);
+ S3Vga *s3vga = &s3c->s3vga;
+ S3Ptr s3 = s3c->s3;
+ CARD32 gb1, gb2;
+ int depth;
+ int length;
+ KdCheckSync (pScreen);
+ switch (s3s->fb[ma].accel_bpp) {
+ case 8:
+ case 24:
+ length = 0;
+ break;
+ case 16:
+ length = 1;
+ break;
+ case 32:
+ length = 3;
+ break;
+ }
+ s3SetImm (s3vga, s3_pixel_length, length);
+ gb1 = s3s->fb[ma].bitmap_offset;
+ gb2 = ((1 << 0) |
+ (0 << 2) |
+ (1 << 3) |
+ ((s3s->fb[ma].accel_stride >> 4) << 4) |
+ (s3s->fb[ma].accel_bpp << 16) |
+ (0 << 24) |
+ (1 << 28));
+ s3->global_bitmap_1 = gb1;
+ s3->global_bitmap_2 = gb2;
+ s3->global_bitmap_2 = gb2;
+ s3s->current_ma = ma;
+ }
+}
+
+void
s3Enable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
@@ -878,7 +981,7 @@ s3Enable (ScreenPtr pScreen)
int h_screen_off;
int h_start_fifo_fetch;
- int primary_stream_l1;
+ int primary_stream_l1[KD_MAX_FB];
int v_total;
int v_retrace_start;
@@ -886,9 +989,14 @@ s3Enable (ScreenPtr pScreen)
int v_display_end;
int v_blank_start;
int v_blank_end;
-
- int h_blank_start_adjust;
- int h_blank_end_adjust;
+ int v_blank_start_adjust = 0;
+ int v_blank_end_adjust = 0;
+
+ int h_blank_start_adjust = 0;
+ int h_blank_end_adjust = 0;
+ int h_sync_start_adjust = 0;
+ int h_sync_end_adjust = 0;
+ int h_start_fifo_fetch_adjust = 0;
int h_sync_extend;
int h_blank_extend;
int i;
@@ -899,6 +1007,13 @@ s3Enable (ScreenPtr pScreen)
int cpu_timeout;
int accel_timeout;
int bytes_per_ms;
+ CARD32 control[2];
+ int fb;
+ int ma;
+
+ s3s->primary_depth = screen->fb[s3s->fbmap[0]].depth;
+
+ s3s->use_streams = TRUE;
t = KdFindMode (screen, s3ModeSupported);
@@ -912,24 +1027,38 @@ s3Enable (ScreenPtr pScreen)
vblank = t->vblank;
vactive = t->vertical;
+
m = s3Get (s3vga, s3_dclk_m);
n = s3Get (s3vga, s3_dclk_n);
r = s3Get (s3vga, s3_dclk_r);
-#ifdef DEBUG
- fprintf (stderr, "old clock %d, %d, %d\n", m, n, r);
+#define DEBUG_CLOCK
+#ifdef DEBUG_CLOCK
+ fprintf (stderr, "old clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r));
#endif
clock_double = FALSE;
- s3GetClock (t->clock, &m, &n, &r, 511, 127, 4);
- if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
+ s3GetClock (t->clock, &m, &n, &r, 511, 127, 4, 250000);
+ if (S3_CLOCK(m,n,r) > S3_MAX_CLOCK && !s3s->use_streams)
clock_double = TRUE;
s3Set (s3vga, s3_clock_select, 3);
s3Set (s3vga, s3_dclk_m, m);
s3Set (s3vga, s3_dclk_n, n);
s3Set (s3vga, s3_dclk_r, r);
-#ifdef DEBUG
+#ifdef DEBUG_CLOCK
fprintf (stderr, "new clock %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r));
#endif
+ if (s3s->use_streams)
+ {
+ s3Set (s3vga, s3_streams_mode, 3);
+ s3Set (s3vga, s3_enable_l1_parameter, 1);
+ }
+ else
+ {
+ s3Set (s3vga, s3_streams_mode, 0);
+ s3Set (s3vga, s3_enable_l1_parameter, 0);
+ }
+ s3Set (s3vga, s3_flat_panel_output_control_1, 0);
+ s3Set (s3vga, s3_flat_panel_output_control_2, 0);
s3Set (s3vga, s3_select_graphics_mode, 1);
s3Set (s3vga, s3_enable_blinking, 0);
s3Set (s3vga, s3_enable_vga_16bit, 0);
@@ -949,10 +1078,12 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_enable_2d_3d, 1);
s3Set (s3vga, s3_refresh_control, 1);
s3Set (s3vga, s3_disable_pci_read_bursts, 0);
+ s3Set (s3vga, s3_pci_disconnect_enable, 1);
+ s3Set (s3vga, s3_primary_load_control, 0);
+ s3Set (s3vga, s3_secondary_load_control, 0);
s3Set (s3vga, s3_pci_retry_enable, 1);
s3Set (s3vga, s3_enable_256, 1);
-/* s3Set (s3vga, s3_border_select, 1); /* eliminate white border */
- s3Set (s3vga, s3_border_select, 0); /* eliminate white border */
+ s3Set (s3vga, s3_border_select, 1); /* eliminate white border */
s3SetImm (s3vga, s3_lock_palette, 0); /* unlock palette/border regs */
s3Set (s3vga, s3_disable_v_retrace_int, 1);
if (t->hpol == KdSyncPositive)
@@ -976,16 +1107,48 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_enable_clock_double, 0);
s3Set (s3vga, s3_dclk_over_2, 0);
- s3Set (s3vga, s3_fifo_fetch_timing, 1);
- s3Set (s3vga, s3_fifo_drain_delay, 7);
-
-
s3Set (s3vga, s3_delay_h_enable, 0);
s3Set (s3vga, s3_sdclk_skew, 0);
s3Set (s3vga, s3_dac_mask, 0xff);
- s3Set (s3vga, s3_dac_power_saving_disable, 1);
+#if 0
+#ifdef DEBUG_CLOCK
+ m = s3Get (s3vga, s3_mclk_m);
+ n = s3Get (s3vga, s3_mclk_n);
+ r = s3Get (s3vga, s3_mclk_r);
+ fprintf (stderr, "old mclk %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r));
+#endif
+
+ s3GetClock (125282, &m, &n, &r, 127, 31, 3, 250000);
+
+#ifdef DEBUG_CLOCK
+ fprintf (stderr, "new mclk %d, %d, %d (%d)\n", m, n, r,S3_CLOCK(m,n,r));
+#endif
+
+ s3Set (s3vga, s3_mclk_m, m);
+ s3Set (s3vga, s3_mclk_n, n);
+ s3Set (s3vga, s3_mclk_r, r);
+
+#ifdef DEBUG_CLOCK
+ m = s3Get (s3vga, s3_eclk_m);
+ n = s3Get (s3vga, s3_eclk_n);
+ r = s3Get (s3vga, s3_eclk_r);
+ fprintf (stderr, "old eclk %d, %d, %d (%d)\n", m, n, r, S3_CLOCK(m,n,r));
+#endif
+
+#define S3_ECLK 125282
+
+ s3GetClock (S3_ECLK, &m, &n, &r, 127, 31, 3, 250000);
+
+#ifdef DEBUG_CLOCK
+ fprintf (stderr, "new eclk %d, %d, %d (%d)\n", m, n, r,S3_CLOCK(m,n,r));
+#endif
+
+ s3Set (s3vga, s3_eclk_m, m);
+ s3Set (s3vga, s3_eclk_n, n);
+ s3Set (s3vga, s3_eclk_r, r);
+#endif
s3s->manage_border = FALSE;
/*
@@ -998,61 +1161,85 @@ s3Enable (ScreenPtr pScreen)
/*
* Set pixel size, choose clock doubling mode
*/
- h_blank_start_adjust = 0;
- h_blank_end_adjust = 0;
-
- switch (screen->bitsPerPixel) {
- case 8:
- h_screen_off = hactive;
- s3Set (s3vga, s3_pixel_length, 0);
- s3Set (s3vga, s3_color_mode, 0);
- /*
- * Set up for double-pixel mode, switch color modes,
- * divide the dclk and delay h blank by 2 dclks
- */
- if (clock_double)
- {
- s3Set (s3vga, s3_color_mode, 1);
- s3Set (s3vga, s3_dclk_over_2, 1);
- s3Set (s3vga, s3_enable_clock_double, 1);
- s3Set (s3vga, s3_border_select, 0);
-/* s3Set (s3vga, s3_border_color, pScreen->blackPixel); */
- h_blank_start_adjust = 4;
- h_blank_end_adjust = -4;
- s3s->manage_border = TRUE;
- }
- break;
- case 16:
- h_screen_off = hactive * 2;
- s3Set (s3vga, s3_pixel_length, 1);
- if (clock_double)
- {
- if (screen->depth == 15)
- s3Set (s3vga, s3_color_mode, 3);
+
+ bytes_per_ms = 0;
+
+ for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+ {
+ fb = s3s->fbmap[ma];
+ s3s->fb[ma].accel_bpp = screen->fb[fb].bitsPerPixel;
+ s3s->fb[ma].accel_stride = screen->fb[fb].pixelStride;
+ s3s->fb[ma].bitmap_offset = screen->fb[fb].frameBuffer - s3c->frameBuffer;
+ switch (s3s->fb[ma].accel_bpp) {
+ case 8:
+ h_screen_off = hactive;
+ s3Set (s3vga, s3_pixel_length, 0);
+ s3Set (s3vga, s3_color_mode, 0);
+ control[ma] = 0;
+ /*
+ * Set up for double-pixel mode, switch color modes,
+ * divide the dclk and delay h blank by 2 dclks
+ */
+ if (clock_double)
+ {
+ s3Set (s3vga, s3_color_mode, 1);
+ s3Set (s3vga, s3_dclk_over_2, 1);
+ s3Set (s3vga, s3_enable_clock_double, 1);
+ s3Set (s3vga, s3_h_skew, 1);
+ h_blank_start_adjust = -3;
+ h_blank_end_adjust = -4;
+ s3Set (s3vga, s3_border_select, 0);
+#if 0
+ s3s->manage_border = TRUE;
+ /* s3Set (s3vga, s3_border_color, pScreen->blackPixel); */
+#endif
+ }
+ break;
+ case 16:
+ h_screen_off = hactive * 2;
+ s3Set (s3vga, s3_pixel_length, 1);
+ if (screen->fb[fb].depth == 15)
+ control[ma] = 3 << 24;
else
- s3Set (s3vga, s3_color_mode, 5);
- s3Set (s3vga, s3_dclk_over_2, 1);
- s3Set (s3vga, s3_enable_clock_double, 1);
- s3Set (s3vga, s3_border_select, 0);
- h_blank_start_adjust = 4;
- h_blank_end_adjust = -4;
- }
- else
- {
- if (screen->depth == 15)
- s3Set (s3vga, s3_color_mode, 2);
+ control[ma] = 5 << 24;
+ if (clock_double)
+ {
+ if (screen->fb[fb].depth == 15)
+ s3Set (s3vga, s3_color_mode, 3);
+ else
+ s3Set (s3vga, s3_color_mode, 5);
+ s3Set (s3vga, s3_dclk_over_2, 1);
+ s3Set (s3vga, s3_enable_clock_double, 1);
+ s3Set (s3vga, s3_border_select, 0);
+ h_blank_start_adjust = 4;
+ h_blank_end_adjust = -4;
+ }
else
- s3Set (s3vga, s3_color_mode, 4);
- s3Set (s3vga, s3_dclk_over_2, 0);
- s3Set (s3vga, s3_enable_clock_double, 0);
- s3Set (s3vga, s3_delay_blank, 0);
+ {
+ if (screen->fb[fb].depth == 15)
+ s3Set (s3vga, s3_color_mode, 2);
+ else
+ s3Set (s3vga, s3_color_mode, 4);
+ s3Set (s3vga, s3_dclk_over_2, 0);
+ s3Set (s3vga, s3_enable_clock_double, 0);
+ s3Set (s3vga, s3_delay_blank, 0);
+ }
+ break;
+ case 24:
+ control[ma] = 6 << 24;
+ h_screen_off = hactive * 3;
+ s3s->fb[ma].accel_bpp = 8;
+ s3s->fb[ma].accel_stride = screen->fb[fb].pixelStride * 3;
+ break;
+ case 32:
+ control[ma] = 7 << 24;
+ h_screen_off = hactive * 4;
+ s3Set (s3vga, s3_pixel_length, 3);
+ s3Set (s3vga, s3_color_mode, 0xd);
+ break;
}
- break;
- case 32:
- h_screen_off = hactive * 4;
- s3Set (s3vga, s3_pixel_length, 3);
- s3Set (s3vga, s3_color_mode, 0xd);
- break;
+ bytes_per_ms += t->clock * (screen->fb[fb].bitsPerPixel / 8);
+ primary_stream_l1[ma] = (screen->width * screen->fb[fb].bitsPerPixel / (8 * 8)) - 1;
}
/*
@@ -1060,11 +1247,9 @@ s3Enable (ScreenPtr pScreen)
*/
s3Set (s3vga, s3_start_address, 0);
-
/*
* Set various registers to avoid snow on the screen
*/
- bytes_per_ms = t->clock * (screen->bitsPerPixel / 8);
fprintf (stderr, "bytes_per_ms %d\n", bytes_per_ms);
fprintf (stderr, "primary 0x%x master 0x%x command 0x%x lpb 0x%x cpu 0x%x 2d 0x%x\n",
@@ -1075,28 +1260,105 @@ s3Enable (ScreenPtr pScreen)
s3Get (s3vga, s3_cpu_timeout),
s3Get (s3vga, s3_2d_graphics_engine_timeout));
- /* cpu 2d
- * 576000
- * 288000 0x1f 0x19
-
+ /*
+ * Test:
+ * accel x11perf -line500
+ * cpu x11perf -circle500
+ *
+ * cpu accel
+ * 1600x1200x32x85 (918000) 1 1 not enough
+ * 1600x1200x32x75 (810000) 3 2
+ * 1600x1200x32x70 (756000) 4 3
+ * 1600x1200x32x60 (648000) 6 5
+ *
+ * 1280x1024x32x85 (630000) 6 4
+ * 1280x1024x32x75 (540000) a 6
+ * 1280x1024x32x60 (432000) 1f a
+ *
+ * 1152x900x32x85 (490000) a 6
+ * 1152x900x32x75 (433000) 1f 8
+ * 1152x900x32x70 (401000) 1f a
+ * 1152x900x32x66 (380000) 1f a
+ *
+ * 1024x768x32x85 (378000) 1f a
+ * 1024x768x32x75 (315000) 1f b
+ * 1024x768x32x70 (300000) 1f b
+ * 1024x768x32x60 (260000) 1f 12
+ *
+ * 800x600x32x85 (225000) 1f 1a
+ * 800x600x32x72 (200000) 1f 1d
+ * 800x600x32x75 (198000) 1f 1d
+ *
+ * 1600x1200x16x85 (459000) 1f 8
+ * 1600x1200x16x75 (405000) 1f a
+ * 1600x1200x16x70 (378000) 1f b
+ * 1600x1200x16x60 (324000) 1f f
+ *
+ * 1280x1024x16x85 (315000) 1f 12
+ * 1280x1024x16x75 (270000) 1f 16
+ * 1280x1024x16x60 (216000) 1f 1d
+ *
+ * 1600x1200x8x85 (229000) 1f 1f
+ *
*/
+
if (s3CpuTimeout)
{
- cpu_timeout = s3CpuTimeout;
- if (s3AccelTimeout)
+ if (s3CpuTimeout < 0)
+ cpu_timeout = 0;
+ else
+ cpu_timeout = s3CpuTimeout;
+ if (s3AccelTimeout < 0)
+ accel_timeout = 0;
+ else if (s3AccelTimeout)
accel_timeout = s3AccelTimeout;
else
accel_timeout = s3CpuTimeout;
}
- else if (bytes_per_ms > 400000)
+ else if (bytes_per_ms >= 900000)
{
- cpu_timeout = 0x10;
- accel_timeout = 0x7;
+ cpu_timeout = 0x01;
+ accel_timeout = 0x01;
}
- else if (bytes_per_ms > 250000)
+ else if (bytes_per_ms >= 800000)
{
- cpu_timeout = 0x10;
- accel_timeout = 0x18;
+ cpu_timeout = 0x03;
+ accel_timeout = 0x02;
+ }
+ else if (bytes_per_ms >= 700000)
+ {
+ cpu_timeout = 0x04;
+ accel_timeout = 0x03;
+ }
+ else if (bytes_per_ms >= 600000)
+ {
+ cpu_timeout = 0x06;
+ accel_timeout = 0x04;
+ }
+ else if (bytes_per_ms >= 475000)
+ {
+ cpu_timeout = 0x0a;
+ accel_timeout = 0x06;
+ }
+ else if (bytes_per_ms >= 425000)
+ {
+ cpu_timeout = 0x1f;
+ accel_timeout = 0x8;
+ }
+ else if (bytes_per_ms >= 300000)
+ {
+ cpu_timeout = 0x1f;
+ accel_timeout = 0x0a;
+ }
+ else if (bytes_per_ms >= 250000)
+ {
+ cpu_timeout = 0x1f;
+ accel_timeout = 0x12;
+ }
+ else if (bytes_per_ms >= 200000)
+ {
+ cpu_timeout = 0x1f;
+ accel_timeout = 0x1a;
}
else
{
@@ -1104,6 +1366,8 @@ s3Enable (ScreenPtr pScreen)
accel_timeout = 0x1f;
}
+ fprintf (stderr, "cpu 0x%x accel 0x%x\n", cpu_timeout, accel_timeout);
+
s3Set (s3vga, s3_primary_stream_timeout, 0xc0);
s3Set (s3vga, s3_master_control_unit_timeout, 0xf);
s3Set (s3vga, s3_command_buffer_timeout, 0x1f);
@@ -1111,14 +1375,17 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_2d_graphics_engine_timeout, accel_timeout);
s3Set (s3vga, s3_cpu_timeout, cpu_timeout);
+ s3Set (s3vga, s3_fifo_fetch_timing, 1);
+ s3Set (s3vga, s3_fifo_drain_delay, 2);
+
/*
* Compute horizontal register values from timings
*/
h_total = hactive + hblank - 5;
h_display_end = hactive - 1;
- h_sync_start = hactive + hfp;
- h_sync_end = hactive + hblank - hbp;
+ h_sync_start = hactive + hfp + h_sync_start_adjust;
+ h_sync_end = hactive + hblank - hbp + h_sync_end_adjust;
/*
* pad the blank values narrow a bit and use the border_select to
* eliminate the remaining border; don't know why, but it doesn't
@@ -1141,6 +1408,7 @@ s3Enable (ScreenPtr pScreen)
else
h_start_fifo_fetch = h_total - 5;
+ h_start_fifo_fetch += h_start_fifo_fetch_adjust;
if (h_blank_end - h_blank_start >= 0x40)
h_blank_extend = 1;
else
@@ -1151,8 +1419,6 @@ s3Enable (ScreenPtr pScreen)
else
h_sync_extend = 0;
- primary_stream_l1 = (screen->width * screen->bitsPerPixel / (8 * 8)) - 1;
-
#ifdef DEBUG
fprintf (stderr, "h_total %d h_display_end %d\n",
h_total, h_display_end);
@@ -1173,18 +1439,18 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_h_sync_extend, h_sync_extend);
s3Set (s3vga, s3_h_blank_extend, h_blank_extend);
- s3Set (s3vga, s3_primary_stream_l1, primary_stream_l1);
+ s3Set (s3vga, s3_dac_power_saving_disable, 0);
+ s3Set (s3vga, s3_dac_power_up_time, hactive + hblank);
+
+ s3Set (s3vga, s3_primary_stream_l1, primary_stream_l1[0]);
+ s3Set (s3vga, s3_streams_fifo_delay, 0);
+
v_total = vactive + vblank - 2;
v_display_end = vactive - 1;
-#if 0
- v_blank_start = vactive - 1;
- v_blank_end = v_blank_start + vblank - 1;
-#else
- v_blank_start = vactive - 1;
- v_blank_end = v_blank_start + vblank - 1;
-#endif
+ v_blank_start = vactive - 1 + v_blank_start_adjust;
+ v_blank_end = v_blank_start + vblank - 1 + v_blank_end_adjust;
v_retrace_start = vactive + vfp;
v_retrace_end = vactive + vblank - vbp;
@@ -1206,7 +1472,7 @@ s3Enable (ScreenPtr pScreen)
*/
if (!screen->softCursor)
{
- cursor_address = (s3s->cursor_base - screen->frameBuffer) / 1024;
+ cursor_address = (s3s->cursor_base - s3c->frameBuffer) / 1024;
s3Set (s3vga, s3_cursor_address, cursor_address);
s3Set (s3vga, s3_cursor_ms_x11, 0);
@@ -1225,12 +1491,14 @@ s3Enable (ScreenPtr pScreen)
* Set accelerator
*/
switch (screen->width) {
- case 640: s3Set (s3vga, s3_ge_screen_width, 1); break;
- case 800: s3Set (s3vga, s3_ge_screen_width, 2); break;
- case 1024: s3Set (s3vga, s3_ge_screen_width, 0); break;
- case 1152: s3Set (s3vga, s3_ge_screen_width, 4); break;
- case 1280: s3Set (s3vga, s3_ge_screen_width, 3); break;
- case 1600: s3Set (s3vga, s3_ge_screen_width, 6); break;
+#if 0
+ case 640: s3Set (s3vga, s3_ge_screen_width, 1); break;
+ case 800: s3Set (s3vga, s3_ge_screen_width, 2); break;
+ case 1024: s3Set (s3vga, s3_ge_screen_width, 0); break;
+ case 1152: s3Set (s3vga, s3_ge_screen_width, 4); break;
+ case 1280: s3Set (s3vga, s3_ge_screen_width, 3); break;
+ case 1600: s3Set (s3vga, s3_ge_screen_width, 6); break;
+#endif
default:
s3Set (s3vga, s3_ge_screen_width, 7); /* use global bitmap descriptor */
}
@@ -1246,17 +1514,70 @@ s3Enable (ScreenPtr pScreen)
s3Set (s3vga, s3_vsync_control, 0);
_s3SetBlank (s3, s3vga, TRUE);
+ if (s3s->use_streams)
+ s3Set (s3vga, s3_primary_stream_definition, 1);
+ else
+ s3Set (s3vga, s3_primary_stream_definition, 0);
+
VgaFlush(&s3vga->card);
VgaSetImm (&s3vga->card, s3_clock_load_imm, 1);
VgaSetImm(&s3vga->card, s3_clock_load_imm, 0);
- s3->global_bitmap_1 = 0;
- s3->global_bitmap_2 = MAKE_GBF (1, /* 64 bit bitmap descriptor size */
- 0, /* disable BCI */
- pScreenPriv->screen->pixelStride >> 4,
- pScreenPriv->screen->bitsPerPixel,
- 0); /* tile format */
+ if (s3s->use_streams)
+ {
+ fb = s3s->fbmap[0];
+ s3->primary_stream_control = control[0];
+ s3->primary_stream_addr_0 =
+ s3->primary_stream_addr_1 = s3s->fb[0].bitmap_offset;
+ s3->primary_stream_stride = screen->fb[fb].byteStride;
+ s3->primary_stream_xy = (1 << 16) | 1;
+ s3->primary_stream_size = ((screen->fb[fb].pixelStride - 1) << 16) | screen->height;
+ s3->primary_stream_mem = (screen->fb[fb].byteStride * screen->height) / 8 - 1;
+ if (s3s->fbmap[1] >= 0)
+ {
+ fb = s3s->fbmap[1];
+ s3->blend_control = 5 << 24;
+ if (s3s->fb[0].accel_bpp == 8)
+ s3->chroma_key_control = 0x330000ff;
+ else
+ s3->chroma_key_control = 0x13010101;
+ s3->secondary_stream_control = control[1] | screen->width;
+ s3->secondary_stream_h_scale = (1 << 15);
+ s3->color_adjustment = 0;
+ s3->secondary_stream_vscale = (1 << 15);
+ s3->secondary_stream_vinit = 0;
+ s3->secondary_stream_mbuf = 0;
+ s3->secondary_stream_addr_0 =
+ s3->secondary_stream_addr_1 = s3s->fb[1].bitmap_offset;
+ s3->secondary_stream_stride = screen->fb[fb].byteStride;
+ s3->secondary_stream_scount = screen->height;
+ s3->secondary_stream_xy = (1 << 16) | 1;
+ s3->secondary_stream_size = ((screen->fb[fb].pixelStride - 1) << 16) | screen->height;
+ s3->secondary_stream_mem = (1 << 22) | ((screen->fb[fb].byteStride * screen->height) / 8 - 1);
+ }
+ else
+ {
+ s3->blend_control = 1 << 24;
+ s3->secondary_stream_xy = 0x07ff07ff;
+ s3->secondary_stream_size = 0x00010001;
+ }
+ s3->streams_fifo = (0x20 << 11) | (0x20 << 5) | 0x2;
+ }
+ s3->mult_misc_read_sel = (((1 << 9) |
+ (1 << 11) |
+ (0xe << 12)) |
+ (((0xe << 0) |
+ (0xf << 12)) << 16));
+
+ s3->cmd_overflow_buf_ptr = (1 << 3);
+ s3->bci_power_management = (1 << 9);
+ s3->adv_func_cntl = (3 << 8) | (1 << 4) | (1 << 2) | 1;
+ s3->primary_bitmap_1 = 0;
+ s3->primary_bitmap_2 = 0;
+ s3->secondary_bitmap_1 = 0;
+ s3->secondary_bitmap_2 = 0;
+ s3s->current_ma = -1;
_s3SetBlank (s3, s3vga, FALSE);
-#if 1
+#if 0
{
VGA16 r;
static CARD32 streams[][2] = {
@@ -1354,10 +1675,32 @@ s3Restore (KdCardInfo *card)
S3Vga *s3vga = &s3c->s3vga;
S3Save *save = &s3c->save;
CARD8 *cursor_base;
+ CARD8 streams_mode;
- /* graphics engine state */
+ _s3SetBlank (s3, s3vga, TRUE);
+ /* streams processor state */
+ streams_mode = s3Get (s3vga, s3_streams_mode);
+ s3SetImm (s3vga, s3_streams_mode, 3);
s3->global_bitmap_1 = save->global_bitmap_1;
s3->global_bitmap_2 = save->global_bitmap_2;
+ s3->adv_func_cntl = save->adv_func_cntl;
+ s3->primary_bitmap_1 = save->primary_bitmap_1;
+ s3->primary_bitmap_2 = save->primary_bitmap_2;
+ s3->secondary_bitmap_1 = save->secondary_bitmap_1;
+ s3->secondary_bitmap_2 = save->secondary_bitmap_2;
+ s3->primary_stream_control = save->primary_stream_control;
+ s3->blend_control = save->blend_control;
+ s3->primary_stream_addr_0 = save->primary_stream_addr_0;
+ s3->primary_stream_addr_0 = save->primary_stream_addr_0;
+ s3->primary_stream_stride = save->primary_stream_stride;
+ s3->primary_stream_xy = save->primary_stream_xy;
+ s3->primary_stream_size = save->primary_stream_size;
+ s3->primary_stream_mem = save->primary_stream_mem;
+ s3->secondary_stream_xy = save->secondary_stream_xy;
+ s3->secondary_stream_size = save->secondary_stream_size;
+ s3->streams_fifo = save->streams_fifo;
+ s3SetImm (s3vga, s3_streams_mode, streams_mode);
+ /* graphics engine state */
s3->alt_mix = save->alt_mix;
s3->write_mask = save->write_mask;
s3->fg = save->fg;
@@ -1366,7 +1709,6 @@ s3Restore (KdCardInfo *card)
s3->scissors_tl = 0x00000000;
s3->scissors_br = 0x0fff0fff;
- _s3SetBlank (s3, s3vga, TRUE);
VgaRestore (&s3vga->card);
s3Set (s3vga, s3_linear_window_size, 3);
s3Set (s3vga, s3_enable_linear, 1);
@@ -1417,6 +1759,100 @@ s3DPMS (ScreenPtr pScreen, int mode)
}
void
+s3DumbPaintChromaKey (WindowPtr pWin, RegionPtr pRegion)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ s3CardInfo (pScreenPriv);
+ s3ScreenInfo (pScreenPriv);
+
+ if (pWin->drawable.depth != s3s->primary_depth)
+ {
+ int nBox = REGION_NUM_RECTS(pRegion);
+ BoxPtr pBox = REGION_RECTS(pRegion);
+ PixmapPtr pPixmap;
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+
+ if (pScrPriv->pLayer[0]->drawable.depth == pWin->drawable.depth)
+ pPixmap = pScrPriv->pLayer[1];
+ else
+ pPixmap = pScrPriv->pLayer[0];
+ fbGetDrawable (&pPixmap->drawable, dst, dstStride, dstBpp);
+ while (nBox--)
+ {
+ fbSolid (dst + pBox->y1 * dstStride,
+ dstStride,
+ pBox->x1 * dstBpp,
+ dstBpp,
+ (pBox->x2 - pBox->x1) * dstBpp,
+ (pBox->y2 - pBox->y1),
+ 0x0, FB_ALLONES);
+ pBox++;
+ }
+ }
+}
+
+void
+s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ s3DumbPaintChromaKey (pWin, pRegion);
+ fbPaintWindow (pWin, pRegion, what);
+}
+
+void
+s3DumbCopyWindow (WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ RegionRec rgnDst;
+ int dx, dy;
+ PixmapPtr pPixmap;
+ FbOverlayScrPrivPtr pScrPriv = fbOverlayGetScrPriv(pScreen);
+ int fb;
+
+ KdCheckSync (pScreen);
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ for (fb = 0; fb < pScrPriv->nlayers; fb++)
+ {
+ pPixmap = pScrPriv->pLayer[fb];
+ fbCopyRegion (&pPixmap->drawable, &pPixmap->drawable,
+ 0,
+ &rgnDst, dx, dy, fbCopyWindowProc, 0, 0);
+ }
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ fbValidateDrawable (&pWin->drawable);
+}
+
+Bool
+s3InitScreen(ScreenPtr pScreen)
+{
+ KdScreenPriv(pScreen);
+ KdCardInfo *card = pScreenPriv->card;
+ KdScreenInfo *screen = pScreenPriv->screen;
+ s3CardInfo (pScreenPriv);
+ s3ScreenInfo (pScreenPriv);
+
+ pScreen->PaintWindowBackground = s3DumbPaintWindow;
+ pScreen->PaintWindowBorder = s3DumbPaintWindow;
+ pScreen->CopyWindow = s3DumbCopyWindow;
+ return TRUE;
+}
+
+void
s3ScreenFini (KdScreenInfo *screen)
{
S3ScreenInfo *s3s = (S3ScreenInfo *) screen->driver;
@@ -1439,7 +1875,7 @@ s3CardFini (KdCardInfo *card)
KdCardFuncs s3Funcs = {
s3CardInit,
s3ScreenInit,
- 0,
+ s3InitScreen,
s3Preserve,
s3Enable,
s3DPMS,
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3.h b/xc/programs/Xserver/hw/kdrive/savage/s3.h
index b88371186..602411598 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3.h
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3.h
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.3 2000/02/23 20:30:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3.h,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
#ifndef _S3_H_
#define _S3_H_
@@ -98,110 +98,37 @@ typedef volatile struct _s3 {
VOL32 blend_control; /* 81a0 */
VOL8 _pad3c[0x1c]; /* 81a4 */
VOL32 primary_stream_addr_0; /* 81c0 */
- VOL8 _pad3d[0x124]; /* 81c4 */
-#if 0
- VOL16 cur_y; /* 82e8 */
- VOL8 _pad4[0xc6]; /* 82ea */
-#else
+ VOL32 primary_stream_addr_1; /* 81c4 */
+ VOL32 primary_stream_stride; /* 81c8 */
+ VOL32 secondary_stream_mbuf; /* 81cc */
+ VOL32 secondary_stream_addr_0;/* 81d0 */
+ VOL32 secondary_stream_addr_1;/* 81d4 */
+ VOL32 secondary_stream_stride;/* 81d8 */
+ VOL8 _pad81dc[4]; /* 81dc */
+ VOL32 secondary_stream_vscale;/* 81e0 */
+ VOL32 secondary_stream_vinit; /* 81e4 */
+ VOL32 secondary_stream_scount;/* 81e8 */
+ VOL32 streams_fifo; /* 81ec */
+ VOL32 primary_stream_xy; /* 81f0 */
+ VOL32 primary_stream_size; /* 81f4 */
+ VOL32 secondary_stream_xy; /* 81f8 */
+ VOL32 secondary_stream_size; /* 81fc */
+ VOL8 _pad8200[0xe8]; /* 8200 */
VOL32 cur_y; /* 82e8 */
- VOL8 _pad4[0xc4]; /* 82ec */
-#endif
-
-#if 0
- VOL8 crt_vga_3b0; /* 83b0 */
- VOL8 crt_vga_3b1; /* 83b1 */
- VOL8 crt_vga_3b2; /* 83b2 */
- VOL8 crt_vga_3b3; /* 83b3 */
- VOL8 crt_vga_3b4; /* 83b4 */
- VOL8 crt_vga_3b5; /* 83b5 */
- VOL8 crt_vga_3b6; /* 83b6 */
- VOL8 crt_vga_3b7; /* 83b7 */
- VOL8 crt_vga_3b8; /* 83b8 */
- VOL8 crt_vga_3b9; /* 83b9 */
- VOL8 crt_vga_3ba; /* 83ba */
- VOL8 crt_vga_3bb; /* 83bb */
- VOL8 crt_vga_3bc; /* 83bc */
- VOL8 crt_vga_3bd; /* 83bd */
- VOL8 crt_vga_3be; /* 83be */
- VOL8 crt_vga_3bf; /* 83bf */
-
- VOL8 crt_vga_3c0; /* 83c0 */
- VOL8 crt_vga_3c1; /* 83c1 */
- VOL8 crt_vga_3c2; /* 83c2 */
- VOL8 crt_vga_3c3; /* 83c3 */
- VOL8 crt_vga_3c4; /* 83c4 */
- VOL8 crt_vga_3c5; /* 83c5 */
- VOL8 crt_vga_dac_ad_mk; /* 83c6 */
- VOL8 crt_vga_dac_rd_ad; /* 83c7 */
- VOL8 crt_vga_dac_wt_ad; /* 83c8 */
- VOL8 crt_vga_dac_data; /* 83c9 */
- VOL8 crt_vga_3ca; /* 83ca */
- VOL8 crt_vga_3cb; /* 83cb */
- VOL8 crt_vga_3cc; /* 83cc */
- VOL8 crt_vga_3cd; /* 83cd */
- VOL8 crt_vga_3ce; /* 83ce */
- VOL8 crt_vga_3cf; /* 83cf */
-
- VOL8 crt_vga_3d0; /* 83d0 */
- VOL8 crt_vga_3d1; /* 83d1 */
- VOL8 crt_vga_3d2; /* 83d2 */
- VOL8 crt_vga_3d3; /* 83d3 */
- VOL8 crt_vga_3d4; /* 83d4 */
- VOL8 crt_vga_3d5; /* 83d5 */
- VOL8 crt_vga_3d6; /* 83d6 */
- VOL8 crt_vga_3d7; /* 83d7 */
- VOL8 crt_vga_3d8; /* 83d8 */
- VOL8 crt_vga_3d9; /* 83d9 */
- VOL8 crt_vga_status_1; /* 83da */
- VOL8 crt_vga_3db; /* 83db */
- VOL8 crt_vga_3dc; /* 83dc */
- VOL8 crt_vga_3dd; /* 83dd */
- VOL8 crt_vga_3de; /* 83de */
- VOL8 crt_vga_3df; /* 83df */
-
- VOL8 _pad5[0x124]; /* 83e0 */
- VOL16 subsys_status; /* 8504 */
- VOL8 _pad6[0x6]; /* 8506 */
- VOL32 subsys_status; /* 8504 */
- VOL8 _pad6[0x4]; /* 8508 */
- VOL16 adv_control; /* 850c */
- VOL8 _pad7[0x1da]; /* 850e */
- VOL16 cur_x; /* 86e8 */
- VOL8 _pad8[0x3fe]; /* 86ea */
- VOL16 desty_axstp; /* 8ae8 */
- VOL8 _pad9[0x3fe]; /* 8aea */
- VOL16 destx_diastp; /* 8ee8 */
- VOL8 _pad10[0x3fe]; /* 8eea */
- VOL16 enh_err_term; /* 92e8 */
- VOL8 _pad11[0x3fe]; /* 92ea */
- VOL16 maj_axis_pcnt; /* 96e8 */
- VOL8 _pad12[0x3fe]; /* 96ea */
- VOL16 enh_cmd_gp_stat; /* 9ae8 */
- VOL8 _pad13[0x3fe]; /* 9aea */
- VOL16 enh_short_stroke; /* 9ee8 */
- VOL8 _pad14[0x3fe]; /* 9eea */
- VOL16 enh_bg; /* a2e8 */
- VOL8 _pad15[0x3fe]; /* a2ea */
- VOL16 enh_fg; /* a6e8 */
- VOL8 _pad16[0x3fe]; /* a6ea */
- VOL16 enh_wrt_mask; /* aae8 */
- VOL8 _pad17[0x3fe]; /* aaea */
- VOL16 enh_rd_mask; /* aee8 */
- VOL8 _pad18[0x3fe]; /* aeea */
- VOL16 enh_color_cmp; /* b2e8 */
- VOL8 _pad19[0x3fe]; /* b2ea */
- VOL16 enh_bg_mix; /* b6e8 */
- VOL8 _pad20[0x3fe]; /* b6ea */
- VOL16 enh_fg_mix; /* bae8 */
- VOL8 _pad21[0x3fe]; /* baea */
- VOL16 enh_rd_reg_dt; /* bee8 */
- VOL8 _pad22[0x23fe]; /* beea */
-#else
- VOL8 _pad_reg[0x5f38]; /* 83b0 */
-#endif
+ VOL8 _pad4[0x14]; /* 82ec */
+ VOL32 primary_stream_mem; /* 8300 */
+ VOL32 secondary_stream_mem; /* 8304 */
+ VOL8 _pad8308[0xD2]; /* 8308 */
+ VOL8 input_status_1; /* 83da */
+ VOL8 _pad83db[0x131]; /* 83db */
+ VOL32 adv_func_cntl; /* 850c */
+ VOL8 _pad8510[0x5dd8]; /* 8510 */
VOL32 pix_trans; /* e2e8 */
-
- VOL8 _pad23[0x3a974]; /* e2ec */
+ VOL8 _pade2ec[0x3a92c]; /* e2ec */
+ VOL32 cmd_overflow_buf_ptr; /* 48c18 */
+ VOL8 _pad48c1c[0x8]; /* 48c1c */
+ VOL32 bci_power_management; /* 48c24 */
+ VOL8 _pad48c28[0x38]; /* 48c28 */
VOL32 alt_status_0; /* 48c60 */
VOL32 alt_status_1; /* 48c64 */
} S3, *S3Ptr;
@@ -368,6 +295,22 @@ typedef volatile struct _s3 {
#define COLCMPOP_GT 0x0038
#define PLANEMODE 0x0004
+/* Multifunction Control Misc 8144 */
+#define MISC_DST_BA_0 (0x0 << 0)
+#define MISC_DST_BA_1 (0x1 << 0)
+#define MISC_DST_BA_2 (0x2 << 0)
+#define MISC_DST_BA_3 (0x3 << 0)
+#define MISC_SRC_BA_0 (0x0 << 2)
+#define MISC_SRC_BA_1 (0x1 << 2)
+#define MISC_SRC_BA_2 (0x2 << 2)
+#define MISC_SRC_BA_3 (0x3 << 2)
+#define MISC_RSF (1 << 4)
+#define MISC_EXT_CLIP (1 << 5)
+#define MISC_SRC_NE (1 << 7)
+#define MISC_ENB_CMP (1 << 8)
+#define MISC_32B (1 << 9)
+#define MISC_DC (1 << 11)
+#define MISC_INDEX_E (0xe << 12)
#define S3_SAVAGE4_SLOTS 0x0001ffff
#define S3_SAVAGE4_2DI 0x00800000
@@ -393,8 +336,7 @@ typedef volatile struct _s3 {
}
#define _s3WaitEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS, 0)
-#define _s3WaitIdleEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, \
- S3_SAVAGE4_2DI)
+#define _s3WaitIdleEmpty(s3) _s3WaitLoop(s3,S3_SAVAGE4_SLOTS|S3_SAVAGE4_2DI, S3_SAVAGE4_2DI)
#define _s3WaitIdle(s3) _s3WaitLoop(s3,S3_SAVAGE4_2DI, S3_SAVAGE4_2DI)
typedef struct _s3Cursor {
@@ -457,8 +399,22 @@ typedef struct _s3Save {
CARD32 bg;
CARD32 global_bitmap_1;
CARD32 global_bitmap_2;
+ CARD32 adv_func_cntl;
CARD32 primary_bitmap_1;
CARD32 primary_bitmap_2;
+ CARD32 secondary_bitmap_1;
+ CARD32 secondary_bitmap_2;
+ CARD32 primary_stream_control;
+ CARD32 blend_control;
+ CARD32 primary_stream_addr_0;
+ CARD32 primary_stream_addr_1;
+ CARD32 primary_stream_stride;
+ CARD32 primary_stream_xy;
+ CARD32 primary_stream_size;
+ CARD32 primary_stream_mem;
+ CARD32 secondary_stream_xy;
+ CARD32 secondary_stream_size;
+ CARD32 streams_fifo;
CARD8 text_save[S3_TEXT_SAVE];
} S3Save;
@@ -473,18 +429,29 @@ typedef struct _s3CardInfo {
Bool bios_initialized; /* whether the bios has been run */
} S3CardInfo;
-typedef struct _s3ScreenInfo {
- CARD8 *cursor_base; /* pointer to cursor area */
+typedef struct _s3FbInfo {
CARD8 *offscreen; /* pointer to offscreen area */
int offscreen_y; /* top y coordinate of offscreen area */
int offscreen_x; /* top x coordinate of offscreen area */
int offscreen_width; /* width of offscreen area */
int offscreen_height; /* height of offscreen area */
- S3Cursor cursor;
S3Patterns patterns;
+ CARD32 bitmap_offset;
+ int accel_stride;
+ int accel_bpp;
+} S3FBInfo;
+
+typedef struct _s3ScreenInfo {
+ CARD8 *cursor_base; /* pointer to cursor area */
+ S3Cursor cursor;
Bool manage_border;
Bool managing_border;
+ Bool use_streams;
+ int primary_depth;
+ int current_ma;
CARD32 border_pixel;
+ S3FBInfo fb[KD_MAX_FB];
+ int fbmap[KD_MAX_FB+1]; /* map from fb to stream */
} S3ScreenInfo;
#define getS3CardInfo(kd) ((S3CardInfo *) ((kd)->card->driver))
@@ -505,18 +472,21 @@ void s3CursorDisable (ScreenPtr pScreen);
void s3CursorFini (ScreenPtr pScreen);
void s3RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
+void s3DumbPaintWindow (WindowPtr pWin, RegionPtr pRegion, int what);
+void s3DumbCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
+
Bool s3DrawInit (ScreenPtr pScreen);
void s3DrawEnable (ScreenPtr pScreen);
void s3DrawSync (ScreenPtr pScreen);
void s3DrawDisable (ScreenPtr pScreen);
void s3DrawFini (ScreenPtr pScreen);
-void s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
-void s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
+void s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+void s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
void S3InitCard (KdCardAttr *attr);
-void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR);
+void s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR, int minVco);
extern KdCardFuncs s3Funcs;
@@ -539,6 +509,13 @@ extern KdCardFuncs s3Funcs;
_loop_count = 0; \
while (s3GetImm(s3vga, s3_vertical_sync_active) == 0) S3_RETRACE_LOOP_CHECK; \
}
+#define _s3WaitVRetraceFast(s3) { \
+ int _loop_count; \
+ _loop_count = 0; \
+ while (s3->input_status_1 & 8) S3_RETRACE_LOOP_CHECK; \
+ _loop_count = 0; \
+ while ((s3->input_status_1 & 8) == 0) S3_RETRACE_LOOP_CHECK; \
+}
/*
* Wait for the begining of the retrace interval
*/
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3clock.c b/xc/programs/Xserver/hw/kdrive/savage/s3clock.c
index dcab1cd6b..4fd7c8805 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3clock.c
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3clock.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3clock.c,v 1.3 2000/02/23 20:30:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3clock.c,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
#include "s3.h"
@@ -41,11 +41,9 @@
*/
/* all in kHz */
-#define MIN_VCO 135000.0
-#define MAX_VCO 270000.0
void
-s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
+s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR, int minVco)
{
int M, N, R, bestM, bestN;
int f_vco, f_out;
@@ -57,15 +55,15 @@ s3GetClock (int target, int *Mp, int *Np, int *Rp, int maxM, int maxN, int maxR)
for (R = 0; R <= maxR; R++)
{
f_vco = target * (1 << R);
- if (f_vco >= MIN_VCO)
+ if (f_vco >= minVco)
break;
}
/* M = f_out / f_ref * ((N + 2) * (1 << R)); */
besterr = target;
- for (N = 0; N <= maxN; N++)
+ for (N = 1; N <= maxN; N++)
{
- M = (target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) / S3_CLOCK_REF - 2;
+ M = ((target * (N + 2) * (1 << R) + (S3_CLOCK_REF/2)) + S3_CLOCK_REF/2) / S3_CLOCK_REF - 2;
if (0 <= M && M <= maxM)
{
f_out = S3_CLOCK(M,N,R);
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3cmap.c b/xc/programs/Xserver/hw/kdrive/savage/s3cmap.c
index fb334a1f0..d861be66d 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3cmap.c
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3cmap.c
@@ -22,12 +22,12 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.3 2000/02/23 20:30:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3cmap.c,v 1.4 2000/05/06 22:17:45 keithp Exp $ */
#include "s3.h"
void
-s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
+s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
@@ -44,7 +44,7 @@ s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
}
void
-s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
+s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
@@ -53,7 +53,12 @@ s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
Bool hit_border = FALSE;
Bool check_border = FALSE;
+#if 0
_s3WaitVRetrace (s3vga);
+#else
+ S3Ptr s3 = s3c->s3;
+ _s3WaitVRetraceFast(s3);
+#endif
if (pScreenPriv->enabled && s3s->manage_border && !s3s->managing_border)
check_border = TRUE;
while (ndef--)
@@ -77,10 +82,10 @@ s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
black.green = 0;
black.blue = 0;
s3s->managing_border = TRUE;
- FakeAllocColor (pScreenPriv->pInstalledmap,
+ FakeAllocColor (pScreenPriv->pInstalledmap[fb],
&black);
s3s->border_pixel = black.pixel;
- FakeFreeColor (pScreenPriv->pInstalledmap, s3s->border_pixel);
+ FakeFreeColor (pScreenPriv->pInstalledmap[fb], s3s->border_pixel);
/* s3SetImm (&s3c->s3vga, s3_border_color, (VGA8) s3s->border_pixel); */
}
}
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3curs.c b/xc/programs/Xserver/hw/kdrive/savage/s3curs.c
index 68fef0682..dbe4c712f 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3curs.c
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3curs.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3curs.c,v 1.3 2000/02/23 20:30:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3curs.c,v 1.4 2000/05/06 22:17:46 keithp Exp $ */
#include "s3.h"
#include "s3draw.h"
@@ -90,24 +90,42 @@ s3MoveCursor (ScreenPtr pScreen, int x, int y)
_s3MoveCursor (pScreen, x, y);
}
+#define S3Trunc(c) (((c) >> 8) & 0xff)
+
+#define S3CursColor(r,g,b) ((S3Trunc(r) << 16) | \
+ (S3Trunc(g) << 8) | \
+ (S3Trunc(b)))
+
static void
s3AllocCursorColors (ScreenPtr pScreen)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
- KdAllocateCursorPixels (pScreen, pCursor,
- &pCurPriv->source, &pCurPriv->mask);
- switch (pScreenPriv->screen->bitsPerPixel) {
- case 4:
- pCurPriv->source |= pCurPriv->source << 4;
- pCurPriv->mask |= pCurPriv->mask << 4;
- case 8:
- pCurPriv->source |= pCurPriv->source << 8;
- pCurPriv->mask |= pCurPriv->mask << 8;
- case 16:
- pCurPriv->source |= pCurPriv->source << 16;
- pCurPriv->mask |= pCurPriv->mask << 16;
+ if (s3s->use_streams)
+ {
+ pCurPriv->source = S3CursColor(pCursor->foreRed,
+ pCursor->foreGreen,
+ pCursor->foreBlue);
+ pCurPriv->mask = S3CursColor(pCursor->backRed,
+ pCursor->backGreen,
+ pCursor->backBlue);
+ }
+ else
+ {
+ KdAllocateCursorPixels (pScreen, 0, pCursor,
+ &pCurPriv->source, &pCurPriv->mask);
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
+ case 4:
+ pCurPriv->source |= pCurPriv->source << 4;
+ pCurPriv->mask |= pCurPriv->mask << 4;
+ case 8:
+ pCurPriv->source |= pCurPriv->source << 8;
+ pCurPriv->mask |= pCurPriv->mask << 8;
+ case 16:
+ pCurPriv->source |= pCurPriv->source << 16;
+ pCurPriv->mask |= pCurPriv->mask << 16;
+ }
}
}
@@ -221,6 +239,13 @@ s3LoadCursor (ScreenPtr pScreen, int x, int y)
S3AdjustBits32(and);
S3AdjustBits32(xor);
+#define S3SwapNibbles(x) ((x) = (((x) & 0x0f0f0f0f) << 4 | \
+ ((x) >> 4) & 0x0f0f0f0f))
+ if (s3s->use_streams)
+ {
+ S3SwapNibbles(and);
+ S3SwapNibbles(xor);
+ }
*ram++ = (and & 0xffff) | (xor << 16);
*ram++ = (and >> 16) | (xor & 0xffff0000);
}
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3draw.c b/xc/programs/Xserver/hw/kdrive/savage/s3draw.c
index eb6114af9..f90ca3355 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3draw.c
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3draw.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.3 2000/02/23 20:30:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.c,v 1.4 2000/05/06 22:17:46 keithp Exp $ */
#include "s3.h"
#include "s3draw.h"
@@ -114,6 +114,7 @@ s3CopyNtoN (DrawablePtr pSrcDrawable,
return;
}
+ s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC));
_s3SetBlt(s3,pGC->alu,pGC->planemask);
DRAW_DEBUG ((DEBUG_RENDER, "s3CopyNtoN alu %d planemask 0x%x",
pGC->alu, pGC->planemask));
@@ -265,6 +266,7 @@ s3Copy1toN (DrawablePtr pSrcDrawable,
return;
}
+ s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC));
fbGetStipDrawable (pSrcDrawable, psrcBase, widthSrc, srcBpp);
if (args->opaque)
@@ -345,6 +347,7 @@ s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
SetupS3(pDrawable->pScreen);
register int r;
+ s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable));
_s3SetSolidFill(s3,pixel,alu,planemask);
while (nBox--) {
@@ -355,13 +358,13 @@ s3FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
}
void
-_s3SetPattern (ScreenPtr pScreen,
+_s3SetPattern (ScreenPtr pScreen, int ma,
int alu, unsigned long planemask, s3PatternPtr pPattern)
{
SetupS3(pScreen);
S3PatternCache *cache;
- _s3LoadPattern (pScreen, pPattern);
+ _s3LoadPattern (pScreen, ma, pPattern);
cache = pPattern->cache;
switch (pPattern->fillStyle) {
@@ -385,7 +388,8 @@ s3FillBoxPattern (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
S3PatternCache *cache;
int patx, paty;
- _s3SetPattern (pDrawable->pScreen, alu, planemask, pPattern);
+ s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable));
+ _s3SetPattern (pDrawable->pScreen, s3DrawMap(pDrawable), alu, planemask, pPattern);
cache = pPattern->cache;
while (nBox--)
{
@@ -415,6 +419,7 @@ s3FillBoxLargeStipple (DrawablePtr pDrawable, GCPtr pGC,
stipHeight = pStipple->height;
fbGetStipDrawable (pStipple, stip, stipStride, stipBpp);
+ s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable));
if (pGC->fillStyle == FillOpaqueStippled)
{
_s3SetOpaquePlaneBlt(s3,pGC->alu,pGC->planemask,
@@ -648,6 +653,7 @@ _s3FillSpanLargeStipple (DrawablePtr pDrawable, GCPtr pGC,
int stipWidth, stipHeight;
int dstX, dstY, width, height;
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
stipWidth = pStipple->width;
stipHeight = pStipple->height;
fbGetStipDrawable (pStipple, stip, stipStride, stipBpp);
@@ -711,6 +717,7 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
S3PatternCache *cache;
RegionPtr pClip = fbGetCompositeClip (pGC);
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
if (REGION_NUM_RECTS(pClip) == 1 &&
(pGC->fillStyle == FillSolid || s3Priv->pPattern))
{
@@ -726,7 +733,7 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
}
else
{
- _s3SetPattern (pDrawable->pScreen, pGC->alu, pGC->planemask,
+ _s3SetPattern (pDrawable->pScreen, s3GCMap(pGC), pGC->alu, pGC->planemask,
s3Priv->pPattern);
cache = s3Priv->pPattern->cache;
}
@@ -793,7 +800,7 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
}
else if (s3Priv->pPattern)
{
- _s3SetPattern (pDrawable->pScreen, pGC->alu, pGC->planemask,
+ _s3SetPattern (pDrawable->pScreen, s3GCMap(pGC), pGC->alu, pGC->planemask,
s3Priv->pPattern);
cache = s3Priv->pPattern->cache;
while (n--)
@@ -843,6 +850,7 @@ s3FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
static void
_s3FillEllipse (DrawablePtr pDraw, S3Ptr s3, xArc *arc)
{
+ KdScreenPriv(pDraw->pScreen);
int x, y, e;
int yk, xk, ym, xm, dx, dy, xorg, yorg;
int y_top, y_bot;
@@ -850,6 +858,7 @@ _s3FillEllipse (DrawablePtr pDraw, S3Ptr s3, xArc *arc)
register int xpos;
int slw;
+ s3SetGlobalBitmap (pDraw->pScreen, s3DrawMap (pDraw));
miFillArcSetup(arc, &info);
MIFILLARCSETUP();
y_top = pDraw->y + yorg - y;
@@ -873,6 +882,7 @@ _s3FillEllipse (DrawablePtr pDraw, S3Ptr s3, xArc *arc)
static void
_s3FillArcSlice (DrawablePtr pDraw, GCPtr pGC, S3Ptr s3, xArc *arc)
{
+ KdScreenPriv(pDraw->pScreen);
int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
register int x, y, e;
miFillArcRec info;
@@ -880,6 +890,7 @@ _s3FillArcSlice (DrawablePtr pDraw, GCPtr pGC, S3Ptr s3, xArc *arc)
int xl, xr, xc;
int y_top, y_bot;
+ s3SetGlobalBitmap (pDraw->pScreen, s3DrawMap (pDraw));
DRAW_DEBUG ((DEBUG_ARCS, "slice %dx%d+%d+%d %d->%d",
arc->width, arc->height, arc->x, arc->y,
arc->angle1, arc->angle2));
@@ -1013,6 +1024,7 @@ s3FillPoly1Rect (DrawablePtr pDrawable, GCPtr pGC, int shape,
return;
}
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
fbPriv = fbGetGCPrivate(pGC);
sy = pDrawable->y;
sx = pDrawable->x;
@@ -1258,6 +1270,7 @@ s3PolyGlyphBltClipped (DrawablePtr pDrawable,
Bool set;
PixTransDeclare;
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
x += pDrawable->x;
y += pDrawable->y;
@@ -1408,6 +1421,7 @@ s3PolyGlyphBlt (DrawablePtr pDrawable,
unsigned char alu;
PixTransDeclare;
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
x += pDrawable->x;
y += pDrawable->y;
@@ -1549,6 +1563,7 @@ s3ImageTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC,
CARD32 tmp;
PixTransDeclare;
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
if (!widthGlyph)
return;
@@ -1701,6 +1716,7 @@ _s3Segment (DrawablePtr pDrawable,
unsigned int oc1; /* outcode of point 1 */
unsigned int oc2; /* outcode of point 2 */
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
nBox = REGION_NUM_RECTS (pClip);
pBox = REGION_RECTS (pClip);
CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
@@ -1875,6 +1891,7 @@ s3PolySegment (DrawablePtr pDrawable, GCPtr pGC,
Bool
s3AllocPattern (ScreenPtr pScreen,
+ int ma,
PixmapPtr pPixmap,
int xorg, int yorg,
int fillStyle, Pixel fg, Pixel bg,
@@ -1884,7 +1901,7 @@ s3AllocPattern (ScreenPtr pScreen,
s3ScreenInfo(pScreenPriv);
s3PatternPtr pPattern;
- if (s3s->patterns.cache && fillStyle != FillSolid &&
+ if (s3s->fb[ma].patterns.cache && fillStyle != FillSolid &&
s3CheckPattern (pPixmap->drawable.width, pPixmap->drawable.height))
{
if (!(pPattern = *ppPattern))
@@ -1935,6 +1952,7 @@ s3CheckGCFill (GCPtr pGC)
break;
}
s3AllocPattern (pGC->pScreen,
+ s3GCMap(pGC),
pPixmap,
pGC->patOrg.x + pGC->lastWinOrg.x,
pGC->patOrg.y + pGC->lastWinOrg.y,
@@ -2005,27 +2023,33 @@ s3FetchPatternPixel (s3PatternPtr pPattern, int x, int y)
* Place pattern image on screen; done with S3 locked
*/
void
-_s3PutPattern (ScreenPtr pScreen, s3PatternPtr pPattern)
+_s3PutPattern (ScreenPtr pScreen, int ma, s3PatternPtr pPattern)
{
SetupS3(pScreen);
+ s3ScreenInfo(pScreenPriv);
int x, y;
CARD8 *dstLine, *dst8;
CARD16 *dst16;
CARD32 *dst32;
S3PatternCache *cache = pPattern->cache;
+#ifdef S3_TRIO
+ int fb = 0;
+#else
+ int fb = s3s->fbmap[ma];
+#endif
DRAW_DEBUG ((DEBUG_PATTERN, "_s3PutPattern 0x%x id %d to %d %d",
pPattern, pPattern->id, cache->x, cache->y));
- dstLine = (pScreenPriv->screen->frameBuffer +
- cache->y * pScreenPriv->screen->byteStride +
- cache->x * pScreenPriv->bytesPerPixel);
+ dstLine = (pScreenPriv->screen->fb[fb].frameBuffer +
+ cache->y * pScreenPriv->screen->fb[fb].byteStride +
+ cache->x * pScreenPriv->bytesPerPixel[fb]);
CheckSyncS3 (pScreen);
for (y = 0; y < S3_TILE_SIZE; y++)
{
- switch (pScreenPriv->screen->bitsPerPixel) {
+ switch (pScreenPriv->screen->fb[fb].bitsPerPixel) {
case 8:
dst8 = dstLine;
for (x = 0; x < S3_TILE_SIZE; x++)
@@ -2051,7 +2075,7 @@ _s3PutPattern (ScreenPtr pScreen, s3PatternPtr pPattern)
*dst32++ = s3FetchPatternPixel (pPattern, x, y);
break;
}
- dstLine += pScreenPriv->screen->byteStride;
+ dstLine += pScreenPriv->screen->fb[fb].byteStride;
}
}
@@ -2059,7 +2083,7 @@ _s3PutPattern (ScreenPtr pScreen, s3PatternPtr pPattern)
* Load a stipple to off-screen memory; done with S3 locked
*/
void
-_s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern)
+_s3LoadPattern (ScreenPtr pScreen, int ma, s3PatternPtr pPattern)
{
SetupS3(pScreen);
s3ScreenInfo(pScreenPriv);
@@ -2078,13 +2102,13 @@ _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern)
/*
* Lame replacement strategy; assume we'll have plenty of room.
*/
- cache = &s3s->patterns.cache[s3s->patterns.last_used];
- if (++s3s->patterns.last_used == s3s->patterns.ncache)
- s3s->patterns.last_used = 0;
- cache->id = ++s3s->patterns.last_id;
+ cache = &s3s->fb[ma].patterns.cache[s3s->fb[ma].patterns.last_used];
+ if (++s3s->fb[ma].patterns.last_used == s3s->fb[ma].patterns.ncache)
+ s3s->fb[ma].patterns.last_used = 0;
+ cache->id = ++s3s->fb[ma].patterns.last_id;
pPattern->id = cache->id;
pPattern->cache = cache;
- _s3PutPattern (pScreen, pPattern);
+ _s3PutPattern (pScreen, ma, pPattern);
}
void
@@ -2110,6 +2134,8 @@ GCFuncs s3GCFuncs = {
int
s3CreateGC (GCPtr pGC)
{
+ KdScreenPriv(pGC->pScreen);
+ s3ScreenInfo(pScreenPriv);
s3PrivGCPtr s3Priv;
if (!fbCreateGC (pGC))
@@ -2121,17 +2147,30 @@ s3CreateGC (GCPtr pGC)
s3Priv = s3GetGCPrivate(pGC);
s3Priv->type = DRAWABLE_PIXMAP;
s3Priv->pPattern = 0;
-
+#ifndef S3_TRIO
+ if (pGC->depth == s3s->primary_depth)
+ s3Priv->ma = 0;
+ else
+ s3Priv->ma = 1;
+#endif
return TRUE;
}
Bool
s3CreateWindow (WindowPtr pWin)
{
+ KdScreenPriv(pWin->drawable.pScreen);
+ s3ScreenInfo(pScreenPriv);
+
if (!KdCreateWindow (pWin))
return FALSE;
pWin->devPrivates[s3WindowPrivateIndex].ptr = 0;
- return TRUE;
+#ifndef S3_TRIO
+ if (pWin->drawable.depth != s3s->primary_depth)
+ return fbOverlayCreateWindow (pWin);
+ else
+#endif
+ return fbCreateWindow (pWin);
}
Bool
@@ -2146,6 +2185,7 @@ s3DestroyWindow (WindowPtr pWin)
Bool
s3ChangeWindowAttributes (WindowPtr pWin, Mask mask)
{
+ KdScreenPriv(pWin->drawable.pScreen);
Bool ret;
s3PatternPtr pPattern;
PixmapPtr pPixmap;
@@ -2165,7 +2205,9 @@ s3ChangeWindowAttributes (WindowPtr pWin, Mask mask)
fillStyle = FillSolid;
}
pPattern = s3GetWindowPrivate(pWin);
- s3AllocPattern (pWin->drawable.pScreen, pPixmap,
+ s3AllocPattern (pWin->drawable.pScreen,
+ s3DrawMap (&pWin->drawable),
+ pPixmap,
pWin->drawable.x, pWin->drawable.y,
fillStyle, 0, 0, &pPattern);
DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "Background pattern 0x%x pixmap 0x%x style %d",
@@ -2175,6 +2217,30 @@ s3ChangeWindowAttributes (WindowPtr pWin, Mask mask)
return ret;
}
+#ifndef S3_TRIO
+void
+s3PaintChromaKey (WindowPtr pWin, RegionPtr pRegion)
+{
+ SetupS3 (pWin->drawable.pScreen);
+ s3ScreenInfo (pScreenPriv);
+
+ if (pWin->drawable.depth != s3s->primary_depth)
+ {
+ int nBox = REGION_NUM_RECTS(pRegion);
+ BoxPtr pBox = REGION_RECTS(pRegion);
+
+ s3SetGlobalBitmap (pWin->drawable.pScreen, 0);
+ _s3SetSolidFill(s3,0xffffffff,GXcopy,0xffffffff);
+ while (nBox--)
+ {
+ _s3SolidRect(s3,pBox->x1,pBox->y1,pBox->x2-pBox->x1,pBox->y2-pBox->y1);
+ pBox++;
+ }
+ MarkSyncS3 (pWin->drawable.pScreen);
+ }
+}
+#endif
+
void
s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
{
@@ -2188,6 +2254,9 @@ s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
REGION_NUM_RECTS(pRegion)));
if (!REGION_NUM_RECTS(pRegion))
return;
+#ifndef S3_TRIO
+ s3PaintChromaKey (pWin, pRegion);
+#endif
switch (what) {
case PW_BACKGROUND:
switch (pWin->backgroundState) {
@@ -2234,11 +2303,24 @@ s3PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
}
void
+s3RestoreAreas(PixmapPtr pPixmap,
+ RegionPtr prgnRestore,
+ int xorg,
+ int yorg,
+ WindowPtr pWin)
+{
+#ifndef S3_TRIO
+ s3PaintChromaKey (pWin, prgnRestore);
+#endif
+ KdCheckRestoreAreas (pPixmap, prgnRestore, xorg, yorg, pWin);
+}
+
+void
s3CopyWindowProc (DrawablePtr pSrcDrawable,
DrawablePtr pDstDrawable,
GCPtr pGC,
- BoxPtr pbox,
- int nbox,
+ BoxPtr pboxOrig,
+ int nboxOrig,
int dx,
int dy,
Bool reverse,
@@ -2247,23 +2329,248 @@ s3CopyWindowProc (DrawablePtr pSrcDrawable,
void *closure)
{
SetupS3(pDstDrawable->pScreen);
+ s3ScreenInfo(pScreenPriv);
+ int srcX, srcY, dstX, dstY;
+ int x1, x2;
+ int w, h;
+ int flags;
+ int ma;
+ BoxPtr pbox;
+ int nbox;
+
+ if (pSrcDrawable->bitsPerPixel == 24)
+ dx *= 3;
+#ifdef S3_TRIO
+ ma = 0;
+#else
+ for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+#endif
+ {
+ nbox = nboxOrig;
+ pbox = pboxOrig;
+ s3SetGlobalBitmap (pDstDrawable->pScreen, ma);
+ _s3SetBlt(s3,GXcopy,~0);
+ while (nbox--)
+ {
+ x1 = pbox->x1;
+ x2 = pbox->x2;
+ if (pSrcDrawable->bitsPerPixel == 24)
+ {
+ x1 *= 3;
+ x2 *= 3;
+ }
+
+ w = x2 - x1;
+ h = pbox->y2 - pbox->y1;
+ flags = 0;
+ if (reverse)
+ {
+ dstX = x2 - 1;
+ }
+ else
+ {
+ dstX = x1;
+ flags |= INC_X;
+ }
+ srcX = dstX + dx;
+
+ if (upsidedown)
+ {
+ dstY = pbox->y2 - 1;
+ }
+ else
+ {
+ dstY = pbox->y1;
+ flags |= INC_Y;
+ }
+ srcY = dstY + dy;
+
+ _s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags);
+ pbox++;
+ }
+ MarkSyncS3 (pDstDrawable->pScreen);
+ }
+}
+
+void
+s3CopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ KdScreenPriv(pScreen);
+ RegionRec rgnDst;
+ int dx, dy;
+ WindowPtr pwinRoot;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+
+ REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+
+ REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+
+ fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ 0,
+ &rgnDst, dx, dy, s3CopyWindowProc, 0, 0);
+
+ REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+}
+
+void
+s3_24FillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox,
+ unsigned long pixel, int alu, unsigned long planemask)
+{
+ SetupS3(pDrawable->pScreen);
+ register int r;
+ int x1, x2;
+
+ s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable));
+ _s3SetSolidFill(s3,pixel,alu,planemask);
+
+ while (nBox--) {
+ x1 = pBox->x1 * 3;
+ x2 = pBox->x2 * 3;
+ _s3SolidRect(s3,x1,pBox->y1,x2-x1,pBox->y2-pBox->y1);
+ pBox++;
+ }
+ MarkSyncS3 (pDrawable->pScreen);
+}
+
+#define ok24(p) (((p) & 0xffffff) == ((((p) & 0xff) << 16) | (((p) >> 8) & 0xffff)))
+
+void
+s3_24FillSpans (DrawablePtr pDrawable, GCPtr pGC, int n,
+ DDXPointPtr ppt, int *pwidth, int fSorted)
+{
+ SetupS3(pDrawable->pScreen);
+ int x, y, x1, y1, x2, y2;
+ int width;
+ /* next three parameters are post-clip */
+ int nTmp;
+ int *pwidthFree;/* copies of the pointers to free */
+ DDXPointPtr pptFree;
+ FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
+ BoxPtr extents;
+ RegionPtr pClip = fbGetCompositeClip (pGC);
+
+ if (pGC->fillStyle != FillSolid || !ok24 (pGC->fgPixel) || !ok24(pGC->planemask))
+ {
+ KdCheckFillSpans (pDrawable, pGC, n, ppt, pwidth, fSorted);
+ return;
+ }
+
+ s3SetGlobalBitmap (pDrawable->pScreen, s3GCMap (pGC));
+ if (REGION_NUM_RECTS(pClip) == 1)
+ {
+ extents = REGION_RECTS(pClip);
+ x1 = extents->x1;
+ x2 = extents->x2;
+ y1 = extents->y1;
+ y2 = extents->y2;
+ _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
+ while (n--)
+ {
+ y = ppt->y;
+ if (y1 <= y && y < y2)
+ {
+ x = ppt->x;
+ width = *pwidth;
+ if (x < x1)
+ {
+ width -= (x1 - x);
+ x = x1;
+ }
+ if (x2 < x + width)
+ width = x2 - x;
+ if (width > 0)
+ {
+ _s3SolidRect(s3,x*3,y,width*3,1);
+ }
+ }
+ ppt++;
+ pwidth++;
+ }
+ }
+ else
+ {
+ nTmp = n * miFindMaxBand(pClip);
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if(!pptFree || !pwidthFree)
+ {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(fbGetCompositeClip(pGC),
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ _s3SetSolidFill(s3,pGC->fgPixel,pGC->alu,pGC->planemask);
+ while (n--)
+ {
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ width = *pwidth++;
+ if (width)
+ {
+ _s3SolidRect(s3,x*3,y,width*3,1);
+ }
+ }
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ }
+ MarkSyncS3 (pDrawable->pScreen);
+}
+
+void
+s3_24CopyNtoN (DrawablePtr pSrcDrawable,
+ DrawablePtr pDstDrawable,
+ GCPtr pGC,
+ BoxPtr pbox,
+ int nbox,
+ int dx,
+ int dy,
+ Bool reverse,
+ Bool upsidedown,
+ Pixel bitplane,
+ void *closure)
+{
+ SetupS3(pDstDrawable->pScreen);
int srcX, srcY, dstX, dstY;
int w, h;
int flags;
+ int x1, x2;
+
+ if (sourceInvarient (pGC->alu))
+ {
+ s3_24FillBoxSolid (pDstDrawable, nbox, pbox, 0, pGC->alu, pGC->planemask);
+ return;
+ }
- _s3SetBlt(s3,GXcopy,~0);
+ s3SetGlobalBitmap (pDstDrawable->pScreen, s3GCMap (pGC));
+ _s3SetBlt(s3,pGC->alu,pGC->planemask);
+ DRAW_DEBUG ((DEBUG_RENDER, "s3CopyNtoN alu %d planemask 0x%x",
+ pGC->alu, pGC->planemask));
+ dx *= 3;
while (nbox--)
{
- w = pbox->x2 - pbox->x1;
+ x1 = pbox->x1 * 3;
+ x2 = pbox->x2 * 3;
+ w = x2 - x1;
h = pbox->y2 - pbox->y1;
flags = 0;
if (reverse)
{
- dstX = pbox->x2 - 1;
+ dstX = x2 - 1;
}
else
{
- dstX = pbox->x1;
+ dstX = x1;
flags |= INC_X;
}
srcX = dstX + dx;
@@ -2282,33 +2589,456 @@ s3CopyWindowProc (DrawablePtr pSrcDrawable,
_s3Blt (s3, srcX, srcY, dstX, dstY, w, h, flags);
pbox++;
}
- MarkSyncS3 (pDstDrawable->pScreen);
+ MarkSyncS3 (pSrcDrawable->pScreen);
}
-void
-s3CopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+RegionPtr
+s3_24CopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GCPtr pGC,
+ int srcx, int srcy, int width, int height, int dstx, int dsty)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- KdScreenPriv(pScreen);
- RegionRec rgnDst;
- int dx, dy;
- WindowPtr pwinRoot;
+ SetupS3(pDstDrawable->pScreen);
+
+ if (pSrcDrawable->type == DRAWABLE_WINDOW &&
+ pDstDrawable->type == DRAWABLE_WINDOW &&
+ ok24(pGC->planemask))
+ {
+ return fbDoCopy (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, s3_24CopyNtoN, 0, 0);
+ }
+ return KdCheckCopyArea (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height, dstx, dsty);
+}
- pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
- dx = ptOldOrg.x - pWin->drawable.x;
- dy = ptOldOrg.y - pWin->drawable.y;
- REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+#define NUM_STACK_RECTS 1024
- REGION_INIT (pWin->drawable.pScreen, &rgnDst, NullBox, 0);
+void
+s3_24PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ s3GCPrivate(pGC);
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ BoxRec stackRects[NUM_STACK_RECTS];
+ FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC);
+ int numRects;
+ int n;
+ int xorg, yorg;
+ int x, y;
+
+ if (pGC->fillStyle != FillSolid || !ok24 (pGC->fgPixel) || !ok24(pGC->planemask))
+ {
+ KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
+ return;
+ }
- REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst, &pWin->borderClip, prgnSrc);
+ prgnClip = fbGetCompositeClip(pGC);
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+
+ if (xorg || yorg)
+ {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--)
+ {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
- fbCopyRegion ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
- 0,
- &rgnDst, dx, dy, s3CopyWindowProc, 0, 0);
+ numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+ if (numRects > NUM_STACK_RECTS)
+ {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(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;
- REGION_UNINIT(pWin->drawable.pScreen, &rgnDst);
+ 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)
+ {
+ s3_24FillBoxSolid(pDrawable,
+ pboxClipped-pboxClippedBase, pboxClippedBase,
+ pGC->fgPixel, pGC->alu, pGC->planemask);
+ }
+ if (pboxClippedBase != stackRects)
+ DEALLOCATE_LOCAL(pboxClippedBase);
+}
+
+void
+s3_24SolidBoxClipped (DrawablePtr pDrawable,
+ RegionPtr pClip,
+ int x1,
+ int y1,
+ int x2,
+ int y2,
+ FbBits fg)
+{
+ SetupS3 (pDrawable->pScreen);
+ BoxPtr pbox;
+ int nbox;
+ int partX1, partX2, partY1, partY2;
+
+ s3SetGlobalBitmap (pDrawable->pScreen, s3DrawMap (pDrawable));
+ _s3SetSolidFill(s3,fg,GXcopy,~0);
+
+ for (nbox = REGION_NUM_RECTS(pClip), pbox = REGION_RECTS(pClip);
+ nbox--;
+ pbox++)
+ {
+ partX1 = pbox->x1;
+ if (partX1 < x1)
+ partX1 = x1;
+
+ partX2 = pbox->x2;
+ if (partX2 > x2)
+ partX2 = x2;
+
+ if (partX2 <= partX1)
+ continue;
+
+ partY1 = pbox->y1;
+ if (partY1 < y1)
+ partY1 = y1;
+
+ partY2 = pbox->y2;
+ if (partY2 > y2)
+ partY2 = y2;
+
+ if (partY2 <= partY1)
+ continue;
+
+ partX1 *= 3;
+ partX2 *= 3;
+ _s3SolidRect(s3,partX1, partY1, partX2-partX1, partY2-partY1);
+ }
+ MarkSyncS3(pDrawable->pScreen);
+}
+
+void
+s3_24ImageGlyphBlt (DrawablePtr pDrawable,
+ GCPtr pGC,
+ int x,
+ int y,
+ unsigned int nglyph,
+ CharInfoPtr *ppciInit,
+ pointer pglyphBase)
+{
+ FbGCPrivPtr pPriv = fbGetGCPrivate(pGC);
+ CharInfoPtr *ppci;
+ CharInfoPtr pci;
+ unsigned char *pglyph; /* pointer bits in glyph */
+ int gWidth, gHeight; /* width and height of glyph */
+ FbStride gStride; /* stride of glyph */
+ Bool opaque;
+ int n;
+ int gx, gy;
+ FbBits *dst;
+ FbStride dstStride;
+ int dstBpp;
+ FbBits depthMask;
+ int xBack, widthBack;
+ int yBack, heightBack;
+
+ depthMask = FbFullMask(pDrawable->depth);
+ if (!ok24 (pGC->fgPixel) ||
+ !ok24(pGC->bgPixel) ||
+ !ok24(pGC->planemask))
+ {
+ KdCheckImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppciInit, pglyphBase);
+ return;
+ }
+ fbGetDrawable (pDrawable, dst, dstStride, dstBpp);
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ ppci = ppciInit;
+ n = nglyph;
+ widthBack = 0;
+ while (n--)
+ widthBack += (*ppci++)->metrics.characterWidth;
+
+ xBack = x;
+ if (widthBack < 0)
+ {
+ xBack += widthBack;
+ widthBack = -widthBack;
+ }
+ yBack = y - FONTASCENT(pGC->font);
+ heightBack = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ s3_24SolidBoxClipped (pDrawable,
+ fbGetCompositeClip(pGC),
+ xBack,
+ yBack,
+ xBack + widthBack,
+ yBack + heightBack,
+ pPriv->bg);
+
+ KdCheckSync (pDrawable->pScreen);
+
+ ppci = ppciInit;
+ while (nglyph--)
+ {
+ pci = *ppci++;
+ pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ gWidth = GLYPHWIDTHPIXELS(pci);
+ gHeight = GLYPHHEIGHTPIXELS(pci);
+ if (gWidth && gHeight)
+ {
+ gx = x + pci->metrics.leftSideBearing;
+ gy = y - pci->metrics.ascent;
+ if (gWidth <= sizeof (FbStip) * 8 &&
+ fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
+ {
+ fbGlyph24 (dst + gy * dstStride,
+ dstStride,
+ dstBpp,
+ (FbStip *) pglyph,
+ pPriv->fg,
+ gx,
+ gHeight);
+ }
+ else
+ {
+ gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
+ fbPutXYImage (pDrawable,
+ fbGetCompositeClip(pGC),
+ pPriv->fg,
+ pPriv->bg,
+ pPriv->pm,
+ GXcopy,
+ FALSE,
+
+ gx,
+ gy,
+ gWidth, gHeight,
+
+ (FbStip *) pglyph,
+ gStride,
+ 0);
+ }
+ }
+ x += pci->metrics.characterWidth;
+ }
+}
+
+static const GCOps s3_24GCOps = {
+ s3_24FillSpans,
+ KdCheckSetSpans,
+ KdCheckPutImage,
+ KdCheckCopyArea,
+ KdCheckCopyPlane,
+ KdCheckPolyPoint,
+ KdCheckPolylines,
+ KdCheckPolySegment,
+ KdCheckPolyRectangle,
+ KdCheckPolyArc,
+ KdCheckFillPolygon,
+ s3_24PolyFillRect,
+ KdCheckPolyFillArc,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ s3_24ImageGlyphBlt,
+ KdCheckPolyGlyphBlt,
+ KdCheckPushPixels,
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+void
+s3_24ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
+{
+ if (pDrawable->type != DRAWABLE_WINDOW)
+ pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
+ else
+ pGC->ops = (GCOps *) &s3_24GCOps;
+ fbValidateGC (pGC, changes, pDrawable);
+}
+
+GCFuncs s3_24GCFuncs = {
+ s3_24ValidateGC,
+ miChangeGC,
+ miCopyGC,
+ miDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+Bool
+s3_24CreateGC (GCPtr pGC)
+{
+ if (!fbCreateGC (pGC))
+ return FALSE;
+
+ if (pGC->depth != 1)
+ pGC->funcs = &s3_24GCFuncs;
+
+ return TRUE;
+}
+
+Bool
+s3_24CreateWindow(WindowPtr pWin)
+{
+ return fbCreateWindow (pWin);
+}
+
+void
+s3_24PaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ SetupS3(pWin->drawable.pScreen);
+ s3PatternPtr pPattern;
+
+ DRAW_DEBUG ((DEBUG_PAINT_WINDOW, "s3PaintWindow 0x%x extents %d %d %d %d n %d",
+ pWin->drawable.id,
+ pRegion->extents.x1, pRegion->extents.y1,
+ pRegion->extents.x2, pRegion->extents.y2,
+ REGION_NUM_RECTS(pRegion)));
+ if (!REGION_NUM_RECTS(pRegion))
+ return;
+ switch (what) {
+ case PW_BACKGROUND:
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+ what);
+ return;
+ case BackgroundPixel:
+ if (ok24(pWin->background.pixel))
+ {
+ s3_24FillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel, GXcopy, ~0);
+ return;
+ }
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel && ok24(pWin->border.pixel))
+ {
+ s3_24FillBoxSolid((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel, GXcopy, ~0);
+ return;
+ }
+ break;
+ }
+ KdCheckPaintWindow (pWin, pRegion, what);
}
Bool
@@ -2319,25 +3049,20 @@ s3DrawInit (ScreenPtr pScreen)
int ncache_w, ncache_h, ncache;
int px, py;
S3PatternCache *cache;
+ Bool dumb = FALSE;
+ int ma;
- switch (pScreenPriv->screen->bitsPerPixel) {
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 8:
case 16:
case 32:
break;
+ case 24:
+ dumb = TRUE;
+ break;
default:
return FALSE;
}
- if (serverGeneration != s3Generation)
- {
- s3GCPrivateIndex = AllocateGCPrivateIndex ();
- s3WindowPrivateIndex = AllocateWindowPrivateIndex ();
- s3Generation = serverGeneration;
- }
- if (!AllocateWindowPrivate(pScreen, s3WindowPrivateIndex, 0))
- return FALSE;
- if (!AllocateGCPrivate(pScreen, s3GCPrivateIndex, sizeof (s3PrivGCRec)))
- return FALSE;
/*
* Hook up asynchronous drawing
*/
@@ -2345,38 +3070,75 @@ s3DrawInit (ScreenPtr pScreen)
/*
* Replace various fb screen functions
*/
- pScreen->CreateGC = s3CreateGC;
- pScreen->CreateWindow = s3CreateWindow;
- pScreen->ChangeWindowAttributes = s3ChangeWindowAttributes;
- pScreen->DestroyWindow = s3DestroyWindow;
- pScreen->PaintWindowBackground = s3PaintWindow;
- pScreen->PaintWindowBorder = s3PaintWindow;
- pScreen->CopyWindow = s3CopyWindow;
-
- /*
- * Initialize patterns
- */
- ncache_w = s3s->offscreen_width / S3_TILE_SIZE;
- ncache_h = s3s->offscreen_height / S3_TILE_SIZE;
- ncache = ncache_w * ncache_h;
- DRAW_DEBUG ((DEBUG_S3INIT, "ncache_w %d ncache_h %d ncache %d",
- ncache_w, ncache_h, ncache));
- s3s->patterns.cache = (S3PatternCache *) xalloc (ncache * sizeof (S3PatternCache));
- if (s3s->patterns.cache)
- {
- DRAW_DEBUG ((DEBUG_S3INIT, "Have pattern cache"));
- s3s->patterns.ncache = ncache;
- s3s->patterns.last_used = 0;
- s3s->patterns.last_id = 0;
- cache = s3s->patterns.cache;
- for (py = 0; py < ncache_h; py++)
- for (px = 0; px < ncache_w; px++)
+ if (dumb)
+ {
+ pScreen->CreateGC = s3_24CreateGC;
+ pScreen->CreateWindow = s3_24CreateWindow;
+ pScreen->PaintWindowBackground = s3_24PaintWindow;
+ pScreen->PaintWindowBorder = s3_24PaintWindow;
+ pScreen->CopyWindow = s3CopyWindow;
+ }
+ else
+ {
+ if (serverGeneration != s3Generation)
+ {
+ s3GCPrivateIndex = AllocateGCPrivateIndex ();
+ s3WindowPrivateIndex = AllocateWindowPrivateIndex ();
+ s3Generation = serverGeneration;
+ }
+ if (!AllocateWindowPrivate(pScreen, s3WindowPrivateIndex, 0))
+ return FALSE;
+ if (!AllocateGCPrivate(pScreen, s3GCPrivateIndex, sizeof (s3PrivGCRec)))
+ return FALSE;
+ pScreen->CreateGC = s3CreateGC;
+ pScreen->CreateWindow = s3CreateWindow;
+ pScreen->ChangeWindowAttributes = s3ChangeWindowAttributes;
+ pScreen->DestroyWindow = s3DestroyWindow;
+ pScreen->PaintWindowBackground = s3PaintWindow;
+ pScreen->PaintWindowBorder = s3PaintWindow;
+ pScreen->CopyWindow = s3CopyWindow;
+ pScreen->BackingStoreFuncs.RestoreAreas = s3RestoreAreas;
+#if 0
+ pScreen->PaintWindowBackground = s3DumbPaintWindow;
+ pScreen->PaintWindowBorder = s3DumbPaintWindow;
+ pScreen->CopyWindow = s3DumbCopyWindow;
+#endif
+
+ /*
+ * Initialize patterns
+ */
+#ifdef S3_TRIO
+ ma = 0;
+#else
+ for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+#endif
+ {
+ ncache_w = s3s->fb[ma].offscreen_width / S3_TILE_SIZE;
+ ncache_h = s3s->fb[ma].offscreen_height / S3_TILE_SIZE;
+ ncache = ncache_w * ncache_h;
+ if (ncache > 64)
+ ncache = 64;
+ DRAW_DEBUG ((DEBUG_S3INIT, "ncache_w %d ncache_h %d ncache %d",
+ ncache_w, ncache_h, ncache));
+ s3s->fb[ma].patterns.cache = (S3PatternCache *) xalloc (ncache * sizeof (S3PatternCache));
+ if (s3s->fb[ma].patterns.cache)
{
- cache->id = 0;
- cache->x = s3s->offscreen_x + px * S3_TILE_SIZE;
- cache->y = s3s->offscreen_y + py * S3_TILE_SIZE;
- cache++;
+ DRAW_DEBUG ((DEBUG_S3INIT, "Have pattern cache"));
+ s3s->fb[ma].patterns.ncache = ncache;
+ s3s->fb[ma].patterns.last_used = 0;
+ s3s->fb[ma].patterns.last_id = 0;
+ cache = s3s->fb[ma].patterns.cache;
+ for (py = 0; py < ncache_h && ncache; py++)
+ for (px = 0; px < ncache_w && ncache; px++)
+ {
+ cache->id = 0;
+ cache->x = s3s->fb[ma].offscreen_x + px * S3_TILE_SIZE;
+ cache->y = s3s->fb[ma].offscreen_y + py * S3_TILE_SIZE;
+ cache++;
+ ncache--;
+ }
}
+ }
}
return TRUE;
}
@@ -2387,18 +3149,37 @@ s3DrawEnable (ScreenPtr pScreen)
SetupS3(pScreen);
s3ScreenInfo(pScreenPriv);
int c;
+ int ma;
- /*
- * Flush pattern cache
- */
- for (c = 0; c < s3s->patterns.ncache; c++)
- s3s->patterns.cache[c].id = 0;
-
+ s3SetGlobalBitmap (pScreen, 0);
_s3WaitIdleEmpty (s3);
- _s3SetScissorsTl(s3, 0, 0);
- _s3SetScissorsBr(s3, pScreenPriv->screen->width - 1, pScreenPriv->screen->height - 1);
- _s3SetSolidFill(s3, pScreen->blackPixel, GXcopy, ~0);
- _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width, pScreenPriv->screen->height);
+ if (pScreenPriv->screen->fb[0].bitsPerPixel == 24)
+ {
+ _s3SetScissorsTl(s3, 0, 0);
+ _s3SetScissorsBr(s3, pScreenPriv->screen->width*3 - 1, pScreenPriv->screen->height - 1);
+ _s3SetSolidFill(s3, pScreen->whitePixel, GXcopy, ~0);
+ _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width*3, pScreenPriv->screen->height);
+ }
+ else
+ {
+ /*
+ * Flush pattern cache
+ */
+#ifdef S3_TRIO
+ ma = 0;
+#else
+ for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+#endif
+ {
+ for (c = 0; c < s3s->fb[ma].patterns.ncache; c++)
+ s3s->fb[ma].patterns.cache[c].id = 0;
+ }
+
+ _s3SetScissorsTl(s3, 0, 0);
+ _s3SetScissorsBr(s3, pScreenPriv->screen->width - 1, pScreenPriv->screen->height - 1);
+ _s3SetSolidFill(s3, pScreen->blackPixel, GXcopy, ~0);
+ _s3SolidRect (s3, 0, 0, pScreenPriv->screen->width, pScreenPriv->screen->height);
+ }
MarkSyncS3 (pScreen);
}
@@ -2414,12 +3195,20 @@ s3DrawFini (ScreenPtr pScreen)
{
SetupS3(pScreen);
s3ScreenInfo(pScreenPriv);
+ int ma;
- if (s3s->patterns.cache)
+#ifdef S3_TRIO
+ ma = 0;
+#else
+ for (ma = 0; s3s->fbmap[ma] >= 0; ma++)
+#endif
{
- xfree (s3s->patterns.cache);
- s3s->patterns.cache = 0;
- s3s->patterns.ncache = 0;
+ if (s3s->fb[ma].patterns.cache)
+ {
+ xfree (s3s->fb[ma].patterns.cache);
+ s3s->fb[ma].patterns.cache = 0;
+ s3s->fb[ma].patterns.ncache = 0;
+ }
}
}
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3draw.h b/xc/programs/Xserver/hw/kdrive/savage/s3draw.h
index 5c524453d..73260e259 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3draw.h
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3draw.h
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.h,v 1.3 2000/02/23 20:30:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3draw.h,v 1.4 2000/05/06 22:17:47 keithp Exp $ */
#ifndef _S3DRAW_H_
#define _S3DRAW_H_
@@ -41,6 +41,7 @@ typedef struct _s3Pattern {
typedef struct _s3PrivGC {
int type; /* type of drawable validated against */
+ int ma; /* stream descriptor */
s3PatternPtr pPattern; /* pattern */
} s3PrivGCRec, *s3PrivGCPtr;
@@ -55,8 +56,7 @@ typedef struct _s3PrivGC {
#define s3SetWindowPrivate(w,p) (\
(w)->devPrivates[s3WindowPrivateIndex].ptr = (pointer) p)
-
-void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
+void _s3LoadPattern (ScreenPtr pScreen, int fb, s3PatternPtr pPattern);
#define SetupS3(s) KdScreenPriv(s); \
s3CardInfo(pScreenPriv); \
@@ -82,6 +82,18 @@ void _s3LoadPattern (ScreenPtr pScreen, s3PatternPtr pPattern);
#define WIDEN(x) ((unsigned long) (x))
#define MERGE(a,b) ((WIDEN(a) << 16) | WIDEN(b))
+#define s3BitmapDescriptor(_stream) ((_stream) + 1)
+
+#ifdef S3_TRIO
+#define s3DrawMap(pDraw) 0
+#define s3SetGlobalBitmap(s,d)
+#else
+#define s3DrawMap(pDraw) ((pDraw)->depth == \
+ getS3ScreenInfo(pScreenPriv)->primary_depth ? 0 : 1)
+#endif
+
+#define s3GCMap(pGC) (s3GetGCPrivate(pGC)->ma)
+
/*
* Ok, so the S3 is broken -- it expects bitmaps to come MSB bit order,
* but it's willing to take them in LSB byte order. These macros
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3reg.c b/xc/programs/Xserver/hw/kdrive/savage/s3reg.c
index 5801402cf..af6185017 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3reg.c
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3reg.c
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.c,v 1.3 2000/02/23 20:30:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.c,v 1.4 2000/05/06 22:17:47 keithp Exp $ */
#include "s3reg.h"
@@ -403,6 +403,11 @@ VgaReg s3_line_compare[] = {
VGA_REG_END
};
+VgaReg s3_delay_primary_load[] = {
+ CR21, 1, 1,
+ VGA_REG_END
+};
+
VgaReg s3_device_id[] = {
CR2E, 0, 8,
CR2D, 0, 8,
@@ -654,16 +659,36 @@ VgaReg s3_pci_disconnect_enable[] = {
VGA_REG_END
};
+VgaReg s3_primary_load_control[] = {
+ CR66, 4, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_secondary_load_control[] = {
+ CR66, 5, 1,
+ VGA_REG_END
+};
+
VgaReg s3_pci_retry_enable[] = {
CR66, 7, 1,
VGA_REG_END
};
+VgaReg s3_streams_mode[] = {
+ CR67, 2, 2,
+ VGA_REG_END
+};
+
VgaReg s3_color_mode[] = {
CR67, 4, 4,
VGA_REG_END
};
+VgaReg s3_primary_stream_definition[] = {
+ CR69, 7, 1,
+ VGA_REG_END
+};
+
VgaReg s3_primary_stream_timeout[] = {
CR71, 0, 8,
VGA_REG_END
@@ -714,6 +739,26 @@ VgaReg s3_dac_power_saving_disable[] = {
VGA_REG_END
};
+VgaReg s3_flat_panel_output_control_1[] = {
+ CR90, 3, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_streams_fifo_delay[] = {
+ CR90, 4, 2,
+ VGA_REG_END
+};
+
+VgaReg s3_flat_panel_output_control_2[] = {
+ CR90, 6, 1,
+ VGA_REG_END
+};
+
+VgaReg s3_enable_l1_parameter[] = {
+ CR90, 7, 1,
+ VGA_REG_END
+};
+
VgaReg s3_primary_stream_l1[] = {
CR91, 0, 8,
CR90, 0, 3,
@@ -975,6 +1020,21 @@ VgaReg s3_dclk_control[] = {
VGA_REG_END
};
+VgaReg s3_eclk_n[] = {
+ SR32, 0, 5,
+ VGA_REG_END
+};
+
+VgaReg s3_eclk_r[] = {
+ SR32, 5, 2,
+ VGA_REG_END
+};
+
+VgaReg s3_eclk_m[] = {
+ SR32, 0, 5,
+ VGA_REG_END
+};
+
VgaReg s3_vga_dclk_n[] = {
SR36, 0, 6,
SR39, 4, 1,
diff --git a/xc/programs/Xserver/hw/kdrive/savage/s3reg.h b/xc/programs/Xserver/hw/kdrive/savage/s3reg.h
index fa8ae20ba..fec03fd06 100644
--- a/xc/programs/Xserver/hw/kdrive/savage/s3reg.h
+++ b/xc/programs/Xserver/hw/kdrive/savage/s3reg.h
@@ -22,7 +22,7 @@
*
* Author: Keith Packard, SuSE, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.h,v 1.3 2000/02/23 20:30:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/savage/s3reg.h,v 1.4 2000/05/06 22:17:48 keithp Exp $ */
#ifndef _S3REG_H_
#define _S3REG_H_
@@ -74,6 +74,7 @@ extern VgaReg s3_word_mode[];
extern VgaReg s3_byte_mode[];
extern VgaReg s3_hardware_reset[];
extern VgaReg s3_line_compare[];
+extern VgaReg s3_delay_primary_load[];
extern VgaReg s3_device_id[];
extern VgaReg s3_revision[];
extern VgaReg s3_enable_vga_16bit[];
@@ -123,8 +124,12 @@ extern VgaReg s3_delay_blank[];
extern VgaReg s3_delay_h_enable[];
extern VgaReg s3_enable_2d_3d[];
extern VgaReg s3_pci_disconnect_enable[];
+extern VgaReg s3_primary_load_control[];
+extern VgaReg s3_secondary_load_control[];
extern VgaReg s3_pci_retry_enable[];
+extern VgaReg s3_streams_mode[];
extern VgaReg s3_color_mode[];
+extern VgaReg s3_primary_stream_definition[];
extern VgaReg s3_primary_stream_timeout[];
extern VgaReg s3_master_control_unit_timeout[];
extern VgaReg s3_command_buffer_timeout[];
@@ -135,6 +140,10 @@ extern VgaReg s3_fifo_drain_delay[];
extern VgaReg s3_fifo_fetch_timing[];
extern VgaReg s3_dac_power_up_time[];
extern VgaReg s3_dac_power_saving_disable[];
+extern VgaReg s3_flat_panel_output_control_1[];
+extern VgaReg s3_streams_fifo_delay[];
+extern VgaReg s3_flat_panel_output_control_2[];
+extern VgaReg s3_enable_l1_parameter[];
extern VgaReg s3_primary_stream_l1[];
extern VgaReg s3_dot_clock_8[];
@@ -165,6 +174,9 @@ extern VgaReg s3_dclk_double_15_16_invert[];
extern VgaReg s3_enable_gamma_correction[];
extern VgaReg s3_enable_8_bit_luts[];
extern VgaReg s3_dclk_control[];
+extern VgaReg s3_eclk_n[];
+extern VgaReg s3_eclk_r[];
+extern VgaReg s3_eclk_m[];
extern VgaReg s3_vga_dclk_n[];
extern VgaReg s3_vga_dclk_r[];
extern VgaReg s3_vga_dclk_m1[];
diff --git a/xc/programs/Xserver/hw/kdrive/sis530/sis.c b/xc/programs/Xserver/hw/kdrive/sis530/sis.c
index c4d1a9b53..1961f8040 100644
--- a/xc/programs/Xserver/hw/kdrive/sis530/sis.c
+++ b/xc/programs/Xserver/hw/kdrive/sis530/sis.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.c,v 1.3 2000/02/23 20:30:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.c,v 1.4 2000/05/06 22:17:49 keithp Exp $ */
#include "sis.h"
@@ -253,30 +253,30 @@ sisScreenInit (KdScreenInfo *screen)
screen->height = 600;
screen->rate = 72;
}
- if (!screen->depth)
- screen->depth = 8;
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 8;
for (;;)
{
- if (screen->depth >= 24)
+ if (screen->fb[0].depth >= 24)
{
- screen->depth = 24;
- screen->bitsPerPixel = 24;
+ screen->fb[0].depth = 24;
+ screen->fb[0].bitsPerPixel = 24;
}
- else if (screen->depth >= 16)
+ else if (screen->fb[0].depth >= 16)
{
- screen->depth = 16;
- screen->bitsPerPixel = 16;
+ screen->fb[0].depth = 16;
+ screen->fb[0].bitsPerPixel = 16;
}
- else if (screen->depth >= 15)
+ else if (screen->fb[0].depth >= 15)
{
- screen->depth = 15;
- screen->bitsPerPixel = 16;
+ screen->fb[0].depth = 15;
+ screen->fb[0].bitsPerPixel = 16;
}
else
{
- screen->depth = 8;
- screen->bitsPerPixel = 8;
+ screen->fb[0].depth = 8;
+ screen->fb[0].bitsPerPixel = 8;
}
/* Normalize width to supported values */
@@ -294,10 +294,10 @@ sisScreenInit (KdScreenInfo *screen)
else
screen->width = 640;
- byte_width = screen->width * (screen->bitsPerPixel >> 3);
+ byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3);
pixel_width = screen->width;
- screen->pixelStride = pixel_width;
- screen->byteStride = byte_width;
+ screen->fb[0].pixelStride = pixel_width;
+ screen->fb[0].byteStride = byte_width;
screen_size = byte_width * screen->height;
@@ -307,10 +307,10 @@ sisScreenInit (KdScreenInfo *screen)
/*
* Fix requested depth and geometry until it works
*/
- if (screen->depth > 16)
- screen->depth = 16;
- else if (screen->depth > 8)
- screen->depth = 8;
+ if (screen->fb[0].depth > 16)
+ screen->fb[0].depth = 16;
+ else if (screen->fb[0].depth > 8)
+ screen->fb[0].depth = 8;
else if (screen->width > 1152)
{
screen->width = 1152;
@@ -346,30 +346,30 @@ sisScreenInit (KdScreenInfo *screen)
/*
* Take requested geometry and adjust to fit possible geometries
*/
- switch (screen->depth) {
+ switch (screen->fb[0].depth) {
case 4:
- screen->bitsPerPixel = 4;
+ screen->fb[0].bitsPerPixel = 4;
break;
case 8:
- screen->bitsPerPixel = 8;
+ screen->fb[0].bitsPerPixel = 8;
break;
case 15:
case 16:
- screen->bitsPerPixel = 16;
+ screen->fb[0].bitsPerPixel = 16;
break;
case 24:
case 32:
- screen->bitsPerPixel = 24;
+ screen->fb[0].bitsPerPixel = 24;
screen->dumb = TRUE;
break;
}
- screen->byteStride = screen->width * (screen->bitsPerPixel >> 3);
- screen->pixelStride = screen->width;
+ screen->fb[0].byteStride = screen->width * (screen->fb[0].bitsPerPixel >> 3);
+ screen->fb[0].pixelStride = screen->width;
memory = sisc->memory - screen_size;
- screen->frameBuffer = sisc->frameBuffer;
+ screen->fb[0].frameBuffer = sisc->frameBuffer;
/*
* Cursor lives in the last 16k of memory
@@ -389,7 +389,7 @@ sisScreenInit (KdScreenInfo *screen)
if (memory > 8192)
{
- siss->expand = screen->frameBuffer + screen_size;
+ siss->expand = screen->fb[0].frameBuffer + screen_size;
siss->expand_off = siss->expand - sisc->frameBuffer;
siss->expand_len = memory;
memory = 0;
@@ -400,35 +400,35 @@ sisScreenInit (KdScreenInfo *screen)
siss->expand_len = 0;
}
- switch (screen->depth) {
+ switch (screen->fb[0].depth) {
case 8:
- screen->visuals = ((1 << StaticGray) |
+ screen->fb[0].visuals = ((1 << StaticGray) |
(1 << GrayScale) |
(1 << StaticColor) |
(1 << PseudoColor) |
(1 << TrueColor) |
(1 << DirectColor));
- screen->blueMask = 0x00;
- screen->greenMask = 0x00;
- screen->redMask = 0x00;
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
break;
case 15:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x001f;
- screen->greenMask = 0x03e0;
- screen->redMask = 0x7c00;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x001f;
+ screen->fb[0].greenMask = 0x03e0;
+ screen->fb[0].redMask = 0x7c00;
break;
case 16:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x001f;
- screen->greenMask = 0x07e0;
- screen->redMask = 0xf800;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x001f;
+ screen->fb[0].greenMask = 0x07e0;
+ screen->fb[0].redMask = 0xf800;
break;
case 24:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x0000ff;
- screen->greenMask = 0x00ff00;
- screen->redMask = 0xff0000;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x0000ff;
+ screen->fb[0].greenMask = 0x00ff00;
+ screen->fb[0].redMask = 0xff0000;
break;
}
@@ -752,7 +752,7 @@ sisEnable (ScreenPtr pScreen)
pixel = (hactive + hblank) * (vactive + vblank) * t->rate;
- switch (screen->bitsPerPixel) {
+ switch (screen->fb[0].bitsPerPixel) {
case 8:
hactive /= 8;
hblank /= 8;
@@ -775,7 +775,7 @@ sisEnable (ScreenPtr pScreen)
crtc.color_mode_256 = 0;
- if (screen->depth == 15)
+ if (screen->fb[0].depth == 15)
crtc.graphics_mode_32k = 1;
else
crtc.graphics_mode_64k = 1;
@@ -826,7 +826,7 @@ sisEnable (ScreenPtr pScreen)
crtc.high_speed_dac_0 = crtc.high_speed_dac_1 = pixel > 135000000;
- sisEngThresh (&crtc, pixel, screen->bitsPerPixel);
+ sisEngThresh (&crtc, pixel, screen->fb[0].bitsPerPixel);
/*
* Compute horizontal register values from timings
diff --git a/xc/programs/Xserver/hw/kdrive/sis530/sis.h b/xc/programs/Xserver/hw/kdrive/sis530/sis.h
index d41da8948..2bcb94bf3 100644
--- a/xc/programs/Xserver/hw/kdrive/sis530/sis.h
+++ b/xc/programs/Xserver/hw/kdrive/sis530/sis.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.h,v 1.3 2000/02/23 20:30:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sis.h,v 1.4 2000/05/06 22:17:49 keithp Exp $ */
#ifndef _SIS_H_
#define _SIS_H_
@@ -1102,8 +1102,8 @@ void sisDrawSync (ScreenPtr pScreen);
void sisDrawDisable (ScreenPtr pScreen);
void sisDrawFini (ScreenPtr pScreen);
-void sisGetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
-void sisPutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
+void sisGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+void sisPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
void SISInitCard (KdCardAttr *attr);
diff --git a/xc/programs/Xserver/hw/kdrive/sis530/siscmap.c b/xc/programs/Xserver/hw/kdrive/sis530/siscmap.c
index 09ba8ef0a..569347110 100644
--- a/xc/programs/Xserver/hw/kdrive/sis530/siscmap.c
+++ b/xc/programs/Xserver/hw/kdrive/sis530/siscmap.c
@@ -21,12 +21,12 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/siscmap.c,v 1.2 2000/02/23 20:30:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/siscmap.c,v 1.3 2000/05/06 22:17:50 keithp Exp $ */
#include "sis.h"
void
-sisGetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
+sisGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
sisCardInfo(pScreenPriv);
@@ -44,7 +44,7 @@ sisGetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
}
void
-sisPutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
+sisPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
sisCardInfo(pScreenPriv);
diff --git a/xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c b/xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c
index 618bf2bc0..68b64af93 100644
--- a/xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c
+++ b/xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c,v 1.3 2000/02/23 20:30:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/sis530/sisdraw.c,v 1.4 2000/05/06 22:17:50 keithp Exp $ */
#include "sis.h"
#include "sisdraw.h"
@@ -1636,8 +1636,8 @@ sisDrawEnable (ScreenPtr pScreen)
CARD32 base;
CARD16 stride;
- base = pScreenPriv->screen->frameBuffer - sisc->frameBuffer;
- stride = pScreenPriv->screen->byteStride;
+ base = pScreenPriv->screen->fb[0].frameBuffer - sisc->frameBuffer;
+ stride = pScreenPriv->screen->fb[0].byteStride;
sis->u.general.dst_base = base;
sis->u.general.dst_pitch = stride;
sis->u.general.dst_height = pScreenPriv->screen->height;
diff --git a/xc/programs/Xserver/hw/kdrive/trident/trident.c b/xc/programs/Xserver/hw/kdrive/trident/trident.c
index 39ddea7f8..c93c0827a 100644
--- a/xc/programs/Xserver/hw/kdrive/trident/trident.c
+++ b/xc/programs/Xserver/hw/kdrive/trident/trident.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.4 2000/02/23 20:30:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/trident.c,v 1.5 2000/05/06 22:17:51 keithp Exp $ */
#include "trident.h"
#define extern
@@ -74,7 +74,7 @@ tridentScreenInit (KdScreenInfo *screen)
}
if (!tridentc->cop)
screen->dumb = TRUE;
- screen_size = screen->byteStride * screen->height;
+ screen_size = screen->fb[0].byteStride * screen->height;
memory = (2048 + 512) * 1024;
if (memory >= screen_size + 2048)
{
diff --git a/xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c b/xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c
index 4a4ea9289..c916a5aeb 100644
--- a/xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c
+++ b/xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.3 2000/02/23 20:30:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentcurs.c,v 1.4 2000/05/06 22:17:51 keithp Exp $ */
#include "trident.h"
#include "cursorstr.h"
@@ -88,9 +88,9 @@ tridentAllocCursorColors (ScreenPtr pScreen)
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
- KdAllocateCursorPixels (pScreen, pCursor,
+ KdAllocateCursorPixels (pScreen, 0, pCursor,
&pCurPriv->source, &pCurPriv->mask);
- switch (pScreenPriv->screen->bitsPerPixel) {
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
pCurPriv->mask |= pCurPriv->mask << 4;
diff --git a/xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c b/xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c
index a080da16a..d5017be72 100644
--- a/xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c
+++ b/xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.3 2000/02/23 20:30:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trident/tridentdraw.c,v 1.4 2000/05/06 22:17:51 keithp Exp $ */
#include "trident.h"
#include "tridentdraw.h"
@@ -812,8 +812,8 @@ tridentDrawEnable (ScreenPtr pScreen)
CARD32 alpha;
int tries;
- stride = pScreenPriv->screen->pixelStride;
- switch (pScreenPriv->screen->bitsPerPixel) {
+ stride = pScreenPriv->screen->fb[0].pixelStride;
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 8:
format = COP_DEPTH_8;
break;
diff --git a/xc/programs/Xserver/hw/kdrive/trio/s3.c b/xc/programs/Xserver/hw/kdrive/trio/s3.c
index 6ad63ed75..82e0d68b7 100644
--- a/xc/programs/Xserver/hw/kdrive/trio/s3.c
+++ b/xc/programs/Xserver/hw/kdrive/trio/s3.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.3 2000/02/23 20:30:12 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.c,v 1.4 2000/05/06 22:17:52 keithp Exp $ */
#include "s3.h"
@@ -445,31 +445,31 @@ s3ModeUsable (KdScreenInfo *screen)
int pixel_width;
int byte_width;
- if (screen->depth >= 24)
+ if (screen->fb[0].depth >= 24)
{
- screen->depth = 24;
- screen->bitsPerPixel = 32;
+ screen->fb[0].depth = 24;
+ screen->fb[0].bitsPerPixel = 32;
}
- else if (screen->depth >= 16)
+ else if (screen->fb[0].depth >= 16)
{
- screen->depth = 16;
- screen->bitsPerPixel = 16;
+ screen->fb[0].depth = 16;
+ screen->fb[0].bitsPerPixel = 16;
}
- else if (screen->depth >= 15)
+ else if (screen->fb[0].depth >= 15)
{
- screen->depth = 15;
- screen->bitsPerPixel = 16;
+ screen->fb[0].depth = 15;
+ screen->fb[0].bitsPerPixel = 16;
}
else
{
- screen->depth = 8;
- screen->bitsPerPixel = 8;
+ screen->fb[0].depth = 8;
+ screen->fb[0].bitsPerPixel = 8;
}
- byte_width = screen->width * (screen->bitsPerPixel >> 3);
+ byte_width = screen->width * (screen->fb[0].bitsPerPixel >> 3);
pixel_width = screen->width;
- screen->pixelStride = pixel_width;
- screen->byteStride = byte_width;
+ screen->fb[0].pixelStride = pixel_width;
+ screen->fb[0].byteStride = byte_width;
screen_size = byte_width * screen->height;
@@ -505,8 +505,8 @@ s3ScreenInit (KdScreenInfo *screen)
screen->height = 600;
screen->rate = 72;
}
- if (!screen->depth)
- screen->depth = 8;
+ if (!screen->fb[0].depth)
+ screen->fb[0].depth = 8;
DRAW_DEBUG ((DEBUG_S3INIT, "Requested parameters %dx%dx%d",
screen->width, screen->height, screen->rate));
@@ -524,8 +524,8 @@ s3ScreenInit (KdScreenInfo *screen)
/*
* Can only operate in pixel-doubled mode at 8 bits per pixel
*/
- if (screen->depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
- screen->depth = 8;
+ if (screen->fb[0].depth > 8 && S3_CLOCK(m,n,r) > S3_MAX_CLOCK)
+ screen->fb[0].depth = 8;
if (!KdTuneMode (screen, s3ModeUsable, s3ModeSupported))
{
@@ -538,7 +538,7 @@ s3ScreenInit (KdScreenInfo *screen)
/*
* Stick frame buffer at start of memory
*/
- screen->frameBuffer = s3c->frameBuffer;
+ screen->fb[0].frameBuffer = s3c->frameBuffer;
/*
* Stick cursor at end of memory
@@ -557,25 +557,25 @@ s3ScreenInit (KdScreenInfo *screen)
*/
if (memory >= byte_width * S3_TILE_SIZE)
{
- s3s->offscreen = s3c->frameBuffer + screen_size;
- s3s->offscreen_x = 0;
- s3s->offscreen_y = screen_size / byte_width;
- s3s->offscreen_width = pixel_width;
- s3s->offscreen_height = memory / byte_width;
- memory -= s3s->offscreen_height * byte_width;
+ s3s->fb[0].offscreen = s3c->frameBuffer + screen_size;
+ s3s->fb[0].offscreen_x = 0;
+ s3s->fb[0].offscreen_y = screen_size / byte_width;
+ s3s->fb[0].offscreen_width = pixel_width;
+ s3s->fb[0].offscreen_height = memory / byte_width;
+ memory -= s3s->fb[0].offscreen_height * byte_width;
}
else if (pixel_width - screen->width >= S3_TILE_SIZE)
{
- s3s->offscreen = s3c->frameBuffer + screen->width;
- s3s->offscreen_x = screen->width;
- s3s->offscreen_y = 0;
- s3s->offscreen_width = pixel_width - screen->width;
- s3s->offscreen_height = screen->height;
+ s3s->fb[0].offscreen = s3c->frameBuffer + screen->width;
+ s3s->fb[0].offscreen_x = screen->width;
+ s3s->fb[0].offscreen_y = 0;
+ s3s->fb[0].offscreen_width = pixel_width - screen->width;
+ s3s->fb[0].offscreen_height = screen->height;
}
else
- s3s->offscreen = 0;
+ s3s->fb[0].offscreen = 0;
- DRAW_DEBUG ((DEBUG_S3INIT, "depth %d bits %d", screen->depth, screen->bitsPerPixel));
+ DRAW_DEBUG ((DEBUG_S3INIT, "depth %d bits %d", screen->fb[0].depth, screen->fb[0].bitsPerPixel));
DRAW_DEBUG ((DEBUG_S3INIT, "Screen size %dx%d memory %d",
screen->width, screen->height, s3c->memory));
@@ -585,35 +585,35 @@ s3ScreenInit (KdScreenInfo *screen)
s3s->offscreen_width, s3s->offscreen_height,
s3s->offscreen_x, s3s->offscreen_y));
- switch (screen->depth) {
+ switch (screen->fb[0].depth) {
case 8:
- screen->visuals = ((1 << StaticGray) |
+ screen->fb[0].visuals = ((1 << StaticGray) |
(1 << GrayScale) |
(1 << StaticColor) |
(1 << PseudoColor) |
(1 << TrueColor) |
(1 << DirectColor));
- screen->blueMask = 0x00;
- screen->greenMask = 0x00;
- screen->redMask = 0x00;
+ screen->fb[0].blueMask = 0x00;
+ screen->fb[0].greenMask = 0x00;
+ screen->fb[0].redMask = 0x00;
break;
case 15:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x001f;
- screen->greenMask = 0x03e0;
- screen->redMask = 0x7c00;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x001f;
+ screen->fb[0].greenMask = 0x03e0;
+ screen->fb[0].redMask = 0x7c00;
break;
case 16:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x001f;
- screen->greenMask = 0x07e0;
- screen->redMask = 0xf800;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x001f;
+ screen->fb[0].greenMask = 0x07e0;
+ screen->fb[0].redMask = 0xf800;
break;
case 24:
- screen->visuals = (1 << TrueColor);
- screen->blueMask = 0x0000ff;
- screen->greenMask = 0x00ff00;
- screen->redMask = 0xff0000;
+ screen->fb[0].visuals = (1 << TrueColor);
+ screen->fb[0].blueMask = 0x0000ff;
+ screen->fb[0].greenMask = 0x00ff00;
+ screen->fb[0].redMask = 0xff0000;
break;
}
@@ -712,7 +712,7 @@ s3Enable (ScreenPtr pScreen)
/*
* Compute character lengths for horizontal timing values
*/
- switch (screen->bitsPerPixel) {
+ switch (screen->fb[0].bitsPerPixel) {
case 8:
hactive = screen->width / 8;
hblank /= 8;
@@ -830,7 +830,7 @@ s3Enable (ScreenPtr pScreen)
*/
if (!screen->softCursor)
{
- cursor_address = (s3s->cursor_base - screen->frameBuffer) / 1024;
+ cursor_address = (s3s->cursor_base - screen->fb[0].frameBuffer) / 1024;
crtc->cursor_address_0_7 = cursor_address;
crtc->cursor_address_8_15 = cursor_address >> 8;
@@ -855,8 +855,8 @@ s3Enable (ScreenPtr pScreen)
/*
* Set depth values
*/
- crtc->bits_per_pixel = screen->bitsPerPixel;
- crtc->depth = screen->depth;
+ crtc->bits_per_pixel = screen->fb[0].bitsPerPixel;
+ crtc->depth = screen->fb[0].depth;
crtc->l_parm_0_7 = screen->width / 4; /* Undocumented. */
diff --git a/xc/programs/Xserver/hw/kdrive/trio/s3.h b/xc/programs/Xserver/hw/kdrive/trio/s3.h
index bd34edaff..50a6d7c5a 100644
--- a/xc/programs/Xserver/hw/kdrive/trio/s3.h
+++ b/xc/programs/Xserver/hw/kdrive/trio/s3.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.h,v 1.3 2000/02/23 20:30:12 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3.h,v 1.4 2000/05/06 22:17:53 keithp Exp $ */
#ifndef _S3_H_
#define _S3_H_
@@ -1097,15 +1097,22 @@ typedef struct _s3CardInfo {
Bool need_sync;
} S3CardInfo;
-typedef struct _s3ScreenInfo {
- CARD8 *cursor_base; /* pointer to cursor area */
+typedef struct _s3FbInfo {
CARD8 *offscreen; /* pointer to offscreen area */
int offscreen_y; /* top y coordinate of offscreen area */
int offscreen_x; /* top x coordinate of offscreen area */
int offscreen_width; /* width of offscreen area */
int offscreen_height; /* height of offscreen area */
- S3Cursor cursor;
S3Patterns patterns;
+ CARD32 bitmap_offset;
+ int accel_stride;
+ int accel_bpp;
+} S3FBInfo;
+
+typedef struct _s3ScreenInfo {
+ CARD8 *cursor_base; /* pointer to cursor area */
+ S3Cursor cursor;
+ S3FBInfo fb[1];
} S3ScreenInfo;
#define LockS3(s3c)
@@ -1135,8 +1142,8 @@ void s3DrawSync (ScreenPtr pScreen);
void s3DrawDisable (ScreenPtr pScreen);
void s3DrawFini (ScreenPtr pScreen);
-void s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
-void s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs);
+void s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
+void s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
void S3InitCard (KdCardAttr *attr);
diff --git a/xc/programs/Xserver/hw/kdrive/trio/s3cmap.c b/xc/programs/Xserver/hw/kdrive/trio/s3cmap.c
index 44bc3d001..4a3391924 100644
--- a/xc/programs/Xserver/hw/kdrive/trio/s3cmap.c
+++ b/xc/programs/Xserver/hw/kdrive/trio/s3cmap.c
@@ -21,12 +21,12 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3cmap.c,v 1.2 2000/02/23 20:30:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3cmap.c,v 1.3 2000/05/06 22:17:53 keithp Exp $ */
#include "s3.h"
void
-s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
+s3GetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
@@ -47,7 +47,7 @@ s3GetColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
}
void
-s3PutColors (ScreenPtr pScreen, int ndef, xColorItem *pdefs)
+s3PutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
s3CardInfo(pScreenPriv);
diff --git a/xc/programs/Xserver/hw/kdrive/trio/s3curs.c b/xc/programs/Xserver/hw/kdrive/trio/s3curs.c
index e353b7eb3..54a1cf80c 100644
--- a/xc/programs/Xserver/hw/kdrive/trio/s3curs.c
+++ b/xc/programs/Xserver/hw/kdrive/trio/s3curs.c
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3curs.c,v 1.3 2000/02/23 20:30:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/trio/s3curs.c,v 1.4 2000/05/06 22:17:53 keithp Exp $ */
#include "s3.h"
#include "s3draw.h"
@@ -95,9 +95,9 @@ s3AllocCursorColors (ScreenPtr pScreen)
CursorPtr pCursor = pCurPriv->pCursor;
xColorItem sourceColor, maskColor;
- KdAllocateCursorPixels (pScreen, pCursor,
+ KdAllocateCursorPixels (pScreen, 0, pCursor,
&pCurPriv->source, &pCurPriv->mask);
- switch (pScreenPriv->screen->bitsPerPixel) {
+ switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
pCurPriv->mask |= pCurPriv->mask << 4;
diff --git a/xc/programs/Xserver/hw/kdrive/vga.c b/xc/programs/Xserver/hw/kdrive/vga.c
index 9f52f2ba2..75c9e46fe 100644
--- a/xc/programs/Xserver/hw/kdrive/vga.c
+++ b/xc/programs/Xserver/hw/kdrive/vga.c
@@ -21,18 +21,23 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/vga.c,v 1.3 2000/02/23 20:29:56 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vga.c,v 1.4 2000/05/24 23:57:56 keithp Exp $ */
#include "vga.h"
#include <stdio.h>
#ifdef linux
+#ifdef __i386__
#define extern static
#include <asm/io.h>
#undef extern
#define _VgaInb(r) inb(r)
#define _VgaOutb(v,r) outb(v,r)
+#else
+#define _VgaInb(r) 0
+#define _VgaOutb(v,r)
+#endif
#define _VgaByteAddr(a) ((VGAVOL8 *) (a))
#define _VgaBytePort(a) (a)
diff --git a/xc/programs/Xserver/hw/kdrive/vga.h b/xc/programs/Xserver/hw/kdrive/vga.h
index e7be1c808..eaf8670b2 100644
--- a/xc/programs/Xserver/hw/kdrive/vga.h
+++ b/xc/programs/Xserver/hw/kdrive/vga.h
@@ -21,7 +21,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/kdrive/vga.h,v 1.3 2000/02/23 20:29:56 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/kdrive/vga.h,v 1.4 2000/05/24 23:57:56 keithp Exp $ */
#ifndef _VGA_H_
#define _VGA_H_
@@ -57,7 +57,7 @@ typedef struct _vgaValue {
typedef enum _vgaAccess {
VgaAccessMem, VgaAccessIo, VgaAccessIndMem, VgaAccessIndIo,
- VgaAccessDone,
+ VgaAccessDone
} VgaAccess;
typedef struct _vgaMap {
diff --git a/xc/programs/Xserver/hw/sun/Imakefile b/xc/programs/Xserver/hw/sun/Imakefile
index effef3ee4..09fb39add 100644
--- a/xc/programs/Xserver/hw/sun/Imakefile
+++ b/xc/programs/Xserver/hw/sun/Imakefile
@@ -1,4 +1,6 @@
XCOMM $TOG: Imakefile /main/48 1997/11/13 15:48:43 msr $
+XCOMM $XFree86: xc/programs/Xserver/hw/sun/Imakefile,v 1.4 2000/06/17 18:23:23 dawes Exp $
+
#include <Server.tmpl>
SRCS1 = sunInit.c \
@@ -45,7 +47,7 @@ OBJS2 = sunGX.o
OBJS = $(OBJS1) $(OBJS2)
INCLUDES = -I. -I../.. -I../../mi -I../../mfb -I../../cfb -I../../cfb32 \
- -I../../include -I$(XINCLUDESRC) -I$(FONTINCSRC)
+ -I../../include -I$(XINCLUDESRC) -I$(FONTINCSRC) -I$(EXTINCSRC)
LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
../mfb/llib-lmfb.ln ../mi/llib-lmi.ln ../cfb/llib-lcfb.ln
@@ -60,7 +62,7 @@ NormalLintTarget($(SRCS1))
#ifndef i386Architecture
sunInExMono.o: $(ICONFIGFILES)
-ObjectFromSpecialSource(sunInExMono,../../mi/miinitext,$(EXT_DEFINES) -UPEXEXT)
+ObjectFromSpecialSource(sunInExMono,../../mi/miinitext,-I$(EXTINCSRC) $(EXT_DEFINES) -UPEXEXT -UGLXEXT)
ObjectFromSpecialSource(sunInitMono,sunInit,-DSUNMAXDEPTH=1)
ObjectFromSpecialSource(sunInitMulti,sunInit,-DSUNMAXDEPTH=32)
#endif
diff --git a/xc/programs/Xserver/hw/sun/kbd_mode.c b/xc/programs/Xserver/hw/sun/kbd_mode.c
index 2206ee779..f30c688cf 100644
--- a/xc/programs/Xserver/hw/sun/kbd_mode.c
+++ b/xc/programs/Xserver/hw/sun/kbd_mode.c
@@ -27,7 +27,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/hw/sun/kbd_mode.c,v 3.6 1998/10/04 09:38:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/kbd_mode.c,v 3.7 2000/05/17 19:52:21 dawes Exp $ */
#ifndef lint
static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
@@ -42,7 +42,7 @@ static char sccsid[] = "@(#)kbd_mode.c 7.1 87/04/13";
#include <sys/types.h>
#include <sys/file.h>
#include <sys/ioctl.h>
-#if defined(SVR4) || defined(__bsdi_)
+#if defined(SVR4) || defined(__bsdi__)
#include <fcntl.h>
#ifndef __bsdi__
#include <sys/kbio.h>
diff --git a/xc/programs/Xserver/hw/sun/sun.h b/xc/programs/Xserver/hw/sun/sun.h
index d501eae0c..f8899ec51 100644
--- a/xc/programs/Xserver/hw/sun/sun.h
+++ b/xc/programs/Xserver/hw/sun/sun.h
@@ -13,7 +13,7 @@
* express or implied warranty.
*/
-/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.7 1998/06/27 12:53:52 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.9 2000/05/17 19:52:21 dawes Exp $ */
#ifndef _SUN_H_
#define _SUN_H_
@@ -53,7 +53,7 @@ extern char *getenv();
#include <fcntl.h>
-#ifndef __bsdi_
+#ifndef __bsdi__
# ifndef CSRG_BASED
# ifndef i386
# include <poll.h>
@@ -67,6 +67,7 @@ extern char *getenv();
#include <errno.h>
#include <memory.h>
+#include <signal.h>
#ifdef X_NOT_STDC_ENV
extern int errno;
diff --git a/xc/programs/Xserver/hw/xfree86/CHANGELOG b/xc/programs/Xserver/hw/xfree86/CHANGELOG
index 0f9947ad5..6f06897ad 100644
--- a/xc/programs/Xserver/hw/xfree86/CHANGELOG
+++ b/xc/programs/Xserver/hw/xfree86/CHANGELOG
@@ -1,3 +1,784 @@
+XFree86 4.0.1 (1 July 2000)
+ 417. Update OpenBSD and NetBSD docs (#4053, Matthieu Herrb).
+ 416. Fix segfault when destroying a GLX context (Kevin Martin).
+ 415. Doc updates (Georgina Economou).
+ 414. Fix some palette and fbdev problems, and add a missing break to the
+ video memory type detection code for the r128 (#4043, Benjamin
+ Herrenschmidt).
+
+XFree86 4.0Z (30 June 2000)
+ 413. README updates (Georgina Economou).
+ 412. Add some SiS DRI code, but currently disabled because the X server
+ driver level support hasn't been integrated yet (Can-Ru Yeou, SiS).
+ 411. Remove the PPC-specific assembly for load/stores from the r128 driver,
+ and use the versions now provided in compiler.h, which are faster (#4051,
+ Ani Joshi).
+ 410. Fix the UTF-8 converters so that cut&paste works better in UTF-8 locales
+ (#4049, Bruno Haible).
+ 409. Complete the move of glx.h to xc/include/GL, and don't include
+ Xmd.h in glx.h (#4048, Brian Paul).
+ 408. Apm driver updates, including fixing 24/32 access, fixing an
+ initialization bug, and some code cleanups (#4047, Loic Grenie).
+ 407. Sparc/sbus updates: put sparcProm* in the correct header file, add
+ xf86SbusSetOsHwCursorCmap sbus layer interface, and export symbols for
+ this new interface and the sparcProm* interfaces in the loader (#4046,
+ Jakub Jelinek).
+ 406. Add cg3/cg14/tcx/bw2 drivers (sparc), and fix a few bugs in leo and
+ cg6 drivers. Build these driver, plus the ati and glint drivers
+ on Linux/sparc (#4046, Jakub Jelinek).
+ 405. Fix Elite3D detection (#4045, David S. Miller).
+ 404. Treat SBUS like ISA when assigning access control records, so now
+ multi-head, Xinerama, etc works with SBUS drivers (#4045,
+ David S. Miller).
+ 403. SDK install updates (#4044, David Bateman).
+ 402. Work around an odd problem with waitpid() in the code for auto-loading
+ DRM kernel modules on Linux (#4042, Brian Paul).
+ 401. Change the imake parameter for BSD/OS from BSD386Architecture to
+ BSDOSArchitecture (#4041, Kurt Lidl).
+ 400. Make the neomagic driver recognise the NM2380 chip, and treat it
+ exactly like a NM2360 (#4041, Kurt Lidl).
+ 399. Updates for compiling cleanly on BSD/OS 4.0.1, and to make the
+ BSD/OS support less i386-centric (#4041, Kurt Lidl).
+ 398. Disable SilkenMouse for the s3virge GX2 to avoid some lockup problems
+ (#4039, Kevin Brosius).
+ 397. Some mga DRI updates to improve stability (Jeff Hartmann).
+ 396. Fix some DRI offscreen memory calculations in the Matrox driver
+ (Mark Vojkovich).
+ 395. IA64 workarounds - should compile and run right out of the box now
+ (Mark Vojkovich).
+ 394. LBX, X-TrueType and Xnest warning fixes (Marc La France).
+ 393. Remove unused xf86MapDisplay() and xf86UnMapDisplay() os-support entry
+ points (Marc La France).
+
+XFree86 4.0g (26 June 2000)
+ 392. Fix a missing -I in sunffb/Imakefile (#4038, David S. Miller).
+ 391. Some -misc-fixed-* BDF font updates, primarily expanding the 7x13
+ set to include the same 8-bit variants as the 6x13 set, including
+ a new oblique/italic version (#4037, Markus Kuhn).
+ 390. Fix an endless loop in the UTF-8 converters (#4036, Bruno Haible).
+ 389. Straighten out xfindproxy exit codes to match success/failer status;
+ also change one instance where error message was printed to stdout
+ (#4035, Huver).
+ 388. With LBX enabled, the X server wasn't checking the proxy connection,
+ and so fails the connection request without calling InvalidHost()
+ (#4033, Huver).
+ 387. xfwp doProcessWritables() closes connection, but then proceeds
+ to reset client fd via FD_SET() (#4031, Huver).
+ 386. Don't build a non-DRI libOSMesa (#4029, Takaaki Nomura).
+ 385. Add generic DGA support to SiS driver (Alan Hourihane).
+ 384. Add more support structure for Alpha/DRI (not enabled yet though)
+ (Alan Hourihane).
+ 383. Fix glXDestroyContext bug that caused Q3A to use old clip rect info
+ when opening a new window (Kevin Martin).
+ 382. Fix R128 3D driver clear problem which caused R128Pro cards to lock
+ up, and fix dword count on ring-based vertex buffer code for PCI
+ R128 cards (Gareth Hughes).
+ 381. Possible fix for a problem introduced with item 332 that resulted
+ in the first screen's config file data being used for all screens
+ (Mark Vojkovich, David Dawes).
+ 380. Add an imake parameter NothingOutsideProjectRoot that turns off
+ installing links and config files, etc, outside of ProjectRoot
+ (David Dawes).
+ 379. Possible fix a problem with 'make install' on Linux when there is
+ already a /usr/include/GL directory (David Dawes).
+ 378. Fix a DGA-related crash when using multiple input devices with the
+ DGA extension disabled (Matthieu Herrb).
+
+XFree86 4.0f (23 June 2000)
+ 377. Suppress the use of a temporary directory to build man pages on
+ OpenBSD, which fixes problems with some external programs (#4028,
+ Matthieu Herrb).
+ 376. Allow some linux/mips settings in linux.cf to be overriden (#4026,
+ Guido Guenther).
+ 375. Synchronize the pointer state before checking it in xf86CheckButton()
+ (Paulo Cesar Pereira de Andrade).
+ 374. s3virge driver fixes for noise and console corruptionn on the GX2 and
+ MX (but they're commented out for the MX because it hasn't been tested
+ yet) (#4027, Kevin Brosius).
+ 373. Fixes for lib/GL Imakefiles (Marc La France).
+ 372. Update DRI drivers sunffb,mga,i810,glint,r128,tdfx to check for
+ DRIQueryVersion, overcomes an older libdri issue (Alan Hourihane).
+ 371. Change tdfx driver to use fb instead of cfb (Alan Hourihane).
+ 370. Make using libpthread optional for OpenBSD 2.7.
+ 369. Fix a problem when calling XF86VidModeSwitchMode() when the switched
+ screen is different from the one that has the pointer (#4024,
+ Paulo Cesar Pereira de Andrade).
+ 368. Bindist files for Linux/mips (#4023, Guido Guenther).
+ 367. Allow XFree86 to compile on NetBSD-current and 1.5_ALPHA, which
+ no longer use the pcvt console, but have a compatibility mode for it
+ in wscons (#4021, Bernd Ernesti).
+ 366. Add support for the iso8859-13 charset to Xlib (#4020, Bruno Haible).
+ 365. Add ISO-8859-13 support to the UTF-8 converters, which is needed for
+ Lithuanian UTF-8 locales (#4019, Bruno Haible).
+ 364. Fix three bugs in the UTF-8 converters:
+ - In an UTF-8 locale, keyboard input coming in as UTF-8 would not be
+ accepted.
+ - Incorrect handling of the "end of string" and "invalid byte sequence"
+ situations.
+ - A bug on platforms with sizeof(wchar_t) != sizeof(int).
+ (#4018, Bruno Haible).
+ 363. Enable building DRI support for FreeBSD 4.1 and higher.
+ 362. Don't try to use kldload() on FreeBSD versions prior to 3.0 (#4016,
+ Takaaki Nomura).
+ 361. Some sunffb cleanups (#4015, David S. Miller).
+ 360. Add DRI drawable index callback (#4015, David S. Miller).
+ 359. Fix -configure option to print out fatal message and abort gracefully
+ when pci data isn't entered into xf86PciInfo.h (Alan Hourihane).
+ 358. Add generic DGA support to NeoMagic (not tested) (Alan Hourihane).
+ 357. Add generic DGA support to i810 (not tested) (Alan Hourihane).
+ 356. Fix GCC 2.96 complaints in big font extension and imstt driver
+ (Steven King).
+ 355. Fix remaining DRI III compile glitches (Marc La France).
+ 354. Fix long standing bug with 3Dfx driver when DRI module isn't loaded.
+ It complained about unresolved symbol called after 'Textures memory'
+ output (Alan Hourihane).
+
+XFree86 4.0e (20 June 2000)
+ 353. Fix a couple of acceleration problems in glint driver (Alan Hourihane).
+ 352. Don't attempt to build the Sparc DRI drivers on ix86, and vice versa
+ (David Dawes).
+ 351. Fix a lib/GL build problem when the DRI isn't enabled (#4014,
+ Nicholas J Brealey).
+ 350. Fix location of dri module links in the xc/exports directory of the
+ build tree.
+ 349. Replace LoaderSymbol() with xf86LoaderCheckSymbol() in drivers.
+ 348. Disable SmartScheduler on LynxOS 3.1 (#4013, Thomas Mueller).
+ 347. Update Japanese PC98 docs (#4012, Isao Ohishi, Takaaki Nomura).
+ 346. Add some S3/Diamond PCI IDs (#4011, Werner Leeb).
+ 345. Update sbus support for recent bus infrastructure changes
+ (David S. Miller)
+ 344. Check for NULL pointers from item 332 (Alan Hourihane).
+ 343. Xf86cfg updates (#4010, Paulo Cesar Pereira de Andrade).
+ 342. Fix threads support in OpenBSD 2.7 and above (#4006, 4009,
+ Carlos A M dos Santos).
+ 341. UCS misc BDF fonts updates, including new oblique/italic versions
+ (6x13O, 8x13O), Korean font covering all Hangul symbols (18x18ko)
+ and many additional autogenerated ISO 8859 fonts to cover with
+ 6x13 and 8x13 all the locale encodings suggested by the Li18nux
+ specification (#4007, Markus Kuhn).
+ 340. Add Linux/Sparc support for the DRI, and a DRI driver for Sun
+ Creator3D hardware (#4004).
+ 339. Fix DRI BusIDString length usage (#4003, David S. Miller).
+ 338. Xterm patch #139 (#4002, Thomas Dickey).
+ 337. Make the use of GlxDefines for libGL independent of BuildXF86DRI (#4001,
+ David S. Miller).
+ 336. Fix i810 build warnings (#4000, Jarno Paananen).
+ 335. Fix an i810 build problem (Keith Whitwell, #4000, Jarno Paananen).
+ 334. Fix a multihead problem with the mga driver (Mark Vojkovich).
+ 333. Add support to the i810 driver for the i815 (Keith Whitwell).
+ 332. Add infrastructure support for cards with multiple CRTCs (screens)
+ per accelerator (PCI entity) (Jeff Hartmann and David Dawes).
+ 331. Fix some Mesa problems (Brian Paul).
+ 330. Rework patch for mapping drmAddMap on Alpha platforms
+ (Bruce Stockwell/Compaq, Alan Hourihane).
+ 329. Don't build Debuggable Library on Linux for the release (Alan Hourihane).
+ 328. Don't build lib/GL/mesa/src/X86 on Alpha systems (Alan Hourihane).
+ 327. xdm warning fix (Marc La France).
+ 326. Make x11perf die gracefully when display cannot be opened
+ (Marc La France).
+ 325. Fix rendition driver compile glitch (Marc La France).
+ 324. #ifdef out glitch in glint driver (Marc La France).
+ 323. Preliminary DGA support in ATI driver (Marc La France).
+ 322. Minor update to DESIGN and Status documents (Marc La France).
+ 321. Fix DGA's reporting of vertical refresh rates to clients
+ (Marc La France).
+ 320. Make driver-provided Sync(), SetViewport() and GetViewport() DGA
+ callbacks optional (Marc La France).
+ 319. Fix XKB compile glitch (Marc La France).
+ 318. Make imstt driver compile (Marc La France).
+
+XFree86 4.0d (16 June 2000)
+ 317. Fix a typo in the xfree86 xkb keycodes file (#3999, Matthieu Herrb).
+ 316. Fix some build problems when the DRI is not enabled (#3998,
+ Matthieu Herrb).
+ 315. Add missing Linux/mips config changes (#3997, Guido Guenther).
+ 314. Fix for libICE DOS (Keith Packard).
+ 313. FontInfo.c (lib/X11) needs to be built with the bigfont defines (#3996,
+ Paulo Cesar Pereira de Andrade).
+ 312. Disable the smart scheduler for SVR4.0 (based on #3916, Takaaki Nomura).
+ 311. Add a check for PS/2 mice on Linux for the X server's -configure
+ option (#3991, Paulo Cesar Pereira de Andrade).
+ 310. Fix a problem mouse driver button flush was causing with Xaw menus
+ (#3991, Paulo Cesar Pereira de Andrade, David Dawes).
+ 309. Modify scanpci to print out card/subsys information, and add a few
+ more entries to the pci data (David Dawes).
+ 308. Fix r128_cursor.c build problem for big-endian machines (#3989,
+ Thomas Mueller, #3994, Ani Joshi).
+ 307. Update LynxOS docs (#3989, Thomas Mueller).
+ 306. Add a few PPC compiler internal symbols to the loader's export list
+ (#3989, Thomas Mueller).
+ 305. Add crypt support to xdm for LynxOS (#3989, Thomas Mueller).
+ 304. Add preliminary build support for LynxOS 3.1.0 (#3989, Thomas Mueller).
+ 303. Add keysyms to complete the set for the Compaq SK2850 keyboard and
+ the Microsoft Natural Keyboard Pro (David Dawes).
+ 302. Add new keysyms for PDAs (#3985, 3987, 3988, Jim Gettys).
+ 301. Xterm patch #138 (#3986, Thomas Dickey).
+ 300. DRI megapatch III. This includes DRI enhancements, 3dfx fixes and
+ updates, updates Mesa to the latest version, adds Intel i810, Matrox
+ G200/G400, ATI Rage 128 and 3dfx Voodoo5 3D support, adds ATI Rage
+ Mobility 2D support (disabled by default). (Precision Insight and
+ VA Linux Systems).
+ 299. Add a function to the X server that performs the same checks on
+ command line arguments and environment variables as the Xwrapper
+ from 3.3.x. This function is called very early from main()
+ (David Dawes).
+ 298. Fix for some Xlib problems that can show up when connecting to
+ a rogue server (Keith Packard, with analysis by Chris Evans).
+ 297. Increase MAXVISUALSPERDEPTH to 64 for Xnest so that it can handle
+ GLX's visuals.
+ 296. Add a Macedonian xkb symbols file (#A.96, Zlatko Trajceski).
+ 295. Fix a buffer overflow with the -xkbmap X server flag (#A.91,
+ Trevor Johnson).
+ 294. Fix a rectangle fill problem that shows up with an AGP SiS 6326
+ (A.81, A.83, Milivoj Savin).
+ 293. Fix a problem in xcalc when the current locale uses a character
+ other than "." for the decimal point (#A.63, Stanislav Brabec).
+ 292. Allow some more parameters in linux.cf and lnxLib.rules to be
+ redefined (#A.60, Stanislav Brabec).
+ 291. Fix a typo in lib/Xss/Imakefile (#A.59, Stanislav Brabec).
+ 290. Fix an xfs crash that shows up when many clients connect (#A.48,
+ Remy Card).
+ 289. Fix some man page build problems (#A.43, Ian Collier).
+ 288. Fix xedit core dump (in Xaw) on Solaris, related to the bsearch()
+ usage (#A.42, Ian Collier).
+ 287. Add xkb mappings for the keycodes generated by the SysRq and Break
+ keys, which are different from the keycodes generated when used as
+ PrtScn and Pause (#A.29, Eric W. Biederman).
+ 286. Fix problems when building on Solaris 2.6/sparc and Irix 6.5.5
+ (#A.21, A.28, Sullivan N. Beck).
+ 285. Fix a core dump in fstobdf when using 16 bit fonts (#A.25,
+ Morten Storgaard Nielsen).
+ 284. Clean up some of the messages printed by the neomagic driver
+ (David Dawes).
+ 283. Add support for the 2360 (256ZX) to the neomagic driver, and enable
+ acceleration at depth 24 for this chip (#A.23, Gregory M Pomerantz).
+ 282. Adjust the bigfont extension to not use SHM segments for fonts with
+ a small glyph metric size, and fix a build problem on systems without
+ shared memory (#3984, Bruno Haible).
+ 281. Status doc updates (#A.9, Chris Smith, A.80, Ferenc Acs).
+ 280. Fix memleak warning when doing realloc(NULL, size) (#A.7,
+ Charles G Waldman).
+ 279. xf86cfg fixes (#3983, Paulo Cesar Pereira de Andrade).
+ 278. Add SilkenMouse support to the s3virge driver (#3982, Kevin Brosius).
+ 277. Update Xv support in the glint driver and add the XvPutImage function
+ for the Permedia 2 (#3926, Michael Schimek).
+
+XFree86 4.0c (13 June 2000)
+ 276. Xterm patch #137 (#3976, Thomas Dickey).
+ 275. Doc update for the chips driver (#3981, David Bateman).
+ 274. Fix some problems building with the SDK (#3981, David Bateman).
+ 273. Fix comments for the address matching algorithm in
+ XauGetAuthByAddr() and XauGetBestAuthByAddr() (Keith Packard, based on
+ #3939, Peter Runestig).
+ 272. Handle setting SharedLibXdmGreet in the OS imake config files rather
+ than having a complicated expression in the xdm Imakefile (#3980,
+ Matthieu Herrb).
+ 271. xdm updates from the OpenBSD team, including:
+ - support for Kerberos IV authentication [enabled only in OpenBSD.cf,
+ but could be enabled for other systems by setting HasdKrbIV]
+ - use the arc4random(4) random number generator on OpenBSD
+ - add a new resource "allowRootLogin", which can be used to disable
+ root logins through xdm
+ - log failed logins to syslogd [OpenBSD only, but could be enabled on
+ other systems]
+ - verify that the shell is valid using /etc/shells [OpenBSD only]
+ - verify that the account hasn't expired [OpenBSD only, but could be
+ enabled on other system that use the same passwd aging structure]
+ (#3948, 3980, OpenBSD team, Matthieu Herrb).
+ 270. Big/little endian MMIO_XX macros for ppc, and also PIO macros check
+ that IOBase is mmapped before doing any accesses (#3979,
+ Kostas Gewrgiou).
+ 269. Preliminary driver for Integrated Micro Solutions TwinTurbo128
+ (imstt) (#3978, Ani Joshi).
+ 268. Fix broken czsk keymaps, and let the user directly select either
+ Czech or Slovak keyboard in xf86config (#3975, Kamil Toman).
+ 267. Implement DGA2 support with depth switching for ATI Rage 128 cards
+ (#3974, Ove Kaaven).
+ 266. Recent versions of FreeBSD have the xpg4 library folded into libc.
+ 265. xf86cfg updates (#3973, Paulo Cesar Pereira de Andrade).
+ 264. Xaw bug fixes (#3973, Paulo Cesar Pereira de Andrade).
+ 263. Fix M-d and M-h key bindings in the Xaw Text widget (#A.87,
+ Jonathan Kamens).
+ 262. Fix some Xaw memory errors (#A.79, Jonathan Kamens).
+ 261. Xman fixes/updates, including:
+ - Fix a core dump in fclose()
+ - Append the default search path when MANPATH ends in a ':'
+ - Understand man pages that have a single line with a .so directive
+ (#3969, 3973, Paulo Cesar Pereira de Andrade).
+ 260. Resync nls Compose file with 3.3.6 (#3964, 3973,
+ Paulo Cesar Pereira de Andrade).
+ 259. Fix moving the pointer between screens when using MouseKeys, and fix
+ some bugs in the xkbfile code (#3963, 3973,
+ Paulo Cesar Pereira de Andrade).
+ 258. Fix XC-SECURITY security bug (#3954, 3973,
+ Paulo Cesar Pereira de Andrade).
+ 257. Bigfont bug fix, which stops cvsup crashing (#3954, 3973,
+ Paulo Cesar Pereira de Andrade).
+ 256. Replace some bitswapping assembler code in XAA with faster C code
+ (Mark Vojkovich).
+ 255. Rendition driver updates, including:
+ - add DirectColor support
+ - add SilkenMouse support
+ - documentation updates
+ - some code cleanups
+ (#3972, Dejan Ilic).
+ 254. For v4l: don't advertise the XV_VOLUME attr if we're only going to
+ return BadMatch on use (#3968, David Woodhouse).
+ 253. Modify the I2C delay routine to use xf86getsecs (gettimeofday) instead
+ of an uncalibrated loop (#3967, Andrew Aitchison).
+ 252. Add some PCI ids to xf86PciInfo.h, and include some instructions
+ about how to add new PCI data (#3966, Kevin Brosius).
+ 251. Update documentation for Japanese PC98 (#3965, Satoshi Kimura,
+ Akio Morita, Takaaki Nomura).
+ 250. XIM patch (imInt.c) (#3962, Fuminori Hirayama).
+ 249. Xterm patch #136 (#3960, Thomas Dickey).
+ 248. Fix Imake.rules for building on Solaris 7 with gcc-2.95.2 (#3958,
+ Nicholas Brealey).
+ 247. Add basic support for the Linux/mips and mipsel architecture (#3957,
+ 3970, Guido Guenther).
+ 246. Disable reading the BIOS in the int10 code for Japanese PC98 (#3959,
+ Isao Ohishi).
+ 245. Add a "NoPciBurst" option to the Trident drive for Japanese PC98
+ cards with the TGUi968x chip (#3955, Akio Morita).
+ 244. Xterm patch #135 (#3951, Thomas Dickey).
+ 243. Fbdev driver fix (#3953, Ani Joshi).
+ 242. Xterm patch #134 (#3949, Thomas Dickey).
+ 241. Import the mktemp() usage fixes for imake from the 3.3.x branch
+ (#3947, Matthieu Herrb).
+ 240. Rman updates, including:
+ - minor reformating (make { and } match)
+ - fix logic for parsing comments in man pages, which allows the
+ copyrights to appear in the output html
+ - a few changes based on weblint and tidy
+ (#3946, Thomas Dickey).
+ 239. Fix incorrect type for vgaIOBase in the neomagic driver (#3944,
+ Ani Joshi).
+ 238. Fix an Xlib build problem when the big-font extension is disabled
+ (#3945, Mutsumi Ishikawa).
+ 237. Xv v4l attribute handling bug fix (#3928, Gerd Knorr).
+ 236. Fix some problems with the locale-dependent input processing in Xlib
+ by:
+ - removing unneeded to/from CTEXT conversion for characters coming
+ from keyboard input
+ - move "locale_code" and "keyboard charset" searching to the
+ initialization step (XIM creation)
+ - Fix some inconsistencies between memory allocation and freeing
+ in XIM objects (imLcIm.c imThaiIm.c)
+ (#3927, Ivan Pascal).
+ 235. Update support for Appian J2000 board with dual PM3 chips, and
+ add partial acceleration (#3977, Sven Luther).
+ 234. Only claim other devices on the same card when gamma chip is used
+ in the glint driver (Alan Hourihane).
+ 233. Separate offscreen memory manager API from implementation to facilitate
+ driver replacement of the default manager (Mark Vojkovich).
+ 232. Add Option "TexturedVideo" to have the Matrox driver optionally use
+ YUV textures instead of the video overlay for XvImage support
+ (Mark Vojkovich).
+ 232. Add Xv functions for allocating/freeing XvVideoAdaptorRecs to shield
+ drivers from structure size changes (Mark Vojkovich).
+ 231. Have XDGAQueryModes return no modes as being available instead of an
+ error when DGA is not supported on the particular screen (Mark Vojkovich).
+ 230. Fix xdm when PAM is not available (Marc La France).
+ 229. Fix int10 bug on non-PC platforms (Marc La France).
+ 228. Finish prototyping of DPS libraries. Fix argument promotions in
+ pswrap. Fix yytext portability problem. Fix non-standard format
+ in pswrap (#3941, #3942, Nomura Takaaki, Thomas Dickey).
+ 227. Fixed FP chipset handling in Trident driver. LCD-CRT switching
+ should work now (Egbert Eich).
+ 226. Modified device detection on PCI bus to handle Host-to-PCI bridges
+ better (Egbert Eich).
+ 225. Fix i810 driver so it advertises 32bpp pixmaps in depth 24 like the
+ rest of the drivers do (Mark Vojkovich).
+ 224. Added a call ioperm() to to allow vm86 to execute in/out calls
+ directly to avoid problems with certain notebook bioses (Egbert Eich).
+ 223. Fixed mouse driver to flush pending button press events on
+ protocol change (Egbert Eich).
+ 222. Fixed DDC support and sync flags handling in trident driver
+ (Egbert Eich).
+ 221. Added PAM support to xdm, ANSIfied prototypes (Werner Fink).
+ 220. Added ServerFlag to force the use of OS PCI config space
+ support (Egbert Eich).
+ 219. Fix Xv DDX stop overlaid stills/images when XvStopVideo() is called
+ (Mark Vojkovich).
+ 218. Have the Xv DDX send clients exposure events when windows containing
+ overlaid data, which isn't actually in the framebuffer, are moved
+ (Mark Vojkovich).
+ 217. Fix ordering of calling DDC probe in VBE to respect NoDDC options
+ (Alan Hourihane).
+ 216. Fix VBE initialization in trident driver for DDC (Alan Hourihane).
+ 215. Fix a typo in the glint driver (#3943, Michael Schimek).
+ 214. Fix multithread bug in Xlib big font support (Mark Vojkovich).
+ 213. Fix a window class initialization problem in Xinerama (Mark Vojkovich).
+ 212. Fix some multithreading related problems in the Xv client library
+ (Mark Vojkovich).
+
+XFree86 4.0b (23 May 2000)
+ 211. Add support to the sunffb driver for multiple visuals on the same screen,
+ overlays, double buffering and some other niceties (#3938,
+ David S. Miller, Jakub Jelinek).
+ 210. Make the modifier setting on Sun keyboards match what XFree86 expects
+ (#3937, Jakub Jelinek).
+ 209. Add unaccelerated support for the Sun CG6 (#3935, Jakub Jelinek).
+ 208. Make the -configure option work with SBUS/UPA drivers, fix some
+ bugs in the sbus layer, add support for ioctl based colormap setting,
+ and fix leds on Sun keyboards (#3934, Jakub Jelinek).
+ 207. Fix a parallel build problem in lib/dps (#3932, H. J. Lu).
+ 206. Fix some build problems that show up with LynxOS x86 and PowerPC (#3929,
+ Thomas Mueller).
+ 205. Fix documentation files for the mutouch and elographics drivers,
+ and build these drivers by default (#3935, Patrick Lecoanet).
+ 204. Make the dga2 library use the device name provide by the driver rather
+ than always using the default (3924, David S. Miller).
+ 203. Fix a problem with the internal xalloc that shows up on Sparc (#3923,
+ David S. Miller).
+ 202. Fix a GLX visual problem that causes a crash at server shutdown
+ (#3922, David S. Miller).
+ 201. 8+32 framebuffer for hardware that uses window IDs (David S. Miller).
+ 200. Fix a memory allocation in lbxproxy that can cause it to crash at
+ startup (#3921, Peter Runestig, #A.46, Rob Clark).
+ 199. Fix a problem with imake's handling of DefaultGccIncludeDir (#3920,
+ Peter Runestig, #A.64, Stanislav Brabec).
+ 198. lib/X11/imInt.c fix from the OpenMotif release notes (#3919).
+ 197. Prototype and fix almost all compiler warnings fot he dps library
+ and the related pswrap program (#3912, Thomas Dickey).
+ 196. Fix for x-tt font cache corruption (#3911, H. J. Lu).
+ 195. Ansi prototypes for the lbxusilt library and Xserver/lbx directory
+ (#3908, Matthieu Herrb).
+ 194. Fix some bugs in the cirrus lg driver (#3900, Itai Nahshon).
+ 193. Accelerated driver for Sun Leo/ZX cards (#3899, 3936, Jakub Jelinek).
+ 192. Fully accelerated driver for Sun FFB and AFB chips (#3898,
+ Jakub Jelinek).
+ 191. Generic SBUS and UPA support for XFree86 (#3897, Jakub Jelinek).
+ 190. Fix building xf86cfg on systems where libxpm isn't linked in
+ implicitly (#3903, Matthieu Herrb).
+ 189. Update the fbdevhw stubs for an interface change (#3902, Matthieu Herrb,
+ #3910, Bernd Ernesti).
+ 188. Simplify the platform defines in servermd.h to make them more hardware
+ dependent than OS dependent (#3913, Kurt Lidl).
+ 187. Fix a bug in the search/replace dialog in the Xaw text widget (#3896,
+ Paulo Cesar Pereira de Andrade).
+ 186. Xterm patch #133 (#3894, Thomas Dickey).
+ 185. Fixes for the Xaw TipWidget (#3893, Paulo Cesar Pereira de Andrade).
+ 184. Change CTEXT from/to converters to allow processing of "C1" codes
+ (0x80-0x9f) as ordinary characters for "non-standard" encodings
+ (such as UTF-8) (#3891, Ivan Pascal).
+ 183. Add "software" per-key auto-repeat disabling (#3889, Ivan Pascal).
+ 182. Refix fog.c build problem on Alpha (#3888, Dave Gilbert).
+ 181. Add some new things for the VidMode interface in xf86cfg (#3877,
+ Paulo Cesar Pereira de Andrade).
+ 180. Rework most of the look and feel of xf86cfg, and fix some bugs (#3877,
+ 3886, 3892, Paulo Cesar Pereira de Andrade).
+ 179. Add a ProjectRoot to Xaw rather than hard-coding it, so that the
+ pixmap code can find pixmaps and bitmaps on non-standard installations
+ (#3877, Paulo Cesar Pereira de Andrade).
+ 178. Fix a bug in the DRI section parsing (David Dawes).
+ 177. Add support for building shared libraries on BSD/OS (#3876, Kurt Lidl).
+ 176. Add imake support for automatically determining the version for BSD/OS,
+ and update bsdi.cf for the features relevant to the different versions
+ (#3876, 3940, Kurt Lidl).
+ 175. Xterm patch #132 (#3874, Thomas Dickey).
+ 174. Fix rman-related build problems when building external applications
+ (#3869, Matthieu Herrb, #3890, H. J. Lu).
+ 173. Fix a typo in OpenBSD.cf (#3867, Matthieu Herrb).
+ 172. Fix some build warnings (#3864, Ani Joshi).
+ 171. Fix some BSDI typos in hw/sun (#3862, Kurt Lidl).
+ 170. Fix r128 palette save/restore when VT switching (#3861, Ani Joshi).
+ 169. Disable the X server's internal malloc by default (#3860, Keith Packard).
+ 168. Make xdpyinfo and xf86dga fail gracefully when DGA is not enabled
+ in the driver, but the extension is enabled (#3870, Andrew Aitchison).
+ 167. Fix too many xfree calls in lbxproxy (#3907, Matthieu Herrb).
+ 166. Fix uninitialized fd_set mask in lbxproxy (#3906, Matthieu Herrb).
+ 165. Fix typo when printing HSync frequency when not a range
+ (#3895, Andrew Aitchison).
+ 164. Fix a window unmapping bug in the mioverlay code (Mark Vojkovich).
+ 163. Attempt to improve memory detection reliability in the Matrox driver
+ (Mark Vojkovich).
+ 162. Fix possible SEGV in generic int10 module (Marc La France).
+ 161. Fix *BSD aperture driver to allow for int10 (Bernd Ernesti,
+ Marc La France).
+ 160. Fix vesafb restore problem in ATI driver (Marc La France).
+ 159. Fix a few more compilation glitches (Marc La France).
+ 158. Fix DRM for gamma for single and dual MX chips (Alan Hourihane).
+ 157. Fix Mesa for single and dual MX chips (Alan Hourihane).
+ 156. Fix Mesa for multiple screen widths (Alan Hourihane).
+ 155. Add DGA support to the glint driver.
+ - Fix initialization of DRI when using single or dual MX's.
+ - Fix register resources.
+ - Turn on more acceleration for DualMX boards.
+ - Fix DualMX boards displaywidth problems at >640 widths.
+ - Fix depth15/16 for PM2v and PM3 chipsets (Alan Hourihane).
+ 154. Use MMIO_xx macros in glint driver (#3904, Michel Danzer).
+ 153. Fix lib/GL/mesa/src/X86/Imakefile for m4 (Alan Hourihane).
+ 152. Fix m4 rules in Imake.tmpl (Alan Hourihane).
+ 151. ATI documentation update (Marc La France).
+ 150. Disable debugging messages from XF86-Misc extension (Marc La France).
+ 149. Ensure XAA always respects user options that disable subsets of its
+ primitives (Marc La France).
+ 148. Bug fix in XAA's CPU-to-screen colour expansion (Marc La France).
+ 147. Finish off XAA's CPU-to-screen colour expansion for 24bpp
+ (Marc La France).
+ 146. When matching adapters to XF86Config sections, the ATI driver will now
+ look at the primary adapter before any other non-primary PCI adapters
+ (Marc La France).
+ 145. Ensure Mach64 acceleration is disabled when using the VGA CRTC
+ (Marc La France).
+ 144. Set a Mach64's scaler/overlay clock divider in preparation for a GATOS
+ merge (Marc La France).
+ 143. Make VBE use its own option instead of DDC's (a consequence of
+ re-entrancy) (Marc La France).
+ 142. Make option processing re-entrant in DDC, int10, VBE and XAA modules, and
+ in the common layer (Marc La France).
+ 141. Add Permedia3 support to the glint driver (Sven Luther).
+ 140. Fix XvPutImage in the client libs so that it can use the BIG-REQUESTS
+ extension (Mark Vojkovich).
+ 139. Fixed xf4bpp for devPrivates in PixmapRec. (Egbert Eich).
+ 138. Fixed laguna driver to map FB after the video RAM size is known
+ (Egbert Eich).
+ 137. Fixed xdm to give up to respawn Xservers if the server crashes
+ more than once within 60 seconds (Egbert Eich).
+ 136. Added VGA default clock option to generic driver (Egbert Eich).
+ 135. Fixed CyberShadow option in Trident driver (Egbert Eich).
+ 134. Fix bug where the cursor is not put back after a failed DGA mode
+ initialization attempt (Mark Vojkovich).
+ 133. Add a missing symbol "AllocateColormapPrivateIndex" (Mark Vojkovich).
+ 132. Remove Intel 440BX-specific resources from os-support layer
+ (Marc La France).
+ 131. Change ATI driver to mark VGA resources as unused in operating state when
+ appropriate (Marc La France).
+ 130. Fix bug in the generation of default screen layout (Marc La France).
+ 129. Include all resource attributes when printing them (Marc La France).
+ 128. Fix compiled-in input driver list (Marc La France).
+ 127. Allow driver access to resource manipulation functions (Marc La France).
+ 126. Fix a DGA 2.0 crash that happened when bogus mode numbers were sent
+ by the client (Lionel Ulmer).
+ 125. Make a recent shm pixmap fix Xinerama aware (Mark Vojkovich).
+ 124. Fix mode setting bug in ATI driver (Marc La France).
+ 123. Add int10, DDC & VBE support to ATI driver
+ (Andrew C Aitchison, Marc La France).
+ 122. Allow driver to supply DDC module to VBE (Marc La France).
+ 121. Attempt to fix cyrix driver (untested). (Egbert Eich)
+ 120. Added support for 'inactive' devices. (Egbert Eich)
+ 119. Fixed xf86misc extensions. (Egbert Eich)
+ 118. Fixed design of xf86SetAccessFuncs(). Now all old access funcs
+ are returned if the driver asks for them not only the one
+ that is used in OPERATING state. (Egbert Eich)
+ 117. Added a function LoadDrvSubModule() to allow drivers to load
+ sub modules before a screen is allocated. (Egbert Eich)
+ 116. Fixed lndir to handle trailing '/' on path correctly. (Egbert Eich)
+ 115. Undefined i486/i586/i686 in Imake.cf. cpp might predefine
+ them which might cause undesirable results. (Egbert Eich)
+ 114. Updated x86emu. (Egbert Eich)
+ 113. Fixed problems with xf86RegisterResources() if preregistered
+ resources are not marked ResBios. Identical ranges are not considered
+ to conflict with each other. (Egbert Eich)
+ 112. Improved DDC information printout. (Egbert Eich)
+ 111. Added NODDC options to vbe. (Egbert Eich)
+ 110. Added fixes for Lynx OS. (Egbert Eich)
+ Changed int10 code to always map/allocate entire 1Meg. (Egbert Eich)
+ 109. Let int10 code try harder to locate a video bios to work
+ around some system bios bugs. (Holger Veit, Egbert Eich)
+ 108. Modified fbdevProbe() to return the name string representing
+ the chipset. (Egbert Eich)
+ 107. Minor fixes to i810 driver (Egbert Eich)
+ 106. Fixed format of float numbers in C&T driver. (Jens Taprogge)
+ 105. Added support for the NeoMagic 2360. (Gregory Pomerantz)
+ 104. Add an xf86UnloadSubModule() entry (temporarily disabled)
+ (Marc La France).
+ 103. Fix missing symbol "ServerGrabCallback" (Mark Vojkovich).
+ 102. Fix XAA problems with CPU-to-screen colour expansion (Marc La France).
+ 101. For panel support in the ATI driver, add an entry to the monitor
+ section's mode list for the panel's native resolution (Marc La France).
+ 100. Fix depth24 acceleration problems with 300SX (Alan Hourihane).
+ 99. Update glint driver for fb24_32 and ensure memset used in fb is
+ xf86memset when using loader (Alan Hourihane).
+ 98. By default, limit ATI 3DRage LTPro's to 200 MHz, instead of 230 MHz
+ (Marc La France).
+ 97. Remove some leftover INTERNAL_VS_EXTERNAL_PADDING stuff from the
+ extensions (Mark Vojkovich).
+ 96. Fix a NonTE text bug in XAA where zero-height primitives could be passed
+ to the driver (Mark Vojkovich).
+ 95. Add CPU-to-screen colour expansion acceleration for Mach64's
+ (Kevin Martin, Marc La France).
+
+XFree86 4.0a (6 April 2000)
+ 94. Major OS/2 resync (#3859, Holger Veit).
+ 93. Fix some 'XFree86 -configure' problems when multiple cards (#3850,
+ Paulo Cesar Pereira de Andrade).
+ 92. New graphical config tool (xf86cfg) (#3850,
+ Paulo Cesar Pereira de Andrade).
+ 91. Fix a typo in Xinstall.sh that prevents moving config files to
+ /etc/X11 from being optional (#3858, Richard Gooch).
+ 90. Add lt_LT.ISO_8859-4 to locale.alias, and update the lt symbols for
+ xkb (#3857, Ricardas Cepas).
+ 89. Fix the return values of some "xkb action" filters (SetControls and
+ RedirectKey) (#3854, Ivan Pascal).
+ 88. Fix problems with using "radio group" number one in XKB keyboard
+ descriptions (#3853, Ivan Pascal).
+ 87. Fix MIT-SHM crash caused by incorrect reference tracking (#3851,
+ Keith Packard).
+ 86. Updates to allow a build on sparc-linux to succeed (#3849,
+ Jakub Jelinek).
+ 85. Fix GetImage in XY format in fb at 32bpp (#3848, Keith Packard).
+ 84. Add support for 24/32 fb/pixmap format conversion to fb (#3847,
+ Keith Packard).
+ 83. Update the r128 driver to use fb and fb24_32, and disable
+ transparency at 24bpp (#3846, Keith Packard).
+ 82. Let the server continue when a font path element in the default path
+ is found to be invalid (#3843, Keith Packard).
+ 81. Fix parsing of the Group keyword in the DRI section of the config file
+ (#3842, Stefan Dirsch, David Dawes).
+ 80. Add support for YUV422, YV12, RGB15 and RGB16 XvImages to the C&T driver
+ (#3840, David Bateman).
+ 79. Change the config file Xkb* option priority. Now, if XkbKeymap is
+ set it will be tried first. If a component is present it will override
+ components computed from ruls/module/layout/etc (#3839, Ivan Pascal).
+ 78. Fix an infinite loop problem that can show up in makedepend (#3838, A.10,
+ Jeremy Buhler).
+ 77. Fix Overlay support in the TI ramdac module (Alan Hourihane).
+ 76. Fix mixup between TVP3026/3030 ramdacs in the ramdac module
+ (Alan Hourihane).
+ 75. Increase usage of ReadPixmap within XAA (Mark Vojkovich).
+ 74. Allow the v4l driver to use offscreen YUV surfaces exported by the
+ chipset drivers (Gerd Knorr).
+ 73. Change xf86LoadModules() so that it doesn't quit at the first module
+ that fails to load (David Dawes).
+ 72. SIGIO doesn't work on Linux pipes, so diasble it for input devices
+ which are pipes (#3835, Keith Packard).
+ 71. Bring the SDK support up to date (#3834, David Bateman).
+ 70. Fix an Xlib problem that causes an application crash when inputting
+ cyrillic symbols with the koi8-r locale (and other locales with
+ long esc-sequences) (#3833, Ivan Pascal, #A.15, Serguei Poliakov, #A.34,
+ Stanislav Meduna, #A.40, Rimantas Plaipa, #A.74, Sergei Laskavy).
+ 69. Fixes for S3 Trio3D/2X:
+ - flickering for some cards (bad FIFO setting from bios).
+ - workaround for 8MB ram (ramdac can access only 4MB).
+ - adjust clock limits which have been too low.
+ (#3832, Harald Koenig).
+ 68. Fix v4l problem with a function being called after the module is
+ unloaded (#3831, gbritton@light-brigade.mit.edu).
+ 67. Fixes for the PPC icache flushing code (#3830, Kostas Gewrgiou).
+ 66. Fix for /tmp race installing man pages on OpenBSD (#3829,
+ Matthieu Herrb).
+ 65. Fix problems building the Xsun and XsunMono servers on
+ NetBSD-current/sparc (#3828, Matthieu Herrb).
+ 64. Add a comment to site.def about how to move the /etc/X11 contents to
+ a directory under ProjectRoot (#3827, R Horn).
+ 63. Fix an Xaw bug that shows up when usingn c-mode with xedit on Linux
+ (#3824, Paulo Cesar Pereira de Andrade).
+ 62. Enable devfs support for the v4l driver (based on #3823,
+ Christopher Sekiya).
+ 61. Update for README.FreeBSD (#3822, Kazutaka Yokota).
+ 60. Bump the video driver ABI minor version because of interface changes
+ (now 0.2).
+ 59. Disable SilkenMouse when IO/MEM resource sharing means that it cannot
+ be reliably used (#382o, Keith Packard and Egbert Eich).
+ 58. Fix DGA 1.0 compatibility for mouse events and SetViewport behaviour
+ (#3820, Keith Packard).
+ 57. Fix the Linux APM code so that the X server doesn't hang the machine
+ on suspend (#3820, Keith Packard and Egbert Eich).
+ 56. Fix problems that break Overlay support in the glint driver (#3818,
+ Michel Dänzer).
+ 55. Possible fix for AvailableOptions function and submodule loading
+ for the cirrus driver (David Dawes).
+ 54. Add an entry for the GeForce to the Cards file (#A.6, Oliver Lau).
+ 53. Fix pswrap build problem when cross compiling (#3815, Jim Gettys).
+ 52. Fix a typo in itsy.cf (#3814, Jim Gettys).
+ 51. SiS driver fixes:
+ - 630/540/300 display abnormal for all modes.
+ - 630/540/300 cannot enter true color modes.
+ - 530/620 1600x1200x8bpp display abnormal.
+ (#3807, Can-Ru Yeou, SiS).
+ 50. Fix a -configure crash in the nv driver (#3805, Jarno Paananen).
+ 49. Rendition driver updates:
+ - rename most v_ to verite_ to avoid potential namespace clashes.
+ - add support for VBE DDC and "XFree86 -configure".
+ - fix PROBE_DETECT issues.
+ - Replace a number of ErrorF's with xf86DrvMsg to reduce noise
+ when not requested. A number of debugging messages #ifdef'ed also.
+ - Option "MTRR" reenabled. Was disabled when acceleration was debugged.
+ (#3785, 3808, Dejan Ilic).
+ 48. S3virge driver updates:
+ - Revert WAITIDLE to cleanly abort a segfaulting imagewrite.
+ - Start of GX2 fixes.
+ - Add DDC monitor X -configure code.
+ - Update copyrights
+ (#3783, Kevin Brosius).
+ 47. Update XSetWMProperties() to set the WM_LOCALE_NAME property (#3780,
+ Peter Novodvorsky).
+ 46. Xterm patch #131 (#3777, Thomas Dickey).
+ 45. Add some xtest tests to cover some accelerated cases implemented by
+ XAA, and fix some Linux/glibc build problems (#3767, Rik Faith).
+ 44. Xineramification of XvImage support (Mark Vojkovich).
+ 43. By default, cache writes to selected Mach64 MMIO registers and allow this
+ cache to be disabled (Marc La France).
+ 42. Add detection of Rage128 Mobility to ATI driver (Marc La France).
+ 41. Fix a Xinerama GetImage bug that showed up in 24+32 (Mark Vojkovich).
+ 40. Fix XAA transparent blits. They are broken in 4.0 (Mark Vojkovich).
+ 39. Fix typo in mioverlay that broke resize gravity (Mark Vojkovich).
+ 38. Fix PCI/AGP bridge I/O and memory window detection (Marc La France).
+ 37. Add Mach64 solid zero-width line acceleration, except for 24bpp
+ (Kevin Martin, Marc La France).
+ 36. Add Mach64 mono 8x8 pattern fill acceleration (Kevin Martin,
+ Marc La France).
+ 35. Fix DDC bug (John McCorquodale).
+ 34. Fix minClock and maxClock determination in ATI driver (Marc La France).
+ 33. A first step at allowing -configure to deal with more than one device per
+ driver (Marc La France).
+ 32. ATI driver changes: Implement Mach64 engine restriction on virtual
+ resolution; Add DPMS support; More DSP calculation fixes; Fix text
+ mode restoration bug; Fix Mach64 screen blanking; Don't probe for
+ previously claimed VGA compatibles; Fix device section matching for
+ Mach64 controllers made by UMC foundry; Miscellaneous cleanups
+ (Marc La France).
+ 31. Add GLINT 300SX support to the glint driver (Alan Hourihane).
+ 30. Remove the unused GLINT Delta code (for now) to re-implement as
+ a chipset (like the gamma) from the glint driver (Alan Hourihane).
+ 29. Add support for the TVP3026 ramdac to the ramdac module (Alan Hourihane).
+ 28. Add support for building and installing HTML versions of the man
+ pages (David Dawes).
+ 27. Fix some limitation in rman so that it will handle our man pages
+ correctly (David Dawes).
+ 26. Import rman-3.0.8, for generating HTML versions of the man pages
+ (David Dawes).
+ 25. ATI fixes to Cards database (Marc La France).
+ 24. Fix some man page formatting problems that show up on some platforms
+ (David Dawes).
+ 23. Fix an 8+24 bug that occured when shared memory pixmaps were used as
+ tiles (Mark Vojkovich).
+ 22. Support for the Trident CyberBlade/DSTN/i1 (Alan Hourihane).
+ 21. Fix Xinerama problems that occured when screen zero was not at (0,0)
+ (Mark Vojkovich).
+ 20. Add untested support for Matrox SDRAM G400s (Mark Vojkovich).
+ 19. Improve memory probing reliability in the Matrox driver (Mark Vojkovich).
+ 18. Fix DESIGN doc and XF86Config man page information about the Screen
+ entry format in the ServerLayout sections (David Dawes).
+ 17. Add missing file permission flags to xf86shmget (Mark Vojkovich).
+ 16. Workaround in 8+32 for applications that assume changes to window
+ background pixmaps go into effect immediately (Mark Vojkovich).
+ 15. Change loader search order to look in more specific subdirectories first,
+ thereby avoiding loading 3.3.* module versions (Marc La France).
+ 14. Remove the var-* bindist files for platforms that don't use Xvar.tgz
+ (David Dawes).
+ 13. No Xset.tgz, so remove the set-list bindist files (David Dawes).
+ 12. Fix Xinstall's symlink testing for Solaris (/bin/sh's builtin doesn't
+ recognise '-L') (David Dawes).
+ 11. Update Xinstall.sh to handle the xkb/compiled directory properly in all
+ cases, including when there is no Xvar.tgz tarball (David Dawes).
+ 10. Add missing cs_CZ.ISO_8859-2 entries to locale.alias (#A.20,
+ Cejka Rudolf).
+ 9. Updates to Linux-ix86 bindist host.def file.
+ 8. Fix installation of iso8859-{1,2,3} Compose files, and fix the czech
+ entry in locale.alias (Charles Lopes, #A.62, Stanislav Brabec).
+ 7. Fix some problems with layers forgetting that SwitchMode is an
+ optional function (Mark Vojkovich).
+ 6. Parser bug fix for hexadecimal numbers (Marc La France).
+ 5. Fix scanpci (Marc La France).
+ 4. DPMS #include fix (Marc La France).
+ 3. Fix an event ordering problem in Xinerama (Mark Vojkovich).
+ 2. Fix some clipping bugs in the Xv DDX (Mark Vojkovich).
+ 1. Remove 24bpp shadowfb support from the NV driver since the hardware
+ is not capable of 24bpp (Mark Vojkovich).
+
XFree86 4.0 (8 March 2000)
3972. Possible fix for a cirrus driver crash when using -configure
(David Dawes).
@@ -94,7 +875,7 @@ XFree86 3.9.18Z (3 March 2000)
Thomas Mueller).
3920. Update the wacom input driver to suppor the PL400 model and the
stroking pen on the Intuos model (#3778, Frederic Lepied).
-3919. Xterm patch #131 (#3777, Thomas Dickey).
+3919. -
3918. -
3917. Add prototypes for xman, and eliminate most of the compiler warnings
(#3772, Thomas Dickey).
@@ -103,7 +884,8 @@ XFree86 3.9.18Z (3 March 2000)
when hardware clipping is not available (Mark Vojkovich).
3914. Update the mga man page (Mark Vojkovich).
3913. A Q&D fix for GLX segment violation in loader server (Marc La France).
-3912. Add Mach64 screen-to-screen copy acceleration (Marc La France).
+3912. Add Mach64 screen-to-screen copy acceleration (Kevin Martin,
+ Marc La France).
3911. IA-64 fixes (Mark Vojkovich).
3910. Add skeleton man pages for the video and input drivers that don't
already have one (David Dawes).
@@ -164,7 +946,7 @@ XFree86 3.9.18b (29 February 2000)
3883. Update Xinstall.sh for NetBSD-current-ELF (#3754, Matthieu Herrb).
3882. Update NetBSD and OpenBSD bindist files (#3753, Matthieu Herrb).
3881. Apm driver update, including extending the Rush extension to allow
- initialisation of the Rush chip in a legal way (#3751, Loic Grenie).
+ initialisation of the Rush chip in a legal way (#3752, Loic Grenie).
3880. Xterm patch #129 (#3751, Thomas Dickey).
3879. Add DDC support to the tdfx driver via the vbe interface (#3750,
Jarno Paananen).
@@ -10035,4 +10817,4 @@ XFree86 3.0 (26 April 1994)
-$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.1079 2000/03/08 19:27:44 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/CHANGELOG,v 3.1230 2000/07/02 02:35:25 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/DebuggingHints b/xc/programs/Xserver/hw/xfree86/DebuggingHints
new file mode 100644
index 000000000..300fe4813
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/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 <file>.o
+ # xc/config/util/makeg.sh <file>.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 <file>.s
+
+ or
+
+ # xc/config/util/makeg.sh <file>.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 <file>.o
+
+ <file>.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/<libname>.a # ld -r *.o -o module-path/<name>.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-<name>.c in tmp/
+ containing:
+ void Dummy-<name>() {}
+
+ Compile it:
+
+ # gcc -c 1-<name>.c
+
+ and do the link step above.
+
+ This way Dummy-<name>() 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 <file>.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 <filename>.i
+
+ This will generate a preprocessed source in <filename>.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/xc/programs/Xserver/hw/xfree86/Imakefile b/xc/programs/Xserver/hw/xfree86/Imakefile
index 6547d719b..ea8f837e6 100644
--- a/xc/programs/Xserver/hw/xfree86/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/Imakefile
@@ -3,7 +3,7 @@ XCOMM $XConsortium: Imakefile /main/12 1996/12/16 12:31:46 rws $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/Imakefile,v 3.64 2000/03/08 05:38:30 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/Imakefile,v 3.68 2000/06/13 02:28:30 dawes Exp $
#include <Server.tmpl>
#define IHaveSubdirs
@@ -27,6 +27,10 @@ XF4BPPDIR = xf4bpp
# endif
#endif
+#if XF8_32Wid
+XF8_32WIDDIR = xf8_32wid
+#endif
+
#if XF8_32Bpp
XF8_32BPPDIR = xf8_32bpp
#endif
@@ -65,7 +69,7 @@ INT10DIR = int10
#if !defined(OsfArchitecture) && !defined(AmoebaArchitecture) && \
!defined(ArcArchitecture) && !defined(Arm32Architecture) && \
- !defined(PpcArchitecture)
+ !defined(PpcArchitecture) && !defined(MipsArchitecture)
SUPERPROBE = SuperProbe
#endif
@@ -85,12 +89,16 @@ INPUTDIR = input
DRIVERSDK = sdk
#endif
+#if !BuildServersOnly
+XF86CFGDIR = xf86cfg
+#endif
+
SUBDIRS = os-support common $(XAADIR) $(XF1BPPDIR) $(XF4BPPDIR) \
$(XF8_32BPPDIR) $(XF8_16BPPDIR) $(XF24_32BPPDIR) $(SHADOWFBDIR) \
drivers $(LOADERDIR) $(VGAHWDIR) $(FBDEVHWDIR) $(RAMDACDIR) \
$(RACDIR) $(I2CDIR) $(DDCDIR) $(INPUTDIR) $(INT10DIR) parser \
- scanpci doc xf86config $(XF86SETUPDIR) dummylib etc \
- $(SUPERPROBE) $(DRIVERSDK)
+ scanpci doc xf86config $(XF86CFGDIR) $(XF86SETUPDIR) dummylib etc \
+ $(SUPERPROBE) $(DRIVERSDK) $(XF8_32WIDDIR)
#ifndef OS2Architecture
XF86CONFIG = XF86Config
diff --git a/xc/programs/Xserver/hw/xfree86/RAC.Notes b/xc/programs/Xserver/hw/xfree86/RAC.Notes
index 1f9300523..0aec9d795 100644
--- a/xc/programs/Xserver/hw/xfree86/RAC.Notes
+++ b/xc/programs/Xserver/hw/xfree86/RAC.Notes
@@ -488,11 +488,18 @@ 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, xf86AccessPtr p_io,
- xf86AccessPtr p_mem, xf86AccessPtr p_io_mem,
- xf86AccessPtr *ppAccessOld);
+ void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs);
-Is used for that. The driver can pass three functions: one for I/O
+ 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
@@ -500,8 +507,8 @@ 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 fifth argument it is interpreted as an address
-where to store the old access record. If the fifth argument is NULL
+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
diff --git a/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c b/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c
index 81583b905..01adde304 100644
--- a/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c
+++ b/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c,v 3.16 1999/08/01 07:57:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_386BSD.c,v 3.17 2000/06/23 22:42:02 dawes Exp $ */
/*
* (c) Copyright 1993,1994 by David Dawes <dawes@xfree86.org>
*
@@ -74,7 +74,12 @@
# include <machine/ioctl_pc.h>
# endif
# if defined(PCVT_SUPPORT) && !defined(SYSCONS_SUPPORT)
-# include <machine/pcvt_ioctl.h>
+# if defined(__NetBSD__) && defined(WSCONS_SUPPORT)
+ /* NetBSD's wscons has a PCVT compatibility module. */
+# include <dev/wscons/wsdisplay_usl_io.h>
+# else
+# include <machine/pcvt_ioctl.h>
+# endif
# endif
# ifdef SYSCONS_SUPPORT
/* both, Free and NetBSD have syscons */
diff --git a/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c b/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c
index 1e857db61..7850c8a9d 100644
--- a/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c
+++ b/xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c,v 3.7 1997/07/10 08:17:19 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/SuperProbe/OS_LynxOS.c,v 3.8 2000/06/17 00:27:31 dawes Exp $ */
/*
* Copyright 1993 by Thomas Mueller
*
@@ -30,8 +30,7 @@
#include <kd.h>
#include <vt.h>
#include <smem.h>
-
-#include <kernel.h> /* for PHYSBASE */
+#include <info.h>
#ifdef __powerpc__
unsigned char *ioBase = NULL;
@@ -141,9 +140,15 @@ Byte *Buffer;
int Len;
#endif
{
+ unsigned long physbase;
Word tmp;
Byte *Base = Bios_Base + Offset;
+ physbase = info(_I_PHYSBASE);
+ if (physbase == -1) {
+ fprintf(stderr, "%s: can't inquire PHYSBASE\n", MyName);
+ return(-1);
+ }
if (BIOS_fd == -1)
{
if ((BIOS_fd = open("/dev/mem", O_RDONLY, 0)) < 0)
@@ -157,7 +162,7 @@ int Len;
/*
* Sanity check...
*/
- (void)lseek(BIOS_fd, (off_t)PHYSBASE + ((off_t)Base & 0xF8000), SEEK_SET);
+ (void)lseek(BIOS_fd, (off_t)physbase + ((off_t)Base & 0xF8000), SEEK_SET);
(void)read(BIOS_fd, &tmp, 2);
if (tmp != (Word)0xAA55)
{
@@ -170,8 +175,8 @@ int Len;
return(-1);
}
}
- /* check carefully against -1 because of PHYSBASE offset.. */
- if (lseek(BIOS_fd, (off_t)(PHYSBASE + Base), SEEK_SET) == -1)
+ /* check carefully against -1 because of physbase offset.. */
+ if (lseek(BIOS_fd, (off_t)(physbase + Base), SEEK_SET) == -1)
{
fprintf(stderr, "%s: BIOS seek failed\n", MyName);
return(-1);
diff --git a/xc/programs/Xserver/hw/xfree86/XF86Config.cpp b/xc/programs/Xserver/hw/xfree86/XF86Config.cpp
index 7a9ad4780..96597ff11 100644
--- a/xc/programs/Xserver/hw/xfree86/XF86Config.cpp
+++ b/xc/programs/Xserver/hw/xfree86/XF86Config.cpp
@@ -1,5 +1,7 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/XF86Config.cpp,v 1.3 2000/03/08 19:12:44 dawes Exp $
-.TH XF86Config __filemansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/XF86Config.cpp,v 1.10 2000/06/20 05:08:42 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH XF86Config __filemansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
XF86Config - Configuration File for XFree86
.SH DESCRIPTION
@@ -84,8 +86,10 @@ the form:
.PP
.RS 4
.nf
-.BI "Section """ SectionName """"
-.I " SectionEntry"
+.\" Some man macros don't handle quotes in .BI, etc very well
+.\" \fBSection "\fP\fISectionName\fP\fB"\fP
+.BI "Section \*q" SectionName \*q
+.RI " " SectionEntry
...
.B EndSection
.fi
@@ -162,10 +166,13 @@ on the keyword. The argument types are:
.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 ("")"
+.BR "String " "a string enclosed in double quote marks (\*q)"
.fi
.RE
.PP
+Note: hex integer values must be prefixed with "0x", and octal values
+with "0".
+.PP
A special keyword called
.B Option
may be used to provide free-form data to various components of the server.
@@ -214,18 +221,18 @@ and the following boolean option values are recognised as
.RE
.PP
If an option name is prefixed with
-.RB """" No """",
+.RB \*q No \*q,
then the option value is negated.
.PP
Example: the following option entries are equivalent:
.PP
.RS 4
.nf
-.B "Option ""Accel"" ""Off"""
-.B "Option ""NoAccel"""
-.B "Option ""NoAccel"" ""On"""
-.B "Option ""Accel"" ""false"""
-.B "Option ""Accel"" ""no"""
+.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
@@ -256,14 +263,14 @@ The command line settings override the values specified in the config
file.
The entries that can appear in this section are:
.TP 7
-.BI "FontPath """ path """"
+.BI "FontPath \*q" path \*q
sets the search path for fonts. This path is a comma separated
list of font path elements which the X 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 may be either absolute directory paths, or the
+Font path elements may be either absolute directory paths, or
a font server identifier. Font server identifiers have the form:
.PP
.RS 11
@@ -318,7 +325,7 @@ Font path elements that are found to be invalid are removed from the
font path when the server starts up.
.RE
.TP 7
-.BI "RGBPath """ path """"
+.BI "RGBPath \*q" path \*q
sets the path name for the RGB color database.
When this entry is not specified in the config file, the server falls back
to the compiled-in default RGB path, which is:
@@ -327,7 +334,7 @@ to the compiled-in default RGB path, which is:
__projectroot__/lib/X11/rgb
.RE
.TP 7
-.BI "ModulePath """ path """"
+.BI "ModulePath \*q" path \*q
sets the search path for loadable X server modules. This path is a
comma separated list of directories which the X server searches for
loadable modules loading in the order specified. Multiple
@@ -337,7 +344,7 @@ module search path used by the server.
.\" The LogFile keyword is not currently implemented
.ig
.TP 7
-.BI "LogFile """ path """"
+.BI "LogFile \*q" path \*q
sets the name of the X server log file. The default log file name is
.PP
.RS 11
@@ -368,7 +375,7 @@ 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 ""NoTrapSignals"" """ boolean """"
+.BI "Option \*qNoTrapSignals\*q \*q" boolean \*q
This prevents the X server from trapping a range of unexpected
fatal signals and exiting cleanly. Instead, the X server will die
and drop core where the fault occurred. The default behaviour is
@@ -376,14 +383,14 @@ for the X server exit cleanly, but still drop a core file. In
general you never want to use this option unless you are debugging
an X server problem and know how to deal with the consequences.
.TP 7
-.BI "Option ""DontZap"" """ boolean """"
+.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 X server.
When this option is enabled, that key sequence has no special meaning
and is passed to clients. Default: off.
.TP 7
-.BI "Option ""DontZoom"" """ boolean """"
+.BI "Option \*qDontZoom\*q \*q" boolean \*q
This disallows the use of the
.B Ctrl+Alt+Keypad-Plus
and
@@ -392,29 +399,29 @@ 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 ""DisableVidModeExtension"" """ boolean """"
+.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 ""AllowNonLocalXvidtune"" """ boolean """"
+.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 ""DisableModInDev"" """ boolean """"
+.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 ""AllowNonLocalModInDev"" """ boolean """"
+.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 ""AllowMouseOpenFail"" """ boolean """"
+.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 ""VTInit"" """ command """"
+.BI "Option \*qVTInit\*q \*q" command \*q
Runs
.I command
after the VT used by the server has been opened.
@@ -423,7 +430,7 @@ real user's id with stdin and stdout set to the VT. The purpose
of this option is to allow system dependent VT initialisation
commands to be run. This option should rarely be needed. Default: not set.
.TP 7
-.BI "Option ""VTSysReq"" """ boolean """"
+.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
@@ -436,26 +443,26 @@ access them. Default: off.
.\" The following four options are "undocumented".
.ig
.TP 7
-.BI "Option ""PciProbe1"""
+.BI "Option \*qPciProbe1\*q"
Use PCI probe method 1. Default: set.
.TP 7
-.BI "Option ""PciProbe2"""
+.BI "Option \*qPciProbe2\*q"
Use PCI probe method 2. Default: not set.
.TP 7
-.BI "Option ""PciForceConfig1"""
+.BI "Option \*qPciForceConfig1\*q"
Force the use PCI config type 1. Default: not set.
.TP 7
-.BI "Option ""PciForceConfig2"""
+.BI "Option \*qPciForceConfig2\*q"
Force the use PCI config type 2. Default: not set.
..
.TP 7
-.BI "Option ""BlankTime"" """ time """"
+.BI "Option \*qBlankTime\*q \*q" time \*q
sets the inactivity timeout for the blanking phase of the screensaver.
.I time
is in minutes. This is equivalent to the Xserver's `-s' flag, and the
value can be changed at run-time with \fIxset(1)\fP. Default: 10 minutes.
.TP 7
-.BI "Option ""StandbyTime"" """ time """"
+.BI "Option \*qStandbyTime\*q \*q" time \*q
sets the inactivity timeout for the "standby" phase of DPMS mode.
.I time
is in minutes, and the value can be changed at run-time with \fIxset(1)\fP.
@@ -463,10 +470,10 @@ 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 """DPMS"""
-option set.
+.B \*qDPMS\*q
+option set (see the MONITOR section below).
.TP 7
-.BI "Option ""SuspendTime"" """ time """"
+.BI "Option \*qSuspendTime\*q \*q" time \*q
sets the inactivity timeout for the "suspend" phase of DPMS mode.
.I time
is in minutes, and the value can be changed at run-time with \fIxset(1)\fP.
@@ -474,10 +481,10 @@ 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 """DPMS"""
-option set.
+.B \*qDPMS\*q
+option set (see the MONITOR section below).
.TP 7
-.BI "Option ""OffTime"" """ time """"
+.BI "Option \*qOffTime\*q \*q" time \*q
sets the inactivity timeout for the "off" phase of DPMS mode.
.I time
is in minutes, and the value can be changed at run-time with \fIxset(1)\fP.
@@ -485,28 +492,28 @@ 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 """DPMS"""
-option set.
+.B \*qDPMS\*q
+option set (see the MONITOR section below).
.TP 7
-.BI "Option ""Pixmap"" """ bpp """"
+.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 ""PC98"" """ boolean """"
+.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 ""EstimateSizesAggressively"" """ value """"
+.BI "Option \*qEstimateSizesAggressively\*q \*q" value \*q
This option affects the way that bus resource sizes are estimated. Default: 0.
..
.TP 7
-.BI "Option ""NoPM"" """ boolean """"
+.BI "Option \*qNoPM\*q \*q" boolean \*q
Disables something to do with power management events. Default: PM enabled
on platforms that support it.
.SH MODULE SECTION
@@ -523,7 +530,7 @@ used form is an entry that uses the
.B Load
keyword, as described here:
.TP 7
-.BI "Load """ modulename """"
+.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
@@ -534,7 +541,7 @@ include the "lib" prefix, or the ".a", ".o", or ".so" suffixes.
Example: the Type 1 font rasteriser can be loaded with the following entry:
.PP
.RS 4
-.B "Load ""type1"""
+.B "Load \*qtype1\*q"
.RE
.RE
.PP
@@ -552,8 +559,8 @@ disabled by using the following entry:
.PP
.RS 4
.nf
-.B "SubSection ""extmod"""
-.B " Option ""omit XFree86-DGA"""
+.B "SubSection \*qextmod\*q"
+.B " Option \*qomit XFree86-DGA\*q"
.B EndSubSection
.fi
.RE
@@ -590,9 +597,9 @@ sections have the following format:
.PP
.RS 4
.nf
-.B "Section ""InputDevice"""
-.BI " Identifier """ name """"
-.BI " Driver """ inputdriver """"
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" name \*q
+.BI " Driver \*q" inputdriver \*q
.I " options"
.I " ..."
.B "EndSection"
@@ -605,7 +612,7 @@ 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 """ inputdriver """
+.RI \*q inputdriver \*q
will be loaded for each active
.B InputDevice
section. An
@@ -625,7 +632,7 @@ sections recognise some driver-independent
which are described here. See the individual input driver manual pages
for a description of the device-specific options.
.TP 7
-.BI "Option ""CorePointer"""
+.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
@@ -638,7 +645,7 @@ This option is implicitly set when the obsolete
.B Pointer
section is used.
.TP 7
-.BI "Option ""CoreKeyboard"""
+.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
@@ -651,18 +658,18 @@ This option is implicitly set when the obsolete
.B Keyboard
section is used.
.TP 7
-.BI "Option ""AlwaysCore"" """ boolean """"
+.BI "Option \*qAlwaysCore\*q \*q" boolean \*q
.TP 7
-.BI "Option ""SendCoreEvents"" """ boolean """"
+.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 ""HistorySize"" """ number """"
+.BI "Option \*qHistorySize\*q \*q" number \*q
Sets the motion history size. Default: 0.
.TP 7
-.BI "Option ""SendDragEvents"" """ boolean """"
+.BI "Option \*qSendDragEvents\*q \*q" boolean \*q
???
.SH DEVICE SECTION
The config file may have multiple
@@ -674,9 +681,9 @@ sections have the following format:
.PP
.RS 4
.nf
-.B "Section ""Device"""
-.BI " Identifier """ name """"
-.BI " Driver """ driver """"
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" name \*q
+.BI " Driver \*q" driver \*q
.I " entries"
.I " ..."
.B "EndSection"
@@ -689,7 +696,7 @@ 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 """ driver """
+.RI \*q driver \*q
will be loaded for each active
.B Device
section. A
@@ -714,7 +721,7 @@ section instead of here in the
.B Device
section.
.TP 7
-.BI "BusID """ bus-id """"
+.BI "BusID \*q" bus-id \*q
This specifies the bus location of the graphics card. For PCI/AGP cards,
the
.I bus-id
@@ -730,14 +737,27 @@ can usually be found by running the X server with the
.B \-scanpci
command line option.
.TP 7
-.BI "Chipset """ chipset """"
+.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 """ ramdac-type """"
+.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
@@ -769,7 +789,7 @@ 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 """ clockchip-type """"
+.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 X servers support programmable clock chips. For details,
@@ -840,8 +860,8 @@ sections have the following format:
.PP
.RS 4
.nf
-.B "Section ""Monitor"""
-.BI " Identifier """ name """"
+.B "Section \*qMonitor\*q"
+.BI " Identifier \*q" name \*q
.I " entries"
.I " ..."
.B "EndSection"
@@ -871,10 +891,10 @@ The entries that may be used in
.B Monitor
sections are described below.
.TP 7
-.BI "VendorName """ vendor """"
+.BI "VendorName \*q" vendor \*q
This optional entry specifies the monitor's manufacturer.
.TP 7
-.BI "ModelName """ model """"
+.BI "ModelName \*q" model \*q
This optional entry specifies the monitor's model.
.TP 7
.BI "HorizSync " "horizsync-range"
@@ -916,7 +936,7 @@ 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 """ modesection-id """"
+.BI "UseModes \*q" modesection-id \*q
Include the set of modes listed in the
.B Modes
section called
@@ -945,27 +965,27 @@ specifies the horizontal timings for the mode.
.BI "VTimings " "vdisp vsyncstart vsyncend vtotal"
specifies the vertical timings for the mode.
.TP 4
-.BI "Flags """ flag """" " ..."
+.BI "Flags \*q" flag \*q " ..."
specifies an optional set of mode flags, each of which is a separate
string in double quotes.
-.B """Interlace"""
+.B \*qInterlace\*q
indicates that the mode is interlaced.
-.B """DoubleScan"""
+.B \*qDoubleScan\*q
indicates a mode where each scanline is doubled.
-.B """+HSync"""
+.B \*q+HSync\*q
and
-.B """\-HSync"""
+.B \*q\-HSync\*q
can be used to select the polarity of the HSync signal.
-.B """+VSync"""
+.B \*q+VSync\*q
and
-.B """\-VSync"""
+.B \*q\-VSync\*q
can be used to select the polarity of the VSync signal.
-.B """Composite"""
+.B \*qComposite\*q
can be used to specify composite sync on hardware where this is supported.
Additionally, on some hardware,
-.B """+CSync"""
+.B \*q+CSync\*q
and
-.B """\-CSync"""
+.B \*q\-CSync\*q
may be used to select the composite sync polarity.
.TP 4
.BI "HSkew " hskew
@@ -981,12 +1001,12 @@ decreased.
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 """DoubleScan"""
+.B \*qDoubleScan\*q
.B Flag
mentioned above doubles this value.
.RE
.TP 7
-.BI "ModeLine """ name """" " mode-description"
+.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.
@@ -1048,9 +1068,9 @@ Some
flags that may be useful to include in
.B Monitor
sections (when needed) include
-.BR """DPMS""" ,
+.BR \*qDPMS\*q ,
and
-.BR """SyncOnGreen""" .
+.BR \*qSyncOnGreen\*q .
.SH MODES SECTION
The config file may have multiple
@@ -1073,8 +1093,8 @@ sections have the following format:
.PP
.RS 4
.nf
-.B "Section ""Modes"""
-.BI " Identifier """ name """"
+.B "Section \*qModes\*q"
+.BI " Identifier \*q" name \*q
.I " entries"
.I " ..."
.B "EndSection"
@@ -1116,13 +1136,13 @@ sections have the following format:
.PP
.RS 4
.nf
-.B "Section ""Screen"""
-.BI " Identifier """ name """"
-.BI " Device """ devid """"
-.BI " Monitor """ monid """"
+.B "Section \*qScreen\*q"
+.BI " Identifier \*q" name \*q
+.BI " Device \*q" devid \*q
+.BI " Monitor \*q" monid \*q
.I " entries"
.I " ..."
-.BI " SubSection ""Display"""
+.BI " SubSection \*qDisplay\*q"
.I " entries"
.I " ...
.B " EndSubSection"
@@ -1144,7 +1164,7 @@ sections, one for each head.
The entries available
for this section are:
.TP 7
-.BI "Device """ device-id """"
+.BI "Device \*q" device-id \*q
This specifies the
.B Device
section to be used for this screen. This is what ties a specific
@@ -1156,10 +1176,10 @@ of a
.B Device
section in the config file.
.TP 7
-.BI "Monitor """ monitor-id """"
+.BI "Monitor \*q" monitor-id \*q
specifies which monitor description is to be used for this screen.
.TP 7
-.BI "VideoAdaptor """ xv-id """"
+.BI "VideoAdaptor \*q" xv-id \*q
specifies an optional Xv video adaptor description to be used with this
screen.
.TP 7
@@ -1213,7 +1233,7 @@ subsections have the following format:
.PP
.RS 4
.nf
-.B " SubSection ""Display"""
+.B " SubSection \*qDisplay\*q"
.BI " Depth " depth
.I " entries"
.I " ..."
@@ -1277,7 +1297,7 @@ 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 """ mode-name """" " ..."
+.BI "Modes \*q" mode-name \*q " ..."
This entry is highly desirable for most drivers, and it specifies the list
of video modes to use. Each
.I mode-name
@@ -1297,7 +1317,7 @@ appropriate
.B Monitor
section will be used.
.TP 7
-.BI "Visual """ visual-name """"
+.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
.I Xserver(1)
@@ -1387,11 +1407,11 @@ sections have the following format:
.PP
.RS 4
.nf
-.B "Section ""ServerLayout"""
-.BI " Identifier """ name """"
-.BI " Screen """ screen-id """"
+.B "Section \*qServerLayout\*q"
+.BI " Identifier \*q" name \*q
+.BI " Screen \*q" screen-id \*q
.I " ..."
-.BI " InputDevice """ idev-id """"
+.BI " InputDevice \*q" idev-id \*q
.I " ..."
.I " options"
.I " ..."
@@ -1415,7 +1435,7 @@ section.
.PP
The entries that may be used in this section are described here.
.TP 7
-.BI "Screen """ screen-id """" " screen-num position-information"
+.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
@@ -1438,19 +1458,19 @@ This says that the upper left corner's coordinates are
If the coordinates are omitted or if no positioning information
is given, (0,0) is assumed.
.TP 4
-.BI "RightOf """ screen-id """"
+.BI "RightOf \*q" screen-id \*q
.TP 4
-.BI "LeftOf """ screen-id """"
+.BI "LeftOf \*q" screen-id \*q
.TP 4
-.BI "Above """ screen-id """"
+.BI "Above \*q" screen-id \*q
.TP 4
-.BI "Below """ screen-id """"
+.BI "Below \*q" screen-id \*q
.TP 4
-.BI "Relative """ screen-id """" " x y"
+.BI "Relative \*q" screen-id \*q " x y"
These give the screen's location relative to another screen.
.RE
.TP 7
-.BI "InputDevice """ idev-id """ """ option """" " ..."
+.BI "InputDevice \*q" idev-id "\*q \*q" option \*q " ..."
One of these entries must 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. The
@@ -1467,9 +1487,9 @@ be used here. The most commonly used options are:
.PP
.RS 11
.nf
-.B """CorePointer"""
-.B """CoreKeyboard"""
-.B """SendCoreEvents"""
+.B \*qCorePointer\*q
+.B \*qCoreKeyboard\*q
+.B \*qSendCoreEvents\*q
.fi
.RE
.PP
@@ -1492,14 +1512,14 @@ section for a dual headed configuration with two mice:
.PP
.RS 4
.nf
-.B "Section ""ServerLayout"""
-.B " Identifier ""Layout 1"""
-.B " Screen ""MGA 1"""
-.B " Screen ""MGA 2"" RightOf ""MGA 1"""
-.B " InputDevice ""Keyboard 1"" ""CoreKeyboard"""
-.B " InputDevice ""Mouse 1"" ""CorePointer"""
-.B " InputDevice ""Mouse 2"" ""SendCoreEvents"""
-.B " Option ""BlankTime"" ""5"""
+.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
@@ -1526,7 +1546,7 @@ For an example of an XF86Config file, see the file installed as
__projectroot__/lib/X11/XF86Config.eg.
.fi
.SH "SEE ALSO"
-X(1), Xserver(1), XFree86(1),
+X(__miscmansuffix__), Xserver(1), XFree86(1),
apm(__drivermansuffix__),
ati(__drivermansuffix__),
chips(__drivermansuffix__),
@@ -1550,12 +1570,24 @@ trident(__drivermansuffix__),
tseng(__drivermansuffix__),
v4l(__drivermansuffix__),
vga(__drivermansuffix__),
-.IR README ,
-.IR RELNOTES ,
-.IR README.mouse ,
-.IR README.DRI ,
-.IR Status ,
-.IR Install .
+.br
+README
+.IR <http://www.xfree86.org/current/README.html> ,
+.br
+RELNOTES
+.IR <http://www.xfree86.org/current/RELNOTES.html> ,
+.br
+README.mouse
+.IR <http://www.xfree86.org/current/mouse.html> ,
+.br
+README.DRI
+.IR <http://www.xfree86.org/current/DRI.html> ,
+.br
+Status
+.IR <http://www.xfree86.org/current/Status.html> ,
+.br
+Install
+.IR <http://www.xfree86.org/current/Install.html> .
.SH AUTHORS
This manual page was largely rewritten for XFree86 4.0 by David Dawes
.IR <dawes@xfree86.org> .
diff --git a/xc/programs/Xserver/hw/xfree86/XF98Conf.cpp b/xc/programs/Xserver/hw/xfree86/XF98Conf.cpp
index be962bd4a..d7e1cd61d 100644
--- a/xc/programs/Xserver/hw/xfree86/XF98Conf.cpp
+++ b/xc/programs/Xserver/hw/xfree86/XF98Conf.cpp
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/XF98Conf.cpp,v 1.1 1999/07/19 13:36:11 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/XF98Conf.cpp,v 1.2 2000/06/13 02:28:30 dawes Exp $
XCOMM
XCOMM Copyright (c) 1994-1998 by The XFree86 Project, Inc.
XCOMM
@@ -474,6 +474,20 @@ Section "Device"
XCOMM BusID "PCI:0:10:0"
EndSection
+Section "Device"
+ Identifier "NECTrident"
+ VendorName "NEC"
+ BoardName "NEC Trident"
+ Driver "trident"
+XCOMM BusID "PCI:0:8:0"
+XCOMM Option "NoPciBurst"
+XCOMM Option "XaaNoScreenToScreenCopy"
+XCOMM Option "XaaNoCPUToScreenColorExpandFill"
+XCOMM Option "XaaNoScanlineCPUToScreenColorExpandFill"
+XCOMM Option "XaaNoScreenToScreenColorExpandFill"
+XCOMM VideoRam 2048
+Endsection
+
XCOMM **********************************************************************
XCOMM Screen sections.
XCOMM **********************************************************************
diff --git a/xc/programs/Xserver/hw/xfree86/XFree86.cpp b/xc/programs/Xserver/hw/xfree86/XFree86.cpp
index b215dc64c..8f9e755dd 100644
--- a/xc/programs/Xserver/hw/xfree86/XFree86.cpp
+++ b/xc/programs/Xserver/hw/xfree86/XFree86.cpp
@@ -1,4 +1,4 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/XFree86.cpp,v 1.1 2000/03/07 01:37:42 dawes Exp $
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/XFree86.cpp,v 1.2 2000/06/15 20:50:02 dawes Exp $
.TH XFree86 1 "Version 4.0" "XFree86"
.SH NAME
XFree86 - X11R6 X server
@@ -559,13 +559,13 @@ Linux/m68k Frame Buffer Device driver
Guenther Kelleter, \fIguenther@Pool.Informatik.RWTH-Aachen.de\fP
Linux/m68k Frame Buffer Device driver
.TP 8
-Frederic Lepied, \fLepied@XFree86.Org\fP
+Frederic Lepied, \fILepied@XFree86.Org\fP
XInput extension integration. Wacom, joystick and extended mouse drivers.
.TP 8
-Patrick Lecoanet, \flecoanet@cena.dgac.fr\fP
+Patrick Lecoanet, \fIlecoanet@cena.dgac.fr\fP
Elographics touchscreen driver.
.TP 8
-Steven Lang, \ftiger@tyger.org\fP
+Steven Lang, \fItiger@tyger.org\fP
SummaSketch tablet driver.
.PP
... and many more people out there on the net who helped with beta-testing
diff --git a/xc/programs/Xserver/hw/xfree86/common/Imakefile b/xc/programs/Xserver/hw/xfree86/common/Imakefile
index eb1b75975..5801b594f 100644
--- a/xc/programs/Xserver/hw/xfree86/common/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/common/Imakefile
@@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/34 1996/10/27 11:05:08 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.114 2000/02/24 05:36:48 tsi Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.117 2000/06/30 17:15:10 dawes Exp $
@@ -32,6 +32,11 @@ XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/common/Imakefile,v 3.114 2000/02/
# endif
#endif
+#ifdef SparcArchitecture
+ SBUSSRC = xf86sbusBus.c
+ SBUSOBJ = xf86sbusBus.o
+#endif
+
#if BuildXKB
XKBDDXSRC = xf86XKB.c
XKBDDXOBJ = xf86XKB.o
@@ -101,6 +106,7 @@ SRCS = \
xf86cmap.c\
xf86PM.c \
$(KBD).c \
+ $(SBUSSRC) \
$(XF86_XINPUT_SRC) \
$(XINPUT_DEV_SRCS) \
$(XKBDDXSRC) \
@@ -131,6 +137,7 @@ OBJS = \
xf86xv.o \
xf86cmap.o\
xf86PM.o \
+ $(SBUSOBJ) \
$(XF86_XINPUT_OBJ) \
$(XKBDDXOBJ) \
$(BETAOBJ) \
@@ -158,7 +165,7 @@ CONSDEFINES = XFree86ConsoleDefines
EXP_DEFINES = -DEXPIRY_TIME=XF86ServerExpiry $(EXP_FORCE_DEFINES)
PROJECTROOT = ProjectRoot
DRIVERS = XF86CardDrivers
- IDRIVERS = mouse XInputDrivers
+ IDRIVERS = XInputDrivers
XCONFIGDEFINES = -DPROJECTROOT='"$(PROJECTROOT)"' \
-DDRIVERS='"$(DRIVERS)"' \
-DIDRIVERS='"$(IDRIVERS)"'
@@ -189,12 +196,16 @@ NormalLibraryTarget(xf86,$(OBJS))
LinkFile(xf86IniExt.c,$(SERVERSRC)/mi/miinitext.c)
LinkSourceFile(xf86Version.h,..)
LinkSourceFile(xf86Pci.h,$(XF86OSSRC)/bus)
+#ifdef SparcArchitecture
+LinkSourceFile(xf86Sbus.h,$(XF86OSSRC)/bus)
+#endif
#ifndef OS2Architecture
DependTarget()
#endif
InstallDriverSDKNonExecFile(compiler.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(fourcc.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86Module.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86Opt.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/hw/xfree86/common/compiler.h b/xc/programs/Xserver/hw/xfree86/common/compiler.h
index 621a2f3b1..b8d8123a4 100644
--- a/xc/programs/Xserver/hw/xfree86/common/compiler.h
+++ b/xc/programs/Xserver/hw/xfree86/common/compiler.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.58 2000/03/05 16:59:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.62 2000/06/25 12:35:53 alanh Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -436,45 +436,92 @@ static __inline__ unsigned int inl(unsigned long port)
#endif /* !Lynx */
-#include <string.h>
+/*
+ * 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 __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 __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 __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 __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 __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 __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 */
@@ -583,74 +630,210 @@ static __inline__ unsigned long ldw_u(unsigned short * r11)
#elif (defined(Lynx) || defined(linux)) && defined(__powerpc__)
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
extern volatile unsigned char *ioBase;
#define eieio() __asm__ __volatile__ ("eieio")
+static __inline__ unsigned char
+xf86ReadMmio8(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(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(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(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(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(void *base, const unsigned long offset,
+ const unsigned int 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(void *base, const unsigned long offset,
+ const unsigned int 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(void *base, const unsigned long offset,
+ const unsigned int 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(void *base, const unsigned long offset,
+ const unsigned long 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(void *base, const unsigned long offset,
+ const unsigned long 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(void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB8(base,offset,val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Le(void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB16Le(base,offset,val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio16Be(void *base, const unsigned long offset,
+ const unsigned int val)
+{
+ xf86WriteMmioNB16Be(base,offset,val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Le(void *base, const unsigned long offset,
+ const unsigned long val)
+{
+ xf86WriteMmioNB32Le(base,offset,val);
+ eieio();
+}
+
+static __inline__ void
+xf86WriteMmio32Be(void *base, const unsigned long offset,
+ const unsigned long val)
+{
+ xf86WriteMmioNB32Be(base,offset,val);
+ eieio();
+}
+
+
static __inline__ void
outb(unsigned short port, unsigned char value)
{
- *((volatile unsigned char *)(ioBase + port)) = value; eieio();
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio8((void *)ioBase,port,value);
}
static __inline__ void
outw(unsigned short port, unsigned short value)
{
- __asm__ __volatile__ (
- "sthbrx %0,%1,%2\n\t"
- "eieio"
- :
- : "r" (value), "b" (ioBase), "r" (port)
- : "memory"
- );
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio16Le((void *)ioBase,port,value);
}
static __inline__ void
outl(unsigned short port, unsigned int value)
{
- __asm__ __volatile__ (
- "stwbrx %0,%1,%2\n\t"
- "eieio"
- :
- : "r" (value), "b" (ioBase), "r" (port)
- : "memory"
- );
+ if(ioBase == MAP_FAILED) return;
+ xf86WriteMmio32Le((void *)ioBase,port,value);
}
static __inline__ unsigned int
inb(unsigned short port)
{
- unsigned char val;
-
- val = *((volatile unsigned char *)(ioBase + port));
- eieio();
- return(val);
+ if(ioBase == MAP_FAILED) return(0);
+ return(xf86ReadMmio8((void *)ioBase, port));
}
static __inline__ unsigned int
inw(unsigned short port)
{
- register unsigned short val;
-
- __asm__ ("lhbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (ioBase), "r" (port)
- );
- return(val);
+ if(ioBase == MAP_FAILED) return(0);
+ return(xf86ReadMmio16Le((void *)ioBase, port));
}
static __inline__ unsigned int
inl(unsigned short port)
{
- register unsigned long val;
-
- __asm__ ("lwbrx %0,%1,%2\n\t"
- "eieio"
- : "=r" (val)
- : "b" (ioBase), "r" (port)
- );
- return(val);
+ if(ioBase == MAP_FAILED) return(0);
+ return(xf86ReadMmio32Le((void *)ioBase, port));
}
#define ldq_u(p) ldl_u(p)
@@ -1625,16 +1808,6 @@ testinx(unsigned short port, unsigned char ind)
/* Some macros to hide the system dependencies for MMIO accesses */
#ifdef __alpha__
-extern void (*xf86WriteMmio8)(int Value, void *Base, unsigned long Offset);
-extern void (*xf86WriteMmio16)(int Value, void *Base, unsigned long Offset);
-extern void (*xf86WriteMmio32)(int Value, void *Base, unsigned long Offset);
-extern void (*xf86WriteMmioNB8)(int Value, void *Base, unsigned long Offset);
-extern void (*xf86WriteMmioNB16)(int Value, void *Base, unsigned long Offset);
-extern void (*xf86WriteMmioNB32)(int Value, void *Base, unsigned long Offset);
-extern int (*xf86ReadMmio8)(void *Base, unsigned long Offset);
-extern int (*xf86ReadMmio16)(void *Base, unsigned long Offset);
-extern int (*xf86ReadMmio32)(void *Base, unsigned long Offset);
-
#define MMIO_IN8(base, offset) (*xf86ReadMmio8)(base, offset)
#define MMIO_IN16(base, offset) (*xf86ReadMmio16)(base, offset)
# if defined (JENSEN_SUPPORT)
@@ -1655,7 +1828,31 @@ extern int (*xf86ReadMmio32)(void *Base, unsigned long Offset);
#define MMIO_OUT16(base, offset, val) (*xf86WriteMmio16)(val, base, offset)
#define MMIO_ONB8(base, offset, val) (*xf86WriteMmioNB8)(val, base, offset)
#define MMIO_ONB16(base, offset, val) (*xf86WriteMmioNB16)(val, base, offset)
-#else /* !__alpha__ */
+#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, val)
+ #define MMIO_ONB8(base, offset, val) xf86WriteMmioNB8(base, offset, 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, val)
+ #define MMIO_OUT32(base, offset, val) xf86WriteMmio32Be(base, offset, val)
+ #define MMIO_ONB16(base, offset, val) xf86WriteMmioNB16Be(base, offset, val)
+ #define MMIO_ONB32(base, offset, val) xf86WriteMmioNB32Be(base, offset, 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, val)
+ #define MMIO_OUT32(base, offset, val) xf86WriteMmio32Le(base, offset, val)
+ #define MMIO_ONB16(base, offset, val) xf86WriteMmioNB16Le(base, offset, val)
+ #define MMIO_ONB32(base, offset, val) xf86WriteMmioNB32Le(base, offset, val)
+ #endif
+#else /* !__alpha__ && !__powerpc__ */
#define MMIO_IN8(base, offset) *(volatile CARD8 *)(((CARD8*)(base)) + (offset))
#define MMIO_IN16(base, offset) *(volatile CARD16 *)(((CARD8*)(base)) + (offset))
#define MMIO_IN32(base, offset) *(volatile CARD32 *)(((CARD8*)(base)) + (offset))
diff --git a/xc/programs/Xserver/hw/xfree86/common/fourcc.h b/xc/programs/Xserver/hw/xfree86/common/fourcc.h
new file mode 100644
index 000000000..16985a252
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/fourcc.h
@@ -0,0 +1,89 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/fourcc.h,v 1.2 2000/06/14 18:20:33 dawes Exp $ */
+
+/*
+ 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.
+*/
+
+#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 \
+ }
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86.h b/xc/programs/Xserver/hw/xfree86/common/xf86.h
index a6b1ec176..aed451cc2 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.131 2000/03/02 23:15:03 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.140 2000/06/20 05:08:43 dawes Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
@@ -17,7 +17,11 @@
#include "xf86str.h"
#include "xf86Opt.h"
#include <X11/Xfuncproto.h>
+#ifndef IN_MODULE
#include <stdarg.h>
+#else
+#include "xf86_ansic.h"
+#endif
#include "propertyst.h"
@@ -80,20 +84,28 @@ Bool xf86IsPrimaryPci(pciVideoPtr pPci);
Bool xf86IsPrimaryIsa(void);
int xf86CheckPciGAType(pciVideoPtr pPci);
/* 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);
pciVideoPtr xf86GetPciInfoForEntity(int entityIndex);
-int xf86GetEntityForPciInfo(pciVideoPtr pvp);
+int xf86GetPciEntity(int bus, int dev, int func);
Bool xf86SetEntityFuncs(int entityIndex, EntityProc init,
EntityProc enter, EntityProc leave, pointer);
void xf86DeallocateResourcesForEntity(int entityIndex, long type);
-resPtr xf86RegisterResources(int entityIndex, resList list, int access);
+resPtr xf86RegisterResources(int entityIndex, resList list, int Access);
Bool xf86CheckPciMemBase(pciVideoPtr pPci, memType base);
-void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io,
- xf86AccessPtr p_mem, xf86AccessPtr p_io_mem,
- xf86AccessPtr *ppAccessOld);
+void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs);
Bool xf86IsEntityPrimary(int entityIndex);
Bool xf86FixPciResource(int entityIndex, int prt, memType alignment,
long type);
@@ -109,7 +121,7 @@ resRange xf86GetSparse(long type, memType fixed_bits,
memType xf86ChkConflict(resRange *rgp, int entityIndex);
Bool xf86IsPciDevPresent(int bus, int dev, int func);
ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
-Bool xf86NoSharedMem(int screenIndex);
+Bool xf86NoSharedResources(int screenIndex, resType res);
resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
pciVideoPtr xf86FindPciDeviceVendor(CARD16 vendorID, CARD16 deviceID,
char n, pciVideoPtr pvp_exclude);
@@ -120,8 +132,22 @@ Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCa
#ifdef async
Bool xf86QueueAsyncEvent(void (*func)(pointer),pointer arg);
#endif
-
+
+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, pciVideoPtr pVideo,
int chipset);
@@ -165,7 +191,7 @@ Bool xf86SetDepthBpp(ScrnInfoPtr scrp, int depth, int bpp, int fbbpp,
void xf86PrintDepthBpp(ScrnInfoPtr scrp);
Bool xf86SetWeight(ScrnInfoPtr scrp, rgb weight, rgb mask);
Bool xf86SetDefaultVisual(ScrnInfoPtr scrp, int visual);
-Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma gamma);
+Bool xf86SetGamma(ScrnInfoPtr scrp, Gamma newGamma);
void xf86SetDpi(ScrnInfoPtr pScrn, int x, int y);
void xf86SetBlackWhitePixels(ScreenPtr pScreen);
void xf86EnableDisableFBAccess(int scrnIndex, Bool enable);
@@ -216,7 +242,9 @@ Bool xf86GetModInDevAllowNonLocal(void);
Bool xf86GetModInDevEnabled(void);
Bool xf86GetAllowMouseOpenFail(void);
Bool xf86IsPc98(void);
+pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name);
pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name);
+void xf86UnloadSubModule(pointer mod);
Bool xf86LoaderCheckSymbol(const char *name);
void xf86LoaderReqSymLists(const char **, ...);
void xf86LoaderReqSymbols(const char *, ...);
@@ -243,14 +271,28 @@ 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);
-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);
+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);
+/* 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,
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c
index ecef40d68..d4e514b78 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.44 2000/03/05 23:47:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.c,v 1.52 2000/06/30 17:15:10 dawes Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
*/
@@ -29,6 +29,7 @@
/* 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};
@@ -76,13 +77,16 @@ static void notifyStateChange(xf86NotifyState state);
/*
* Call the bus probes relevant to the architecture.
*
- * The only one available so far is for PCI
+ * The only one available so far is for PCI and SBUS.
*/
void
xf86BusProbe(void)
{
xf86PciProbe();
+#ifdef __sparc__
+ xf86SbusProbe();
+#endif
}
/*
@@ -113,6 +117,8 @@ StringToBusType(const char* busID, const char **retID)
ret = BUS_PCI;
if (!xf86NameCmp(p, "isa"))
ret = BUS_ISA;
+ if (!xf86NameCmp(p, "sbus"))
+ ret = BUS_SBUS;
if (ret != BUS_NONE)
if (retID)
*retID = busID + strlen(p) + 1;
@@ -164,6 +170,8 @@ xf86AllocateEntity(void)
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);
}
@@ -240,12 +248,24 @@ xf86SetEntityFuncs(int entityIndex, EntityProc init, EntityProc enter,
return TRUE;
}
+Bool
+xf86DriverHasEntities(DriverPtr drvp)
+{
+ int i;
+ for (i = 0; i < xf86NumEntities; i++) {
+ if (xf86Entities[i]->driver == drvp)
+ return TRUE;
+ }
+ return FALSE;
+}
+
void
xf86AddEntityToScreen(ScrnInfoPtr pScrn, int entityIndex)
{
if (entityIndex == -1)
return;
- if (xf86Entities[entityIndex]->inUse)
+ if (xf86Entities[entityIndex]->inUse &&
+ !(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL))
FatalError("Requested Entity already in use!\n");
pScrn->numEntities++;
@@ -255,8 +275,31 @@ xf86AddEntityToScreen(ScrnInfoPtr pScrn, int 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;
+}
+
+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.
+ */
ScrnInfoPtr
xf86FindScreenForEntity(int entityIndex)
{
@@ -328,6 +371,8 @@ xf86ClearEntityListForScreen(int scrnIndex)
xf86DeallocateResourcesForEntity(i, ResShared);
}
xfree(xf86Screens[scrnIndex]->entityList);
+ if (xf86Screens[scrnIndex]->entityInstanceList)
+ xfree(xf86Screens[scrnIndex]->entityInstanceList);
if (xf86Screens[scrnIndex]->CurrentAccess->pIoAccess
== (EntityAccessPtr) xf86Screens[scrnIndex]->access)
xf86Screens[scrnIndex]->CurrentAccess->pIoAccess = NULL;
@@ -335,6 +380,7 @@ xf86ClearEntityListForScreen(int scrnIndex)
== (EntityAccessPtr) xf86Screens[scrnIndex]->access)
xf86Screens[scrnIndex]->CurrentAccess->pMemAccess = NULL;
xf86Screens[scrnIndex]->entityList = NULL;
+ xf86Screens[scrnIndex]->entityInstanceList = NULL;
}
void
@@ -356,6 +402,25 @@ xf86DeallocateResourcesForEntity(int entityIndex, long type)
}
/*
+ * 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;
+}
+
+/*
* xf86GetEntityInfo() -- This function hands information from the
* EntityRec struct to the drivers. The EntityRec structure itself
* remains invisible to the driver.
@@ -364,6 +429,7 @@ EntityInfoPtr
xf86GetEntityInfo(int entityIndex)
{
EntityInfoPtr pEnt;
+ int i;
if (entityIndex >= xf86NumEntities)
return NULL;
@@ -374,11 +440,46 @@ xf86GetEntityInfo(int entityIndex)
pEnt->active = xf86Entities[entityIndex]->active;
pEnt->chipset = xf86Entities[entityIndex]->chipset;
pEnt->resources = xf86Entities[entityIndex]->resources;
- pEnt->device = xf86Entities[entityIndex]->device;
+ pEnt->driver = xf86Entities[entityIndex]->driver;
+ if (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;
}
+int
+xf86GetNumEntityInstances(int entityIndex)
+{
+ if (entityIndex >= xf86NumEntities)
+ return -1;
+
+ return xf86Entities[entityIndex]->numInstances;
+}
+
+GDevPtr
+xf86GetDevFromEntity(int entityIndex, int instance)
+{
+ int i;
+
+ /* We might not use AddDevtoEntity */
+ if (!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.
*/
@@ -723,8 +824,8 @@ xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn)
}
void
-xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io, xf86AccessPtr p_mem,
- xf86AccessPtr p_io_mem, xf86AccessPtr *ppAccessOld)
+xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+ xf86SetAccessFuncPtr oldFuncs)
{
AccessFuncPtr rac;
@@ -733,16 +834,16 @@ xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io, xf86AccessPtr p_mem,
rac = xf86Entities[pEnt->index]->rac;
- if (p_mem == p_io_mem && p_mem && p_io)
+ if (funcs->mem == funcs->io_mem && funcs->mem && funcs->io)
xf86Entities[pEnt->index]->entityProp |= NO_SEPARATE_MEM_FROM_IO;
- if (p_io == p_io_mem && p_mem && p_io)
+ if (funcs->io == funcs->io_mem && funcs->mem && funcs->io)
xf86Entities[pEnt->index]->entityProp |= NO_SEPARATE_IO_FROM_MEM;
- rac->mem_new = p_mem;
- rac->io_new = p_io;
- rac->io_mem_new = p_io_mem;
+ rac->mem_new = funcs->mem;
+ rac->io_new = funcs->io;
+ rac->io_mem_new = funcs->io_mem;
- rac->old = ppAccessOld;
+ rac->old = oldFuncs;
}
/*
@@ -971,7 +1072,8 @@ needCheck(resPtr pRes, long type, int entityIndex, xf86State state)
* function call.
*/
static memType
-checkConflict(resRange *rgp, resPtr pRes, int entityIndex, xf86State state)
+checkConflict(resRange *rgp, resPtr pRes, int entityIndex,
+ xf86State state, Bool ignoreIdentical)
{
memType ret;
@@ -987,9 +1089,12 @@ checkConflict(resRange *rgp, resPtr pRes, int entityIndex, xf86State state)
rgp->rEnd,rgp->rBegin);
return 0;
}
- if ((ret = checkConflictBlock(rgp, pRes)))
- return ret;
- break;
+ 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)"
@@ -997,8 +1102,11 @@ checkConflict(resRange *rgp, resPtr pRes, int entityIndex, xf86State state)
rgp->rBase, rgp->rMask);
return 0;
}
- if ((ret = checkConflictSparse(rgp, pRes)))
- return ret;
+ if ((ret = checkConflictSparse(rgp, pRes))) {
+ if (!ignoreIdentical || (rgp->rBase != pRes->sparse_base)
+ || (rgp->rMask != pRes->sparse_mask))
+ return ret;
+ }
break;
}
pRes = pRes->next;
@@ -1012,7 +1120,7 @@ checkConflict(resRange *rgp, resPtr pRes, int entityIndex, xf86State state)
memType
ChkConflict(resRange *rgp, resPtr res, xf86State state)
{
- return checkConflict(rgp, res, -2, state);
+ return checkConflict(rgp, res, -2, state,FALSE);
}
/*
@@ -1023,7 +1131,7 @@ ChkConflict(resRange *rgp, resPtr res, xf86State state)
memType
xf86ChkConflict(resRange *rgp, int entityIndex)
{
- return checkConflict(rgp, Acc, entityIndex, SETUP);
+ return checkConflict(rgp, Acc, entityIndex, SETUP,FALSE);
}
/*
@@ -1184,6 +1292,22 @@ xf86PrintResList(int verb, resPtr list)
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++;
}
@@ -1517,6 +1641,7 @@ xf86GetResourcesImplicitly(int entityIndex)
switch (xf86Entities[entityIndex]->bus.type) {
case BUS_ISA:
case BUS_NONE:
+ case BUS_SBUS:
return NULL;
case BUS_PCI:
return GetImplicitPciResources(entityIndex);
@@ -1548,6 +1673,7 @@ convertRange2Host(int entityIndex, resRange *pRange)
* If list is NULL it tries to obtain resources implicitly. Function
* returns a resPtr listing all resources not successfully registered.
*/
+
resPtr
xf86RegisterResources(int entityIndex, resList list, int access)
{
@@ -1570,7 +1696,7 @@ xf86RegisterResources(int entityIndex, resList list, int access)
range.type = (range.type & ~ResAccMask) | (access & ResAccMask);
}
range.type &= ~ResEstimated; /* Not allowed for drivers */
- if(xf86ChkConflict(&range,entityIndex))
+ if (checkConflict(&range, Acc, entityIndex, SETUP,TRUE))
res = xf86AddResToList(res,&range,entityIndex);
else {
Acc = xf86AddResToList(Acc,&range,entityIndex);
@@ -1755,6 +1881,7 @@ busTypeSpecific(EntityPtr pEnt, xf86State state, xf86AccessPtr *acc_mem,
switch (pEnt->bus.type) {
case BUS_ISA:
+ case BUS_SBUS:
*acc_mem = *acc_io = *acc_mem_io = &AccessNULL;
break;
break;
@@ -1830,50 +1957,49 @@ setAccess(EntityPtr pEnt, xf86State state)
switch(pEnt->access->rt) {
case IO:
pEnt->access->pAccess = acc_io;
- 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) = org_io;
- } else if (org_io->AccessEnable) {
- /* driver doesn't want it - enable generic access */
- org_io->AccessEnable(org_io->arg);
- }
- }
break;
case MEM:
pEnt->access->pAccess = acc_mem;
- 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) = org_mem;
- } else if (org_mem->AccessEnable) {
- /* driver doesn't want it - enable generic access */
- org_mem->AccessEnable(org_mem->arg);
- }
- }
break;
case MEM_IO:
pEnt->access->pAccess = acc_mem_io;
- 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) = 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);
- }
- }
break;
default: /* no conflicts at all */
pEnt->access->pAccess = NULL; /* remove from RAC */
- if (pEnt->rac && pEnt->rac->old)
- (*pEnt->rac->old) = NULL;
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->AccessEnable)
@@ -2115,7 +2241,8 @@ xf86ClaimFixedResources(resList list, int entityIndex)
} else {
range.type |= ResEstimated;
if (!xf86ChkConflict(&range, entityIndex) &&
- !checkConflict(&range, AccReducers, entityIndex, SETUP)) {
+ !checkConflict(&range, AccReducers, entityIndex,
+ SETUP, FALSE)) {
range.type &= ~(ResEstimated | ResBios);
AccReducers =
xf86AddResToList(AccReducers, &range, entityIndex);
@@ -2192,7 +2319,7 @@ checkRoutingForScreens(xf86State state)
while (pAcc) {
if (pAcc->entityIndex == entityIndex)
if (checkConflict(&pAcc->val,pResVGA,
- entityIndex,state)) {
+ entityIndex,state,FALSE)) {
if (vga && vga != pEnt->busAcc) {
xf86Msg(X_ERROR, "Screen %i needs vga routed to"
"different buses - deleting\n",i);
@@ -2241,7 +2368,7 @@ xf86PostProbe(void)
xf86Entities[i]->resources = NULL;
resp_x = NULL;
while (resp) {
- if (! (val = checkConflict(&resp->val,acc,i,SETUP))) {
+ if (! (val = checkConflict(&resp->val,acc,i,SETUP,FALSE))) {
resp->res_type &= ~(ResBios); /* just used for chkConflict() */
tmp = resp_x;
resp_x = resp;
@@ -2250,7 +2377,7 @@ xf86PostProbe(void)
#ifdef REDUCER
} else {
resp->res_type |= ResEstimated;
- if (!checkConflict(&resp->val, acc, i, SETUP)) {
+ if (!checkConflict(&resp->val, acc, i, SETUP, FALSE)) {
resp->res_type &= ~(ResEstimated | ResBios);
tmp = AccReducers;
AccReducers = resp;
@@ -2303,7 +2430,7 @@ checkRequiredResources(int entityIndex)
range = pAcc->val;
/* ResAny to find conflicts with anything. */
range.type = (range.type & ~ResAccMask) | ResAny | ResBios;
- if (checkConflict(&range,Acc,entityIndex,OPERATING))
+ if (checkConflict(&range,Acc,entityIndex,OPERATING,FALSE))
switch (pAcc->res_type & ResPhysMask) {
case ResMem:
pEnt->entityProp |= NEED_MEM_SHARED;
@@ -2434,15 +2561,11 @@ xf86PostScreenInit(void)
flags = 0;
if (needRACforMem) {
flags |= xf86Screens[i]->racMemFlags;
-#ifdef DEBUG
- ErrorF("Screen %d is using RAC for mem\n", i);
-#endif
+ xf86ErrorFVerb(3, "Screen %d is using RAC for mem\n", i);
}
if (needRACforIo) {
flags |= xf86Screens[i]->racIoFlags;
-#ifdef DEBUG
- ErrorF("Screen %d is using RAC for io\n", i);
-#endif
+ xf86ErrorFVerb(3, "Screen %d is using RAC for io\n", i);
}
#ifdef XFree86LOADER
@@ -2802,7 +2925,7 @@ xf86FindPrimaryDevice()
static void
CheckGenericGA()
{
-#if !defined(__sparc__) && !defined(__powerpc__) /* FIXME ?? */
+#if !defined(__sparc__) && !defined(__powerpc__) && !defined(__mips__) /* FIXME ?? */
CARD16 GenericIOBase = VGAHW_GET_IOBASE();
CARD8 CurrentValue, TestValue;
@@ -2824,7 +2947,7 @@ CheckGenericGA()
}
Bool
-xf86NoSharedMem(int screenIndex)
+xf86NoSharedResources(int screenIndex,resType res)
{
int j;
@@ -2832,9 +2955,25 @@ xf86NoSharedMem(int screenIndex)
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;
+ return FALSE;
+ break;
+ case MEM_IO:
+ if ( xf86Entities[xf86Screens[screenIndex]->entityList[j]]->entityProp
+ & NEED_SHARED)
+ return FALSE;
+ break;
+ case NONE:
+ break;
+ }
}
return TRUE;
}
@@ -2904,3 +3043,122 @@ xf86QueueAsyncEvent(void (*func)(pointer),pointer arg)
return TRUE;
}
#endif
+
+/* Multihead accel sharing accessor functions and entity Private handling */
+
+int
+xf86GetLastScrnFlag(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ return(xf86Entities[entityIndex]->lastScrnFlag);
+ } else {
+ return -1;
+ }
+}
+
+void
+xf86SetLastScrnFlag(int entityIndex, int scrnIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->lastScrnFlag = scrnIndex;
+ }
+}
+
+Bool
+xf86IsEntityShared(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & IS_SHARED_ACCEL) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetEntityShared(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= IS_SHARED_ACCEL;
+ }
+}
+
+Bool
+xf86IsEntitySharable(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & ACCEL_IS_SHARABLE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetEntitySharable(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= ACCEL_IS_SHARABLE;
+ }
+}
+
+Bool
+xf86IsPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ if(xf86Entities[entityIndex]->entityProp & SA_PRIM_INIT_DONE) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+void
+xf86SetPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp |= SA_PRIM_INIT_DONE;
+ }
+}
+
+void
+xf86ClearPrimInitDone(int entityIndex)
+{
+ if(entityIndex < xf86NumEntities) {
+ xf86Entities[entityIndex]->entityProp &= ~SA_PRIM_INIT_DONE;
+ }
+}
+
+
+/*
+ * Allocate a private in the entities.
+ */
+
+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;
+}
+
+DevUnion *
+xf86GetEntityPrivate(int entityIndex, int privIndex)
+{
+ if (entityIndex >= xf86NumEntities || privIndex >= xf86EntityPrivateCount)
+ return NULL;
+
+ return &(xf86Entities[entityIndex]->entityPrivates[privIndex]);
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h
index 2668d1f0d..41ca3ecad 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Bus.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.h,v 1.13 2000/03/05 17:04:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Bus.h,v 1.16 2000/06/20 05:08:43 dawes Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
*/
@@ -13,12 +13,15 @@
#define _XF86_BUS_H
#include "xf86pciBus.h"
+#ifdef __sparc__
+#include "xf86sbusBus.h"
+#endif
typedef struct racInfo {
xf86AccessPtr mem_new;
xf86AccessPtr io_new;
xf86AccessPtr io_mem_new;
- xf86AccessPtr *old;
+ xf86SetAccessFuncPtr old;
} AccessFuncRec, *AccessFuncPtr;
@@ -30,7 +33,6 @@ typedef struct {
EntityProc entityEnter;
EntityProc entityLeave;
pointer private;
- GDevPtr device;
resPtr resources;
Bool active;
Bool inUse;
@@ -38,6 +40,10 @@ typedef struct {
EntityAccessPtr access;
AccessFuncPtr rac;
pointer busAcc;
+ int lastScrnFlag;
+ DevUnion * entityPrivates;
+ int numInstances;
+ GDevPtr * devices;
} EntityRec, *EntityPtr;
/* asynchronous event handling */
@@ -57,12 +63,16 @@ typedef struct _AsyncQRec {
#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_SHARED (NEED_MEM_SHARED | NEED_IO_SHARED)
#define busType bus.type
#define pciBusId bus.id.pci
#define isaBusId bus.id.isa
+#define sbusBusId bus.id.sbus
struct x_BusAccRec;
typedef void (*BusAccProcPtr)(struct x_BusAccRec *ptr);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Config.c b/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
index d611d5ea0..fcfc40bf7 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Config.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.214 2000/03/08 05:38:36 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.226 2000/06/20 05:08:43 dawes Exp $ */
/*
@@ -14,6 +14,11 @@
* Author: Dirk Hohndel <hohndel@XFree86.Org>
*/
+#ifdef XF86DRI
+#include <sys/types.h>
+#include <grp.h>
+#endif
+
#include "xf86.h"
#include "xf86Parser.h"
#include "xf86tokens.h"
@@ -40,6 +45,16 @@ extern DeviceAssocRec mouse_assoc;
#define SUPPORT_PC98
#endif
+#ifdef __EMX__
+#define ROOT_CONFIGPATH "%A," "%R," \
+ "%E," \
+ "%D/%X," \
+ "%&/XFree86/lib/X11/%X-%M," "%&/XFree86/lib/X11/%X," "%&XFree86/lib/X11/%X," \
+ "%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
+ "%P/etc/X11/%X,"
+#define USER_CONFIGPATH ROOT_CONFIGPATH
+#endif
+
/*
* These paths define the way the config file search is done. The escape
* sequences are documented in parser/scan.c.
@@ -256,6 +271,7 @@ char **
xf86DriverlistFromConfig()
{
int count = 0;
+ int j;
char **modulearray;
screenLayoutPtr slp;
@@ -273,8 +289,6 @@ xf86DriverlistFromConfig()
* Walk the list of driver lines in active "Device" sections to
* determine now many implicitly loaded modules there are.
*
- * XXX The set of inactive "Device" sections needs to be handled too,
- * when the rest of the supporting code is done.
*/
if (xf86ConfigLayout.screens) {
slp = xf86ConfigLayout.screens;
@@ -283,6 +297,13 @@ xf86DriverlistFromConfig()
}
}
+ /*
+ * Handle the set of inactive "Device" sections.
+ */
+ j = 0;
+ while (xf86ConfigLayout.inactives[j++].identifier)
+ count++;
+
if (count == 0)
return NULL;
@@ -297,6 +318,12 @@ xf86DriverlistFromConfig()
count++;
slp++;
}
+
+ j = 0;
+
+ while (xf86ConfigLayout.inactives[j].identifier)
+ modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
+
modulearray[count] = NULL;
/* Remove duplicates */
@@ -466,10 +493,9 @@ GenerateDriverlist(char * dirname, char * drivernames)
}
}
- driverlist[count++] = NULL;
+ driverlist[count] = NULL;
xfree(clist);
xfree(dlist);
- driverlist = xnfrealloc(driverlist, count * sizeof(char *));
}
#endif /* XFree86LOADER */
@@ -658,6 +684,7 @@ typedef enum {
FLAG_PCIPROBE2,
FLAG_PCIFORCECONFIG1,
FLAG_PCIFORCECONFIG2,
+ FLAG_PCIOSCONFIG,
FLAG_SAVER_BLANKTIME,
FLAG_DPMS_STANDBYTIME,
FLAG_DPMS_SUSPENDTIME,
@@ -697,6 +724,8 @@ static OptionInfoRec FlagOptions[] = {
{0}, FALSE },
{ FLAG_PCIFORCECONFIG2, "PciForceConfig2", 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,
@@ -807,6 +836,8 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
xf86Info.pciFlags = PCIForceConfig1;
if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG2))
xf86Info.pciFlags = PCIForceConfig2;
+ if (xf86IsOptionSet(FlagOptions, FLAG_PCIOSCONFIG))
+ xf86Info.pciFlags = PCIOsConfig;
/*
* XXX This should be handled like a proper boolean option -- see further
* above for examples.
@@ -1470,7 +1501,7 @@ configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen)
return FALSE;
servlayoutp->id = "(implicit)";
servlayoutp->screens = slp;
- servlayoutp->inactives = NULL;
+ 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(IDevRec));
@@ -1819,6 +1850,7 @@ configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
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)
@@ -1844,13 +1876,22 @@ configDRI(XF86ConfDRIPtr drip)
int count = 0;
XF86ConfBuffersPtr bufs;
int i;
+ struct group *grp;
- xf86ConfigDRI.group = drip ? drip->dri_group : NULL;
- xf86ConfigDRI.mode = drip ? drip->dri_mode : NULL;
+ 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;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c b/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c
index 35428bc26..3c72e503d 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Configure.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.27 2000/03/04 03:58:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Configure.c,v 3.39 2000/06/23 11:01:51 alanh Exp $ */
/*
* Copyright 2000 by Alan Hourihane, Sychdyn, North Wales.
*
@@ -41,10 +41,18 @@
#include "Configint.h"
#include "vbe.h"
#include "xf86DDC.h"
+#ifdef __sparc__
+#include "xf86Bus.h"
+#include "xf86Sbus.h"
+#endif
+#include "globals.h"
typedef struct _DevToConfig {
GDevRec GDev;
pciVideoPtr pVideo;
+#ifdef __sparc__
+ sbusDevicePtr sVideo;
+#endif
int iDriver;
} DevToConfigRec, *DevToConfigPtr;
@@ -55,10 +63,22 @@ xf86MonPtr ConfiguredMonitor;
Bool xf86DoConfigurePass1 = TRUE;
Bool foundMouse = FALSE;
+#ifndef __EMX__
+static char *DFLT_MOUSE_DEV = "/dev/mouse";
+static char *DFLT_MOUSE_PROTO = "auto";
+#else
+#define DFLT_MOUSE_DEV "mouse$"
+#define DFLT_MOUSE_PROTO "OS2Mouse"
+#endif
+
static void
GetPciCard(int vendor, int chipType, int *vendor1, int *vendor2, int *card)
{
int k, j;
+
+ *vendor1 = 0;
+ *vendor2 = 0;
+ *card = 0;
k = 0;
while (xf86PCIVendorNameInfo[k].token) {
@@ -92,21 +112,26 @@ GetPciCard(int vendor, int chipType, int *vendor1, int *vendor2, int *card)
* the caller fill in the rest and/or change it as it sees fit.
*/
GDevPtr
-xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
+xf86AddBusDeviceToConfigure(const char *driver, BusType bus, void *busData, int chipset)
{
- int busType, i, j;
+ int i, j;
+ pciVideoPtr pVideo = NULL;
if (xf86DoProbe || !xf86DoConfigure || !xf86DoConfigurePass1)
return NULL;
/* Check for duplicates */
- if (pVideo) {
+ switch (bus) {
+ case BUS_PCI:
+ pVideo = (pciVideoPtr) busData;
for (i = 0; i < nDevToConfig; i++)
- if ((DevToConfig[i].pVideo->bus == pVideo->bus) &&
+ if (DevToConfig[i].pVideo &&
+ (DevToConfig[i].pVideo->bus == pVideo->bus) &&
(DevToConfig[i].pVideo->device == pVideo->device) &&
(DevToConfig[i].pVideo->func == pVideo->func))
return NULL;
- } else {
+ break;
+ case BUS_ISA:
/*
* This needs to be revisited as it doesn't allow for non-PCI
* multihead.
@@ -116,6 +141,17 @@ xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
for (i = 0; i < nDevToConfig; i++)
if (!DevToConfig[i].pVideo)
return NULL;
+ break;
+#ifdef __sparc__
+ 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 */
@@ -129,18 +165,23 @@ xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
NewDevice.GDev.chipID = NewDevice.GDev.chipRev = NewDevice.GDev.irq = -1;
NewDevice.iDriver = CurrentDriver;
- NewDevice.pVideo = pVideo;
/* 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++);
- if (pVideo) {
+ switch (bus) {
+ case BUS_PCI: {
int vendor1, vendor2, card;
+ NewDevice.pVideo = pVideo;
GetPciCard(pVideo->vendor, pVideo->chipType,
&vendor1, &vendor2, &card);
+ if (vendor1 == 0 || (vendor2 == 0 && card == 0)) {
+ FatalError("\nXFree86 has found a valid card configuration.\nUnfortunately the appropriate data has not been added to xf86PciInfo.h.\nPlease forward 'scanpci -v' output to XFree86 support team.");
+ }
+
# define VendorName xf86PCIVendorNameInfo[vendor1].name
# define CardName xf86PCIVendorInfo[vendor2].Device[card].DeviceName
@@ -161,26 +202,59 @@ xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
# undef VendorName
# undef CardName
- busType = BUS_PCI;
if (chipset < 0)
chipset = (pVideo->vendor << 16) || pVideo->chipType;
- } else {
+ }
+ break;
+ case BUS_ISA:
NewDevice.GDev.identifier = "ISA Adapter";
NewDevice.GDev.busID = "ISA";
- busType = BUS_ISA;
+ break;
+#ifdef __sparc__
+ 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 =
(*xf86DriverList[CurrentDriver]->AvailableOptions)(chipset,
- busType);
+ bus);
return &NewDevice.GDev;
# undef NewDevice
}
+/*
+ * Backwards compatibility
+ */
+GDevPtr
+xf86AddDeviceToConfigure(const char *driver, pciVideoPtr pVideo, int chipset)
+{
+ return xf86AddBusDeviceToConfigure(driver, pVideo ? BUS_PCI : BUS_ISA,
+ pVideo, chipset);
+}
+
static XF86ConfInputPtr
configureInputSection (void)
{
@@ -194,8 +268,18 @@ configureInputSection (void)
/* Crude mechanism to auto-detect mouse (os dependent) */
{
int fd;
+#ifdef linux
+ int len;
+ char path[32];
+
+ if ((len = readlink(DFLT_MOUSE_DEV, path, sizeof(path) - 1)) > 0) {
+ path[len] = '\0';
+ if (strstr(path, "psaux") != NULL)
+ DFLT_MOUSE_PROTO = "PS/2";
+ }
+#endif
- fd = open("/dev/mouse", 0);
+ fd = open(DFLT_MOUSE_DEV, 0);
if (fd != -1) {
foundMouse = TRUE;
close(fd);
@@ -207,11 +291,10 @@ configureInputSection (void)
mouse->inp_identifier = "Mouse0";
mouse->inp_driver = "mouse";
mouse->inp_option_lst =
- addNewOption(mouse->inp_option_lst, "Protocol", "auto");
+ addNewOption(mouse->inp_option_lst, "Protocol", DFLT_MOUSE_PROTO);
mouse->inp_option_lst =
- addNewOption(mouse->inp_option_lst, "Device", "/dev/mouse");
+ addNewOption(mouse->inp_option_lst, "Device", DFLT_MOUSE_DEV);
ptr = (XF86ConfInputPtr)addListItem((glp)ptr, (glp)mouse);
-
return ptr;
}
@@ -245,7 +328,8 @@ configureScreenSection (int screennum)
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 = strdup(DevToConfig[screennum].GDev.identifier);
+ ptr->scrn_device_str = xf86confmalloc(16);
+ sprintf(ptr->scrn_device_str, "Card%d", screennum);
for (i=0; i<6; i++)
{
@@ -264,13 +348,16 @@ configureScreenSection (int screennum)
static XF86ConfDevicePtr
configureDeviceSection (int screennum)
{
+ char identifier[16];
OptionInfoPtr p;
int i = 0;
Bool foundFBDEV = FALSE;
parsePrologue (XF86ConfDevicePtr, XF86ConfDeviceRec)
/* Move device info to parser structure */
- ptr->dev_identifier = DevToConfig[screennum].GDev.identifier;
+ 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;
@@ -377,11 +464,18 @@ configureLayoutSection (void)
aptr->list.next = NULL;
aptr->adj_x = 0;
aptr->adj_y = 0;
- aptr->adj_refscreen = 0;
- aptr->adj_scrnum = 0;
+ aptr->adj_scrnum = scrnum;
aptr->adj_screen_str = xnfalloc(18);
sprintf(aptr->adj_screen_str, "Screen%d", scrnum);
- aptr->adj_where = CONF_ADJ_ABSOLUTE;
+ 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)addListItem((glp)ptr->lay_adjacency_lst,
(glp)aptr);
@@ -454,6 +548,15 @@ configureFilesSection (void)
{
parsePrologue (XF86ConfFilesPtr, XF86ConfFilesRec)
+#ifdef XFree86LOADER
+ if (xf86ModulePath && xf86ModPathFrom == X_CMDLINE)
+ ptr->file_modulepath = strdup(xf86ModulePath);
+#endif
+ if (xf86fpFlag && defaultFontPath)
+ ptr->file_fontpath = strdup(defaultFontPath);
+ if (xf86coFlag && rgbPath)
+ ptr->file_rgbpath = strdup(rgbPath);
+
return ptr;
}
@@ -587,13 +690,16 @@ DoConfigure()
xf86config->conf_videoadaptor_lst = configureVideoAdaptorSection();
xf86config->conf_modes_lst = configureModesSection();
xf86config->conf_vendor_lst = configureVendorSection();
- xf86config->conf_dri = configureDRISection();
+/* xf86config->conf_dri = configureDRISection();*/
xf86config->conf_input_lst = configureInputSection();
xf86config->conf_layout_lst = configureLayoutSection();
if (!(home = getenv("HOME")))
home = "/";
{
+#ifdef __EMX__
+#define PATH_MAX 2048
+#endif
char homebuf[PATH_MAX];
/* getenv might return R/O memory, as with OS/2 */
strncpy(homebuf,home,PATH_MAX-1);
@@ -620,7 +726,10 @@ DoConfigure()
xf86DoConfigurePass1 = FALSE;
+ i = -1;
for (screennum = 0; screennum < nDevToConfig; screennum++) {
+ if (i == DevToConfig[screennum].iDriver) continue;
+
i = DevToConfig[screennum].iDriver;
(*xf86DriverList[i]->Probe)(xf86DriverList[i], 0);
@@ -628,6 +737,12 @@ DoConfigure()
xf86SetPciVideo(NULL,NONE);
}
+ if (nDevToConfig != xf86NumScreens) {
+ ErrorF("Number of created screens does not match number of detected"
+ " devices.\n Configuration failed.\n");
+ goto bail;
+ }
+
xf86PostProbe();
xf86EntityInit();
@@ -667,10 +782,12 @@ DoConfigure()
ErrorF("\nXFree86 is not able to detect your mouse.\n"
"Edit the file and correct the Device.\n");
} else {
- ErrorF("\nXFree86 detected your mouse at device /dev/mouse.\n"
+#ifndef __EMX__ /* OS/2 definitely has a mouse */
+ ErrorF("\nXFree86 detected your mouse at device %s.\n"
"Please check your config if the mouse is still not\n"
"operational, as by default XFree86 tries to autodetect\n"
- "the protocol.\n");
+ "the protocol.\n",DFLT_MOUSE_DEV);
+#endif
}
if (xf86NumScreens > 1) {
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c b/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c
index 8609bdfdc..cb43b9418 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.26 2000/02/14 02:54:03 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Cursor.c,v 3.28 2000/06/24 00:33:54 dawes Exp $ */
/* $XConsortium: xf86Cursor.c /main/10 1996/10/19 17:58:23 kaleb $ */
#define NEED_EVENTS
@@ -233,8 +233,10 @@ xf86ZoomViewport (ScreenPtr pScreen, int zoom)
if (pScr->AdjustFrame != NULL)
(pScr->AdjustFrame)(pScr->scrnIndex, pScr->frameX0, pScr->frameY0, 0);
- miPointerPosition(&px, &py);
- xf86WarpCursor(pScreen, px, py);
+ if (pScreen == miPointerCurrentScreen()) {
+ miPointerPosition(&px, &py);
+ xf86WarpCursor(pScreen, px, py);
+ }
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c b/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c
index 58e78cf04..bbc166ba0 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86DGA.c
@@ -3,7 +3,7 @@
Written by Mark Vojkovich
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.32 2000/01/21 01:12:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86DGA.c,v 1.37 2000/06/30 19:06:56 keithp Exp $ */
#include "xf86.h"
#include "xf86str.h"
@@ -74,6 +74,8 @@ typedef struct {
FakedVisualList *fakedVisuals;
ColormapPtr dgaColormap;
ColormapPtr savedColormap;
+ Bool grabMouse;
+ Bool grabKeyboard;
} DGAScreenRec, *DGAScreenPtr;
@@ -88,11 +90,10 @@ DGAInit(
DGAScreenPtr pScreenPriv;
int i;
- if(!funcs->Sync || !funcs->SetMode || !funcs->SetViewport ||
- !funcs->GetViewport || !funcs->OpenFramebuffer)
+ if(!funcs->SetMode || !funcs->OpenFramebuffer)
return FALSE;
- if(!modes || !num)
+ if(!modes || num <= 0)
return FALSE;
if(DGAGeneration != serverGeneration) {
@@ -107,13 +108,16 @@ DGAInit(
pScreenPriv->pScrn = pScrn;
pScreenPriv->numModes = num;
pScreenPriv->modes = modes;
- pScreenPriv->current = NULL;
+ 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;
@@ -271,6 +275,10 @@ DGASetDGAMode(
FreeMarkedVisuals(pScreen);
}
+
+ pScreenPriv->grabMouse = FALSE;
+ pScreenPriv->grabKeyboard = FALSE;
+
return Success;
}
@@ -333,13 +341,28 @@ DGASetDGAMode(
devRet->pPix = device->pPix = pPix;
pScreenPriv->current = device;
pScreenPriv->pixmapMode = FALSE;
-
+ pScreenPriv->grabMouse = TRUE;
+ pScreenPriv->grabKeyboard = TRUE;
+
return Success;
}
+
/*********** exported ones ***************/
+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;
+ }
+}
Bool
DGAChangePixmapMode(int index, int *x, int *y, int mode)
@@ -402,8 +425,8 @@ DGAAvailable(int index)
if(DGAScreenIndex < 0)
return FALSE;
- if (!xf86NoSharedMem(((ScrnInfoPtr)screenInfo.screens[index]->
- devPrivates[xf86ScreenIndex].ptr)->scrnIndex))
+ if (!xf86NoSharedResources(((ScrnInfoPtr)screenInfo.screens[index]->
+ devPrivates[xf86ScreenIndex].ptr)->scrnIndex,MEM))
return FALSE;
if(DGA_GET_SCREEN_PRIV(screenInfo.screens[index]))
@@ -508,7 +531,10 @@ DGAGetViewportStatus(int index)
/* We rely on the extension to check that DGA is active */
- return((*pScreenPriv->funcs->GetViewport)(pScreenPriv->pScrn));
+ if (!pScreenPriv->funcs->GetViewport)
+ return 0;
+
+ return (*pScreenPriv->funcs->GetViewport)(pScreenPriv->pScrn);
}
int
@@ -519,7 +545,8 @@ DGASetViewport(
){
DGAScreenPtr pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- (*pScreenPriv->funcs->SetViewport)(pScreenPriv->pScrn, x, y, mode);
+ if (pScreenPriv->funcs->SetViewport)
+ (*pScreenPriv->funcs->SetViewport)(pScreenPriv->pScrn, x, y, mode);
return Success;
}
@@ -629,7 +656,8 @@ DGASync(int index)
/* We rely on the extension to check that DGA is active */
- (*pScreenPriv->funcs->Sync)(pScreenPriv->pScrn);
+ if (pScreenPriv->funcs->Sync)
+ (*pScreenPriv->funcs->Sync)(pScreenPriv->pScrn);
return Success;
}
@@ -734,8 +762,8 @@ DGACopyModeInfo(
xmode->num = mode->num;
xmode->name = dmode->name;
- xmode->VSync_num = dmode->Clock * 1000.0;
- xmode->VSync_den = dmode->HTotal * dmode->VTotal;
+ xmode->VSync_num = (int)(dmode->VRefresh * 1000.0);
+ xmode->VSync_den = 1000;
xmode->flags = mode->flags;
xmode->imageWidth = mode->imageWidth;
xmode->imageHeight = mode->imageHeight;
@@ -801,7 +829,7 @@ DGAStealKeyEvent(int index, xEvent *e)
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if(!pScreenPriv || !pScreenPriv->current) /* no direct mode */
+ if(!pScreenPriv || !pScreenPriv->grabKeyboard) /* no direct mode */
return FALSE;
de.u.u.type = e->u.u.type + *XDGAEventBase;
@@ -811,6 +839,7 @@ DGAStealKeyEvent(int index, xEvent *e)
return TRUE;
}
+static int DGAMouseX, DGAMouseY;
Bool
DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
@@ -823,17 +852,26 @@ DGAStealMouseEvent(int index, xEvent *e, int dx, int dy)
pScreenPriv = DGA_GET_SCREEN_PRIV(screenInfo.screens[index]);
- if(!pScreenPriv || !pScreenPriv->current) /* no direct mode */
+ if(!pScreenPriv || !pScreenPriv->grabMouse) /* no direct mode */
return FALSE;
- if (!dx && !dy)
- de.u.u.type = e->u.u.type + *XDGAEventBase;
- else
- de.u.u.type = MotionNotify + *XDGAEventBase;
+ 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 = e->u.u.type + *XDGAEventBase;
de.u.u.detail = e->u.u.detail;
de.u.event.time = e->u.keyButtonPointer.time;
de.u.event.dx = dx;
de.u.event.dy = dy;
+ de.u.event.pad1 = DGAMouseX;
+ de.u.event.pad2 = DGAMouseY;
xf86eqEnqueue ((xEvent *) &de);
return TRUE;
}
@@ -842,7 +880,7 @@ Bool
DGAIsDgaEvent (xEvent *e)
{
int coreEquiv;
- if (DGAScreenIndex < 0)
+ if (DGAScreenIndex < 0 || XDGAEventBase == 0)
return FALSE;
coreEquiv = e->u.u.type - *XDGAEventBase;
if (KeyPress <= coreEquiv && coreEquiv <= MotionNotify)
@@ -1039,7 +1077,7 @@ DGADeliverEvent (ScreenPtr pScreen, xEvent *e)
int coreEquiv;
/* no DGA */
- if (DGAScreenIndex < 0)
+ if (DGAScreenIndex < 0 || XDGAEventBase == 0)
return FALSE;
pScreenPriv = DGA_GET_SCREEN_PRIV(pScreen);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
index a9e9432f1..ea6d47781 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Events.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.92 2000/02/13 03:36:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.94 2000/05/18 23:21:33 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -329,7 +329,8 @@ xf86PostKbdEvent(unsigned key)
#if defined (__sparc__)
if (kbdSun == -1) {
- if (xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ || (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
kbdSun = 1;
else
kbdSun = 0;
@@ -872,9 +873,14 @@ special:
/*
* check for an autorepeat-event
*/
- if ((down && KeyPressed(keycode)) &&
- (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode]))
- return;
+ if (down && KeyPressed(keycode)) {
+ KbdFeedbackClassRec *kbdfeed = ((DeviceIntPtr)xf86Info.pKeyboard)->kbdfeed;
+ if ((xf86Info.autoRepeat != AutoRepeatModeOn) ||
+ keyc->modifierMap[keycode] ||
+ (kbdfeed && !(kbdfeed->ctrl.autoRepeats[keycode>>3] & ( 1<<(keycode&7) ))))
+ return;
+ }
+
xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis();
/*
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c b/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c
index 22e476346..0420671b6 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Helper.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.83 2000/03/06 19:07:15 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Helper.c,v 1.94 2000/06/20 05:08:44 dawes Exp $ */
/*
* Copyright (c) 1997-1998 by The XFree86 Project, Inc.
@@ -27,6 +27,8 @@
#include "xf86Xinput.h"
#include "xf86InPriv.h"
#include "mivalidate.h"
+#include "xf86RAC.h"
+#include "xf86Bus.h"
/* For xf86GetClocks */
#if defined(CSRG_BASED) || defined(MACH386)
@@ -62,12 +64,14 @@ xf86AddDriver(DriverPtr driver, pointer module, int flags)
void
xf86DeleteDriver(int drvIndex)
{
- if (xf86DriverList[drvIndex] && xf86DriverList[drvIndex]->module)
- UnloadModule(xf86DriverList[drvIndex]->module);
- xf86DriverList[drvIndex] = NULL;
+ if (xf86DriverList[drvIndex]
+ && (!xf86DriverHasEntities(xf86DriverList[drvIndex]))) {
+ if (xf86DriverList[drvIndex]->module)
+ UnloadModule(xf86DriverList[drvIndex]->module);
+ xf86DriverList[drvIndex] = NULL;
+ }
}
-
/* Add a pointer to a new InputDriverRec to xf86InputDriverList */
void
@@ -1448,6 +1452,7 @@ xf86MatchDevice(const char *drivername, GDevPtr **driversectlist)
static char * drivernames[MAXDRIVERS];
static GDevPtr * devices[MAXDRIVERS];
static int count[MAXDRIVERS];
+ GDevPtr gdp;
confScreenPtr screensecptr;
int i,j;
@@ -1522,6 +1527,22 @@ xf86MatchDevice(const char *drivername, GDevPtr **driversectlist)
devices[i][count[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 */
+ gdp->claimed = TRUE;
+ devices[i] =
+ xnfrealloc(devices[i], (count[i] + 2) * sizeof(GDevPtr));
+ devices[i][count[i]++] = gdp;
+ }
+ j++;
+ }
+
#if 0
/*
* XXX The parser won't let devices with no Driver name through, so
@@ -1565,7 +1586,8 @@ struct Inst {
GDevPtr dev;
Bool foundHW; /* PCIid in list of supported chipsets */
Bool claimed; /* BusID matches with a device section */
- int chip;
+ int chip;
+ int screen;
};
int
@@ -1583,6 +1605,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
Bool foundHW; /* PCIid in list of supported chipsets */
Bool claimed; /* BusID matches with a device section */
int chip;
+ int screen;
} *instances = NULL;
int numClaimedInstances = 0;
int allocatedInstances = 0;
@@ -1608,6 +1631,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
instances[allocatedInstances - 1].claimed = FALSE;
instances[allocatedInstances - 1].foundHW = TRUE;
instances[allocatedInstances - 1].chip = id->numChipset;
+ instances[allocatedInstances - 1].screen = 0;
numFound++;
}
}
@@ -1624,6 +1648,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
instances[allocatedInstances - 1].claimed = FALSE;
instances[allocatedInstances - 1].foundHW = TRUE;
instances[allocatedInstances - 1].chip = id->numChipset;
+ instances[allocatedInstances - 1].screen = 0;
numFound++;
}
}
@@ -1639,6 +1664,7 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
instances[allocatedInstances - 1].dev = NULL;
instances[allocatedInstances - 1].claimed = FALSE;
instances[allocatedInstances - 1].foundHW = FALSE;
+ instances[allocatedInstances - 1].screen = 0;
/* Check if the chip type is listed in the chipsets table */
for (id = PCIchipsets; id->PCIid != -1; id++) {
@@ -1693,6 +1719,36 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
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, pPci->bus,
+ pPci->device,
+ pPci->func)) {
+ allocatedInstances++;
+ instances = xnfrealloc(instances,
+ allocatedInstances *
+ sizeof(struct Inst));
+ instances[allocatedInstances - 1] = instances[i];
+ instances[allocatedInstances - 1].screen =
+ devList[j]->screen;
+ numFound++;
+ break;
+ }
+ }
+ }
+ }
+
for (i = 0; i < allocatedInstances; i++) {
pPci = instances[i].pci;
devBus = NULL;
@@ -1701,13 +1757,15 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
if (devList[j]->busID && *devList[j]->busID) {
if (xf86ComparePciBusString(devList[j]->busID, pPci->bus,
pPci->device,
- pPci->func)) {
+ pPci->func) &&
+ devList[j]->screen == instances[i].screen) {
+
if (devBus)
- xf86MsgVerb(X_WARNING,0,
+ 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);
+ "instances\n\t(BusID: %s) found: %s\n",
+ driverName, devList[j]->busID,
+ devList[j]->identifier);
else
devBus = devList[j];
}
@@ -1831,7 +1889,18 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
if (!instances[i].claimed)
continue;
pPci = instances[i].pci;
- if (!xf86CheckPciSlot(pPci->bus, pPci->device, pPci->func))
+
+
+ /*
+ * 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->bus, pPci->device, pPci->func))
continue;
#ifdef DEBUG
@@ -1847,6 +1916,20 @@ xf86MatchPciInstances(const char *driverName, int vendorID,
pPci->func,drvp, instances[i].chip,
instances[i].dev,instances[i].dev->active ?
TRUE : FALSE);
+ if (retEntities[numFound - 1] == -1 && instances[i].screen > 0) {
+ for (j = 0; j < xf86NumEntities; j++) {
+ EntityPtr pEnt = xf86Entities[j];
+ if (pEnt->busType != BUS_PCI)
+ continue;
+ if (pEnt->pciBusId.bus == pPci->bus &&
+ pEnt->pciBusId.device == pPci->device &&
+ pEnt->pciBusId.func == pPci->func) {
+ retEntities[numFound - 1] = j;
+ xf86AddDevToEntity(j, instances[i].dev);
+ break;
+ }
+ }
+ }
}
xfree(instances);
if (numFound > 0) {
@@ -2208,6 +2291,22 @@ xf86IsPc98()
#endif
}
+pointer
+xf86LoadDrvSubModule(DriverPtr drv, const char *name)
+{
+#ifdef XFree86LOADER
+ 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;
+#else
+ return (pointer)1;
+#endif
+}
pointer
xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
@@ -2226,6 +2325,18 @@ xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name)
#endif
}
+void
+xf86UnloadSubModule(pointer mod)
+{
+ /*
+ * This is disabled for now. The loader isn't smart enough yet to undo
+ * relocations.
+ */
+#if defined(XFree86LOADER) && 0
+ UnloadSubModule(mod);
+#endif
+}
+
Bool
xf86LoaderCheckSymbol(const char *name)
{
@@ -2323,14 +2434,18 @@ static OptionInfoRec BSOptions[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
+#define nBSOptions (sizeof(BSOptions) / sizeof(BSOptions[0]))
+
void
xf86SetBackingStore(ScreenPtr pScreen)
{
Bool useBS = FALSE;
MessageType from = X_DEFAULT;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ OptionInfoRec options[nBSOptions];
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, BSOptions);
+ (void)memcpy(options, BSOptions, sizeof(BSOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
/* check for commandline option here */
if (xf86bsEnableFlag) {
@@ -2340,7 +2455,7 @@ xf86SetBackingStore(ScreenPtr pScreen)
from = X_CMDLINE;
useBS = FALSE;
} else {
- if (xf86GetOptValBool(BSOptions, OPTION_BACKING_STORE, &useBS))
+ if (xf86GetOptValBool(options, OPTION_BACKING_STORE, &useBS))
from = X_CONFIG;
}
pScreen->backingStoreSupport = useBS ? Always : NotUseful;
@@ -2359,21 +2474,32 @@ static OptionInfoRec SMOptions[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
+#define nSMOptions (sizeof(SMOptions) / sizeof(SMOptions[0]))
+
void
xf86SetSilkenMouse (ScreenPtr pScreen)
{
Bool useSM = TRUE;
MessageType from = X_DEFAULT;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ OptionInfoRec options[nSMOptions];
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, SMOptions);
-
+ (void)memcpy(options, SMOptions, sizeof(SMOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
+
/* check for commandline option here */
- if (xf86silkenMouseDisableFlag) {
- from = X_CMDLINE;
+ /* 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(SMOptions, OPTION_SILKEN_MOUSE, &useSM))
+ if (xf86GetOptValBool(options, OPTION_SILKEN_MOUSE, &useSM))
from = X_CONFIG;
}
/*
@@ -2420,24 +2546,32 @@ xf86FindXvOptions(int scrnIndex, int adaptor_index, char *port_name,
/* new RAC */
/*
- * xf86ConfigActiveIsa/PciEntity() -- These helper functions assign an
+ * 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...
*/
-Bool
-xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex,
+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->active || !(pEnt->location.type == BUS_ISA)) {
+ if (!(pEnt->location.type == BUS_ISA)) {
xfree(pEnt);
- return FALSE;
+ return pScrn;
}
-
+
+ if (!pEnt->active) {
+ xf86ConfigIsaEntityInactive(pEnt, i_chip, res, init, enter,
+ leave, private);
+ return pScrn;
+ }
+
+ if (!pScrn)
+ pScrn = xf86AllocateScreen(pEnt->driver,scrnFlag);
xf86AddEntityToScreen(pScrn,entityIndex);
if (i_chip) {
@@ -2448,26 +2582,38 @@ xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex,
}
xfree(pEnt);
xf86ClaimFixedResources(res,entityIndex);
- if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
- return FALSE;
+ xf86SetEntityFuncs(entityIndex,init,enter,leave,private);
- return TRUE;
+ return pScrn;
}
-Bool
-xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
+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->active || !(pEnt->location.type == BUS_PCI)) {
+ if (!(pEnt->location.type == BUS_PCI)) {
xfree(pEnt);
- return FALSE;
+ return pScrn;
+ }
+ if (!pEnt->active) {
+ xf86ConfigPciEntityInactive(pEnt, p_chip, res, init, enter,
+ leave, private);
+ 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;
@@ -2477,9 +2623,72 @@ xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
xfree(pEnt);
xf86ClaimFixedResources(res,entityIndex);
- if (!xf86SetEntityFuncs(entityIndex,init,enter,leave,private))
- return FALSE;
+ 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!
+ */
+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->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;
+}
+
+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->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;
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
index 8f8b90e57..d32025181 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Init.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.157 2000/03/05 23:47:46 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.162 2000/06/25 20:17:32 dawes Exp $ */
/*
* Copyright 1991-1999 by The XFree86 Project, Inc.
@@ -459,16 +459,17 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
layout++) {
Bool found = FALSE;
for (j = 0; j < xf86Screens[i]->numEntities; j++) {
- EntityInfoPtr pEnt =
- xf86GetEntityInfo(xf86Screens[i]->entityList[j]);
- if (pEnt->device == layout->screen->device) {
+
+ 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;
- xfree(pEnt);
break;
}
- xfree(pEnt);
}
if (found) break;
}
@@ -1587,6 +1588,7 @@ xf86LoadModules(char **list, pointer *optlist)
pointer opt;
int i;
char *name;
+ Bool failed = FALSE;
if (!list)
return TRUE;
@@ -1611,16 +1613,15 @@ xf86LoadModules(char **list, pointer *optlist)
if (!LoadModule(name, NULL, NULL, NULL, opt, NULL, &errmaj, &errmin)) {
LoaderErrorMsg(NULL, name, errmaj, errmin);
- xfree(name);
- return FALSE;
+ failed = TRUE;
}
xfree(name);
}
- return TRUE;
+ return !failed;
}
/*
- * xf86LoadModules iterates over a list that is being passed in.
+ * xf86LoadOneModule loads a single module.
*/
pointer
xf86LoadOneModule(char *name, pointer opt)
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Io.c b/xc/programs/Xserver/hw/xfree86/common/xf86Io.c
index 684ab6cd4..5b672981c 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Io.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.38 1999/12/27 00:39:43 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.39 2000/06/13 02:28:31 dawes Exp $ */
/*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -396,7 +396,7 @@ xf86KbdProc (pKeyboard, what)
return (Success);
}
-#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__) && !defined(QNX4)
+#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !(defined(__mips__) && !defined(linux)) && !defined(QNX4)
/*
* These are getting tossed in here until I can think of where
* they really belong
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c b/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
index ce7d1a4b8..a1619b0c4 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.12 1999/04/29 05:12:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdBSD.c,v 3.13 2000/06/23 22:42:02 dawes Exp $ */
/*
* Derived from xf86Kbd.c by S_ren Schmidt (sos@login.dkuug.dk)
* which is Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
@@ -447,7 +447,10 @@ xf86KbdGetMapping (pKeySyms, pModMap)
break;
#endif
-#if defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)
+/*
+ * XXX wscons has no GIO_KEYMAP
+ */
+#if (defined (SYSCONS_SUPPORT) || defined (PCVT_SUPPORT)) && defined(GIO_KEYMAP)
case SYSCONS:
case PCVT:
{
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c b/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
index 6eb915b10..7349b4e6c 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c
@@ -1,7 +1,7 @@
/*
* Copyright (c) 1999 by The XFree86 Project, Inc.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.4 2000/03/05 17:04:15 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86MiscExt.c,v 1.5 2000/04/17 16:29:53 eich Exp $ */
/*
* This file contains the Pointer/Keyboard functions needed by the
@@ -34,8 +34,7 @@
#include "xf86OSmouse.h"
#include "../input/mouse/mouse.h"
-const char * xf86ProtocolIDToName(ProtocolID id);
-
+#define DEBUG
#ifdef DEBUG
# define DEBUG_P(x) ErrorF(x"\n");
#else
@@ -83,17 +82,18 @@ MapMseProto(int proto, MseProtoMapDirection mapping)
MTYPE_LOGITECH, MTYPE_LOGIMAN, MTYPE_MMHIT,
MTYPE_GLIDEPOINT, MTYPE_IMSERIAL, MTYPE_THINKING,
MTYPE_ACECAD, MTYPE_PS_2, MTYPE_IMPS2,
- MTYPE_THINKINGPS2, MTYPE_MMANPLUSPS2, MTYPE_GLIDEPOINTPS2,
- MTYPE_NETPS2, MTYPE_NETSCROLLPS2, MTYPE_BUSMOUSE,
- MTYPE_AUTOMOUSE, MTYPE_SYSMOUSE
+ MTYPE_EXPPS2, MTYPE_THINKINGPS2, MTYPE_MMANPLUSPS2,
+ MTYPE_GLIDEPOINTPS2, MTYPE_NETPS2, MTYPE_NETSCROLLPS2,
+ MTYPE_BUSMOUSE, MTYPE_AUTOMOUSE, MTYPE_SYSMOUSE
};
- static ProtocolID MapProto_FromMisc[] = {
+ static MouseProtocolID MapProto_FromMisc[] = {
PROT_MS, PROT_MSC, PROT_MM, PROT_LOGI,
PROT_BM, PROT_LOGIMAN, PROT_PS2, PROT_MMHIT,
PROT_GLIDE, PROT_IMSERIAL, PROT_THINKING, PROT_IMPS2,
PROT_THINKPS2, PROT_MMPS2, PROT_GLIDEPS2, PROT_NETPS2,
- PROT_NETSCPS2, PROT_SYSMOUSE, PROT_AUTO, PROT_ACECAD
+ PROT_NETSCPS2, PROT_SYSMOUSE, PROT_AUTO, PROT_ACECAD,
+ PROT_EXPPS2
};
#define PROT_DEFAULT -2 /* PROT_UNKNOWN */
@@ -116,23 +116,14 @@ MiscExtGetMouseSettings(pointer *mouse, char **devname)
DEBUG_P("MiscExtGetMouseSettings");
- mseptr = MiscExtCreateStruct(MISC_KEYBOARD);
+ mseptr = MiscExtCreateStruct(MISC_POINTER);
if (!mseptr)
return FALSE;
{
- InputInfoPtr pInfo;
+ InputInfoPtr pInfo = mseptr->private;
MouseDevPtr pMse;
- pInfo = xf86InputDevs;
- while (pInfo) {
- if (xf86IsCorePointer(pInfo->dev))
- break;
- pInfo = pInfo->next;
- }
- if (!pInfo)
- return FALSE;
-
*devname = xf86FindOptionValue(pInfo->options, "Device");
pMse = pInfo->private;
@@ -145,7 +136,6 @@ MiscExtGetMouseSettings(pointer *mouse, char **devname)
mseptr->em3timeout = pMse->emulate3Timeout;
mseptr->chordmiddle = pMse->chordMiddle;
mseptr->flags = pMse->mouseFlags;
- mseptr->private = pInfo;
}
*mouse = mseptr;
return TRUE;
@@ -181,7 +171,7 @@ MiscExtSetMouseValue(pointer mouse, MiscExtMseValType valtype, int value)
switch (valtype) {
case MISC_MSE_PROTO:
- mse->type = value;
+ mse->type = value;
return TRUE;
case MISC_MSE_BAUDRATE:
mse->baudrate = value;
@@ -269,12 +259,28 @@ pointer
MiscExtCreateStruct(MiscExtStructType mse_or_kbd)
{
DEBUG_P("MiscExtCreateStruct");
-
+
switch (mse_or_kbd) {
- case MISC_POINTER:
- return xcalloc(sizeof(mseParamsRec),1);
- case MISC_KEYBOARD:
- return xcalloc(sizeof(kbdParamsRec),1);
+ case MISC_POINTER:
+ {
+ mseParamsPtr mseptr;
+ InputInfoPtr pInfo = xf86InputDevs;
+
+ while (pInfo) {
+ if (xf86IsCorePointer(pInfo->dev))
+ 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;
}
@@ -301,9 +307,12 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
mseParamsPtr mse = structure;
InputInfoPtr pInfo;
MouseDevPtr pMse;
- MouseProtocolPtr protocol;
- char tmpbuf[128];
-
+#ifdef XFree86LOADER
+ pointer xf86MouseProtocolIDToName
+ = LoaderSymbol("xf86MouseProtocolIDToName");
+ if (!xf86MouseProtocolIDToName)
+ return MISC_RET_NOMODULE;
+#endif
if (mse->type < MTYPE_MICROSOFT
|| ( mse->type > MTYPE_ACECAD
&& (mse->type!=MTYPE_OSMOUSE && mse->type!=MTYPE_XQUEUE)))
@@ -393,7 +402,12 @@ MiscExtApply(pointer structure, MiscExtStructType mse_or_kbd)
pMse->chordMiddle = mse->chordmiddle;
pMse->mouseFlags = mse->flags;
- pMse->protocol = xf86ProtocolIDToName(pMse->protocolID);
+#ifdef XFree86LOADER
+ pMse->protocol = ((const char *(*)(MouseProtocolID))
+ xf86MouseProtocolIDToName)(pMse->protocolID);
+#else
+ pMse->protocol = xf86MouseProtocolIDToName(pMse->protocolID);
+#endif
if (reopen)
(pMse->device->deviceProc)(pMse->device, DEVICE_ON);
/* Set pInfo->options too */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c b/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
index 0f6d495f5..ac3a20536 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Mode.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.27 2000/03/05 23:47:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Mode.c,v 1.32 2000/06/20 05:08:44 dawes Exp $ */
/*
* Copyright (c) 1997,1998 by The XFree86 Project, Inc.
@@ -125,6 +125,12 @@ xf86ModeStatusToString(ModeStatus status)
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_BAD:
return "unknown reason";
case MODE_ERROR:
@@ -151,8 +157,24 @@ xf86ShowClockRanges(ScrnInfoPtr scrp, ClockRangePtr clockRanges)
DivFactor = max(1, cp->ClockDivFactor);
MulFactor = max(1, cp->ClockMulFactor);
if (scrp->progClock) {
- xf86DrvMsg(scrp->scrnIndex, X_INFO, "clock range: %6.2f to %6.2f MHz\n",
- (double)cp->minClock / 1000.0, (double)cp->maxClock / 1000);
+ 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++) {
@@ -370,7 +392,6 @@ xf86LookupMode(ScrnInfoPtr scrp, DisplayModePtr modep,
if (p->type & M_T_BUILTIN)
return xf86HandleBuiltinMode(scrp, p,modep, clockRanges,
allowDiv2);
-
/* Skip over previously rejected modes */
if (p->status != MODE_OK) {
if (!found)
@@ -1112,6 +1133,19 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
scrp->monitor->hsync[0].lo = 28;
scrp->monitor->hsync[0].hi = 33;
scrp->monitor->nHsync = 1;
+ } else {
+ 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 hsync value of %6.2f kHz\n",
+ scrp->monitor->id,
+ scrp->monitor->hsync[i].lo);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using hsync range of %6.2f-%6.2f kHz\n",
+ scrp->monitor->id,
+ scrp->monitor->hsync[i].lo,
+ scrp->monitor->hsync[i].hi);
}
if (scrp->monitor->nVrefresh <= 0) {
xf86DrvMsg(scrp->scrnIndex, X_WARNING,
@@ -1120,6 +1154,19 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
scrp->monitor->vrefresh[0].lo = 43;
scrp->monitor->vrefresh[0].hi = 72;
scrp->monitor->nVrefresh = 1;
+ } else {
+ 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 vrefresh value of %6.2f Hz\n",
+ scrp->monitor->id,
+ scrp->monitor->vrefresh[i].lo);
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_INFO,
+ "%s: Using vrefresh range of %6.2f-%6.2f Hz\n",
+ scrp->monitor->id,
+ scrp->monitor->vrefresh[i].lo,
+ scrp->monitor->vrefresh[i].hi);
}
}
@@ -1299,7 +1346,6 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
endp = &new->next;
}
}
-
/* Lookup each mode */
for (p = scrp->modes; ; p = p->next) {
/*
@@ -1307,6 +1353,7 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
* unconsidered modePool members until one survives validation. This
* is done in decreasing order by mode pixel area.
*/
+
if (p == NULL) {
if (numModes > 0)
break;
@@ -1346,8 +1393,10 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
*endp = last = p;
endp = &p->next;
}
+
lookupNext:
status = xf86LookupMode(scrp, p, clockRanges, strategy);
+
if (status == MODE_ERROR) {
ErrorF("xf86ValidateModes: "
"unexpected result from xf86LookupMode()\n");
@@ -1425,8 +1474,18 @@ xf86ValidateModes(ScrnInfoPtr scrp, DisplayModePtr availModes,
scrp->displayWidth = newLinePitch;
p->status = (scrp->ValidMode)(scrp->scrnIndex, p, FALSE,
MODECHECK_FINAL);
- if (p->status != MODE_OK)
- goto lookupNext;
+
+ if (p->status != MODE_OK) {
+ if (p->type & M_T_BUILTIN)
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+ "Built-in mode \"%s\" deleted (%s)\n", p->name,
+ xf86ModeStatusToString(p->status));
+ else
+ xf86DrvMsg(scrp->scrnIndex, X_WARNING,
+ "Mode \"%s\" deleted (%s)\n", p->name,
+ xf86ModeStatusToString(p->status));
+ goto lookupNext;
+ }
}
/* Mode has passed all the tests */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Module.h b/xc/programs/Xserver/hw/xfree86/common/xf86Module.h
index b1939622c..bc887d267 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Module.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Module.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Module.h,v 1.21 2000/03/01 23:54:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Module.h,v 1.24 2000/04/05 18:13:45 dawes Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
@@ -62,7 +62,7 @@ typedef enum {
* mask is 0xFFFF0000.
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 1)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(0, 1)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(0, 2)
#define ABI_XINPUT_VERSION SET_ABI_VERSION(0, 1)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(0, 1)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 1)
@@ -71,7 +71,11 @@ typedef enum {
#define MODINFOSTRING2 0x10dc023a
#ifndef MODULEVENDORSTRING
+#ifndef __OS2ELF__
#define MODULEVENDORSTRING "The XFree86 Project"
+#else
+#define MODULEVENDORSTRING "The XFree86 Project - XFree86/OS2"
+#endif
#endif
/* Error return codes for errmaj. New codes must only be added at the end. */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Option.c b/xc/programs/Xserver/hw/xfree86/common/xf86Option.c
index 1657b5028..538514de8 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Option.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Option.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Option.c,v 1.14 1999/06/12 07:18:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Option.c,v 1.15 2000/06/20 05:08:45 dawes Exp $ */
/*
* Copyright (c) 1998 by The XFree86 Project, Inc.
@@ -42,22 +42,22 @@ xf86CollectOptions(ScrnInfoPtr pScrn, pointer extraOpts)
{
XF86OptionPtr tmp;
XF86OptionPtr extras = (XF86OptionPtr)extraOpts;
- EntityInfoPtr pEnt;
+ GDevPtr device;
int i;
pScrn->options = NULL;
for (i=pScrn->numEntities - 1; i >= 0; i--) {
- pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
- if (pEnt->device && pEnt->device->options) {
- tmp = OptionListDup(pEnt->device->options);
+ device = xf86GetDevFromEntity(pScrn->entityList[i],
+ pScrn->entityInstanceList[i]);
+ if (device && device->options) {
+ tmp = OptionListDup(device->options);
if (pScrn->options)
OptionListMerge(pScrn->options,tmp);
else
pScrn->options = tmp;
}
- xfree(pEnt);
}
if (pScrn->monitor->options) {
tmp = OptionListDup(pScrn->monitor->options);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
index 9194084e4..38e05cc6e 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
@@ -1,11 +1,38 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.51 2000/02/24 20:39:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h,v 1.65 2000/06/30 17:15:11 dawes Exp $ */
/*
* PCI Probe
*
- * Copyright 1995-1999 by The XFree86 Project, Inc.
+ * Copyright 1995-2000 by The XFree86 Project, Inc.
*
* A lot of this comes from Robin Cutshaw's scanpci
*
+ * Notes -- Jun 6, 2000 -- Kevin Brosius
+ * Tips on adding Entries:
+ * scanpci output can contain up to 4 numeric entries, 2 for chip and 2 for card
+ * some generic cards don't have any valid info in the card field,
+ * here's what you do;
+ * - Add a vendor entry for your device if it doesn't already exist. The
+ * first number of the pair is generally vendor id. Search for it below
+ * and add a #define for it if it doesn't exist.
+ * ie. 5333 is the vendor id for S3
+ * - Go to xf86PCIVendorNameInfoData[] and add a text name for your vendor id.
+ * ie. PCI_VENDOR_S3 is "S3"
+ * - Add an entry to xf86PCIVendorInfoData[], using the PCI_VENDOR define
+ * you added, and a text description of the chipset.
+ * - If your device has 0000 in the card field,
+ * you've probably got a non-video or generic device. Stop here.
+ *
+ * - If you have info in the card field, and it's just a duplicate of the chip
+ * info, then either stop, or add a 'generic' entry to xf86PCICardInfoData[].
+ * - If you have different info in the card field, check the first entry,
+ * does the vendor match and/or already exist? If not, add it. Then
+ * add an entry describing the card to xf86PCICardInfoData[]
+ * - If you are adding a video card, add a PCI_CHIP #define matching the second
+ * entry in your chip field. This gets used in your card driver as the PCI id.
+ * ie. under the S3 comment, one entry is: PCI_CHIP_VIRGE 0x5631
+ *
+ * Several people recommended http://www.yourvote.com/pci for pci device/vendor info.
+ *
*/
#ifndef _XF86_PCIINFO_H
@@ -25,6 +52,7 @@
#define PCI_VENDOR_NS 0x100B
#define PCI_VENDOR_TSENG 0x100C
#define PCI_VENDOR_WEITEK 0x100E
+#define PCI_VENDOR_VIDEOLOGIC 0x1010
#define PCI_VENDOR_DIGITAL 0x1011
#define PCI_VENDOR_CIRRUS 0x1013
#define PCI_VENDOR_IBM 0x1014
@@ -47,6 +75,7 @@
#define PCI_VENDOR_SGS 0x104A
#define PCI_VENDOR_BUSLOGIC 0x104B
#define PCI_VENDOR_TI 0x104C
+#define PCI_VENDOR_SONY 0x104D
#define PCI_VENDOR_OAK 0x104E
#define PCI_VENDOR_WINBOND 0x1050
#define PCI_VENDOR_MOTOROLA 0x1057
@@ -93,6 +122,7 @@
#define PCI_VENDOR_TRUEVISION 0x10FA
#define PCI_VENDOR_INITIO 0x1101
#define PCI_VENDOR_CREATIVE_2 0x1102
+#define PCI_VENDOR_SIGMADESIGNS_2 0x1105
#define PCI_VENDOR_VIA 0x1106
#define PCI_VENDOR_VORTEX 0x1119
#define PCI_VENDOR_EF 0x111A
@@ -105,16 +135,20 @@
#define PCI_VENDOR_MUTECH 0x1159
#define PCI_VENDOR_RENDITION 0x1163
#define PCI_VENDOR_TOSHIBA 0x1179
+#define PCI_VENDOR_RICOH 0x1180
#define PCI_VENDOR_ZEINET 0x1193
+#define PCI_VENDOR_LITEON 0x11AD
#define PCI_VENDOR_SPECIALIX 0x11CB
#define PCI_VENDOR_CONTROL 0x11FE
#define PCI_VENDOR_CYCLADES 0x120E
#define PCI_VENDOR_3DFX 0x121A
#define PCI_VENDOR_SIGMADESIGNS 0x1236
#define PCI_VENDOR_ENSONIQ 0x1274
+#define PCI_VENDOR_ROCKWELL 0x127A
#define PCI_VENDOR_YOKOGAWA 0x1281
#define PCI_VENDOR_TRITECH 0x1292
#define PCI_VENDOR_NVIDIA_SGS 0x12d2
+#define PCI_VENDOR_NETGEAR 0x1385
#define PCI_VENDOR_SYMPHONY 0x1C1C
#define PCI_VENDOR_TEKRAM_2 0x1DE1
#define PCI_VENDOR_3DLABS 0x3D3D
@@ -185,6 +219,8 @@
#define PCI_CHIP_MACH64GZ 0x475A
#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
@@ -192,11 +228,12 @@
#define PCI_CHIP_MACH64LP 0x4C50
#define PCI_CHIP_MACH64LR 0x4C52
#define PCI_CHIP_MACH64LS 0x4C53
+#define PCI_CHIP_RAGE128PF 0x5046
+#define PCI_CHIP_RAGE128PR 0x5052
#define PCI_CHIP_RAGE128RE 0x5245
#define PCI_CHIP_RAGE128RF 0x5246
#define PCI_CHIP_RAGE128RK 0x524B
#define PCI_CHIP_RAGE128RL 0x524C
-#define PCI_CHIP_RAGE128PF 0x5046
#define PCI_CHIP_MACH64VT 0x5654
#define PCI_CHIP_MACH64VU 0x5655
#define PCI_CHIP_MACH64VV 0x5656
@@ -277,6 +314,7 @@
#define PCI_CHIP_8400 0x8400
#define PCI_CHIP_8420 0x8420
#define PCI_CHIP_8500 0x8500
+#define PCI_CHIP_8520 0x8520
#define PCI_CHIP_9320 0x9320
#define PCI_CHIP_9388 0x9388
#define PCI_CHIP_9397 0x9397
@@ -443,6 +481,7 @@
#define PCI_CHIP_VOODOO2 0x0002
#define PCI_CHIP_BANSHEE 0x0003
#define PCI_CHIP_VOODOO3 0x0005
+#define PCI_CHIP_VOODOO5 0x0009
/* Rendition */
#define PCI_CHIP_V1000 0x0001
@@ -457,6 +496,7 @@
#define PCI_CHIP_PERMEDIA2 0x0007
#define PCI_CHIP_GAMMA 0x0008
#define PCI_CHIP_PERMEDIA2V 0x0009
+#define PCI_CHIP_PERMEDIA3 0x000A
/* S3 */
#define PCI_CHIP_PLATO 0x0551
@@ -502,9 +542,19 @@
#define PCI_CHIP_NM2097 0x0083
#define PCI_CHIP_NM2160 0x0004
#define PCI_CHIP_NM2200 0x0005
+#define PCI_CHIP_NM2360 0x0006
+#define PCI_CHIP_NM2380 0x0016
/* Intel */
-#define PCI_CHIP_I740_AGP 0x7800
+#define PCI_CHIP_I815_BRIDGE 0x1130
+#define PCI_CHIP_I815 0x1132
+#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
/*
* first the VendorId - VendorName mapping
@@ -522,6 +572,7 @@ static SymTabRec xf86PCIVendorNameInfoData[] = {
{PCI_VENDOR_NS, "NS"},
{PCI_VENDOR_TSENG, "Tseng Labs"},
{PCI_VENDOR_WEITEK, "Weitek"},
+ {PCI_VENDOR_VIDEOLOGIC, "Video Logic"},
{PCI_VENDOR_DIGITAL, "Digital"},
{PCI_VENDOR_CIRRUS, "Cirrus Logic"},
{PCI_VENDOR_IBM, "IBM"},
@@ -542,6 +593,7 @@ static SymTabRec xf86PCIVendorNameInfoData[] = {
{PCI_VENDOR_SGS, "SGS-Thomson"},
{PCI_VENDOR_BUSLOGIC, "BusLogic"},
{PCI_VENDOR_TI, "Texas Instruments"},
+ {PCI_VENDOR_SONY, "Sony"},
{PCI_VENDOR_OAK, "Oak"},
{PCI_VENDOR_WINBOND,"Winbond"},
{PCI_VENDOR_MOTOROLA, "Motorola"},
@@ -560,6 +612,7 @@ static SymTabRec xf86PCIVendorNameInfoData[] = {
{PCI_VENDOR_FOREX, "FOREX"},
{PCI_VENDOR_OLICOM, "Olicom"},
{PCI_VENDOR_SUN, "Sun"},
+ {PCI_VENDOR_DIAMOND, "Diamond"},
{PCI_VENDOR_CMD, "CMD"},
{PCI_VENDOR_VISION, "Vision"},
{PCI_VENDOR_BROOKTREE, "BrookTree"},
@@ -585,6 +638,7 @@ static SymTabRec xf86PCIVendorNameInfoData[] = {
{PCI_VENDOR_TRUEVISION, "Truevision"},
{PCI_VENDOR_INITIO, "Initio Corp"},
{PCI_VENDOR_CREATIVE_2, "Creative Labs"},
+ {PCI_VENDOR_SIGMADESIGNS_2, "Sigma Designs"},
{PCI_VENDOR_VIA, "VIA"},
{PCI_VENDOR_VORTEX, "Vortex"},
{PCI_VENDOR_EF, "EF"},
@@ -592,17 +646,22 @@ static SymTabRec xf86PCIVendorNameInfoData[] = {
{PCI_VENDOR_IMAGTEC, "Imaging Technology"},
{PCI_VENDOR_PLX, "PLX"},
{PCI_VENDOR_NVIDIA_SGS, "NVidia/SGS-Thomson"},
+ {PCI_VENDOR_NETGEAR, "Netgear"},
{PCI_VENDOR_ALLIANCE, "Alliance Semiconductor"},
{PCI_VENDOR_VMIC, "VMIC"},
{PCI_VENDOR_DIGI, "DIGI*"},
{PCI_VENDOR_MUTECH, "Mutech"},
{PCI_VENDOR_RENDITION, "Rendition"},
+ {PCI_VENDOR_TOSHIBA, "Toshiba"},
+ {PCI_VENDOR_RICOH, "Ricoh"},
+ {PCI_VENDOR_ZEINET, "Zeinet"},
+ {PCI_VENDOR_LITEON, "Lite-On"},
{PCI_VENDOR_3DFX, "3Dfx Interactive"},
{PCI_VENDOR_SIGMADESIGNS, "Sigma Designs"},
{PCI_VENDOR_ENSONIQ, "Ensoniq"},
+ {PCI_VENDOR_ROCKWELL, "Rockwell"},
{PCI_VENDOR_YOKOGAWA, "YOKOGAWA"},
{PCI_VENDOR_TRITECH, "Tritech Microelectronics"},
- {PCI_VENDOR_NVIDIA_SGS, "NVidia/SGS-Thomson"},
{PCI_VENDOR_SYMPHONY, "Symphony"},
{PCI_VENDOR_TEKRAM_2, "Tekram"},
{PCI_VENDOR_3DLABS, "3Dlabs"},
@@ -690,6 +749,8 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_MACH64GZ, "Mach64 GZ",0},
{PCI_CHIP_MACH64LB, "Mach64 LB",0},
{PCI_CHIP_MACH64LD, "Mach64 LD",0},
+ {PCI_CHIP_RAGE128LE, "Rage 128 Mobility LE",0},
+ {PCI_CHIP_RAGE128LF, "Rage 128 Mobility LF",0},
{PCI_CHIP_MACH64LG, "Mach64 LG",0},
{PCI_CHIP_MACH64LI, "Mach64 LI",0},
{PCI_CHIP_MACH64LM, "Mach64 LM",0},
@@ -697,11 +758,12 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_MACH64LP, "Mach64 LP",0},
{PCI_CHIP_MACH64LR, "Mach64 LR",0},
{PCI_CHIP_MACH64LS, "Mach64 LS",0},
+ {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF",0},
+ {PCI_CHIP_RAGE128PR, "Rage 128 Pro PR",0},
{PCI_CHIP_RAGE128RE, "Rage 128 RE",0},
{PCI_CHIP_RAGE128RF, "Rage 128 RF",0},
{PCI_CHIP_RAGE128RK, "Rage 128 RK",0},
{PCI_CHIP_RAGE128RL, "Rage 128 RL",0},
- {PCI_CHIP_RAGE128PF, "Rage 128 Pro PF",0},
{PCI_CHIP_MACH64VT, "Mach64 VT",0},
{PCI_CHIP_MACH64VU, "Mach64 VU",0},
{PCI_CHIP_MACH64VV, "Mach64 VV",0},
@@ -771,14 +833,14 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{0x6001, "CS4236B/CS4611 Audio" ,0},
#endif
{0x0000, NULL,0}}},
-#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_IBM, {
{0x000A, "Fire Coral",0 },
{0x0018, "Token Ring",0 },
{0x001D, "82G2675",0 },
{0x0022, "82351 pci-pci bridge",0 },
+ {0x00B7, "256-bit Graphics Rasterizer",0 },
+ {0x0170, "RC1000 / GT 1000",0},
{0x0000, NULL,0}}},
-#endif
#ifdef INCLUDE_EMPTY_LISTS
{PCI_VENDOR_NCR_2, {
{0x0000, NULL,0}}},
@@ -809,6 +871,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_8400, "CyberBlade/i7",0},
{PCI_CHIP_8420, "CyberBlade/DSTN/i7",0},
{PCI_CHIP_8500, "CyberBlade/i1",0},
+ {PCI_CHIP_8520, "CyberBlade/DSTN/i1",0},
{0x0000, NULL,0}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_ALI, {
@@ -891,6 +954,11 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_PCI_1130, "PCI 1130",0},
{PCI_CHIP_PCI_1131, "PCI 1131",0},
{0x0000, NULL,0}}},
+#ifdef VENDOR_INCLUDE_NONVIDEO
+ {PCI_VENDOR_SONY, {
+ {0x8009, "CXD1947A IEEE1394/Firewire",0},
+ {0x0000, NULL,0}}},
+#endif
{PCI_VENDOR_OAK, {
{PCI_CHIP_OTI107, "OTI107",0},
{0x0000, NULL,0}}},
@@ -1059,6 +1127,11 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_NM2093, "NM2093",0},
{PCI_CHIP_NM2160, "NM2160",0},
{PCI_CHIP_NM2200, "NM2200",0},
+ {PCI_CHIP_NM2360, "NM2360",0},
+ {PCI_CHIP_NM2380, "NM2380",0},
+#ifdef VENDOR_INCLUDE_NONVIDEO
+ {0x8005, "NM2360 MagicMedia 256ZX Audio",0},
+#endif
{0x0000, NULL,0}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_ASP, {
@@ -1107,7 +1180,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_VENDOR_REALTEC, {
{0x8029, "8029",0 },
{0x8129, "8129",0 },
- {0x8139, "RTL8139 Ethernet Controller",0 },
+ {0x8139, "RTL8139 10/100 Ethernet",0 },
{0x0000, NULL,0}}},
{PCI_VENDOR_TRUEVISION, {
{0x000C, "Targa 1000",0 },
@@ -1115,6 +1188,9 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_VENDOR_INITIO, {
{0x9100, "320 P",0 },
{0x0000, NULL,0}}},
+ {PCI_VENDOR_SIGMADESIGNS_2, {
+ {0x8300, "EM8300 MPEG2 decoder", 0 },
+ {0x0000, NULL,0}}},
{PCI_VENDOR_VIA, {
{0x0501, "VT 8501 MVP4 Host Bridge",0 },
{0x0505, "VT 82C505",0 },
@@ -1173,9 +1249,16 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
#ifdef VENDOR_INCLUDE_NONVIDEO
{PCI_VENDOR_TOSHIBA, {
{0x0000, NULL,0}}},
+ { PCI_VENDOR_RICOH, {
+ { 0x0475, "RL5C475 PCI-CardBus bridge/PCMCIA",0 },
+ { 0x0000, NULL,0}}},
{PCI_VENDOR_ZEINET, {
{0x0001, "1221",0 },
{0x0000, NULL,0}}},
+ {PCI_VENDOR_LITEON, {
+ {0x0002, "82C168/9 PNIC 10/100BaseTX",0 },
+ {0xC115, "LC82C115 PNIC II 10/100BaseTX",0 },
+ {0x0000, NULL,0}}},
#ifdef INCLUDE_EMPTY_LISTS
{PCI_VENDOR_SPECIALIX, {
{0x0000, NULL,0}}},
@@ -1190,6 +1273,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_VOODOO2, "Voodoo2",0},
{PCI_CHIP_BANSHEE, "Banshee",0},
{PCI_CHIP_VOODOO3, "Voodoo3",0},
+ {PCI_CHIP_VOODOO5, "Voodoo5",0},
{0x0000, NULL,0}}},
{PCI_VENDOR_SIGMADESIGNS, {
{0x6401, "REALmagic64/GX (SD 6425)",0 },
@@ -1199,6 +1283,9 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{0x1371, "es1371",0 },
{0x0000, NULL,0}}},
#ifdef VENDOR_INCLUDE_NONVIDEO
+ {PCI_VENDOR_ROCKWELL, {
+ {0x2005, "RS56/SP-PCI11P1 56K V90 modem/spkrphone",0 },
+ {0x0000, NULL,0}}},
#ifdef INCLUDE_EMPTY_LISTS
{PCI_VENDOR_YOKOGAWA, {
{0x0000, NULL,0}}},
@@ -1227,6 +1314,7 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{PCI_CHIP_PERMEDIA2, "GLINT Permedia 2",0},
{PCI_CHIP_GAMMA, "GLINT Gamma",0},
{PCI_CHIP_PERMEDIA2V, "GLINT Permedia 2v",0},
+ {PCI_CHIP_PERMEDIA3, "GLINT Permedia 3",0},
{0x0000, NULL,0}}},
{PCI_VENDOR_AVANCE_2, {
{0x0000, NULL,0}}},
@@ -1299,6 +1387,14 @@ static pciVendorDeviceInfo xf86PCIVendorInfoData[] = {
{0x84C4, "P6",0},
{0x84C5, "82450GX20",0},
{PCI_CHIP_I740_AGP, "i740 (AGP)",0},
+ {PCI_CHIP_I815_BRIDGE, "i815 Bridge",0},
+ {PCI_CHIP_I815, "i815",0},
+ {PCI_CHIP_I810_BRIDGE, "i810 Bridge",0},
+ {PCI_CHIP_I810, "i810",0},
+ {PCI_CHIP_I810_DC100_BRIDGE, "i810-dc100 Bridge",0},
+ {PCI_CHIP_I810_DC100, "i810-dc100",0},
+ {PCI_CHIP_I810_E_BRIDGE,"i810e Bridge",0},
+ {PCI_CHIP_I810_E, "i810e",0},
{0x0000, NULL,0}}},
{PCI_VENDOR_ADAPTEC, {
{0x0010, "2940U2",0 },
@@ -1376,18 +1472,15 @@ static pciVendorCardInfo xf86PCICardInfoData[] = {
#endif
/* ATI card info deleted; unmaintainable */
#ifdef VENDOR_INCLUDE_NONVIDEO
-#ifdef INCLUDE_EMPTY_LISTS
{ PCI_VENDOR_COMPAQ, {
+ { 0xC001, "NC3121",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
-#endif
-#ifdef VENDOR_INCLUDE_NONVIDEO
{ PCI_VENDOR_NCR_1, {
{ 0x1000, "SCSI HBA",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
{ PCI_VENDOR_REALTEC, {
{ 0x8139, "Generic",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
-#endif
{ PCI_VENDOR_CREATIVE_2, {
{ 0x1017, "3D Blaster Banshee",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
@@ -1395,18 +1488,32 @@ static pciVendorCardInfo xf86PCICardInfoData[] = {
{ 0x500A, "EtherWORKS 10/100",0, NF},
{ 0x0000, (char *)NULL,0, NF } } },
#endif
+ { PCI_VENDOR_SONY, {
+ { 0x8051, "Vaio Video",0,NF },
+#ifdef VENDOR_INCLUDE_NONVIDEO
+ { 0x8052, "Vaio Audio",0,NF },
+ { 0x8054, "Vaio Firewire",0,NF },
+ { 0x8056, "Vaio Modem",0,NF },
+ { 0x8057, "Vaio Ethernet",0,NF },
+#endif
+ { 0x0000, (char *)NULL,0, NF } } },
{ PCI_VENDOR_DIAMOND, {
- { 0x8000, "C&T 69000",0, NF },
- { 0x1103, "Fire GL 1000",0, NF },
- { 0x0154, "Fire GL 1000 PRO",0, NF },
{ 0x0003, "Monster Fusion",0, NF },
- { 0x8a10, "Stealth 3D 4000",0, NF },
+ { 0x00b8, "Fire GL1",0, NF },
{ 0x0100, "Stealth II G460",0, NF },
- { 0x2000, "Stealth II S220",0, NF },
- { 0x1092, "Viper 330",0, NF },
+ { 0x0154, "Fire GL 1000 PRO",0, NF },
+ { 0x0172, "Fire GL2",0, NF },
+ { 0x0173, "Fire GL2",0, NF },
{ 0x0550, "Viper 550",0, NF },
- { 0x8760, "Fireport 40 Dual",0, NF },
+ { 0x1092, "Viper 330",0, NF },
+ { 0x1103, "Fire GL 1000",0, NF },
+ { 0x2000, "Stealth II S220",0, NF },
{ 0x2110, "Sonic Impact S70",0, NF },
+ { 0x4803, "Monster Fusion",0, NF },
+ { 0x6820, "Viper 770",0, NF },
+ { 0x8000, "C&T 69000",0, NF },
+ { 0x8760, "Fireport 40 Dual",0, NF },
+ { 0x8a10, "Stealth 3D 4000",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
{ PCI_VENDOR_ELSA, {
{ 0x0914, "Winner 1000",0, NF },
@@ -1509,7 +1616,7 @@ static pciVendorCardInfo xf86PCICardInfoData[] = {
#endif
{ PCI_VENDOR_S3, {
{ 0x8904, "Trio3D",0, NF },
- { 0x8a10, "ViRGE/GX2",0, NF },
+ { 0x8a10, "Generic",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
{ PCI_VENDOR_NUMNINE, {
{ 0x8a10, "Reality 334",0, NF },
@@ -1518,9 +1625,15 @@ static pciVendorCardInfo xf86PCICardInfoData[] = {
{ 0x0001, "4010CDT CT65555",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
#ifdef VENDOR_INCLUDE_NONVIDEO
+ { PCI_VENDOR_LITEON, {
+ { 0xc001, "LNE100TX Version 2.0",0, NF },
+ { 0x0000, (char *)NULL,0, NF } } },
{ PCI_VENDOR_BUSLOGIC, {
{ 0x1040, "BT958",0, NF },
{ 0x0000, (char *)NULL,0, NF } } },
+ { PCI_VENDOR_NETGEAR, {
+ { 0xf004, "FA310-TX Rev. D2",0, NF },
+ { 0x0000, (char *)NULL,0, NF } } },
#endif
{0x0000, {
{0x0000, NULL,0, NF } } },
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h b/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
index 6dc85ea0f..00cece3a9 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Priv.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.65 2000/03/08 05:38:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.67 2000/06/20 05:08:45 dawes Exp $ */
/*
* Copyright (c) 1997 by The XFree86 Project, Inc.
@@ -120,13 +120,10 @@ void xf86AccessLeaveState(void);
void xf86FindPrimaryDevice(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 xf86ResourceBrokerInit(void);
void xf86PostProbe(void);
void xf86ClearEntityListForScreen(int scrnIndex);
+void xf86AddDevToEntity(int entityIndex, GDevPtr dev);
extern void xf86PostPreInit(void);
extern void xf86PostScreenInit(void);
extern memType getValidBIOSBase(PCITAG tag, int num);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h b/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
index 4502f8e66..e887a74ef 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.18 2000/02/08 13:13:06 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Privstr.h,v 1.19 2000/05/31 07:15:00 eich Exp $ */
/*
* Copyright (c) 1997,1998 by The XFree86 Project, Inc.
@@ -23,7 +23,8 @@ typedef enum {
PCIProbe1 = 0,
PCIProbe2,
PCIForceConfig1,
- PCIForceConfig2
+ PCIForceConfig2,
+ PCIOsConfig
} PciProbeType;
/*
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h b/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h
index 826aad632..d1ca38b88 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Resources.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.8 2000/02/08 13:13:06 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Resources.h,v 1.9 2000/04/23 19:26:57 tsi Exp $ */
#ifndef _XF86_RESOURCES_H
@@ -23,9 +23,9 @@
{ResShrIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
#define _VGA_SHARED_MEM \
- {ResShrMemBlock | ResBios | ResBus, 0xA0000, 0xAFFFF},\
- {ResShrMemBlock | ResBios | ResBus, 0xB0000, 0xB7FFF},\
- {ResShrMemBlock | ResBios | ResBus, 0xB8000, 0xBFFFF}
+ {ResShrMemBlock | ResBios | ResBus, 0x000A0000, 0x000AFFFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
+ {ResShrMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF}
#define _VGA_SHARED_IO \
{ResShrIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
@@ -40,7 +40,7 @@
{ResExcUusdMemBlock | ResBios | ResBus, 0x000B0000, 0x000B7FFF},\
{ResExcUusdMemBlock | ResBios | ResBus, 0x000B8000, 0x000BFFFF},\
{ResExcUusdIoBlock | ResBios | ResBus, 0x03B0, 0x03BB},\
- {ResExcUusdIoBlock | ResBios | ResBus, 0x3C0, 0x3DF}
+ {ResExcUusdIoBlock | ResBios | ResBus, 0x03C0, 0x03DF}
/*
* Shared unused VGA: resources unneeded but cannot be disabled
@@ -91,6 +91,10 @@ extern resRange resVgaSparseShared[];
extern resRange res8514Exclusive[];
extern resRange res8514Shared[];
+/* Less misleading aliases for xf86SetOpratingState() */
+#define resVgaMem resVgaMemShared
+#define resVgaIo resVgaIoShared
+
/* old style names */
#define RES_EXCLUSIVE_VGA resVgaExclusive
#define RES_SHARED_VGA resVgaShared
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86XKB.c b/xc/programs/Xserver/hw/xfree86/common/xf86XKB.c
index 7e09a6a14..3489f41ea 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86XKB.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86XKB.c
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.8 1999/03/28 15:32:29 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.9 2000/05/23 04:47:41 dawes Exp $ */
#include <stdio.h>
#define NEED_EVENTS 1
@@ -70,7 +70,8 @@ XkbDDXUpdateIndicators(DeviceIntPtr pXDev,CARD32 new)
static int kbdSun = -1;
if (kbdSun == -1) {
- if (xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ if ((xf86Info.xkbmodel && !strcmp(xf86Info.xkbmodel, "sun"))
+ || (xf86Info.xkbrules && !strcmp(xf86Info.xkbrules, "sun")))
kbdSun = 1;
else
kbdSun = 0;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c b/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c
index 8f5061d7b..792f0d2bf 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c
@@ -22,7 +22,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.54 1999/12/13 23:38:11 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Xinput.c,v 3.60 2000/06/30 19:06:56 keithp Exp $ */
#include "Xfuncproto.h"
#include "Xmd.h"
@@ -164,6 +164,8 @@ xf86XInputSetSendCoreEvents(LocalDevicePtr local, Bool always)
}
}
+static int xf86CoreButtonState;
+
/***********************************************************************
*
* xf86CheckButton --
@@ -177,13 +179,21 @@ Bool
xf86CheckButton(int button,
int down)
{
- int state = (inputInfo.pointer->button->state & 0x1f00) >> 8;
- int check = (state & (1 << (button - 1)));
+ int check;
+ int bit = (1 << (button - 1));
+
+ check = xf86CoreButtonState & bit;
- if ((check && down) && (!check && !down)) {
+ DBG(5, ErrorF("xf86CheckButton "
+ "button=%d down=%d state=%d check=%d returns ",
+ button, down, state, check));
+ if ((check && down) || (!check && !down)) {
+ DBG(5, ErrorF("FALSE\n"));
return FALSE;
}
+ xf86CoreButtonState ^= bit;
+ DBG(5, ErrorF("TRUE\n"));
return TRUE;
}
@@ -898,7 +908,7 @@ xf86PostMotionEvent(DeviceIntPtr device,
int dx, dy;
float mult;
#ifdef XFreeXDGA
- int xdelta = 0, ydelta = 0;
+ int rawx = 0, rawy = 0;
#endif
DBG(5, ErrorF("xf86PostMotionEvent BEGIN 0x%x(%s) switch=0x%x is_core=%s is_shared=%s is_absolute=%s\n",
@@ -942,6 +952,18 @@ xf86PostMotionEvent(DeviceIntPtr device,
DBG(5, ErrorF("xf86PostMotionEvent v0=%d v1=%d\n", xv->valuator0, xv->valuator1));
+#ifdef XFreeXDGA
+ /*
+ * DGA wants raw dx/dy (or at least, I think it does -keithp)
+ */
+ rawx = xv->valuator0;
+ rawy = xv->valuator1;
+ if (is_absolute)
+ {
+ rawx -= local->old_x;
+ rawy -= local->old_y;
+ }
+#endif
if (loop == 1 && !is_absolute && device->ptrfeed && device->ptrfeed->ctrl.num) {
/* modeled from xf86Events.c */
if (device->ptrfeed->ctrl.threshold) {
@@ -996,15 +1018,6 @@ xf86PostMotionEvent(DeviceIntPtr device,
DBG(5, ErrorF("xf86PostMotionEvent(mr) x1=%d y1=%d\n", x1,y1));
}
}
-#ifdef XFreeXDGA
- /* We need to save this for DGA so we can undo it
- to get relative motion again */
- if(!is_absolute) {
- xdelta = axisvals[loop+first_valuator-1];
- ydelta = axisvals[loop+first_valuator];
- } else
- xdelta = ydelta = 0;
-#endif
RELATIVE_CHECK(xv->valuator0, loop+first_valuator-1);
RELATIVE_CHECK(xv->valuator1, loop+first_valuator);
break;
@@ -1081,7 +1094,8 @@ xf86PostMotionEvent(DeviceIntPtr device,
*/
#ifdef XFreeXDGA
- if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, x - xdelta, y - ydelta )) {
+ xev->type = MotionNotify;
+ if (!DGAStealMouseEvent(xf86EventQueue.pEnqueueScreen->myNum, xE, rawx, rawy )) {
#endif
miPointerAbsoluteCursor(x, y, xf86Info.lastEventTime);
@@ -1262,7 +1276,9 @@ xf86PostButtonEvent(DeviceIntPtr device,
/* Check the core pointer button state not to send an inconsistent
* event. This can happen with the AlwaysCore feature.
*/
- if ((is_core || is_shared) && !xf86CheckButton(button, is_down)) {
+ if ((is_core || is_shared) &&
+ !xf86CheckButton(device->button->map[button], is_down))
+ {
return;
}
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c b/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c
index 4436186ec..c6d9db03d 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86cmap.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.18 1999/11/12 02:11:13 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.c,v 1.19 2000/03/17 20:43:34 mvojkovi Exp $ */
#ifdef _XOPEN_SOURCE
#include <math.h>
@@ -172,7 +172,7 @@ Bool xf86HandleColormaps(
if (!(flags & CMAP_LOAD_EVEN_IF_OFFSCREEN)) {
pScrn->EnterVT = CMapEnterVT;
- if (flags & CMAP_RELOAD_ON_MODE_SWITCH)
+ if ((flags & CMAP_RELOAD_ON_MODE_SWITCH) && pScrn->SwitchMode)
pScrn->SwitchMode = CMapSwitchMode;
}
#ifdef XFreeXDGA
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86cmap.h b/xc/programs/Xserver/hw/xfree86/common/xf86cmap.h
index 084991dad..8dd5986e2 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86cmap.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86cmap.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.h,v 1.5 1999/07/18 03:26:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86cmap.h,v 1.6 2000/05/11 18:14:28 tsi Exp $ */
#ifndef _XF86CMAP_H
#define _XF86CMAP_H
@@ -35,7 +35,7 @@ Bool xf86HandleColormaps(
int
xf86ChangeGamma(
ScreenPtr pScreen,
- Gamma gamma
+ Gamma newGamma
);
#endif /* _XF86CMAP_H */
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c b/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c
index 7e0e604c7..331893bf3 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86fbman.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.13 1999/11/28 20:29:37 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.c,v 1.15 2000/06/10 18:10:59 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -8,105 +8,156 @@
#include "regionstr.h"
#include "xf86fbman.h"
+static int xf86FBMangerIndex = -1;
+static unsigned long xf86ManagerGeneration = 0;
-static Bool xf86FBCloseScreen(int, ScreenPtr);
-static unsigned long xf86FBGeneration = 0;
-static int xf86FBScreenIndex = -1;
-static void SendCallFreeBoxCallbacks(FBManagerPtr);
-static FBAreaPtr AllocateArea(
- FBManagerPtr offman,
- int w, int h,
- int granularity,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-);
+
+Bool xf86RegisterOffscreenManager(
+ ScreenPtr pScreen,
+ FBManagerFuncsPtr funcs
+){
+
+ if(xf86ManagerGeneration != serverGeneration) {
+ if((xf86FBMangerIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ xf86ManagerGeneration = serverGeneration;
+ }
+
+ pScreen->devPrivates[xf86FBMangerIndex].ptr = (pointer)funcs;
+
+ return TRUE;
+}
Bool
xf86FBManagerRunning(ScreenPtr pScreen)
{
- if(xf86FBScreenIndex < 0)
+ if(xf86FBMangerIndex < 0)
return FALSE;
- if(!pScreen->devPrivates[xf86FBScreenIndex].ptr)
+ if(!pScreen->devPrivates[xf86FBMangerIndex].ptr)
return FALSE;
return TRUE;
}
Bool
-xf86InitFBManager(
+xf86RegisterFreeBoxCallback(
ScreenPtr pScreen,
- BoxPtr FullBox
+ FreeBoxCallbackProcPtr FreeBoxCallback,
+ pointer devPriv
){
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- RegionRec ScreenRegion;
- RegionRec FullRegion;
- BoxRec ScreenBox;
- Bool ret;
+ FBManagerFuncsPtr funcs;
- ScreenBox.x1 = 0;
- ScreenBox.y1 = 0;
- ScreenBox.x2 = pScrn->virtualX;
- ScreenBox.y2 = pScrn->virtualY;
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
- if((FullBox->x1 > ScreenBox.x1) || (FullBox->y1 > ScreenBox.y1) ||
- (FullBox->x2 < ScreenBox.x2) || (FullBox->y2 < ScreenBox.y2)) {
- return FALSE;
- }
+ return (*funcs->RegisterFreeBoxCallback)(pScreen, FreeBoxCallback, devPriv);
+}
- REGION_INIT(pScreen, &ScreenRegion, &ScreenBox, 1);
- REGION_INIT(pScreen, &FullRegion, FullBox, 1);
- REGION_SUBTRACT(pScreen, &FullRegion, &FullRegion, &ScreenRegion);
+FBAreaPtr
+xf86AllocateOffscreenArea(
+ ScreenPtr pScreen,
+ int w, int h,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerFuncsPtr funcs;
- ret = xf86InitFBManagerRegion(pScreen, &FullRegion);
+ if(xf86FBMangerIndex < 0)
+ return NULL;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return NULL;
- REGION_UNINIT(pScreen, &ScreenRegion);
- REGION_UNINIT(pScreen, &FullRegion);
-
- return ret;
+ return (*funcs->AllocateOffscreenArea)(
+ pScreen, w, h, gran, moveCB, removeCB, privData);
+}
+
+
+void
+xf86FreeOffscreenArea(FBAreaPtr area)
+{
+ FBManagerFuncsPtr funcs;
+
+ if(!area) return;
+
+ if(xf86FBMangerIndex < 0)
+ return;
+ if(!(funcs =
+ (FBManagerFuncsPtr)area->pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return;
+
+ (*funcs->FreeOffscreenArea)(area);
+
+ return;
}
+
Bool
-xf86InitFBManagerRegion(
- ScreenPtr pScreen,
- RegionPtr FullRegion
+xf86ResizeOffscreenArea(
+ FBAreaPtr resize,
+ int w, int h
){
- FBManagerPtr offman;
+ FBManagerFuncsPtr funcs;
- if(REGION_NIL(FullRegion))
+ if(!resize) return FALSE;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs =
+ (FBManagerFuncsPtr)resize->pScreen->devPrivates[xf86FBMangerIndex].ptr))
return FALSE;
- if(xf86FBGeneration != serverGeneration) {
- if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0)
- return FALSE;
- xf86FBGeneration = serverGeneration;
- }
+ return (*funcs->ResizeOffscreenArea)(resize, w, h);
+}
- offman = xalloc(sizeof(FBManager));
- if(!offman) return FALSE;
- pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)offman;
+Bool
+xf86QueryLargestOffscreenArea(
+ ScreenPtr pScreen,
+ int *w, int *h,
+ int gran,
+ int preferences,
+ int severity
+){
+ FBManagerFuncsPtr funcs;
- offman->CloseScreen = pScreen->CloseScreen;
- pScreen->CloseScreen = xf86FBCloseScreen;
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
- offman->InitialBoxes = REGION_CREATE(pScreen, NULL, 1);
- offman->FreeBoxes = REGION_CREATE(pScreen, NULL, 1);
+ return (*funcs->QueryLargestOffscreenArea)(
+ pScreen, w, h, gran, preferences, severity);
+}
- REGION_COPY(pScreen, offman->InitialBoxes, FullRegion);
- REGION_COPY(pScreen, offman->FreeBoxes, FullRegion);
- offman->pScreen = pScreen;
- offman->UsedAreas = NULL;
- offman->NumUsedAreas = 0;
- offman->NumCallbacks = 0;
- offman->FreeBoxesUpdateCallback = NULL;
- offman->devPrivates = NULL;
+Bool
+xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
+{
+ FBManagerFuncsPtr funcs;
+
+ if(xf86FBMangerIndex < 0)
+ return FALSE;
+ if(!(funcs = (FBManagerFuncsPtr)pScreen->devPrivates[xf86FBMangerIndex].ptr))
+ return FALSE;
+
+ return (*funcs->PurgeOffscreenAreas)(pScreen);
+}
+
+/************************************************************\
+
+ Below is a specific implementation of an offscreen manager.
+
+\************************************************************/
+
+static unsigned long xf86FBGeneration = 0;
+static int xf86FBScreenIndex = -1;
- return TRUE;
-}
static void
SendCallFreeBoxCallbacks(FBManagerPtr offman)
@@ -119,8 +170,8 @@ SendCallFreeBoxCallbacks(FBManagerPtr offman)
}
}
-Bool
-xf86RegisterFreeBoxCallback(
+static Bool
+localRegisterFreeBoxCallback(
ScreenPtr pScreen,
FreeBoxCallbackProcPtr FreeBoxCallback,
pointer devPriv
@@ -129,9 +180,6 @@ xf86RegisterFreeBoxCallback(
FreeBoxCallbackProcPtr *newCallbacks;
DevUnion *newPrivates;
- if(!xf86FBManagerRunning(pScreen))
- return FALSE;
-
offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
newCallbacks = xrealloc( offman->FreeBoxesUpdateCallback,
@@ -253,8 +301,8 @@ AllocateArea(
return area;
}
-FBAreaPtr
-xf86AllocateOffscreenArea(
+static FBAreaPtr
+localAllocateOffscreenArea(
ScreenPtr pScreen,
int w, int h,
int gran,
@@ -265,8 +313,6 @@ xf86AllocateOffscreenArea(
FBManagerPtr offman;
FBAreaPtr area = NULL;
- if(!xf86FBManagerRunning(pScreen)) return NULL;
-
offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
if((area = AllocateArea(offman, w, h, gran, moveCB, removeCB, privData)))
@@ -275,87 +321,15 @@ xf86AllocateOffscreenArea(
return area;
}
-FBAreaPtr
-xf86AllocateLinearOffscreenArea(
- ScreenPtr pScreen,
- int length,
- int gran,
- MoveAreaCallbackProcPtr moveCB,
- RemoveAreaCallbackProcPtr removeCB,
- pointer privData
-){
- FBManagerPtr offman;
- FBLinkPtr link = NULL;
- FBAreaPtr area = NULL;
- RegionRec NewReg;
- BoxPtr boxp, box1p = NULL;
- int i, num, w, h;
-
- if (!xf86FBManagerRunning(pScreen)) return NULL;
-
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
- if (offman->InitialBoxes->extents.x1 != 0 ||
- length <= 0) return NULL;
-
- w = offman->InitialBoxes->extents.x2 -
- offman->InitialBoxes->extents.x1;
- h = (length + w - 1) / w;
-
- /* look through the free boxes,
- bottom up to reduce fragmentation troubles */
-
- boxp = REGION_RECTS(offman->FreeBoxes);
- num = REGION_NUM_RECTS(offman->FreeBoxes);
-
- for (i = 0; i < num; i++, boxp++) {
- if (((boxp->y2 - boxp->y1) < h) ||
- ((boxp->x2 - boxp->x1) < w) ||
- (box1p && box1p->y1 > boxp->y1))
- continue;
-
- box1p = boxp;
- }
-
- if (!box1p) return NULL;
- link = xalloc(sizeof(FBLink));
- if (!link) return NULL;
- area = &(link->area);
-
- area->pScreen = pScreen;
- area->granularity = gran;
- area->box.x1 = box1p->x1; /* Presumed zero */
- area->box.x2 = box1p->x1 + w;
- area->box.y1 = box1p->y2 - h;
- area->box.y2 = box1p->y2;
- 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);
-
- link->next = offman->UsedAreas;
- offman->UsedAreas = link;
- offman->NumUsedAreas++;
-
- SendCallFreeBoxCallbacks(offman);
-
- return area;
-}
-
-void
-xf86FreeOffscreenArea(FBAreaPtr area)
+static void
+localFreeOffscreenArea(FBAreaPtr area)
{
FBManagerPtr offman;
FBLinkPtr pLink, pLinkPrev = NULL;
RegionRec FreedRegion;
ScreenPtr pScreen;
- if(!area || !xf86FBManagerRunning(area->pScreen))
- return;
-
pScreen = area->pScreen;
offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
@@ -385,8 +359,8 @@ xf86FreeOffscreenArea(FBAreaPtr area)
-Bool
-xf86ResizeOffscreenArea(
+static Bool
+localResizeOffscreenArea(
FBAreaPtr resize,
int w, int h
){
@@ -397,9 +371,6 @@ xf86ResizeOffscreenArea(
FBAreaPtr area = NULL;
FBLinkPtr pLink, newLink, pLinkPrev = NULL;
- if(!resize || !xf86FBManagerRunning(resize->pScreen))
- return FALSE;
-
pScreen = resize->pScreen;
offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
@@ -500,85 +471,8 @@ xf86ResizeOffscreenArea(
return TRUE;
}
-
-
-Bool
-xf86FBCloseScreen (int i, ScreenPtr pScreen)
-{
- FBLinkPtr pLink, tmp;
- FBManagerPtr offman =
- (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
-
- pScreen->CloseScreen = offman->CloseScreen;
-
- pLink = offman->UsedAreas;
-
- while(pLink) {
- tmp = pLink;
- pLink = pLink->next;
- xfree(tmp);
- }
-
- REGION_DESTROY(pScreen, offman->InitialBoxes);
- REGION_DESTROY(pScreen, offman->FreeBoxes);
-
- xfree(offman);
-
- return (*pScreen->CloseScreen) (i, pScreen);
-}
-
-
-Bool
-xf86PurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
-{
- FBManagerPtr offman;
- FBLinkPtr pLink, tmp, pPrev = NULL;
- RegionRec FreedRegion;
- Bool anyUsed = FALSE;
-
- if(!xf86FBManagerRunning(pScreen))
- return FALSE;
-
- offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
-
- 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;
-}
-
-
-Bool
-xf86QueryLargestOffscreenArea(
+static Bool
+localQueryLargestOffscreenArea(
ScreenPtr pScreen,
int *width, int *height,
int granularity,
@@ -593,9 +487,6 @@ xf86QueryLargestOffscreenArea(
*width = *height = oldArea = 0;
- if(!xf86FBManagerRunning(pScreen))
- return FALSE;
-
if(granularity <= 1) granularity = 0;
if((preferences < 0) || (preferences > 3))
@@ -700,3 +591,241 @@ xf86QueryLargestOffscreenArea(
return TRUE;
}
+
+static Bool
+localPurgeUnlockedOffscreenAreas(ScreenPtr pScreen)
+{
+ FBManagerPtr offman;
+ FBLinkPtr pLink, tmp, pPrev = NULL;
+ RegionRec FreedRegion;
+ Bool anyUsed = FALSE;
+
+ offman = pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+ 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 FBManagerFuncs xf86FBManFuncs = {
+ localAllocateOffscreenArea,
+ localFreeOffscreenArea,
+ localResizeOffscreenArea,
+ localQueryLargestOffscreenArea,
+ localRegisterFreeBoxCallback,
+ localPurgeUnlockedOffscreenAreas
+ };
+
+
+static Bool
+xf86FBCloseScreen (int i, ScreenPtr pScreen)
+{
+ FBLinkPtr pLink, tmp;
+ FBManagerPtr offman =
+ (FBManagerPtr) pScreen->devPrivates[xf86FBScreenIndex].ptr;
+
+
+ pScreen->CloseScreen = offman->CloseScreen;
+
+ pLink = offman->UsedAreas;
+
+ while(pLink) {
+ tmp = pLink;
+ pLink = pLink->next;
+ xfree(tmp);
+ }
+
+ REGION_DESTROY(pScreen, offman->InitialBoxes);
+ REGION_DESTROY(pScreen, offman->FreeBoxes);
+
+ xfree(offman);
+
+ return (*pScreen->CloseScreen) (i, pScreen);
+}
+
+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;
+ }
+
+ 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;
+}
+
+Bool
+xf86InitFBManagerRegion(
+ ScreenPtr pScreen,
+ RegionPtr FullRegion
+){
+ FBManagerPtr offman;
+
+ if(REGION_NIL(FullRegion))
+ return FALSE;
+
+ if(xf86FBGeneration != serverGeneration) {
+ if((xf86FBScreenIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ xf86FBGeneration = serverGeneration;
+ }
+
+ if(!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs))
+ return FALSE;
+
+ offman = xalloc(sizeof(FBManager));
+ if(!offman) return FALSE;
+
+ pScreen->devPrivates[xf86FBScreenIndex].ptr = (pointer)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->NumUsedAreas = 0;
+ offman->NumCallbacks = 0;
+ offman->FreeBoxesUpdateCallback = NULL;
+ offman->devPrivates = NULL;
+
+ return TRUE;
+}
+
+/*************************************************************\
+
+ These functions are specific to this implementation and
+ may only be called by the driver that initialized this
+ implementation.
+
+\*************************************************************/
+
+FBAreaPtr
+xf86AllocateLinearOffscreenArea(
+ ScreenPtr pScreen,
+ int length,
+ int gran,
+ MoveAreaCallbackProcPtr moveCB,
+ RemoveAreaCallbackProcPtr removeCB,
+ pointer privData
+){
+ FBManagerPtr offman;
+ FBLinkPtr link = NULL;
+ FBAreaPtr area = NULL;
+ RegionRec NewReg;
+ BoxPtr boxp, box1p = NULL;
+ int i, num, w, h;
+
+ if(xf86FBScreenIndex < 0)
+ return NULL;
+ if(!(offman = pScreen->devPrivates[xf86FBScreenIndex].ptr))
+ return NULL;
+
+ if (offman->InitialBoxes->extents.x1 != 0 ||
+ length <= 0) return NULL;
+
+ w = offman->InitialBoxes->extents.x2 -
+ offman->InitialBoxes->extents.x1;
+ h = (length + w - 1) / w;
+
+ /* look through the free boxes,
+ bottom up to reduce fragmentation troubles */
+
+ boxp = REGION_RECTS(offman->FreeBoxes);
+ num = REGION_NUM_RECTS(offman->FreeBoxes);
+
+ for (i = 0; i < num; i++, boxp++) {
+ if (((boxp->y2 - boxp->y1) < h) ||
+ ((boxp->x2 - boxp->x1) < w) ||
+ (box1p && box1p->y1 > boxp->y1))
+ continue;
+
+ box1p = boxp;
+ }
+
+ if (!box1p) return NULL;
+ link = xalloc(sizeof(FBLink));
+ if (!link) return NULL;
+ area = &(link->area);
+
+ area->pScreen = pScreen;
+ area->granularity = gran;
+ area->box.x1 = box1p->x1; /* Presumed zero */
+ area->box.x2 = box1p->x1 + w;
+ area->box.y1 = box1p->y2 - h;
+ area->box.y2 = box1p->y2;
+ 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);
+
+ link->next = offman->UsedAreas;
+ offman->UsedAreas = link;
+ offman->NumUsedAreas++;
+
+ SendCallFreeBoxCallbacks(offman);
+
+ return area;
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86fbman.h b/xc/programs/Xserver/hw/xfree86/common/xf86fbman.h
index fdb295043..3504fa18f 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86fbman.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86fbman.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.h,v 1.8 1999/06/27 14:07:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86fbman.h,v 1.10 2000/06/10 18:10:59 mvojkovi Exp $ */
#ifndef _XF86FBMAN_H
#define _XF86FBMAN_H
@@ -48,7 +48,34 @@ typedef struct {
DevUnion *devPrivates;
} FBManager, *FBManagerPtr;
-
+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);
+ Bool (*PurgeOffscreenAreas) (ScreenPtr);
+} FBManagerFuncs, *FBManagerFuncsPtr;
+
+
+Bool xf86RegisterOffscreenManager(
+ ScreenPtr pScreen,
+ FBManagerFuncsPtr funcs
+);
Bool
xf86InitFBManagerRegion(
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c b/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c
index 74c76701b..24c37ae00 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c,v 3.3 2000/02/08 13:13:06 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86isaBus.c,v 3.4 2000/06/20 05:08:45 dawes Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
@@ -43,9 +43,9 @@ xf86ClaimIsaSlot(DriverPtr drvp, int chipset, GDevPtr dev, Bool active)
p->driver = drvp;
p->chipset = chipset;
p->busType = BUS_ISA;
- p->device = dev;
p->active = active;
p->inUse = FALSE;
+ xf86AddDevToEntity(num, dev);
p->access = xnfcalloc(1,sizeof(EntityAccessRec));
p->access->fallback = &AccessNULL;
p->access->pAccess = &AccessNULL;
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c b/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
index 3fb5b6ba4..e4e5b45ed 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c,v 3.13 2000/03/05 23:47:48 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86pciBus.c,v 3.18 2000/06/20 05:08:45 dawes Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
@@ -37,6 +37,8 @@ pciConfigPtr *xf86PciInfo = NULL; /* Full PCI probe info */
pciVideoPtr *xf86PciVideoInfo = NULL; /* PCI probe for video hw */
pciAccPtr * xf86PciAccInfo = NULL; /* PCI access related */
+static resPtr pciAvoidRes = NULL;
+
/* PCI buses */
static PciBusPtr xf86PciBus = NULL;
/* Bus-specific probe/sorting functions */
@@ -470,10 +472,6 @@ pciIoAccessEnable(void* arg)
ErrorF("pciIoAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
#endif
((pciArg*)arg)->ctrl |= SETBITS;
-#ifdef notanymore
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
- SETBITS, SETBITS);
-#endif
((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
((pciArg*)arg)->ctrl);
}
@@ -485,9 +483,6 @@ pciIoAccessDisable(void* arg)
ErrorF("pciIoAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
#endif
((pciArg*)arg)->ctrl &= ~SETBITS;
-#ifdef notanymore
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG, SETBITS, 0);
-#endif
((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
((pciArg*)arg)->ctrl);
}
@@ -501,10 +496,6 @@ pciIo_MemAccessEnable(void* arg)
ErrorF("pciIo_MemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
#endif
((pciArg*)arg)->ctrl |= SETBITS;
-#ifdef notanymore
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
- SETBITS, SETBITS);
-#endif
((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
((pciArg*)arg)->ctrl);
}
@@ -516,9 +507,6 @@ pciIo_MemAccessDisable(void* arg)
ErrorF("pciIo_MemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
#endif
((pciArg*)arg)->ctrl &= ~SETBITS;
-#ifdef notanymore
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG, SETBITS, 0);
-#endif
((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
((pciArg*)arg)->ctrl);
}
@@ -532,10 +520,6 @@ pciMemAccessEnable(void* arg)
ErrorF("pciMemAccessEnable: 0x%05lx\n", *(PCITAG *)arg);
#endif
((pciArg*)arg)->ctrl |= SETBITS;
-#ifdef notanymore
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
- SETBITS, SETBITS);
-#endif
((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
((pciArg*)arg)->ctrl);
}
@@ -547,9 +531,6 @@ pciMemAccessDisable(void* arg)
ErrorF("pciMemAccessDisable: 0x%05lx\n", *(PCITAG *)arg);
#endif
((pciArg*)arg)->ctrl &= ~SETBITS;
-#ifdef notanymore
- ((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,SETBITS, 0);
-#endif
((pciArg*)arg)->func(((pciArg*)arg)->tag, PCI_CMD_STAT_REG,
((pciArg*)arg)->ctrl);
}
@@ -599,17 +580,19 @@ pciSetBusAccess(BusAccPtr ptr)
}
}
+/* move to OS layer */
static void
savePciState(PCITAG tag, pciSavePtr ptr)
{
int i;
-
+
ptr->command = pciReadLong(tag,PCI_CMD_STAT_REG);
for (i=0; i < 6; i++)
ptr->base[i] = pciReadLong(tag,PCI_CMD_BASE_REG + i*4 );
ptr->biosBase = pciReadLong(tag,PCI_CMD_BIOS_REG);
}
+/* move to OS layer */
static void
restorePciState(PCITAG tag, pciSavePtr ptr)
{
@@ -624,6 +607,7 @@ restorePciState(PCITAG tag, pciSavePtr ptr)
pciWriteLong(tag,PCI_CMD_STAT_REG,ptr->command);
}
+/* move to OS layer */
static void
savePciBusState(BusAccPtr ptr)
{
@@ -637,6 +621,7 @@ savePciBusState(BusAccPtr ptr)
pciReadByte(ptr->busdep.pci.acc,PCI_PCI_BRIDGE_CONTROL_REG);
}
+/* move to OS layer */
static void
restorePciBusState(BusAccPtr ptr)
{
@@ -657,6 +642,7 @@ disablePciBios(PCITAG tag)
pciSetBitsLong(tag, PCI_CMD_BIOS_REG, PCI_CMD_BIOS_ENABLE, 0);
}
+/* ????? */
static void
correctPciSize(memType base, int oldsize, int newsize, long type)
{
@@ -717,6 +703,7 @@ correctPciSize(memType base, int oldsize, int newsize, long type)
}
}
+/* ????? */
static void
removeOverlapsWithBridges(int busIndex, resPtr target)
{
@@ -747,6 +734,7 @@ removeOverlapsWithBridges(int busIndex, resPtr target)
xf86FreeResList(bridgeRes);
}
+/* ????? */
static void
xf86GetPciRes(resPtr *activeRes, resPtr *inactiveRes)
{
@@ -949,7 +937,7 @@ ResourceBrokerInitPci(resPtr *osRes)
* Adjust OS-reported resource ranges based on the assumption that there
* are no overlaps with the PCI base allocations. This should be a good
* assumption because writes to PCI address space won't be routed directly
- * host memory.
+ * to host memory.
*/
for (tmp = *osRes; tmp; tmp = tmp->next)
@@ -959,6 +947,12 @@ ResourceBrokerInitPci(resPtr *osRes)
" overlaps with PCI:\n");
xf86PrintResList(3, *osRes);
+ pciAvoidRes = xf86AddRangesToList(pciAvoidRes,PciAvoid,-1);
+ for (tmp = pciAvoidRes; tmp; tmp = tmp->next)
+ RemoveOverlaps(tmp, activeRes, FALSE);
+ tmp = xf86DupResList(*osRes);
+ pciAvoidRes = xf86JoinResLists(pciAvoidRes,tmp);
+
return (xf86JoinResLists(activeRes,inactiveRes));
}
@@ -1022,7 +1016,7 @@ fixPciResource(int prt, memType alignment, pciVideoPtr pvp, long type)
type |= ResBlock;
/* setup avoid: PciAvoid is bus range: convert later */
- avoid = xf86AddRangesToList(avoid,PciAvoid,-1);
+ avoid = xf86DupResList(pciAvoidRes);
while (pbp) {
if (pbp->secondary == pvp->bus) {
@@ -1064,7 +1058,8 @@ fixPciResource(int prt, memType alignment, pciVideoPtr pvp, long type)
}
/* convert bus based entries in avoid list to host base */
- xf86ConvertListToHost(xf86GetEntityForPciInfo(pvp),avoid);
+ xf86ConvertListToHost(
+ xf86GetPciEntity(pvp->bus,pvp->device,pvp->func), avoid);
if (!w)
w = xf86DupResList(ResRange);
@@ -1323,7 +1318,7 @@ getValidBIOSBase(PCITAG tag, int num)
alignment = (1 << biosSize) - 1;
if (biosSize > 24)
biosSize = 24;
- avoid = NULL;
+ avoid = xf86DupResList(pciAvoidRes);
pbp = pbp1 = xf86PciBus;
while (pbp) {
@@ -1349,6 +1344,8 @@ getValidBIOSBase(PCITAG tag, int num)
}
pbp = pbp->next;
}
+ xf86ConvertListToHost(
+ xf86GetPciEntity(pvp->bus,pvp->device,pvp->func), avoid);
if (pvp->biosBase) { /* try biosBase first */
P_M_RANGE(range, TAG(pvp),pvp->biosBase,biosSize,ResExcMemBlock);
@@ -1426,6 +1423,7 @@ xf86GetPciBridgeInfo(const pciConfigPtr *pciInfo)
PciBusPtr *pnPciBus = &PciBusBase;
int MaxBus = 0;
int i;
+ memType base, limit;
if (pciInfo == NULL) return NULL;
@@ -1457,38 +1455,50 @@ xf86GetPciBridgeInfo(const pciConfigPtr *pciInfo)
PciBus->brfunc = pcrp->funcnum;
PciBus->subclass = sub_class;
PciBus->brcontrol = pcrp->pci_bridge_control;
- if (pcrp->pci_io_base <= pcrp->pci_io_limit
- && (pcrp->pci_command & PCI_CMD_IO_ENABLE)) {
- PCI_I_RANGE(range,pcrp->tag,pcrp->pci_io_base << 8
- | (pcrp->pci_upper_io_base << 16),
- (pcrp->pci_io_limit << 8)
- | (pcrp->pci_upper_io_limit << 16) | 0xfff,
+ if (pcrp->pci_command & PCI_CMD_IO_ENABLE) {
+ base = (pcrp->pci_upper_io_base << 16) |
+ ((pcrp->pci_io_base & 0xf0u) << 8);
+ limit = (pcrp->pci_upper_io_limit << 16) |
+ ((pcrp->pci_io_limit & 0xf0u) << 8) | 0x0fff;
+ /*
+ * Deal with bridge ISA mode (256 wide ranges spaced 1K
+ * apart, but only in the first 64K).
+ */
+ if (pcrp->pci_bridge_control & PCI_PCI_BRIDGE_ISA_EN) {
+ while ((base <= (CARD16)(-1)) && (base <= limit)) {
+ PCI_I_RANGE(range, pcrp->tag,
+ base, base + (CARD8)(-1),
ResIo | ResBlock | ResExclusive);
- PciBus->io = xf86AddResToList(NULL, &range, -1);
+ PciBus->io = xf86AddResToList(PciBus->io,
+ &range, -1);
+ base += 0x0400;
+ }
+ }
+ if (base <= limit) {
+ PCI_I_RANGE(range, pcrp->tag, base, limit,
+ ResIo | ResBlock | ResExclusive);
+ PciBus->io = xf86AddResToList(PciBus->io, &range, -1);
+ }
}
if (pcrp->pci_command & PCI_CMD_MEM_ENABLE) {
- if (pcrp->pci_mem_base <= pcrp->pci_mem_limit) {
- PCI_M_RANGE(range,pcrp->tag,pcrp->pci_mem_base << 16,
- (pcrp->pci_mem_limit << 16) | 0xfffff,
+ base = pcrp->pci_mem_base & 0xfff0u;
+ limit = pcrp->pci_mem_limit & 0xfff0u;
+ if (base <= limit) {
+ PCI_M_RANGE(range, pcrp->tag,
+ base << 16, (limit << 16) | 0x0fffff,
ResMem | ResBlock | ResExclusive);
PciBus->mem = xf86AddResToList(NULL, &range, -1);
}
- if (pcrp->pci_prefetch_mem_base
- <= pcrp->pci_prefetch_mem_limit) {
-#if !defined(LONG64) && !defined(WORD64)
- PCI_M_RANGE(range,pcrp->tag,
- pcrp->pci_prefetch_mem_base << 16,
- (pcrp->pci_prefetch_mem_limit << 16)
- | 0xfffff,
- ResMem | ResBlock | ResExclusive);
-#else
+ base = pcrp->pci_prefetch_mem_base & 0xfff0u;
+ limit = pcrp->pci_prefetch_mem_limit & 0xfff0u;
+#if defined(LONG64) || defined(WORD64)
+ base |= (memType)pcrp->pci_prefetch_upper_mem_base << 16;
+ limit |= (memType)pcrp->pci_prefetch_upper_mem_limit << 16;
+#endif
+ if (base <= limit) {
PCI_M_RANGE(range, pcrp->tag,
- pcrp->pci_prefetch_mem_base << 16
- | ((memType)pcrp->pci_prefetch_upper_mem_base << 32),
- (pcrp->pci_prefetch_mem_limit << 16) | 0xfffff
- | ((memType)pcrp->pci_prefetch_upper_mem_limit << 32),
+ base << 16, (limit << 16) | 0xfffff,
ResMem | ResBlock | ResExclusive);
-#endif
PciBus->pmem = xf86AddResToList(NULL, &range, -1);
}
}
@@ -1712,8 +1722,9 @@ ValidatePci(void)
resPtr res_mp = NULL, res_m_io = NULL;
resPtr NonSys = NULL;
resPtr tmp, avoid = NULL;
-
+
if (!pvp->validate) continue;
+ avoid = xf86DupResList(pciAvoidRes);
NonSys = xf86DupResList(Sys);
m = n;
while ((pvp1 = xf86PciVideoInfo[m++])) {
@@ -1762,6 +1773,10 @@ ValidatePci(void)
}
if (res_m_io == NULL)
res_m_io = xf86DupResList(ResRange);
+
+ xf86ConvertListToHost(
+ xf86GetPciEntity(pvp->bus,pvp->device,pvp->func), avoid);
+
#ifdef DEBUG
xf86MsgVerb(X_INFO, 3,"avoid:\n");
xf86PrintResList(3,avoid);
@@ -1904,9 +1919,6 @@ initPciState(void)
pcaccp->funcnum = pvp->func;
pcaccp->arg.tag = pciTag(pvp->bus, pvp->device, pvp->func);
pcaccp->arg.func =
-#ifdef notanymore
- (SetBitsProcPtr)pciLongFunc(pcaccp->arg.tag,SET_BITS);
-#endif
(WriteProcPtr)pciLongFunc(pcaccp->arg.tag,WRITE);
pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
@@ -2146,12 +2158,12 @@ xf86ClaimPciSlot(int bus, int device, int func, DriverPtr drvp,
p->driver = drvp;
p->chipset = chipset;
p->busType = BUS_PCI;
- p->device = dev;
p->pciBusId.bus = bus;
p->pciBusId.device = device;
p->pciBusId.func = func;
p->active = active;
p->inUse = FALSE;
+ xf86AddDevToEntity(num, dev);
/* Here we initialize the access structure */
p->access = xnfcalloc(1,sizeof(EntityAccessRec));
while (ppaccp && *ppaccp) {
@@ -2462,7 +2474,7 @@ xf86GetPciInfoForEntity(int entityIndex)
}
int
-xf86GetEntityForPciInfo(pciVideoPtr pvp)
+xf86GetPciEntity(int bus, int dev, int func)
{
int i;
@@ -2470,9 +2482,9 @@ xf86GetEntityForPciInfo(pciVideoPtr pvp)
EntityPtr p = xf86Entities[i];
if (p->busType != BUS_PCI) continue;
- if (p->pciBusId.bus == pvp->bus &&
- p->pciBusId.device == pvp->device &&
- p->pciBusId.func == pvp->func)
+ if (p->pciBusId.bus == bus &&
+ p->pciBusId.device == dev &&
+ p->pciBusId.func == func)
return i;
}
return -1;
@@ -2601,13 +2613,13 @@ xf86FindPciClass(CARD8 intf, CARD8 subClass, CARD16 class,
}
/*
- * This attempts to detect a multi-device card and set up a list
+ * This attempts to detect a multi-device card and sets up a list
* of pci tags of the devices of this card. On some of these
* cards the BIOS is not visible from all chipsets. We therefore
- * need to us the bios from a chipset where it is visible.
+ * need to use the BIOS from a chipset where it is visible.
* We do the following heuristics:
* If we detect only identical pci devices on a bus we assume it's
- * a multi-device card. This assumption isn't true alwaus, however.
+ * a multi-device card. This assumption isn't true always, however.
* One might just use identical cards on a bus. We therefore don't
* detect this situation when we set up the PCI video info. Instead
* we wait until an attempt to read the BIOS fails.
@@ -2641,23 +2653,23 @@ pciTestMultiDeviceCard(int bus, int dev, int func, PCITAG** pTag)
}
if (!pcrp) return 0;
+
/*
* we check all functions here: since multifunc devices need
* to implement func 0 we catch all devices on the bus when
* i = 0
*/
- if (pcrp->pci_header_type &0x80)
- multifunc = TRUE;
-
- ppcrp = xf86PciInfo;
-
+ if (pcrp->pci_header_type &0x80)
+ multifunc = TRUE;
+
+ j = 0;
+
while (ppcrp[j]) {
if (ppcrp[j]->busnum == bus && ppcrp[j]->funcnum == i
&& ppcrp[j]->devnum != pcrp->devnum) {
/* don't test subsys ID here. It might be set by POST
- - however some cars might not have been POSTed */
+ - however some cards might not have been POSTed */
if (ppcrp[j]->pci_device_vendor != pcrp->pci_device_vendor
- || ppcrp[j]->pci_class_revision != pcrp->pci_class_revision
|| ppcrp[j]->pci_header_type != pcrp->pci_header_type )
return 0;
else
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c b/xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c
new file mode 100644
index 000000000..9b221349d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c
@@ -0,0 +1,725 @@
+/*
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.c,v 3.3 2000/06/20 16:01:20 dawes Exp $ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "X.h"
+#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"
+
+#define FB_DEV_PATH "/dev/fb%d"
+
+sbusDevicePtr *xf86SbusInfo = NULL;
+static int xf86nSbusInfo;
+
+#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
+
+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 }
+};
+
+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, FB_DEV_PATH, i);
+ CheckSbusDevice(fbDevName, i);
+ }
+ if (sparcPromInit() >= 0) {
+ useProm = 1;
+ sparcPromAssignNodes();
+ }
+ for (psdpp = xf86SbusInfo, psdp = *psdpp; psdp; psdp = *++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;
+ 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;
+ }
+ }
+ if (useProm && psdp->node.node) {
+ char *promPath;
+ 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;
+ return num;
+ } else
+ return -1;
+}
+
+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(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.
+ */
+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;
+}
+
+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;
+}
+
+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 int sbusPaletteIndex = -1;
+static unsigned long sbusPaletteGeneration = 0;
+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)((pScreen)->devPrivates[sbusPaletteIndex].ptr))
+
+static void
+xf86SbusCmapLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual)
+{
+ int i, index;
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+ unsigned char *data = ALLOCATE_LOCAL(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);
+ DEALLOCATE_LOCAL(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);
+}
+
+Bool
+xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp)
+{
+ sbusCmapPtr cmap;
+ struct fbcmap fbcmap;
+ unsigned char data[2];
+
+ if(sbusPaletteGeneration != serverGeneration) {
+ if((sbusPaletteIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ sbusPaletteGeneration = serverGeneration;
+ }
+ cmap = xnfcalloc(1, sizeof(sbusCmapRec));
+ pScreen->devPrivates[sbusPaletteIndex].ptr = 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/xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.h b/xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.h
new file mode 100644
index 000000000..c6be2d32f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.h
@@ -0,0 +1,88 @@
+/*
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86sbusBus.h,v 3.3 2000/06/30 17:15:11 dawes Exp $ */
+
+#ifndef _XF86_SBUSBUS_H
+#define _XF86_SBUSBUS_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);
+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/xc/programs/Xserver/hw/xfree86/common/xf86str.h b/xc/programs/Xserver/hw/xfree86/common/xf86str.h
index b8412cddd..2743415b6 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86str.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86str.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.67 2000/03/01 16:00:54 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86str.h,v 1.71 2000/06/20 05:08:45 dawes Exp $ */
/*
* Copyright (c) 1997-2000 by The XFree86 Project, Inc.
@@ -86,6 +86,9 @@ typedef enum {
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_BAD = -2, /* unspecified reason */
MODE_ERROR = -1 /* error condition */
} ModeStatus;
@@ -228,7 +231,8 @@ typedef struct _DriverRec {
typedef enum {
BUS_NONE,
BUS_ISA,
- BUS_PCI
+ BUS_PCI,
+ BUS_SBUS
} BusType;
typedef struct {
@@ -241,11 +245,16 @@ typedef struct {
unsigned int dummy;
} IsaBusId;
+typedef struct {
+ int fbNum;
+} SbusBusId;
+
typedef struct _bus {
BusType type;
union {
IsaBusId isa;
PciBusId pci;
+ SbusBusId sbus;
} id;
} BusRec, *BusPtr;
@@ -283,6 +292,7 @@ typedef struct {
int chipRev;
pointer options;
int irq;
+ int screen; /* For multi-CRTC cards */
} GDevRec, *GDevPtr;
typedef int (*FindIsaDevProc)(GDevPtr dev);
@@ -412,7 +422,7 @@ typedef struct _confdrirec {
/* These values should be adjusted when new fields are added to ScrnInfoRec */
#define NUM_RESERVED_INTS 16
-#define NUM_RESERVED_POINTERS 16
+#define NUM_RESERVED_POINTERS 15
#define NUM_RESERVED_FUNCS 16
typedef pointer (*funcPointer)(void);
@@ -474,6 +484,12 @@ typedef struct _AccessRec {
void *arg;
} xf86AccessRec, *xf86AccessPtr;
+typedef struct {
+ xf86AccessPtr mem;
+ xf86AccessPtr io;
+ xf86AccessPtr io_mem;
+} xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
+
/* bus-access-related types */
typedef enum {
NONE,
@@ -608,6 +624,7 @@ typedef struct _entityInfo {
Bool active;
resPtr resources;
GDevPtr device;
+ DriverPtr driver;
} EntityInfoRec, *EntityInfoPtr;
/* server states */
@@ -798,6 +815,8 @@ typedef struct _ScrnInfoRec {
* structure size and alignment unchanged.
*/
int reservedInt[NUM_RESERVED_INTS];
+
+ int * entityInstanceList;
pointer reservedPtr[NUM_RESERVED_POINTERS];
/*
@@ -820,7 +839,7 @@ typedef struct _ScrnInfoRec {
void (*EnableDisableFBAccess)(int scrnIndex, Bool enable);
int (*SetDGAMode)(int scrnIndex, int num,
DGADevicePtr devRet);
- int (*ChangeGamma)(int scrnIndex, Gamma gamma);
+ int (*ChangeGamma)(int scrnIndex, Gamma newGamma);
void (*PointerMoved)(int scrnIndex, int x, int y);
Bool (*PMEvent)(int scrnIndex, pmEvent event);
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86xv.c b/xc/programs/Xserver/hw/xfree86/common/xf86xv.c
index d7d69a67d..cd0331bc5 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86xv.c
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86xv.c
@@ -6,7 +6,7 @@
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.19 2000/02/22 01:58:06 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.c,v 1.26 2000/06/09 22:41:06 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -18,6 +18,7 @@
#include "regionstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
+#include "mivalidate.h"
#include "validate.h"
#include "resource.h"
#include "gcstruct.h"
@@ -73,6 +74,7 @@ static int xf86XVQueryImageAttributes(ClientPtr, XvPortPtr, XvImagePtr,
static Bool xf86XVCreateWindow(WindowPtr pWin);
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 */
@@ -102,6 +104,15 @@ int (*XvScreenInitProc)(ScreenPtr) = XvScreenInit;
#endif
+#define GET_XV_SCREEN(pScreen) \
+ ((XvScreenPtr)((pScreen)->devPrivates[XF86XvScreenIndex].ptr))
+
+#define GET_XF86XV_SCREEN(pScreen) \
+ ((XF86XVScreenPtr)(GET_XV_SCREEN(pScreen)->devPriv.ptr))
+
+#define GET_XF86XV_WINDOW(pWin) \
+ ((XF86XVWindowPtr)((pWin)->devPrivates[XF86XVWindowIndex].ptr))
+
static xf86XVInitGenericAdaptorPtr *GenDrivers = NULL;
static int NumGenDrivers = 0;
@@ -146,6 +157,19 @@ xf86XVListGenericAdaptors(
return num;
}
+XF86VideoAdaptorPtr
+xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn)
+{
+ return xcalloc(1, sizeof(XF86VideoAdaptorRec));
+}
+
+void
+xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr)
+{
+ xfree(ptr);
+}
+
+
Bool
xf86XVScreenInit(
ScreenPtr pScreen,
@@ -173,7 +197,7 @@ xf86XVScreenInit(
XF86XvScreenIndex = (*XvGetScreenIndexProc)();
PortResource = (*XvGetRTPortProc)();
- pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
+ pxvs = GET_XV_SCREEN(pScreen);
/* Anyone initializing the Xv layer must provide these two.
@@ -193,20 +217,23 @@ xf86XVScreenInit(
if(!ScreenPriv) return FALSE;
- ScreenPriv->ClipNotify = pScreen->ClipNotify;
ScreenPriv->CreateWindow = pScreen->CreateWindow;
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->ClipNotify = xf86XVClipNotify;
pScreen->CreateWindow = xf86XVCreateWindow;
pScreen->DestroyWindow = xf86XVDestroyWindow;
+ pScreen->WindowExposures = xf86XVWindowExposures;
+ pScreen->ClipNotify = xf86XVClipNotify;
pScrn->EnterVT = xf86XVEnterVT;
pScrn->LeaveVT = xf86XVLeaveVT;
- pScrn->AdjustFrame = xf86XVAdjustFrame;
+ if(pScrn->AdjustFrame)
+ pScrn->AdjustFrame = xf86XVAdjustFrame;
if(!xf86XVInitAdaptors(pScreen, adaptors, num))
return FALSE;
@@ -274,7 +301,7 @@ xf86XVInitAdaptors(
XF86VideoAdaptorPtr *infoPtr,
int number
) {
- XvScreenPtr pxvs = (XvScreenPtr)(pScreen->devPrivates[XF86XvScreenIndex].ptr);
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
XF86VideoAdaptorPtr adaptorPtr;
XvAdaptorPtr pAdaptor, pa;
@@ -863,8 +890,7 @@ CLIP_VIDEO_BAILOUT:
static int
xf86XVReputAllVideo(WindowPtr pWin, pointer data)
{
- XF86XVWindowPtr WinPriv =
- (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
+ XF86XVWindowPtr WinPriv = GET_XF86XV_WINDOW(pWin);
while(WinPriv) {
if(WinPriv->PortRec->type == XvInputMask)
@@ -882,8 +908,7 @@ xf86XVEnlistPortInWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
XF86XVWindowPtr winPriv, PrivRoot;
- winPriv = PrivRoot =
- (XF86XVWindowPtr)(pWin->devPrivates[XF86XVWindowIndex].ptr);
+ winPriv = PrivRoot = GET_XF86XV_WINDOW(pWin);
/* Enlist our port in the window private */
while(winPriv) {
@@ -908,7 +933,7 @@ xf86XVRemovePortFromWindow(WindowPtr pWin, XvPortRecPrivatePtr portPriv)
{
XF86XVWindowPtr winPriv, prevPriv = NULL;
- winPriv = (XF86XVWindowPtr)(pWin->devPrivates[XF86XVWindowIndex].ptr);
+ winPriv = GET_XF86XV_WINDOW(pWin);
while(winPriv) {
if(winPriv->PortRec == portPriv) {
@@ -933,8 +958,7 @@ static Bool
xf86XVCreateWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
int ret;
pScreen->CreateWindow = ScreenPriv->CreateWindow;
@@ -951,13 +975,10 @@ static Bool
xf86XVDestroyWindow(WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
- XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
- XF86XVWindowPtr tmp, WinPriv =
- (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
+ XF86XVWindowPtr tmp, WinPriv = GET_XF86XV_WINDOW(pWin);
int ret;
- /* The DI layer only stops and removes video not transient stills/images */
while(WinPriv) {
XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
@@ -983,41 +1004,101 @@ xf86XVDestroyWindow(WindowPtr pWin)
}
-
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;
+
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = FALSE;
+ pPriv->pDraw = NULL;
+
+ if(!pPrev)
+ pWin->devPrivates[XF86XVWindowIndex].ptr =
+ (pointer)(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;
- XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
- XF86XVWindowPtr WinPriv =
- (XF86XVWindowPtr)pWin->devPrivates[XF86XVWindowIndex].ptr;
+ 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) {
- XvPortRecPrivatePtr pPriv = WinPriv->PortRec;
+ pPriv = WinPriv->PortRec;
if(pPriv->pCompositeClip && pPriv->FreeCompositeClip)
REGION_DESTROY(pScreen, pPriv->pCompositeClip);
pPriv->pCompositeClip = NULL;
- if(!pPriv->type) { /* overlaid still/image */
- if ((pPriv->AdaptorRec->ReputImage) &&
- ((pWin->visibility == VisibilityUnobscured) ||
- (pWin->visibility == VisibilityPartiallyObscured)))
- {
- xf86XVReputImage(pPriv);
- }
- else {
- (*pPriv->AdaptorRec->StopVideo)(
- pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ /* Stop everything except images, but stop them too if the
+ window isn't visible. But we only remove the images. */
- pPriv->isOn = FALSE;
+ if(pPriv->type || !visible) {
+ (*pPriv->AdaptorRec->StopVideo)(
+ pPriv->pScrn, pPriv->DevPriv.ptr, FALSE);
+ pPriv->isOn = FALSE;
+
+ if(!pPriv->type) { /* overlaid still/image */
pPriv->pDraw = NULL;
+
if(!pPrev)
- pWin->devPrivates[XF86XVWindowIndex].ptr =
- (pointer)(WinPriv->next);
+ pWin->devPrivates[XF86XVWindowIndex].ptr =
+ (pointer)(WinPriv->next);
else
pPrev->next = WinPriv->next;
tmp = WinPriv;
@@ -1025,20 +1106,16 @@ xf86XVClipNotify(WindowPtr pWin, int dx, int dy)
xfree(tmp);
continue;
}
- } else {
- if(pPriv->type == XvInputMask)
- xf86XVReputVideo(pPriv);
- else
- xf86XVRegetVideo(pPriv);
}
+
pPrev = WinPriv;
WinPriv = WinPriv->next;
}
-
+
if(ScreenPriv->ClipNotify) {
- pScreen->ClipNotify = ScreenPriv->ClipNotify;
- (*pScreen->ClipNotify)(pWin, dx, dy);
- pScreen->ClipNotify = xf86XVClipNotify;
+ pScreen->ClipNotify = ScreenPriv->ClipNotify;
+ (*pScreen->ClipNotify)(pWin, dx, dy);
+ pScreen->ClipNotify = xf86XVClipNotify;
}
}
@@ -1050,8 +1127,8 @@ static Bool
xf86XVCloseScreen(int i, ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- XvScreenPtr pxvs = (XvScreenPtr) pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
XvAdaptorPtr pa;
int c;
@@ -1059,6 +1136,7 @@ xf86XVCloseScreen(int i, ScreenPtr pScreen)
pScreen->CreateWindow = ScreenPriv->CreateWindow;
pScreen->DestroyWindow = ScreenPriv->DestroyWindow;
+ pScreen->WindowExposures = ScreenPriv->WindowExposures;
pScreen->ClipNotify = ScreenPriv->ClipNotify;
pScrn->EnterVT = ScreenPriv->EnterVT;
@@ -1085,7 +1163,7 @@ xf86XVQueryAdaptors(
XvAdaptorPtr *p_pAdaptors,
int *p_nAdaptors
){
- XvScreenPtr pxvs = (XvScreenPtr) pScreen->devPrivates[XF86XvScreenIndex].ptr;
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
*p_nAdaptors = pxvs->nAdaptors;
*p_pAdaptors = pxvs->pAdaptors;
@@ -1100,9 +1178,7 @@ static Bool
xf86XVEnterVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- XvScreenPtr pxvs =
- (XvScreenPtr) pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
Bool ret;
ret = (*ScreenPriv->EnterVT)(index, flags);
@@ -1116,9 +1192,8 @@ static void
xf86XVLeaveVT(int index, int flags)
{
ScreenPtr pScreen = screenInfo.screens[index];
- XvScreenPtr pxvs =
- (XvScreenPtr) pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
XvAdaptorPtr pAdaptor;
XvPortPtr pPort;
XvPortRecPrivatePtr pPriv;
@@ -1154,8 +1229,8 @@ xf86XVAdjustFrame(int index, int x, int y, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[index];
ScreenPtr pScreen = pScrn->pScreen;
- XvScreenPtr pxvs = (XvScreenPtr)pScreen->devPrivates[XF86XvScreenIndex].ptr;
- XF86XVScreenPtr ScreenPriv = (XF86XVScreenPtr)pxvs->devPriv.ptr;
+ XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
+ XF86XVScreenPtr ScreenPriv = GET_XF86XV_SCREEN(pScreen);
WindowPtr pWin;
XvAdaptorPtr pa;
int c, i;
@@ -1355,6 +1430,7 @@ xf86XVPutStill(
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:
@@ -1603,8 +1679,8 @@ xf86XVPutImage(
VPBox.x1 = portPriv->pScrn->frameX0;
VPBox.y1 = portPriv->pScrn->frameY0;
- VPBox.x2 = portPriv->pScrn->frameX1;
- VPBox.y2 = portPriv->pScrn->frameY1;
+ VPBox.x2 = portPriv->pScrn->frameX1 + 1;
+ VPBox.y2 = portPriv->pScrn->frameY1 + 1;
REGION_INIT(pScreen, &VPReg, &VPBox, 1);
REGION_INTERSECT(Screen, &ClipRegion, &ClipRegion, &VPReg);
@@ -1650,6 +1726,7 @@ xf86XVPutImage(
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:
diff --git a/xc/programs/Xserver/hw/xfree86/common/xf86xv.h b/xc/programs/Xserver/hw/xfree86/common/xf86xv.h
index 1ff73f11a..48b29159f 100644
--- a/xc/programs/Xserver/hw/xfree86/common/xf86xv.h
+++ b/xc/programs/Xserver/hw/xfree86/common/xf86xv.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.13 2000/03/08 01:14:00 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86xv.h,v 1.17 2000/06/09 22:41:06 mvojkovi Exp $ */
#ifndef _XVDIX_H_
#define _XVDIX_H_
@@ -151,8 +151,8 @@ typedef struct {
short drw_w, short drw_h,
RegionPtr clipBoxes);
int (*stop) (XF86SurfacePtr surface);
- int (*getAttribute) (XF86SurfacePtr surface, Atom attr, INT32 *value);
- int (*setAttribute) (XF86SurfacePtr surface, Atom attr, INT32 value);
+ 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;
@@ -193,6 +193,9 @@ xf86XVQueryOffscreenImages(
int *num
);
+XF86VideoAdaptorPtr xf86XVAllocateVideoAdaptorRec(ScrnInfoPtr pScrn);
+
+void xf86XVFreeVideoAdaptorRec(XF86VideoAdaptorPtr ptr);
/*** These are DDX layer privates ***/
@@ -201,6 +204,7 @@ typedef struct {
CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
ClipNotifyProcPtr ClipNotify;
+ WindowExposuresProcPtr WindowExposures;
void (*AdjustFrame)(int, int, int, int);
Bool (*EnterVT)(int, int);
void (*LeaveVT)(int, int);
@@ -232,6 +236,7 @@ typedef struct {
Bool FreeCompositeClip;
XvAdaptorRecPrivatePtr AdaptorRec;
Bool isOn;
+ Bool moved;
int vid_x, vid_y, vid_w, vid_h;
int drw_x, drw_y, drw_w, drw_h;
DevUnion DevPriv;
@@ -239,7 +244,7 @@ typedef struct {
typedef struct _XF86XVWindowRec{
XvPortRecPrivatePtr PortRec;
- struct _XF86XVWindowRec *next;
+ struct _XF86XVWindowRec *next;
} XF86XVWindowRec, *XF86XVWindowPtr;
#endif /* _XVDIX_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/edid.h b/xc/programs/Xserver/hw/xfree86/ddc/edid.h
index 946c88a59..7a2f30cb4 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/edid.h
+++ b/xc/programs/Xserver/hw/xfree86/ddc/edid.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.h,v 1.4 1999/11/19 13:54:24 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/edid.h,v 1.7 2000/04/20 21:28:26 tsi Exp $ */
/* edid.h: defines to parse an EDID block
*
@@ -9,6 +9,10 @@
*
* Copyright 1998 by Egbert Eich <Egbert.Eich@Physik.TU-Darmstadt.DE>
*/
+
+#ifndef _EDID_H_
+#define _EDID_H_ 1
+
#include "vdif.h"
/* read complete EDID record */
@@ -403,6 +407,7 @@ struct detailed_monitor_section {
};
typedef struct {
+ int scrnIndex;
struct vendor vendor;
struct edid_version ver;
struct disp_features features;
@@ -414,5 +419,6 @@ typedef struct {
Uchar *rawData;
} xf86Monitor, *xf86MonPtr;
+extern xf86MonPtr ConfiguredMonitor;
-
+#endif /* _EDID_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c b/xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c
index 78627b408..9cfc7d90b 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c
+++ b/xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c,v 1.6 2000/01/21 02:30:00 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/interpret_edid.c,v 1.7 2000/04/17 16:29:55 eich Exp $ */
/* interpret_edid.c: interpret a primary EDID block
*
@@ -25,12 +25,13 @@ static void get_whitepoint_section(Uchar *, struct whitePoints *);
static void get_detailed_timing_section(Uchar*, struct detailed_timings *);
xf86MonPtr
-xf86InterpretEDID(Uchar *block)
+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);
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/print_edid.c b/xc/programs/Xserver/hw/xfree86/ddc/print_edid.c
index cf94e5a71..ab1c8c601 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/print_edid.c
+++ b/xc/programs/Xserver/hw/xfree86/ddc/print_edid.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/print_edid.c,v 1.5 1999/09/25 14:37:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/print_edid.c,v 1.12 2000/06/07 22:03:08 tsi Exp $ */
/* print_edid.c: print out all information retrieved from display device
*
@@ -9,253 +9,277 @@
#include "xf86_ansic.h"
#include "xf86_OSproc.h"
#include "xf86DDC.h"
+
+static void print_vendor(int scrnIndex, struct vendor *);
+static void print_version(int scrnIndex, struct edid_version *);
+static void print_display(int scrnIndex, struct disp_features *);
+static void print_established_timings(int scrnIndex,
+ struct established_timings *);
+static void print_std_timings(int scrnIndex, struct std_timings *);
+static void print_detailed_monitor_section(int scrnIndex,
+ struct detailed_monitor_section *);
+static void print_detailed_timings(int scrnIndex, struct detailed_timings *);
-static void print_vendor(struct vendor *);
-static void print_version(struct edid_version *);
-static void print_display(struct disp_features *);
-static void print_established_timings(struct established_timings *);
-static void print_std_timings(struct std_timings *);
-static void print_detailed_monitor_section(struct detailed_monitor_section *);
-static void print_detailed_timings(struct detailed_timings *);
-
-static void print_input_features(struct disp_features *);
-static void print_dpms_features(struct disp_features *);
-static void print_whitepoint(struct disp_features *);
-
+static void print_input_features(int scrnIndex, struct disp_features *);
+static void print_dpms_features(int scrnIndex, struct disp_features *);
+static void print_whitepoint(int scrnIndex, struct disp_features *);
+
xf86MonPtr
xf86PrintEDID(xf86MonPtr m)
{
if (!(m)) return NULL;
- print_vendor(&m->vendor);
- print_version(&m->ver);
- print_display(&m->features);
- print_established_timings(&m->timings1);
- print_std_timings(m->timings2);
- print_detailed_monitor_section(m->det_mon);
+ print_vendor(m->scrnIndex,&m->vendor);
+ print_version(m->scrnIndex,&m->ver);
+ print_display(m->scrnIndex,&m->features);
+ print_established_timings(m->scrnIndex,&m->timings1);
+ print_std_timings(m->scrnIndex,m->timings2);
+ print_detailed_monitor_section(m->scrnIndex,m->det_mon);
return m;
}
-
+
static void
-print_vendor(struct vendor *c)
+print_vendor(int scrnIndex, struct vendor *c)
{
- ErrorF("Manufacturer: %s ",&c->name);
- ErrorF("Model: %x ",c->prod_id);
- ErrorF("Serial#: %u ",c->serial);
- ErrorF("Year: %u ",c->year);
- ErrorF("Week: %u\n",c->week);
+ xf86DrvMsg(scrnIndex, X_INFO, "Manufacturer: %s Model: %x Serial#: %u\n",
+ &c->name, c->prod_id, c->serial);
+ xf86DrvMsg(scrnIndex, X_INFO, "Year: %u Week: %u\n", c->year, c->week);
}
-
+
static void
-print_version(struct edid_version *c)
+print_version(int scrnIndex, struct edid_version *c)
{
- ErrorF("EDID Version: %u.%u\n",c->version,c->revision);
+ xf86DrvMsg(scrnIndex,X_INFO,"EDID Version: %u.%u\n",c->version,
+ c->revision);
}
-
+
static void
-print_display(struct disp_features *disp)
+print_display(int scrnIndex, struct disp_features *disp)
{
- print_input_features(disp);
- ErrorF("Max H-Image Size [cm]: ");
+ print_input_features(scrnIndex,disp);
+ xf86DrvMsg(scrnIndex,X_INFO,"Max H-Image Size [cm]: ");
if (disp->hsize)
- ErrorF("horiz.: %i ",disp->hsize);
+ xf86ErrorF("horiz.: %i ",disp->hsize);
else
- ErrorF("H-Size may change, ");
+ xf86ErrorF("H-Size may change, ");
if (disp->vsize)
- ErrorF("vert.: %i\n",disp->vsize);
- else
- ErrorF("V-Size may change\n");
- ErrorF("Gamma: %.2f\n", disp->gamma);
- print_dpms_features(disp);
- print_whitepoint(disp);
+ xf86ErrorF("vert.: %i\n",disp->vsize);
+ else
+ xf86ErrorF("V-Size may change\n");
+ xf86DrvMsg(scrnIndex,X_INFO,"Gamma: %.2f\n", disp->gamma);
+ print_dpms_features(scrnIndex,disp);
+ print_whitepoint(scrnIndex,disp);
}
-
+
static void
-print_input_features(struct disp_features *c)
+print_input_features(int scrnIndex, struct disp_features *c)
{
if (DIGITAL(c->input_type))
- ErrorF("Digital Display Input, ");
+ xf86DrvMsg(scrnIndex,X_INFO,"Digital Display Input\n");
else {
- ErrorF("Analog Display Input, ");
- ErrorF("Input Voltage Level: ");
+ xf86DrvMsg(scrnIndex,X_INFO,"Analog Display Input, ");
+ xf86ErrorF("Input Voltage Level: ");
switch (c->input_voltage){
case V070:
- ErrorF("0.700/0.300 V\n");
+ xf86ErrorF("0.700/0.300 V\n");
break;
case V071:
- ErrorF("0.714/0.286 V\n");
+ xf86ErrorF("0.714/0.286 V\n");
break;
case V100:
- ErrorF("1.000/0.400 V\n");
+ xf86ErrorF("1.000/0.400 V\n");
break;
case V007:
- ErrorF("0.700/0.700 V\n");
+ xf86ErrorF("0.700/0.700 V\n");
break;
default:
- ErrorF("undefined\n");
+ xf86ErrorF("undefined\n");
}
- if (SIG_SETUP(c->input_setup)) ErrorF("Signal levels configurable\n");
- ErrorF("Sync: ");
- if (SEP_SYNC(c->input_sync)) ErrorF("Separate ");
- if (COMP_SYNC(c->input_sync)) ErrorF("Composite ");
- if (SYNC_O_GREEN(c->input_sync)) ErrorF("SyncOnGreen ");
+ 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))
- ErrorF("\nSerration on V.Sync Pulse req. if CompSync or SyncOnGreen\n");
- else ErrorF("\n");
+ xf86ErrorF("\n Serration on"
+ "V.Sync Pulse req. if CompSync or SyncOnGreen\n");
+ else xf86ErrorF("\n");
}
}
-
+
static void
-print_dpms_features(struct disp_features *c)
+print_dpms_features(int scrnIndex, struct disp_features *c)
{
- ErrorF("DPMS capabilities: ");
- if (DPMS_STANDBY(c->dpms)) ErrorF("StandBy ");
- if (DPMS_SUSPEND(c->dpms)) ErrorF("Suspend ");
- if (DPMS_OFF(c->dpms)) ErrorF("Off ");
+ 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");
switch (c->display_type){
case DISP_MONO:
- ErrorF("; Monochorome/GrayScale Display\n");
+ xf86ErrorF("; Monochorome/GrayScale Display\n");
break;
case DISP_RGB:
- ErrorF("; RGB/Color Display\n");
+ xf86ErrorF("; RGB/Color Display\n");
break;
case DISP_MULTCOLOR:
- ErrorF("; Non RGB Multicolor Display\n");
+ xf86ErrorF("; Non RGB Multicolor Display\n");
break;
default:
break;
}
if (STD_COLOR_SPACE(c->msc))
- ErrorF("Default color space is primary color space\n");
+ xf86DrvMsg(scrnIndex,X_INFO,
+ "Default color space is primary color space\n");
if (PREFERRED_TIMING_MODE(c->msc))
- ErrorF("First detailed timing is preferred mode\n");
+ xf86DrvMsg(scrnIndex,X_INFO,
+ "First detailed timing is preferred mode\n");
if (GFT_SUPPORTED(c->msc))
- ErrorF("GTF timings supported\n");
+ xf86DrvMsg(scrnIndex,X_INFO,
+ "GTF timings supported\n");
}
-
+
static void
-print_whitepoint(struct disp_features *disp)
+print_whitepoint(int scrnIndex, struct disp_features *disp)
{
- ErrorF("redX: %.3f redY: %.3f ",
- disp->redx,disp->redy);
- ErrorF("greenX: %.3f greenY: %.3f\n",
- disp->greenx,disp->greeny);
- ErrorF("blueX: %.3f blueY: %.3f ",
- disp->bluex,disp->bluey);
- ErrorF("whiteX: %.3f whiteY: %.3f\n",
- disp->whitex,disp->whitey);
+ 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_established_timings(struct established_timings *t)
+print_established_timings(int scrnIndex, struct established_timings *t)
{
unsigned char c;
- ErrorF("Supported VESA Video Modes:\n");
+ if (t->t1 || t->t2 || t->t_manu)
+ xf86DrvMsg(scrnIndex,X_INFO,"Supported VESA Video Modes:\n");
c=t->t1;
- if (c&0x80) ErrorF("720x400@70Hz\n");
- if (c&0x40) ErrorF("720x400@88Hz\n");
- if (c&0x20) ErrorF("640x480@60Hz\n");
- if (c&0x10) ErrorF("640x480@67Hz\n");
- if (c&0x08) ErrorF("640x480@72Hz\n");
- if (c&0x04) ErrorF("640x480@75Hz\n");
- if (c&0x02) ErrorF("800x600@56Hz\n");
- if (c&0x01) ErrorF("800x600@60Hz\n");
+ 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) ErrorF("800x600@72Hz\n");
- if (c&0x40) ErrorF("800x600@75Hz\n");
- if (c&0x20) ErrorF("832x624@75Hz\n");
- if (c&0x10) ErrorF("1024x768@87Hz (interlaced)\n");
- if (c&0x08) ErrorF("1024x768@60Hz\n");
- if (c&0x04) ErrorF("1024x768@70Hz\n");
- if (c&0x02) ErrorF("1024x768@75Hz\n");
- if (c&0x01) ErrorF("1280x1024@75Hz\n");
+ 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) ErrorF("1152x870@75Hz\n");
- ErrorF("Manufacturer's mask: %X\n",c&0x7F);
+ 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(struct std_timings *t)
+print_std_timings(int scrnIndex, struct std_timings *t)
{
int i;
- ErrorF("Supported Future Video Modes:\n");
+ char done = 0;
for (i=0;i<STD_TIMINGS;i++) {
if (t[i].hsize > 256) { /* sanity check */
- ErrorF("#%i: hsize: %i vsize %i refresh: %i vid: %i\n",
- i, t[i].hsize, t[i].vsize, t[i].refresh, t[i].id);
+ 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_detailed_monitor_section(struct detailed_monitor_section *m)
+print_detailed_monitor_section(int scrnIndex,
+ struct detailed_monitor_section *m)
{
- int i,j;
-
- for (i=0;i<DET_TIMINGS;i++) {
- switch (m[i].type) {
- case DT:
- print_detailed_timings(&m[i].section.d_timings);
- break;
- case DS_SERIAL:
- ErrorF("Serial No: %s\n",m[i].section.serial);
- break;
- case DS_ASCII_STR:
- ErrorF(" %s\n",m[i].section.ascii_data);
- break;
- case DS_NAME:
- ErrorF("Monitor name: %s\n",m[i].section.name);
- break;
- case DS_RANGES:
- ErrorF("Ranges: V min: %i V max: %i Hz, H min: %i H max: %i kHz,",
- m[i].section.ranges.min_v, m[i].section.ranges.max_v,
- m[i].section.ranges.min_h, m[i].section.ranges.max_h);
- if (m[i].section.ranges.max_clock != 0)
- ErrorF(" PixClock max %i MHz\n",m[i].section.ranges.max_clock);
- else
- ErrorF("\n");
- break;
- case DS_STD_TIMINGS:
- for (j = 0; j<5; i++)
- ErrorF("#%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; i++)
- if (m[i].section.wp[j].index != 0)
- ErrorF("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;
+ int i,j;
+
+ for (i=0;i<DET_TIMINGS;i++) {
+ switch (m[i].type) {
+ case DT:
+ print_detailed_timings(scrnIndex,&m[i].section.d_timings);
+ break;
+ case DS_SERIAL:
+ xf86DrvMsg(scrnIndex,X_INFO,"Serial No: %s",m[i].section.serial);
+ break;
+ case DS_ASCII_STR:
+ xf86DrvMsg(scrnIndex,X_INFO," %s",m[i].section.ascii_data);
+ break;
+ case DS_NAME:
+ xf86DrvMsg(scrnIndex,X_INFO,"Monitor name: %s",m[i].section.name);
+ break;
+ case DS_RANGES:
+ xf86DrvMsg(scrnIndex,X_INFO,
+ "Ranges: V min: %i V max: %i Hz, H min: %i H max: %i kHz,",
+ m[i].section.ranges.min_v, m[i].section.ranges.max_v,
+ m[i].section.ranges.min_h, m[i].section.ranges.max_h);
+ if (m[i].section.ranges.max_clock != 0)
+ xf86ErrorF(" PixClock max %i MHz\n",m[i].section.ranges.max_clock);
+ else
+ xf86DrvMsg(scrnIndex,X_INFO,"\n");
+ 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;
+ }
}
- }
}
-
+
static void
-print_detailed_timings(struct detailed_timings *t)
+print_detailed_timings(int scrnIndex, struct detailed_timings *t)
{
- if (t->clock > 15000000) { /* sanity check */
- ErrorF("Supported additional Video Mode:\n");
- ErrorF("clock: %.1f MHz ",t->clock/1000000.0);
- ErrorF("Image Size: %i x %i mm\n",t->h_size,t->v_size);
- ErrorF("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);
- ErrorF("h_border: %i\n",t->h_border);
- ErrorF("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);
- ErrorF("v_border: %i\n",t->v_border);
- if (IS_STEREO(t->stereo)) {
- ErrorF("Stereo: ");
- if (IS_RIGHT_ON_SYNC(t->stereo))
- ErrorF("right channel on sync\n");
- else ErrorF("right channel on sync\n");
+ 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_ON_SYNC(t->stereo))
+ xf86ErrorF("right channel on sync\n");
+ else xf86ErrorF("right channel on sync\n");
+ }
}
- }
}
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c b/xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c
index 0ae0126fc..71d81bbb7 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c
+++ b/xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c
@@ -1,6 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c,v 1.1 1998/11/28 10:43:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/print_vdif.c,v 1.2 2000/04/14 12:16:04 tsi Exp $ */
#include "vdif.h"
+#include "misc.h"
+
static void print_vdif(xf86VdifPtr l, char *s);
static void print_timings(xf86VdifTimingPtr *pt);
static void print_limits(xf86VdifLimitsPtr *pl);
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/vdif.h b/xc/programs/Xserver/hw/xfree86/ddc/vdif.h
index b0fd02351..38026e56a 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/vdif.h
+++ b/xc/programs/Xserver/hw/xfree86/ddc/vdif.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/vdif.h,v 1.2 1999/12/03 19:17:26 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/vdif.h,v 1.3 2000/04/14 12:16:04 tsi Exp $ */
#ifndef _VDIF_H
#define _VDIF_H
@@ -21,7 +21,8 @@
#define VDIF_SCAN_OTHER 2
#define VDIF_POLARITY_NEGATIVE 0
#define VDIF_POLARITY_POSITIVE 1
-#include "xf86.h"
+
+#include "Xmd.h"
#pragma pack(1)
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c b/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c
index 3157be12d..c62264f19 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c
+++ b/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c,v 1.13 2000/03/06 19:07:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.c,v 1.17 2000/06/07 22:03:09 tsi Exp $ */
/* xf86DDC.c
*
@@ -118,7 +118,8 @@ static OptionInfoRec DDCOptions[] = {
{ DDCOPT_NODDC, "NoDDC", OPTV_BOOLEAN, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE },
};
-
+
+#define nDDCOptions (sizeof(DDCOptions) / sizeof(DDCOptions[0]))
xf86MonPtr
xf86DoEDID_DDC1(
@@ -131,11 +132,13 @@ xf86DoEDID_DDC1(
xf86MonPtr tmp = NULL;
/* Default DDC and DDC1 to enabled. */
Bool noddc = FALSE, noddc1 = FALSE;
+ OptionInfoRec options[nDDCOptions];
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, DDCOptions);
+ (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
- xf86GetOptValBool(DDCOptions, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(DDCOptions, DDCOPT_NODDC1, &noddc1);
+ xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
+ xf86GetOptValBool(options, DDCOPT_NODDC1, &noddc1);
if (noddc || noddc1)
return NULL;
@@ -143,7 +146,7 @@ xf86DoEDID_DDC1(
EDID_block = EDIDRead_DDC1(pScrn,DDC1SetSpeed,DDC1Read);
if (EDID_block){
- tmp = xf86InterpretEDID(EDID_block);
+ tmp = xf86InterpretEDID(scrnIndex,EDID_block);
}
#ifdef DEBUG
else ErrorF("No EDID block returned\n");
@@ -162,11 +165,13 @@ xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
xf86MonPtr tmp = NULL;
/* Default DDC and DDC2 to enabled. */
Bool noddc = FALSE, noddc2 = FALSE;
+ OptionInfoRec options[nDDCOptions];
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, DDCOptions);
+ (void)memcpy(options, DDCOptions, sizeof(DDCOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
- xf86GetOptValBool(DDCOptions, DDCOPT_NODDC, &noddc);
- xf86GetOptValBool(DDCOptions, DDCOPT_NODDC2, &noddc2);
+ xf86GetOptValBool(options, DDCOPT_NODDC, &noddc);
+ xf86GetOptValBool(options, DDCOPT_NODDC2, &noddc2);
if (noddc || noddc2)
return NULL;
@@ -174,7 +179,7 @@ xf86DoEDID_DDC2(int scrnIndex, I2CBusPtr pBus)
EDID_block = EDID1Read_DDC2(scrnIndex,pBus);
if (EDID_block){
- tmp = xf86InterpretEDID(EDID_block);
+ tmp = xf86InterpretEDID(scrnIndex,EDID_block);
} else {
#ifdef DEBUG
ErrorF("No EDID block returned\n");
diff --git a/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h b/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h
index 4758fa7b2..53663955f 100644
--- a/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h
+++ b/xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h,v 1.5 1999/12/03 19:17:26 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ddc/xf86DDC.h,v 1.10 2000/06/07 22:03:09 tsi Exp $ */
/* xf86DDC.h
*
@@ -16,6 +16,7 @@
#include "edid.h"
#include "xf86i2c.h"
+#include "xf86str.h"
/* speed up / slow down */
typedef enum {
@@ -35,11 +36,11 @@ extern xf86MonPtr xf86DoEDID_DDC2(
);
extern xf86MonPtr xf86PrintEDID(
- xf86MonPtr
+ xf86MonPtr monPtr
);
extern xf86MonPtr xf86InterpretEDID(
- Uchar *block
+ int screenIndex, Uchar *block
);
extern xf86vdifPtr xf86InterpretVdif(
diff --git a/xc/programs/Xserver/hw/xfree86/doc/DESIGN b/xc/programs/Xserver/hw/xfree86/doc/DESIGN
index 1a105c44a..3155abc0a 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/DESIGN
+++ b/xc/programs/Xserver/hw/xfree86/doc/DESIGN
@@ -2,7 +2,7 @@
The XFree86 Project, Inc
- Last modified 15 February 2000
+ Last modified 1 May 2000
NOTE: This is a DRAFT document, and the interfaces described here are subject
to change without notice.
@@ -133,8 +133,8 @@ method, with the second located to the right of the first:
Section "ServerLayout"
Identifier "Main Layout"
- Screen "Screen 1" 0 "" "" "" "Screen 2"
- Screen "Screen 2" 1
+ Screen 0 "Screen 1" "" "" "" "Screen 2"
+ Screen 1 "Screen 2"
Screen "Screen 3"
EndSection
@@ -147,8 +147,8 @@ assumed. An example of absolute positioning follows:
Section "ServerLayout"
Identifier "Main Layout"
- Screen "Screen 1" 0 Absolute 0 0
- Screen "Screen 2" 1 Absolute 1024 0
+ Screen 0 "Screen 1" Absolute 0 0
+ Screen 1 "Screen 2" Absolute 1024 0
Screen "Screen 3" Absolute 2048 0
EndSection
@@ -171,8 +171,8 @@ following example shows how to use some of the relative positioning options.
Section "ServerLayout"
Identifier "Main Layout"
- Screen "Screen 1" 0
- Screen "Screen 2" 1 RightOf "Screen 1"
+ Screen 0 "Screen 1"
+ Screen 1 "Screen 2" RightOf "Screen 1"
Screen "Screen 3" Relative "Screen 1" 2048 0
EndSection
@@ -496,14 +496,14 @@ Probe() function of each registered video driver is called.
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 xf86ConfigActivePciEn-
- tity() helper function for PCI and xf86ConfigActiveIsaEn-
- tity() for ISA (see the RAC (section 9., page 1) sec-
- tion). It is possible to register some entity specific
- functions with those helpers. When not using the
- helpers, the xf86AddEntityToScreen() xf86ClaimFixe-
- dResources() and xf86SetEntityFuncs() should be used
- instead (see the RAC (section 9., page 1) section).
+ This is usually best done with the xf86ConfigPciEntity()
+ helper function for PCI and xf86ConfigIsaEntity() for ISA
+ (see the RAC (section 9., page 1) section). It is possi-
+ ble to register some entity specific functions with those
+ helpers. When not using the helpers, the xf86AddEntity-
+ ToScreen() xf86ClaimFixedResources() and xf86SetEntity-
+ Funcs() should be used instead (see the RAC (section 9.,
+ page 1) section).
If a chipset is specified in an active device section
which the driver considers relevant (ie it has no driver
@@ -514,12 +514,16 @@ Probe() function of each registered video driver is called.
If there are no active device sections that the driver
considers relevant, it must return FALSE.
- Allocate a ScrnInfoRec for each instance of the hardware
- found, and fill in the basic information, including the
- other driver entry points. The xf86AllocateScreen()
- function must be used to allocate the ScrnInfoRec, and it
- takes care of initialising fields to defined ``unused''
- values.
+ Allocate a ScrnInfoRec 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 xf86ConfigIsaEntity() helper function for
+ ISA instances or xf86ConfigPciEntity() for PCI instances.
+ These functions allocate a ScrnInfoRec for active enti-
+ ties. Optionally xf86AllocateScreen() function may also
+ be used to allocate the ScrnInfoRec. Any of these func-
+ tions 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
@@ -697,14 +701,16 @@ ChipPreInit() function.
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. The xf86LoadSubModule()
- function should be used to load modules. A driver may
- unload a module within this function if it was only
- needed temporarily, and the UnloadSubModule() 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 auto-
- matically if/when the driver module is unloaded.
+ before the end of this function. Either the
+ xf86LoadSubModule() or the xf86LoadDrvSubModule() func-
+ tion should be used to load modules depending on whether
+ a ScrnInfoRec has been set up. A driver may unload a mod-
+ ule within this function if it was only needed temporar-
+ ily, and the xf86UnloadSubModule() function should be
+ used to do that. Otherwise there is no need to explic-
+ itly unload modules because the loader takes care of mod-
+ ule dependencies and will unload submodules automatically
+ if/when the driver module is unloaded.
The bulk of the ScrnInfoRec fields should be filled out
in this function.
@@ -768,7 +774,8 @@ going to use them:
chipID
chipRev
- pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name):
+ pointer xf86LoadSubModule(ScrnInfoPtr pScrn, const char *name): and
+ pointer xf86LoadDrvSubModule(DriverPtr drv, const char *name):
Load a module that a driver depends on. This function
loads the module name as a sub module of the driver. The
@@ -776,12 +783,13 @@ going to use them:
the load fails, the return value will be NULL. If a
driver needs to explicitly unload a module it has loaded
in this way, the return value must be saved and passed to
- UnloadSubModule() when unloading.
+ xf86UnloadSubModule() when unloading.
- void UnloadSubModule(pointer module)
+ void xf86UnloadSubModule(pointer module)
Unloads the module referenced by module. module should
- be a pointer returned previously by xf86LoadSubModule().
+ be a pointer returned previously by xf86LoadSubModule()
+ or xf86LoadDrvSubModule() .
5.13 Cleaning up Unused Drivers
@@ -1641,30 +1649,29 @@ able at the driver level:
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,
+ 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,
- EntityProc init, EntityProc enter,
-
- EntityProc leave, pointer private)
+ resList res, EntityProc init,
+ EntityProc enter, EntityProc leave,
+ pointer private)
These functions are used to register the non-relocatable
resources for an entity, and the optional entity-specific
Init, Enter and Leave 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. The return
- value is TRUE when successful. The init, enter, leave
- functions are defined as follows:
+ passed. Generally this is not required. For active
+ entities a ScrnInfoRec is allocated if the pScrn argument
+ is NULL. The return value is TRUE when successful. The
+ init, enter, leave functions are defined as follows:
typedef void (*EntityProc)(int entityIndex,
@@ -1672,8 +1679,8 @@ Two helper functions are provided to aid configuring entities:
They are passed the entity index and a pointer to a pri-
vate scratch area. This are can be set up during Probe()
- and its address can be passed to xf86ConfigActiveIsaEn-
- tity() xf86ConfigActivePciEntity() as the last argument.
+ and its address can be passed to xf86ConfigIsaEntity()
+ xf86ConfigPciEntity() as the last argument.
These two helper functions make use of several core functions that are avail-
able at the driver level:
@@ -1833,11 +1840,16 @@ xf86FixPciResource() can be used to do this:
The driver may replace the generic access control functions for an entity by
it's own ones. This is done with the xf86SetAccessFuncs():
- void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io,
+ void xf86SetAccessFuncs(EntityInfoPtr pEnt,
+ xf86SetAccessFuncPtr funcs,
- xf86AccessPtr p_mem, xf86AccessPtr p_io_mem,
+ xf86SetAccessFuncPtr oldFuncs) with:
- xf86AccessPtr *ppAccessOld)
+ typedef struct {
+ xf86AccessPtr mem;
+ xf86AccessPtr io;
+ xf86AccessPtr io_mem;
+ } xf86SetAccessFuncRec, *xf86SetAccessFuncPtr;
The driver can pass three functions: one for I/O access,
one for memory access and one for combined memory and I/O
@@ -2013,6 +2025,12 @@ Next, the higher level functions that most drivers would use.
number is known (e.g., from the ChipProbe() function) a
scrnIndex value of -1 should be used.
+ NOTE 2: Given that this function stores into the Option-
+ InfoRecs pointed to by optinfo, the caller should ensure
+ the OptionInfoRecs are (re-)initialised before the call,
+ especially if the caller expects to use the predefined
+ option values as defaults.
+
The OptionInfoRec is defined as follows:
typedef struct {
@@ -2061,14 +2079,13 @@ Next, the higher level functions that most drivers would use.
specified, freq.units is set to 0, and freq.freq is
unscaled.
- Typical usage is to setup a static array of OptionIn-
- foRecs with the token, name, and type fields initialised.
- The value and found fields get set by xf86ProcessOp-
- tions(). For cases where the value parsing is more com-
- plex, the driver should specify OPTV_STRING, and parse
- the string itself. An example of using this option han-
- dling is included in the Sample Driver (section 20., page
- 1) section.
+ Typical usage is to setup an array of OptionInfoRecs with
+ all fields initialised. The value and found fields get
+ set by xf86ProcessOptions(). For cases where the value
+ parsing is more complex, the driver should specify
+ OPTV_STRING, and parse the string itself. An example of
+ using this option handling is included in the Sample
+ Driver (section 20., page 1) section.
void xf86ShowUnusedOptions(int scrnIndex, pointer options)
@@ -2196,6 +2213,8 @@ The following include files are typically required by video drivers:
"compiler.h"
+ Note: in drivers, this must be included after "xf86_ansic.h".
+
Drivers that need to access PCI vendor/device definitions need
this:
@@ -2704,6 +2723,12 @@ DGAInit.
The offset into the linear framebuffer that
corresponds to pixel (0,0) for this mode.
+ address
+
+ The virtual address of the framebuffer as
+ mapped by the driver. This is needed when
+ DGA_PIXMAP_AVAILABLE is set.
+
/** The DGAFunctionRec **/
typedef struct {
@@ -2719,7 +2744,7 @@ DGAInit.
Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
int (*GetViewport)(ScrnInfoPtr pScrn);
- void (*Flush)(ScrnInfoPtr);
+ void (*Sync)(ScrnInfoPtr);
void (*FillRect)(
ScrnInfoPtr pScrn,
int x, int y, int w, int h,
@@ -2817,7 +2842,7 @@ DGAInit.
the last SetViewport request is still pending, bit one if
the one before that is still pending, etc.
- void Flush (pScrn)
+ void Sync (pScrn)
This function should ensure that any graphics accelerator
operations have finished. This function should not
@@ -3117,7 +3142,7 @@ The XF86VideoAdaptorRec:
typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn,
pointer data, Bool cleanup)
- This indicates the the driver should stop displaying the
+ This indicates the driver should stop displaying the
video. This is used to stop both input and output video.
The cleanup field indicates that the video is being
stopped because the client requested it to stop or
@@ -3488,8 +3513,8 @@ XFree86 common layer.
in other situations.
When loading ``external'' modules (modules that
- don't have the the standard entry point, for
- example a special shared library) the options
+ don't have the standard entry point, for exam-
+ ple a special shared library) the options
parameter can be set to EXTERN_MODULE to tell
the loader not to reject the module when it
doesn't find the standard entry point.
@@ -3762,11 +3787,11 @@ are defined as
if it calls other loader functions that require a refer-
ence to it. The remaining arguments are those that were
passed to the LoadModule() (or LoadSubModule()), and are
- described above. When the SetupProc is successful it
- must return a non-NULL value. The loader checks this,
- and if it is NULL it unloads the module and reports the
- failure to the caller of LoadModule(). If the SetupProc
- does things that need to be undone when the module is
+ described above. When the SetupProc is successful it must
+ return a non-NULL value. The loader checks this, and if
+ it is NULL it unloads the module and reports the failure
+ to the caller of LoadModule(). If the SetupProc does
+ things that need to be undone when the module is
unloaded, it should define a TearDownProc, and return a
pointer that the TearDownProc can use to undo what has
been done.
@@ -5246,6 +5271,8 @@ included:
"compiler.h"
+Note: in drivers, this must be included after "xf86_ansic.h".
+
Drivers that need to access PCI vendor/device definitions need this:
"xf86PciInfo.h"
@@ -5425,6 +5452,8 @@ Drivers must NOT include the following:
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
+ #define nZZZOptions (sizeof(ZZZOptions) / sizeof(ZZZOptions[0]))
+
20.3 Functions
20.3.1 SetupProc
@@ -5570,10 +5599,44 @@ NOTE: The xf86DrvMsg() functions cannot be used from the Probe.
numDevSections, drv, &usedChips);
for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
+ 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 */
+ }
+ }
+ if (numUsed > 0)
+ xfree(usedChips);
+ }
- /* Allocate a ScrnInfoRec */
- pScrn = xf86AllocateScreen(drv, 0);
+ #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;
@@ -5587,41 +5650,7 @@ NOTE: The xf86DrvMsg() functions cannot be used from the Probe.
pScrn->FreeScreen = ZZZFreeScreen;
pScrn->ValidMode = ZZZValidMode;
foundScreen = TRUE;
- /* add screen to entity */
- xf86ConfigActivePciEntity(pScrn, usedChips[i],
- ZZZPciChipsets, NULL, NULL, NULL, NULL, NULL);
-
}
- if (numUsed > 0)
- 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 = xf86AllocateScreen(drv,0);
-
- 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;
- xf86ConfigActiveIsaEntity(pScrn, usedChips[i], ZZZIsaChipsets,
- NULL, NULL, NULL, NULL, NULL);
}
if (numUsed > 0)
xfree(usedChips);
@@ -5669,6 +5698,8 @@ NOTES:
static Bool
ZZZPreInit(ScrnInfoPtr pScrn, int flags)
{
+ OptionInfoRec options[nZZZOptions];
+
/* Fill in the monitor field */
pScrn->monitor = pScrn->confScreen->monitor;
@@ -5747,9 +5778,10 @@ NOTES:
/*
* Process the options based on the information in ZZZOptions.
- * The results are written to ZZZOptions.
+ * The results are written to options.
*/
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ZZZOptions);
+ (void)memcpy(options, ZZZOptions, sizeof(ZZZOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
/*
* Set various fields of ScrnInfoRec and/or ZZZRec based on
@@ -5757,25 +5789,25 @@ NOTES:
*/
from = X_DEFAULT;
pZzz->hwCursor = FALSE;
- if (xf86IsOptionSet(ZZZOptions, OPTION_HW_CURSOR)) {
+ if (xf86IsOptionSet(options, OPTION_HW_CURSOR)) {
from = X_CONFIG;
pZzz->hwCursor = TRUE;
}
xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
pZzz->hwCursor ? "HW" : "SW");
- if (xf86IsOptionSet(ZZZOptions, OPTION_NOACCEL)) {
+ if (xf86IsOptionSet(options, OPTION_NOACCEL)) {
pZzz->noAccel = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Acceleration disabled\n");
} else {
pZzz->noAccel = FALSE;
}
- if (xf86IsOptionSet(ZZZOptions, OPTION_PCI_RETRY)) {
+ if (xf86IsOptionSet(options, OPTION_PCI_RETRY)) {
pZzz->UsePCIRetry = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n");
}
pZzz->fooHack = 0;
- if (xf86GetOptValInteger(ZZZOptions, OPTION_FOO_HACK,
+ if (xf86GetOptValInteger(options, OPTION_FOO_HACK,
&pZzz->fooHack)) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Foo Hack set to %d\n",
pZzz->fooHack);
@@ -6253,7 +6285,7 @@ eScreen() function.
ZZZFreeRec(xf86Screens[scrnIndex]);
}
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.23 2000/02/15 18:00:57 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.30 2000/06/19 15:00:52 tsi Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/DESIGN,v 1.21 2000/03/01 01:47:59 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/DESIGN,v 1.26 2000/06/19 15:12:26 tsi Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/Imakefile b/xc/programs/Xserver/hw/xfree86/doc/Imakefile
index 9a2a9a699..a3eca0397 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/doc/Imakefile
@@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/33 1996/10/28 05:12:24 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/Imakefile,v 3.67 2000/03/08 05:38:40 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/Imakefile,v 3.68 2000/06/17 17:44:20 dawes Exp $
#include <Server.tmpl>
#include <lnxdoc.rules>
@@ -78,7 +78,8 @@ MAINDOCS = LICENSE README /*ReadmeFile(Config)*/ /*BUILD*/ RELNOTES \
Install Status DESIGN
OTHERDOCS = /*VideoModes.doc*/ /*QuickStart.doc*/ /*xinput*/ \
- ReadmeFile(fonts) ReadmeFile(mouse) ReadmeFile(DRI)
+ ReadmeFile(fonts) ReadmeFile(mouse) ReadmeFile(DRI) \
+ ReadmeFile(DRIcomp)
#endif
MISCDOCS = ServersOnly /*LbxproxyOnly*/ $(REPORTFORM) ReadmeFile(DGA) \
diff --git a/xc/programs/Xserver/hw/xfree86/doc/Install b/xc/programs/Xserver/hw/xfree86/doc/Install
index 9cbed305e..3580a61b6 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/Install
+++ b/xc/programs/Xserver/hw/xfree86/doc/Install
@@ -1,126 +1,126 @@
- Installation Details for XFree86[tm] 4.0
+ Installation Details for XFree86[tm] 4.0.1
The XFree86 Project, Inc
- 29 February 2000
+ 30 June 2000
Abstract
- This document contains information about installing XFree86 4.0.
+ How to install XFree86.
1. Introduction
-This document contains information about installing XFree86 4.0 binary dis-
-tributions as provided by The XFree86 Project. The installation procedures
-for binary distributions provided by others may be different.
-
-The XFree86 binary distributions that we provide for UNIX-like OSs are pack-
-aged in the platform-independent gzipped tar format (referred to as "tar-
-balls"). Our tarballs can be identified by the ".tgz" suffix. We do not
-provide binaries in RPM format or any other platform specific package format.
-If you need them in such a format, you should contact your OS vendor.
-Together with the binary distributions, we provide a customised version of
-GNU tar called "extract", and an installation script. We recommend that
-these be used to install the binary distributions.
-
-2. How to get the XFree86 4.0 binary distributions
-
-We, The XFree86 Project, provide XFree86 4.0 binaries for a range of operat-
-ing systems at our ftp site <URL:ftp://ftp.xfree86.org/pub/XFree86/4.0/bina-
-ries/>. Our ftp site is also mirrored by many sites around the world. There
-is a sub-directory for each OS/platform that we have binaries for. The first
-thing you need to do is to decide which of these suits you. In most cases,
-the choice is straightforward. In some cases (e.g., Linux) there may be a
-number of choices depending on what architecture or libc version you are
-using. We recommend that you first download the Xinstall.sh script, and run
-it as follows to find out which binary distribution you should download.
+This document contains information about installing the XFree86 binaries as
+provided by The XFree86 Project.
+
+The XFree86 binaries that we provide for UNIX-like OS's (Linux, the BSDs and
+Solaris) are packaged in a platform-independent gzipped format (aka "tar-
+balls" identified by the .tgz suffix). Along with the binaries we provide a
+customized version of the GNU tar utility called "extract" and an installa-
+tion script. We recommend that these be used to install the binaries.
+
+2. Downloading the XFree86 4.0.1 binaries
+
+We, The XFree86 Project, provide XFree86 4.0.1 binaries for a range of oper-
+ating systems at our ftp site
+<URL:ftp://ftp.xfree86.org/pub/XFree86/4.0.1/binaries/>. Often during
+releases, our ftp site is heavily loaded. Instead of downloading directly
+from us we recommend that instead you use one of our mirror sites. Another
+advantage of using our mirror sites is that some of them support http access
+(ours does not).
+
+Our binaries are organized by sub-directories which correspond to each of the
+OS/platforms for which we provide binaries. First go to the sub-directory
+that represents your OS Platform. In some cases (e.g., Linux) there may be a
+number of choices depending on the architecture or libc version your platform
+uses. In all case we recommend that you first download the Xinstall.sh
+script, and run it as in the following example to find out which binary dis-
+tribution you should download.
sh Xinstall.sh -check
-This should tell you which binary distribution is the correct one for your
-system. Getting this right may save from wasting time downloading the wrong
-distribution.
-
-The next step is to download the necessary files. The mandatory files for
-all installations are listed below. All of them must be downloaded to do the
-installation. The installer script will complain if they are not all pre-
-sent.
-
- Xinstall.sh The installer script
- extract The utility for extracting tarballs
- Xbin.tgz X clients/utilities and run-time libraries
- Xlib.tgz Some data files required at run-time
- Xman.tgz Manual pages
- Xdoc.tgz XFree86 documentation
- Xfnts.tgz Base set of fonts
- Xfenc.tgz Base set of font encoding data
- Xetc.tgz Run-time configuration files
- Xvar.tgz Run-time data
- Xxserv.tgz XFree86 X server
- Xmod.tgz XFree86 X server modules
+The output of this utility tells you which is the correct set of binaries
+for you to download. If you are careful with this step you will save your-
+self a lot time and trouble from NOT downloading an incompatible distribu-
+tion.
+
+Once that is done download the necessary files. The twelve (12) mandatory
+files for all installations are listed below. If you have not downloaded all
+of the files, the installer script will complain.
+
+ 1. Xinstall.sh The installer script
+ 2. extract The utility for extracting tarballs
+ 3. Xbin.tgz X clients/utilities and run-time libraries
+ 4. Xlib.tgz Some data files required at run-time
+ 5. Xman.tgz Manual pages
+ 6. Xdoc.tgz XFree86 documentation
+ 7. Xfnts.tgz Base set of fonts
+ 8. Xfenc.tgz Base set of font encoding data
+ 9. Xetc.tgz Run-time configuration files
+ 10. Xvar.tgz Run-time data
+ 11. Xxserv.tgz XFree86 X server
+ 12. Xmod.tgz XFree86 X server modules
NOTES:
o Some web browsers have a problem downloading the extract utility cor-
rectly. If you encounter this problem, download the version called
- extract.exe instead. The ".exe" suffix is only there to make the trou-
- blesome web browsers do the right thing. It is not a DOS/Windows exe-
- cutable.
+ extract.exe instead. This should fix the problem. (This is not a
+ DOS/Windows executable.)
o A few distributions don't have or require the Xvar.tgz tarball. If it
is present in the binaries sub-directory for your platform, then it is
required.
- o Some distributions may have additional mandatory tarballs. This is
- rare. In these cases, the installer script will tell you if any are
- missing.
-
-The following tarballs are optional. You should download the ones you want
-to install.
-
- Xfsrv.tgz Font server
- Xnest.tgz Nested X server
- Xprog.tgz X header files, config files and compile-time libs
- Xprt.tgz X Print server
- Xvfb.tgz Virtual framebuffer X server
- Xf100.tgz 100dpi fonts
- Xfcyr.tgz Cyrillic fonts
- Xflat2.tgz Latin-2 fonts
- Xfnon.tgz Some large bitmap fonts
- Xfscl.tgz Scalable fonts (Speedo and Type1)
- Xhtml.tgz HTML version of the documentation
- Xps.tgz PostScript version of the documentation
- Xjdoc.tgz Documentation in Japanese
+ o Some distributions may have additional mandatory tarballs. While rare,
+ the installer script will tell you if any are missing.
+
+The following thirteen (13) tarballs are optional. You should download the
+ones you want to install.
+
+ 1. Xfsrv.tgz Font server
+ 2. Xnest.tgz Nested X server
+ 3. Xprog.tgz X header files, config files and compile-time libs
+ 4. Xprt.tgz X Print server
+ 5. Xvfb.tgz Virtual framebuffer X server
+ 6. Xf100.tgz 100dpi fonts
+ 7. Xfcyr.tgz Cyrillic fonts
+ 8. Xflat2.tgz Latin-2 fonts
+ 9. Xfnon.tgz Some large bitmap fonts
+ 10. Xfscl.tgz Scalable fonts (Speedo and Type1)
+ 11. Xhtml.tgz HTML version of the documentation
+ 12. Xps.tgz PostScript version of the documentation
+ 13. Xjdoc.tgz Documentation in Japanese
NOTES:
o Some distributions may have some additional optional tarballs.
-If you miss some and want to install them later, you can do so by following
-the appropriate part of the section that describes manual installation.
+If you miss some and want to install them later, go to the Manual Installa-
+tion (section 4., page 1) section.
-3. Installing XFree86 4.0 using the Xinstall.sh script
+3. Installing XFree86 4.0.1 using the Xinstall.sh script
-We strongly recommend that our XFree86 4.0 binary distributions be installed
-using the Xinstall.sh script that we provide. The main reason that we make
-this recommendation is that there are a lot of steps in the manual installa-
-tion process, and those steps can vary according to the situation. There is,
-however, a description of the manual installation process for the most common
-cases below for those who might need it.
+We strongly recommend that our XFree86 4.0.1 binaries be installed using the
+Xinstall.sh script that we provide. There are a lot of steps in the manual
+installation process, and those steps can vary according to the platform and
+hardware setup. There is a description of the manual installation process
+for the most common cases below (section 4., page 1).
-Put all of the downloaded files into a single directory (choose some tempo-
-rary location with enough space). Become the super user (root), cd to that
-directory, then run the installer script as follows:
+You must login as the super user (root) to run the installer script. Place
+all of the downloaded files into a single directory (choose a temporary loca-
+tion with enough space). Use the cd command to change to that directory and
+then run the installer script as follows:
sh Xinstall.sh
-Answer the prompts that come up. If you are missing something that is
-required to run this version of XFree86, the installer may tell you to
-install it before trying again. If you don't have all of the mandatory files
-listed above, then the installer will tell you which ones are missing and ask
-you to download them before trying again.
+Answer the prompts as they come up. If you are missing something that is
+required, the installer may tell you to install it before trying again. If
+the problem is that you did not download all of mandatory files aforemen-
+tioned, then the installer will tell you which ones are missing and ask you
+to download them before proceeding.
-3.1 Answering the questions that the installer may ask
+3.1 Questions the installer may ask
The installer asks some questions that may not have obvious answers. The
information here should help you answer them. In most cases, apart from the
@@ -158,12 +158,14 @@ ration files are installed by default under /etc/X11 instead of under
create the necessary symbolic links. If you don't want to have these config-
uration files under /etc/X11, then you should answer "no" when asked about
it. Answering "no" here also means that the new configuration files will be
-installed in the old /usr/X11R6/lib/X11 location. Note: for the rare systems
-that don't have symbolic links, this question will not be asked. The default
-answer is "yes" because that is best for most situations. It is our new
-default. It makes it easier to share the /usr/X11R6 directory between multi-
-ple hosts, and allows it to be mounted read-only. If you don't need these
-features, then you can safely answer "no" if you don't want them moved.
+installed in the old /usr/X11R6/lib/X11 location.
+
+Note: for the rare systems that don't have symbolic links, this question will
+not be asked. The default answer is "yes" because that is best for most sit-
+uations. It is our new default. It makes it easier to share the /usr/X11R6
+directory between multiple hosts, and allows it to be mounted read-only. If
+you don't need these features, then you can safely answer "no" if you don't
+want them moved.
When installing over an existing version, you will be prompted before each
set of configuration files is installed. If you haven't made any customisa-
@@ -172,8 +174,8 @@ for each of these. If you have made customisations, you can try answering
"no". If you run into problems later, you may need to manually merge your
customisations into the the new version of the configuration files. The con-
figuration files can all be found in the Xetc.tgz tarball. See the section
-below about manual installation for information about extracting them sepa-
-rately.
+below (section 4., page 1) about manual installation for information about
+extracting them separately.
After the configuration files have been dealt with, the other mandatory com-
ponents of the binary distribution will be installed. This should proceed
@@ -190,12 +192,22 @@ to run "ldconfig" on systems that require it, so that the newly installed
shared libraries are accessible. Then the fonts.dir files in some directo-
ries are updated so that the fonts can be accessed correctly. Next, the
installer checks to see if your system has a termcap file or terminfo files.
-If it finds the former, it tells you how my may update the entries in that
+If it finds the former, it tells you how you may update the entries in that
file. If it finds the latter, it asks you if you want it to update them for
you.
+You may be asked if you want to create links for the GL libraries and header
+files. The OpenGL standard on some platforms (Linux in particular) says that
+these should be installed in the standard system locations (/usr/lib and
+/usr/include), so the installer offers to create the appropriate links. If
+you're running Linux, you should probably answer yes. For other platforms it
+is your choice. If you already have another version of libGL in /usr/lib,
+answering "yes" will remove it and replace it with a link to the version we
+supply. The installer will show you a listing of any existing versions
+before asking if they should be replaced.
+
Finally, the installer asks you if you want a link created for the rstart
-utility. On most modern systems, the link isn't essential, so the default
+utility. On most modern systems the link isn't essential, so the default
answer is "no". Answer "yes" if you know that you need it. If you find
later that you need it, you can create it easily by running:
@@ -206,7 +218,7 @@ later that you need it, you can create it easily by running:
The next step is to configure the X server. That is covered in detail in an
as-yet unwritten document :-(. In the meantime, there are two ways to create
-a basic X server configuration file for XFree86 4.0. One is to run the
+a basic X server configuration file for XFree86 4.0.1. One is to run the
xf86config utility. Another is to use the new -configure X server option:
XFree86 -configure
@@ -220,11 +232,11 @@ old XF86_* and/or XF98_* X server binaries from /usr/X11R6/bin.
After the X server configuration is done, it may be advisable to reboot,
especially if you run xdm (or equivalent) or the font server (xfs).
-4. Installing XFree86 4.0 manually
+4. Installing XFree86 4.0.1 manually
-This section describes how to manually install the XFree86 4.0 binary distri-
-butions. You should only use this method if you know what you're doing. The
-information here covers some common cases, but not every possible case.
+This section describes how to manually install the XFree86 4.0.1 binary dis-
+tributions. You should only use this method if you know what you're doing.
+The information here covers some common cases, but not every possible case.
Put all of the downloaded files into a single directory (choose some tempo-
rary location with enough space). Become the super user (root). All of the
@@ -323,7 +335,7 @@ Once that's done, the main part of the installation can be done:
/sbin/ldconfig -m /usr/X11R6/lib # For FreeBSD, NetBSD, OpenBSD
/usr/X11R6/bin/mkfontdir /usr/X11R6/lib/X11/fonts/misc
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.4 2000/02/29 18:01:17 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.6 2000/07/02 02:35:27 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/Install,v 1.3 2000/03/01 01:48:01 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/Install,v 1.5 2000/07/02 02:46:26 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/Japanese/README98 b/xc/programs/Xserver/hw/xfree86/doc/Japanese/README98
index 26d952b27..573c338a2 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/Japanese/README98
+++ b/xc/programs/Xserver/hw/xfree86/doc/Japanese/README98
@@ -1,6 +1,6 @@
XFree86 PC98 Dependent Information
The XFree86 Project Inc. and X98 CORE TEAM Ãø
- 1999 ǯ 7 ·î 19 Æü
+ 2000 ǯ 6 ·î 20 Æü
¤³¤Î¥É¥­¥å¥á¥ó¥È¤Ç¤Ï¡¢PC98 ¸ÇÍ­¤Î»ö¹à¤Ë¤Ä¤¤¤Æ²òÀ⤷¤Þ¤¹¡£PC/AT ¸ß´¹µ¡
¤È¶¦Ä̤λö¹à¤Ë¤Ä¤¤¤Æ¤Ï¡¢¶¦Ä̤Υɥ­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£
@@ -10,11 +10,12 @@
ËÜ¥ê¥ê¡¼¥¹¤Ç¤Ï¡¢PC98 ÍÑ X ¥µ¡¼¥Ð¤Ï PC/AT ¸ß´¹µ¡ÍÑ X ¥µ¡¼¥Ð¤ÈÅý¹ç (¥Õ¥¡
¥¤¥ë̾: XFree86) ¤µ¤ì¤Æ¤ª¤ê¡¢½¾Íè¤Î¥Ü¡¼¥É / ¥Á¥Ã¥×¥»¥Ã¥ÈËè¤Î¥µ¡¼¥Ð¤â¤Ê
¤¯¤Ê¤ê¤Þ¤·¤¿¡£¤Þ¤¿¡¢³Æ¥É¥é¥¤¥Ð¤Ï¤¹¤Ù¤Æ SVGA ¥Ù¡¼¥¹¤Ç¡¢XF86_S3 ¥Ù¡¼¥¹¤Î
- ¥É¥é¥¤¥Ð¤Ï¤¢¤ê¤Þ¤»¤ó¡£¸½ºß¤Î¤È¤³¤í¡¢PC98 ¤Çưºî¤·¤Æ¤¤¤ë¤Î¤Ï¡¢mga ¥É¥é
- ¥¤¥Ð¤Î¤ß¤Ç¤¹¡£Millennium¡¢Mystique ¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3 ¥Ù¡¼
- ¥¹ (ex. 3.3.3.1, 3.3.4) ¤Î´Ä¶­¤ò¸æÍøÍѲ¼¤µ¤¤¡£EGC ¤ä PEGC ¤¹¤éÍøÍѤÇ
- ¤­¤Þ¤»¤ó¡£³«È¯¥á¥ó¥Ð¤¬Èó¾ï¤Ë¾¯¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢³«È¯¤Ë¶½Ì£¤¬¤ª¤¢¤ê¤Î
- Êý¤Ï X98 Core Team ¤Þ¤Ç¡¢¸æÏ¢Íí²¼¤µ¤¤¡£
+ ¥É¥é¥¤¥Ð¤Ï¤¢¤ê¤Þ¤»¤ó¡£¸½ºß¤Î¤È¤³¤í¡¢PC98 ¤Çưºî¤·¤Æ¤¤¤ë¤Î¤Ï¡¢mga¡¢
+ apm¡¢glint¡¢trident ¥É¥é¥¤¥Ð¤Î¤ß¤Ç¤¹¡£Millennium¡¢Mystique¡¢
+ VoodooRUSH¡¢Permedia2¡¢TGUI968x(¤¤¤º¤ì¤â PCI) ¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°
+ ¤Ï¡¢3.3 ¥Ù¡¼¥¹ (ex. 3.3.6) ¤Î´Ä¶­¤ò¸æÍøÍѲ¼¤µ¤¤¡£¸½¾õ 4.0 ¤Ç¤Ï EGC ¤ä
+ PEGC ¤¹¤éÍøÍѤǤ­¤Þ¤»¤ó¡£³«È¯¥á¥ó¥Ð¤¬Èó¾ï¤Ë¾¯¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢³«È¯
+ ¤Ë¶½Ì£¤¬¤ª¤¢¤ê¤ÎÊý¤Ï X98 Core Team ¤Þ¤Ç¡¢¸æÏ¢Íí²¼¤µ¤¤¡£
XF86Config ¤äµ¯Æ°»þ¤Î¥ª¥×¥·¥ç¥óÅù¤ÎÊѹ¹¤Ë¤Ä¤¤¤Æ¤Ï¡¢RELNOTES ¤Ë¾Ü¤·¤¯½ñ
¤¤¤Æ¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢»²¾È¤·¤Æ²¼¤µ¤¤¡£/usr/X11R6/lib/X11/XF86Config.98
@@ -32,12 +33,16 @@
------------- ----------------------------------------------- -------
NEC ¥Õ¥ë¥«¥é¡¼¥¦¥£¥ó¥É¥¦¥¢¥¯¥»¥é¥ì¡¼¥¿¥Ü¡¼¥É X2 XFree86
Matrox MGA Millennium(PC/AT ¸ß´¹µ¡ÍÑ) XFree86
+ IO-DATA GA-RUSH6/PCI XFree86
+ Melco WHP-PS8, WHP-PS4 XFree86
+ (IO-DATA GA-PII8, GA-PIIH8 XFree86)
2.2. ¥µ¥Ý¡¼¥ÈÆâ¢¥Ó¥Ç¥ª¥·¥¹¥Æ¥à°ìÍ÷
¥Ù¥ó¥À¡¼ ¥Á¥Ã¥×¥»¥Ã¥È ¥µ¡¼¥Ð
------------- ----------------------------------------------- -------
NEC MGA Millennium/Mystique XFree86
+ NEC Trident TGUI968x(X-Mate,ValueStar Åù) XFree86
3. ¶¦ÄÌ»ö¹à
@@ -57,9 +62,10 @@
¤Î»ØÄê¤òÆþ¤ì¤Æ²¼¤µ¤¤¡£¤³¤ì¤Ç PC98 ¤Èǧ¼±¤µ¤ì¡¢¥í¥°¤Ë
(**) Japanese PC98 architecture
+
¤È½ÐÎϤµ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
- xf86config
+ xf86config¡¢xf86cfg
PC98 ÍѤ˰ܿ¢¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£/usr/X11R6/lib/X11/XF86Config.98 ¤ò
XF86Config ¤È¥ê¥Í¡¼¥à¤·¤Æ»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
@@ -99,25 +105,21 @@
XkbModel "pc98"
XkbLayout "nec/jp"
- ¤Î»ØÄê¤ò¤·¤Æ²¼¤µ¤¤¡£
+ ¤Î»ØÄê¤ò¤·¤Æ²¼¤µ¤¤¡£
BusID
XF86Config ¤Î Section "Device" ¤Ç¡¢É¬¤º
BusID "0:10:0"
- ¤Î¤è¤¦¤Ê»ØÄê¤ò¤·¤Æ²¼¤µ¤¤¡£¥í¥°¤Ë
+ ¤Î¤è¤¦¤Ê»ØÄê¤ò¤·¤Æ²¼¤µ¤¤¡£¥í¥°¤Ë
(--) PCI: (0:7:0) NEC unknown chipset (0x0009) rev 2
(--) PCI: (0:12:0) S3 968 rev 0, Mem @ 0x24000000/25
(--) PCI: (0:14:0) Matrox MGA 2064W rev 1, Mem @ 0x20004000/14, 0x21000000/23
- ¤Î¤è¤¦¤Ë½Ð¤Æ¤¤¤Æ¡¢Millennium ¤ò»ÈÍѤ¹¤ë¾ì¹ç¤Ï¡¢"0:14:0" ¤ò»ØÄꤷ¤Þ
- ¤¹¡£S3 968 ¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£Ç°¤Î°Ù¡£
-
- VT switch
- FreeBSD(98) ¤Ç¤Ï¤Ç¤­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£PANIX for 98 ¤Ç¤â¤Ç
- ¤­¤Þ¤»¤ó¡£
+ ¤Î¤è¤¦¤Ë½Ð¤Æ¤¤¤Æ¡¢Millennium ¤ò»ÈÍѤ¹¤ë¾ì¹ç¤Ï¡¢"0:14:0" ¤ò»ØÄꤷ¤Þ
+ ¤¹¡£S3 968 ¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£Ç°¤Î°Ù¡£
CTRL,GRPH,+/- ¤Ë¤è¤ë²òÁüÅÙÀÚÂØ¤¨
¤Ç¤­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£
@@ -139,13 +141,7 @@
o Millennium ¤Ç¤Ï¡¢Modeline ¤ÎÀßÄê¤Ë¤è¤Ã¤Æ¤Ï 24bpp ¤Ç½Ä¤ËÀþ¤¢¤ë¤¤¤Ï¼Ê
ÌÏÍͤΥΥ¤¥º¤¬½Ð¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
- o Millennium ¤Ç¤Ï¡¢½é´ü²½¤¬ÉÔ´°Á´¤Ê¤¿¤á¡¢»ÈÍÑÁ°¤Ë 3.3 ¥Ù¡¼¥¹¤Î¥µ¡¼¥Ð
- ¤òµ¯Æ°¤·¤Æ¤ª¤«¤Ê¤¤¤È¥Ï¥ó¥°¥¢¥Ã¥×¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£°ìöµ¯Æ°¤¹¤ì¤Ð
- ÅŸ»¤ò OFF ¤Ë¤¹¤ë¤Þ¤Ç¤ÏÀµ¾ï¤Ëưºî¤·¤Þ¤¹¡£
-
- o Linux/98 ¤Ç¤Ï¡¢beta 14 °Ê¹ß¤Î¥«¡¼¥Í¥ë¤Ç¤Ê¤¤¤È»ÈÍÑÃæ¤Ë¥Ï¥ó¥°¥¢¥Ã¥×¤¹
- ¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤òÈò¤±¤ë¤Ë¤Ï¡¢root ¸¢¸Â¤Ë¤Æ dmesg -n 1 ¤ò¼Â¹Ô
- ¤¹¤ë¤È¤¤¤¤¤è¤¦¤Ç¤¹¡£
+ o Mystique ¤Ç¤Ï¡¢VideoRam ¤ÎÌÀ¼¨Åª¤Ê»ØÄ꤬ɬ¿Ü¤È¤Ê¤ê¤Þ¤¹¡£
4.1.3. ¤½¤Î¾
@@ -167,27 +163,135 @@
4.2. apm ¥É¥é¥¤¥Ð
- (¾­ÍèŪ¤Ë¤Ï)IO-DATA ¤Î GA-RUSH6/PCI ¤Ç¤âưºî¤¹¤ë (ͽÄê¤Î) ¥É¥é¥¤¥Ð¤Ç
- ¤¹¡£
+ IO-DATA ¤Î GA-RUSH6/PCI ¤Çưºî¤¹¤ë¥É¥é¥¤¥Ð¤Ç¤¹¡£
4.2.1. XF86Config ¤ÎÀßÄê
- README.MGA Æâ¤Ë²òÀ⤵¤ì¤Æ¤¤¤ë¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£Ä̾ï¤ÏÆÃ¤Ë²¿¤â
+ README.apm Æâ¤Ë²òÀ⤵¤ì¤Æ¤¤¤ë¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£Ä̾ï¤ÏÆÃ¤Ë²¿¤â
»ØÄꤹ¤ëɬÍ×̵¤¤È¦¤Ç¤¹¡£
4.2.2. Êó¹ð¤µ¤ì¤Æ¤¤¤ëÌäÂê
- o 8bpp °Ê³°¤Ç¤Ï¤Þ¤Ã¤¿¤¯Æ±´ü¤¬¼è¤ì¤Þ¤»¤ó¡£8bpp ¤Î¾ì¹ç¤Ç¤âƱ´ü¤¬¤ª¤«¤·
- ¤¯¤ÆÆ±¤¸Êª¤¬ 3 ¤Äɽ¼¨¤µ¤ì¤¿¤ê¤·¤Þ¤¹¡£
+ o ¸½»þÅÀ¤Ç¼ÂÍÑŪ¤Ë»ÈÍѤǤ­¤ë»ö¤¬³Îǧ¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï 1024x768 256 ¿§¤Î
+ ¤ß¤Ç¤¹¡£16bpp ¤ä 1280x1024 Åù¤Îɽ¼¨¤Ç¤ÏƱ´ü¤¬¼è¤ì¤Ê¤«¤Ã¤¿¤ê¡¢¥´¥ß¤Ê
+ ¤É¤¬É½¼¨¤µ¤ì¤¿¤ê¤·¤Þ¤¹¡£
- o XF86Config ¤Ç¤Î¥ª¥×¥·¥ç¥ó»ØÄê¤Ë¤è¤Ã¤Æ¤Ï¥Ï¥ó¥°¥¢¥Ã¥×¤·¤¿¤ê¤¹¤ë¤³¤È¤â
- ¤¢¤ê¤Þ¤¹¡£
+ o ¡ÖVideoRam 4096¡×¤Î»ØÄ꤬ɬ¿Ü¤Ç¤¹¡£
4.2.3. ¤½¤Î¾
- o ¤Þ¤À PC-98 Âбþºî¶È¤¬ËؤɽÐÍè¤Æ¤¤¤Þ¤»¤ó¡£¼ÂÍѤˤÏÂѤ¨¤Ê¤¤¤Ç¤·¤ç¤¦¡£
+ o ¼ÂÍÑÀ­¤ò¹Íθ¤¹¤ë¤Ê¤é 1024x768 256 ¿§¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
+
+ o Ëܥӥǥª¥«¡¼¥É¤Ë´Ø¤·¤Æ¤Ï XFree86 4.0 °Ê¹ß¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
+
+ o ¤Þ¤À½½Ê¬¤Ê¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Çưºî¥ì¥Ý¡¼¥È¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£
4.2.4. ´ØÏ¢
XF86_SVGA man page
+ 4.3. glint ¥É¥é¥¤¥Ð
+
+ Melco ¤Î WHP-PS8,WHP-PS4 Åù Permedia2 ÅëºÜ¤Î¥Ó¥Ç¥ª¥«¡¼¥É¤Çưºî¤¹¤ë¥É¥é
+ ¥¤¥Ð¤Ç¤¹¡£IO-DATA ¤Î GA-PII8 ¤ä GA-PIIH8 Åù¤Ç¤âưºî¤¹¤ë¤«¤â¤·¤ì¤Þ¤»
+ ¤ó¡£
+
+ 4.3.1. XF86Config ¤ÎÀßÄê
+
+ README.3Dlabs Æâ¤Ë²òÀ⤵¤ì¤Æ¤¤¤ë¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£Ä̾ï¤ÏÆÃ¤Ë²¿
+ ¤â»ØÄꤹ¤ëɬÍ×̵¤¤È¦¤Ç¤¹¡£
+
+ 4.3.2. Êó¹ð¤µ¤ì¤Æ¤¤¤ëÌäÂê
+
+ o PC-98 ¤Ç¤Îưºî¤µ¤»¤ë¤Ù¤¯Âбþ¥³¡¼¥É¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢Æ°ºî³Îǧ¤¬ËØ
+ ¤É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
+
+ 4.3.3. ¤½¤Î¾
+
+ o ¤Þ¤ÀËØ¤É¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Çưºî¥ì¥Ý¡¼¥È¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£
+
+ o Ëܥӥǥª¥«¡¼¥É¤Ë´Ø¤·¤Æ¤Ï XFree86 4.0 °Ê¹ß¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
+
+ 4.3.4. ´ØÏ¢
+
+ XF86_SVGA man page
+
+ 4.4. trident ¥É¥é¥¤¥Ð
+
+ NEC ¤ÎÆâ¢¥¢¥¯¥»¥é¥ì¡¼¥¿ (Trident TGUI9680/9682) ¤Çưºî¤¹¤ë¥É¥é¥¤¥Ð¤Ç
+ ¤¹¡£Accel ¤Ç¤ª»È¤¤²¼¤µ¤¤¡£
+
+ 4.4.1. XF86Config ¤ÎÀßÄê
+
+ VideoRam 2048(¤Þ¤¿¤Ï 1024)
+ VideoRam ¤¬Àµ¤·¤¯¸¡½Ð¤Ç¤­¤Ê¤¤¾ì¹ç¤ËÀßÄꤷ¤Æ²¼¤µ¤¤¡£
+
+ °Ê²¼¤Î Option(XaaNoScreenToScreenCopy ¤ò½ü¤¯) ¤Ï TGUI9680 ¤Ç¤ÏÀßÄꤷ¤Ê
+ ¤¯¤Æ¤âưºî¤¹¤ë¤³¤È¤¬³Îǧ¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢TGUI9682 ¤Ç¤ÏÉԲķç¤Ç¤¹¡£ÀßÄê
+ ¤·¤Ê¤¤¾ì¹ç¤Î¾ÉÎã¤â´Þ¤á¤Æ²òÀ⤷¤Þ¤¹¤¬¡¢¤³¤ì¤é¤ÎÌäÂ꤬À¸¤¸¤º¡¢¥í¥°¤Ë
+
+ Trident : BitBLT engine time-out.
+
+ ¤¬¸½¤ì¤Ê¤¤¤Î¤Ç¤¢¤ì¤ÐÀßÄêÉÔÍפǤ¹¡£¡Ê¤³¤ì¤é¤ÏÀßÄꤷ¤Ê¤¤Êý¤¬Æ°ºî¤¬Â®¤¤¤³
+ ¤È¤òǰƬ¤Ë¤ª¤¤¤Æ²¼¤µ¤¤¡£¡Ë
+
+ Option ``NoPciBurst''
+ ¥Þ¥¦¥¹¡¦¥«¡¼¥½¥ë¤¬¥Þ¥¦¥¹¤Îư¤­¤ËÄɽ¾¤»¤º¡¢¤Þ¤¿¥Þ¥¦¥¹¡¦¥«¡¼¥½¥ë¤Î
+ ư¤¤¤¿Àפˤ½¤Î¡Ö­Àספ¬»Ä¤ë¾ì¹ç¤äÉÁ²è¤µ¤ì¤ëʸ»ú¤Î¥É¥Ã¥ÈÍî¤Á¤¬¿Ó
+ ¤À¤·¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+
+ Option ``XaaNoScreenToScreenCopy''
+ ²òÁüÅÙ¤¬ 1024x768 °Ê²¼¤Ç¤ÏÀßÄêÉÔÍפǤ¹¡£¤½¤ì¤ò±Û¤¨¤ë²òÁüÅ٤ˤª¤¤
+ ¤Æ¥Þ¥¦¥¹¡¦¥«¡¼¥½¥ë¤¬¥Þ¥¦¥¹¤Îư¤­¤Ë¶Ëü¤ËÄɽ¾¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç
+ ¤¹¡£
+
+ Option ``XaaNoCPUToScreenColorExpandFill''
+ ʸ»ú¤ÎÉÁ²è¤¬¶Ëü¤ËÃÙ¤¤¤«¤Þ¤¿¤ÏÉÁ²è¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+
+ Option ``XaaNoScanlineCPUToScreenColorExpandFill''
+ ʸ»ú¤ÎÉÁ²è¤¬¶Ëü¤ËÃÙ¤¤¤«¤Þ¤¿¤ÏÉÁ²è¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+
+ Option ``XaaNoScreenToScreenColorExpandFill''
+ ʸ»ú¤ÎÉÁ²è¤¬¶Ëü¤ËÃÙ¤¤¤«¤Þ¤¿¤ÏÉÁ²è¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+
+ 4.4.2. Êó¹ð¤µ¤ì¤Æ¤¤¤ëÌäÂê
+
+ ¤¤¤º¤ì¤â TGUI9682 ÆÃÍ­¤Îɽ¼¨¾å¤ÎÌäÂêÅÀ¤Ç¤¹¡£
+
+ o ¥Þ¥¦¥¹¤òư¤«¤¹¤È¡¢¥«¡¼¥½¥ë¤Îµ°Àפ¬¾¯¤·±ø¤ì¤Þ¤¹¡£
+
+ o kterm ¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò²¡¤·¤Ê¤¬¤é¥É¥é¥Ã¥°¤¹¤ë¤È¡¢Ê¸»ú¤¬È¿Å¾¤¹
+ ¤ë¤È¤³¤í¤Ë²£Àþ¾õ¤Î¥Î¥¤¥º¤¬½Ð¤Þ¤¹¡£
+
+ o kterm ¤Ëɽ¼¨¤µ¤ì¤ëʸ»ú¤Î¥É¥Ã¥È¤¬¾¯¤·Íî¤Á¤Þ¤¹¡£
+
+ 4.4.3. ¤½¤Î¾
+
+ o ¤Þ¤À½½Ê¬¤Ê¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Çưºî¥ì¥Ý¡¼¥È¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£
+
+ 4.4.4. ´ØÏ¢
+
+ README.trident ¤Ï¸½»þÅÀ (4.0) ¤Ç¤Ï 3.3.6 ÍÑ¤ÎÆâÍÆ¤Ç¤¢¤ê¡¢¤³¤ì¤Ëµ­ºÜ¤µ
+ ¤ì¤Æ¤¤¤ë Option ¤Î¿¤¯¤Ï»ÈÍѤǤ­¤Ê¤¤¤Î¤ÇÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+
+ 5. ³Æ OS Ëè¤ÎÃí°Õ»ö¹à
+
+ 5.1. FreeBSD(98) ¤Ç¤ÎÃí°Õ»ö¹à
+
+ o VT switch ¤¬¤Ç¤­¤Þ¤»¤ó¡£
+
+ 5.2. NetBSD/pc98 ¤Ç¤ÎÃí°Õ»ö¹à
+
+ o ¸½¾õ¤Ç¤Ï NetBSD/pc98 1.4.x ¤ÇÍøÍѤǤ­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£Âкö½àÈ÷Ãæ¤Ç
+ ¤¹¤Î¤Ç¡¢»Ã¤¯¤ªÂÔ¤Á²¼¤µ¤¤¡£¤Ê¤ª¡¢NetBSD/i386 ¤Ç¤ÏÌäÂê¤Ï¤¢¤ê¤Þ¤»¤ó¡£
+
+ 5.3. PANIX for 98 ¤Ç¤ÎÃí°Õ»ö¹à
+
+ o VT switch ¤¬¤Ç¤­¤Þ¤»¤ó¡£
+
+ 5.4. Linux/98 ¤Ç¤ÎÃí°Õ»ö¹à
+
+ o 2.1.57 ¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢beta 14 °Ê¹ß¤Ç¤Ê¤¤¤È¥µ¡¼¥Ð¤¬¥Ï¥ó¥°¥¢¥Ã¥×¤¹¤ë
+ ¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤òÈò¤±¤ë¤Ë¤Ï¡¢root ¸¢¸Â¤Ë¤Æ dmesg -n 1 ¤ò¼Â¹Ô¤¹
+ ¤ë¤È¤¤¤¤¤è¤¦¤Ç¤¹¡£
+
diff --git a/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/read98.sgml b/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/read98.sgml
index 42f89c501..93909e415 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/read98.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/read98.sgml
@@ -5,7 +5,7 @@
<!-- Title information -->
<title> XFree86 PC98 Dependent Information
<author> The XFree86 Project Inc. and X98 CORE TEAM
-<date> 1999ǯ 7·î 19Æü
+<date> 2000ǯ 6·î20Æü
<abstract>
¤³¤Î¥É¥­¥å¥á¥ó¥È¤Ç¤Ï¡¢PC98¸ÇÍ­¤Î»ö¹à¤Ë¤Ä¤¤¤Æ²òÀ⤷¤Þ¤¹¡£
PC/AT¸ß´¹µ¡¤È¶¦Ä̤λö¹à¤Ë¤Ä¤¤¤Æ¤Ï¡¢¶¦Ä̤Υɥ­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£
@@ -15,10 +15,11 @@ PC/AT¸ß´¹µ¡¤È¶¦Ä̤λö¹à¤Ë¤Ä¤¤¤Æ¤Ï¡¢¶¦Ä̤Υɥ­¥å¥á¥ó¥È¤ò»²¾È¤·¤Æ²¼¤µ¤¤¡£
<p>ËÜ¥ê¥ê¡¼¥¹¤Ç¤Ï¡¢PC98ÍÑX¥µ¡¼¥Ð¤ÏPC/AT¸ß´¹µ¡ÍÑX¥µ¡¼¥Ð¤ÈÅý¹ç(¥Õ¥¡¥¤¥ë̾:
XFree86)¤µ¤ì¤Æ¤ª¤ê¡¢½¾Íè¤Î¥Ü¡¼¥É/¥Á¥Ã¥×¥»¥Ã¥ÈËè¤Î¥µ¡¼¥Ð¤â¤Ê¤¯¤Ê¤ê¤Þ¤·¤¿¡£
¤Þ¤¿¡¢³Æ¥É¥é¥¤¥Ð¤Ï¤¹¤Ù¤ÆSVGA¥Ù¡¼¥¹¤Ç¡¢XF86_S3¥Ù¡¼¥¹¤Î¥É¥é¥¤¥Ð¤Ï¤¢¤ê¤Þ¤»¤ó¡£
-¸½ºß¤Î¤È¤³¤í¡¢PC98¤Çưºî¤·¤Æ¤¤¤ë¤Î¤Ï¡¢mga¥É¥é¥¤¥Ð¤Î¤ß¤Ç¤¹¡£Millennium¡¢
-Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
-¸æÍøÍѲ¼¤µ¤¤¡£EGC¤äPEGC¤¹¤éÍøÍѤǤ­¤Þ¤»¤ó¡£³«È¯¥á¥ó¥Ð¤¬Èó¾ï¤Ë¾¯¤Ê¤¯¤Ê¤Ã¤Æ
-¤¤¤ë¤Î¤Ç¡¢³«È¯¤Ë¶½Ì£¤¬¤ª¤¢¤ê¤ÎÊý¤ÏX98 Core Team¤Þ¤Ç¡¢¸æÏ¢Íí²¼¤µ¤¤¡£</p>
+¸½ºß¤Î¤È¤³¤í¡¢PC98¤Çưºî¤·¤Æ¤¤¤ë¤Î¤Ï¡¢mga¡¢apm¡¢glint¡¢trident¥É¥é¥¤¥Ð¤Î¤ß
+¤Ç¤¹¡£Millennium¡¢Mystique¡¢VoodooRUSH¡¢Permedia2¡¢TGUI968x(¤¤¤º¤ì¤âPCI)¤Î
+¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.6)¤Î´Ä¶­¤ò¸æÍøÍѲ¼¤µ¤¤¡£
+¸½¾õ4.0¤Ç¤ÏEGC¤äPEGC¤¹¤éÍøÍѤǤ­¤Þ¤»¤ó¡£³«È¯¥á¥ó¥Ð¤¬Èó¾ï¤Ë¾¯¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë
+¤Î¤Ç¡¢³«È¯¤Ë¶½Ì£¤¬¤ª¤¢¤ê¤ÎÊý¤ÏX98 Core Team¤Þ¤Ç¡¢¸æÏ¢Íí²¼¤µ¤¤¡£</p>
<p>XF86Config¤äµ¯Æ°»þ¤Î¥ª¥×¥·¥ç¥óÅù¤ÎÊѹ¹¤Ë¤Ä¤¤¤Æ¤Ï¡¢RELNOTES¤Ë¾Ü¤·¤¯½ñ¤¤¤Æ
¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢»²¾È¤·¤Æ²¼¤µ¤¤¡£/usr/X11R6/lib/X11/XF86Config.98¤¬¡¢PC98ÍÑ
@@ -35,6 +36,9 @@ Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
------------- ----------------------------------------------- -------
NEC ¥Õ¥ë¥«¥é¡¼¥¦¥£¥ó¥É¥¦¥¢¥¯¥»¥é¥ì¡¼¥¿¥Ü¡¼¥É X2 XFree86
Matrox MGA Millennium(PC/AT ¸ß´¹µ¡ÍÑ) XFree86
+ IO-DATA GA-RUSH6/PCI XFree86
+ Melco WHP-PS8, WHP-PS4 XFree86
+ (IO-DATA GA-PII8, GA-PIIH8 XFree86)
</verb></p></sect1>
<sect1>¥µ¥Ý¡¼¥ÈÆâ¢¥Ó¥Ç¥ª¥·¥¹¥Æ¥à°ìÍ÷<p>
@@ -42,6 +46,7 @@ Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
¥Ù¥ó¥À¡¼ ¥Á¥Ã¥×¥»¥Ã¥È ¥µ¡¼¥Ð
------------- ----------------------------------------------- -------
NEC MGA Millennium/Mystique XFree86
+ NEC Trident TGUI968x(X-Mate,ValueStarÅù) XFree86
</verb></p>
<sect>¶¦ÄÌ»ö¹à<p>
@@ -63,7 +68,7 @@ Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
(**) Japanese PC98 architecture
¤È½ÐÎϤµ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
-<tag>xf86config</tag>
+<tag>xf86config¡¢xf86cfg</tag>
PC98ÍѤ˰ܿ¢¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£/usr/X11R6/lib/X11/XF86Config.98¤ò
XF86Config¤È¥ê¥Í¡¼¥à¤·¤Æ»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
<tag>xvidtune</tag>
@@ -109,8 +114,6 @@ Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
</verb>
¤Î¤è¤¦¤Ë½Ð¤Æ¤¤¤Æ¡¢Millennium¤ò»ÈÍѤ¹¤ë¾ì¹ç¤Ï¡¢"0:14:0"¤ò»ØÄꤷ¤Þ¤¹¡£
S3 968¤Ï»ÈÍѤǤ­¤Þ¤»¤ó¡£Ç°¤Î°Ù¡£
-<tag>VT switch</tag>
- FreeBSD(98)¤Ç¤Ï¤Ç¤­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£PANIX for 98¤Ç¤â¤Ç¤­¤Þ¤»¤ó¡£
<tag>CTRL,GRPH,+/- ¤Ë¤è¤ë²òÁüÅÙÀÚÂØ¤¨</tag>
¤Ç¤­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤ë¤è¤¦¤Ç¤¹¡£
</descrip>
@@ -126,12 +129,7 @@ Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
<itemize>
<ITEM>Millennium¤Ç¤Ï¡¢Modeline¤ÎÀßÄê¤Ë¤è¤Ã¤Æ¤Ï24bpp¤Ç½Ä¤ËÀþ
¤¢¤ë¤¤¤Ï¼ÊÌÏÍͤΥΥ¤¥º¤¬½Ð¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£
- <ITEM>Millennium¤Ç¤Ï¡¢½é´ü²½¤¬ÉÔ´°Á´¤Ê¤¿¤á¡¢»ÈÍÑÁ°¤Ë3.3¥Ù¡¼¥¹¤Î
- ¥µ¡¼¥Ð¤òµ¯Æ°¤·¤Æ¤ª¤«¤Ê¤¤¤È¥Ï¥ó¥°¥¢¥Ã¥×¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£°ìöµ¯Æ°
- ¤¹¤ì¤ÐÅŸ»¤òOFF¤Ë¤¹¤ë¤Þ¤Ç¤ÏÀµ¾ï¤Ëưºî¤·¤Þ¤¹¡£
- <ITEM>Linux/98¤Ç¤Ï¡¢beta 14°Ê¹ß¤Î¥«¡¼¥Í¥ë¤Ç¤Ê¤¤¤È»ÈÍÑÃæ¤Ë¥Ï¥ó¥°
- ¥¢¥Ã¥×¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤òÈò¤±¤ë¤Ë¤Ï¡¢root¸¢¸Â¤Ë¤Ædmesg
- -n 1 ¤ò¼Â¹Ô¤¹¤ë¤È¤¤¤¤¤è¤¦¤Ç¤¹¡£
+ <ITEM>Mystique¤Ç¤Ï¡¢VideoRam¤ÎÌÀ¼¨Åª¤Ê»ØÄ꤬ɬ¿Ü¤È¤Ê¤ê¤Þ¤¹¡£
</itemize>
<sect2>¤½¤Î¾<p>
<itemize>
@@ -149,21 +147,119 @@ Mystique¤Î¥Ü¡¼¥É¤ò¤ª»ý¤Á¤ÎÊý°Ê³°¤Ï¡¢3.3¥Ù¡¼¥¹(ex. 3.3.3.1, 3.3.4)¤Î´Ä¶­¤ò
README.MGA¡¢XF86_SVGA man page</p>
<sect1>apm¥É¥é¥¤¥Ð<p>
- (¾­ÍèŪ¤Ë¤Ï)IO-DATA¤ÎGA-RUSH6/PCI¤Ç¤âưºî¤¹¤ë(ͽÄê¤Î)¥É¥é¥¤¥Ð¤Ç¤¹¡£</p>
+ IO-DATA¤ÎGA-RUSH6/PCI¤Çưºî¤¹¤ë¥É¥é¥¤¥Ð¤Ç¤¹¡£</p>
<sect2>XF86Config¤ÎÀßÄê<p>
- README.MGAÆâ¤Ë²òÀ⤵¤ì¤Æ¤¤¤ë¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£Ä̾ï¤ÏÆÃ¤Ë
+ README.apmÆâ¤Ë²òÀ⤵¤ì¤Æ¤¤¤ë¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£Ä̾ï¤ÏÆÃ¤Ë
²¿¤â»ØÄꤹ¤ëɬÍ×̵¤¤È¦¤Ç¤¹¡£
<sect2>Êó¹ð¤µ¤ì¤Æ¤¤¤ëÌäÂê<p>
<itemize>
- <ITEM>8bpp°Ê³°¤Ç¤Ï¤Þ¤Ã¤¿¤¯Æ±´ü¤¬¼è¤ì¤Þ¤»¤ó¡£8bpp¤Î¾ì¹ç¤Ç¤âƱ´ü¤¬
- ¤ª¤«¤·¤¯¤ÆÆ±¤¸Êª¤¬3¤Äɽ¼¨¤µ¤ì¤¿¤ê¤·¤Þ¤¹¡£
- <ITEM>XF86Config¤Ç¤Î¥ª¥×¥·¥ç¥ó»ØÄê¤Ë¤è¤Ã¤Æ¤Ï¥Ï¥ó¥°¥¢¥Ã¥×¤·¤¿¤ê¤¹¤ë
- ¤³¤È¤â¤¢¤ê¤Þ¤¹¡£
+ <ITEM>¸½»þÅÀ¤Ç¼ÂÍÑŪ¤Ë»ÈÍѤǤ­¤ë»ö¤¬³Îǧ¤µ¤ì¤Æ¤¤¤ë¤Î¤Ï1024x768 256¿§
+ ¤Î¤ß¤Ç¤¹¡£16bpp¤ä1280x1024Åù¤Îɽ¼¨¤Ç¤ÏƱ´ü¤¬¼è¤ì¤Ê¤«¤Ã¤¿¤ê¡¢¥´¥ß¤Ê¤É
+ ¤¬É½¼¨¤µ¤ì¤¿¤ê¤·¤Þ¤¹¡£
+ <ITEM>¡ÖVideoRam 4096¡×¤Î»ØÄ꤬ɬ¿Ü¤Ç¤¹¡£
</itemize>
<sect2>¤½¤Î¾<p>
<itemize>
- <ITEM>¤Þ¤ÀPC-98Âбþºî¶È¤¬ËؤɽÐÍè¤Æ¤¤¤Þ¤»¤ó¡£¼ÂÍѤˤÏÂѤ¨¤Ê¤¤¤Ç¤·¤ç¤¦¡£
+ <ITEM>¼ÂÍÑÀ­¤ò¹Íθ¤¹¤ë¤Ê¤é1024x768 256¿§¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
+ <ITEM>Ëܥӥǥª¥«¡¼¥É¤Ë´Ø¤·¤Æ¤ÏXFree86 4.0°Ê¹ß¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
+ <ITEM>¤Þ¤À½½Ê¬¤Ê¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Çưºî¥ì¥Ý¡¼¥È¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£
</itemize>
<sect2>´ØÏ¢<p>
XF86_SVGA man page</p>
+
+<sect1>glint¥É¥é¥¤¥Ð<p>
+ Melco¤ÎWHP-PS8,WHP-PS4ÅùPermedia2ÅëºÜ¤Î¥Ó¥Ç¥ª¥«¡¼¥É¤Çưºî¤¹¤ë¥É¥é¥¤¥Ð
+ ¤Ç¤¹¡£IO-DATA¤ÎGA-PII8¤äGA-PIIH8Åù¤Ç¤âưºî¤¹¤ë¤«¤â¤·¤ì¤Þ¤»¤ó¡£</p>
+<sect2>XF86Config¤ÎÀßÄê<p>
+ README.3DlabsÆâ¤Ë²òÀ⤵¤ì¤Æ¤¤¤ë¥ª¥×¥·¥ç¥ó¤ò»ØÄê¤Ç¤­¤Þ¤¹¡£Ä̾ï¤ÏÆÃ¤Ë
+ ²¿¤â»ØÄꤹ¤ëɬÍ×̵¤¤È¦¤Ç¤¹¡£
+<sect2>Êó¹ð¤µ¤ì¤Æ¤¤¤ëÌäÂê<p>
+<itemize>
+ <ITEM>PC-98¤Ç¤Îưºî¤µ¤»¤ë¤Ù¤¯Âбþ¥³¡¼¥É¤¬´Þ¤Þ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢Æ°ºî³Îǧ¤¬
+ ËØ¤É¤µ¤ì¤Æ¤¤¤Þ¤»¤ó¡£
+</itemize>
+<sect2>¤½¤Î¾<p>
+<itemize>
+ <ITEM>¤Þ¤ÀËØ¤É¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Çưºî¥ì¥Ý¡¼¥È¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£
+ <ITEM>Ëܥӥǥª¥«¡¼¥É¤Ë´Ø¤·¤Æ¤ÏXFree86 4.0°Ê¹ß¤ò»ÈÍѤ·¤Æ²¼¤µ¤¤¡£
+</itemize>
+<sect2>´ØÏ¢<p>
+ XF86_SVGA man page</p>
+
+<sect1>trident¥É¥é¥¤¥Ð<p>
+ NEC ¤ÎÆâ¢¥¢¥¯¥»¥é¥ì¡¼¥¿(Trident TGUI9680/9682)¤Çưºî¤¹¤ë¥É¥é¥¤¥Ð¤Ç¤¹¡£
+ Accel¤Ç¤ª»È¤¤²¼¤µ¤¤¡£
+<sect2>XF86Config ¤ÎÀßÄê<p>
+<descrip>
+<tag>VideoRam 2048(¤Þ¤¿¤Ï 1024)</tag>
+VideoRam¤¬Àµ¤·¤¯¸¡½Ð¤Ç¤­¤Ê¤¤¾ì¹ç¤ËÀßÄꤷ¤Æ²¼¤µ¤¤¡£
+</descrip>
+
+°Ê²¼¤ÎOption(XaaNoScreenToScreenCopy¤ò½ü¤¯)¤ÏTGUI9680¤Ç¤ÏÀßÄꤷ¤Ê¤¯¤Æ¤â
+ưºî¤¹¤ë¤³¤È¤¬³Îǧ¤µ¤ì¤Æ¤¤¤Þ¤¹¤¬¡¢TGUI9682¤Ç¤ÏÉԲķç¤Ç¤¹¡£
+ÀßÄꤷ¤Ê¤¤¾ì¹ç¤Î¾ÉÎã¤â´Þ¤á¤Æ²òÀ⤷¤Þ¤¹¤¬¡¢¤³¤ì¤é¤ÎÌäÂ꤬À¸¤¸¤º¡¢¥í¥°¤Ë
+<verb>
+ Trident : BitBLT engine time-out.
+</verb>
+¤¬¸½¤ì¤Ê¤¤¤Î¤Ç¤¢¤ì¤ÐÀßÄêÉÔÍפǤ¹¡£
+¡Ê¤³¤ì¤é¤ÏÀßÄꤷ¤Ê¤¤Êý¤¬Æ°ºî¤¬Â®¤¤¤³¤È¤òǰƬ¤Ë¤ª¤¤¤Æ²¼¤µ¤¤¡£¡Ë
+
+<descrip>
+<tag>Option ``NoPciBurst''</tag>
+¥Þ¥¦¥¹¡¦¥«¡¼¥½¥ë¤¬¥Þ¥¦¥¹¤Îư¤­¤ËÄɽ¾¤»¤º¡¢¤Þ¤¿¥Þ¥¦¥¹¡¦¥«¡¼¥½¥ë¤Îư¤¤¤¿À×
+¤Ë¤½¤Î¡Ö­Àספ¬»Ä¤ë¾ì¹ç¤äÉÁ²è¤µ¤ì¤ëʸ»ú¤Î¥É¥Ã¥ÈÍî¤Á¤¬¿Ó¤À¤·¤¤¾ì¹ç¤ËÍ×Àß
+Äê¤Ç¤¹¡£
+<tag>Option ``XaaNoScreenToScreenCopy''</tag>
+²òÁüÅÙ¤¬1024x768°Ê²¼¤Ç¤ÏÀßÄêÉÔÍפǤ¹¡£¤½¤ì¤ò±Û¤¨¤ë²òÁüÅ٤ˤª¤¤¤Æ¥Þ¥¦¥¹¡¦
+¥«¡¼¥½¥ë¤¬¥Þ¥¦¥¹¤Îư¤­¤Ë¶Ëü¤ËÄɽ¾¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+<tag>Option ``XaaNoCPUToScreenColorExpandFill''</tag>
+ʸ»ú¤ÎÉÁ²è¤¬¶Ëü¤ËÃÙ¤¤¤«¤Þ¤¿¤ÏÉÁ²è¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+<tag>Option ``XaaNoScanlineCPUToScreenColorExpandFill''</tag>
+ʸ»ú¤ÎÉÁ²è¤¬¶Ëü¤ËÃÙ¤¤¤«¤Þ¤¿¤ÏÉÁ²è¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+<tag>Option ``XaaNoScreenToScreenColorExpandFill''</tag>
+ʸ»ú¤ÎÉÁ²è¤¬¶Ëü¤ËÃÙ¤¤¤«¤Þ¤¿¤ÏÉÁ²è¤·¤Ê¤¤¾ì¹ç¤ËÍ×ÀßÄê¤Ç¤¹¡£
+</descrip>
+
+<sect2>Êó¹ð¤µ¤ì¤Æ¤¤¤ëÌäÂê<p>
+¤¤¤º¤ì¤âTGUI9682ÆÃÍ­¤Îɽ¼¨¾å¤ÎÌäÂêÅÀ¤Ç¤¹¡£
+<itemize>
+ <ITEM>¥Þ¥¦¥¹¤òư¤«¤¹¤È¡¢¥«¡¼¥½¥ë¤Îµ°Àפ¬¾¯¤·±ø¤ì¤Þ¤¹¡£
+ <ITEM>kterm¾å¤Ç¥Þ¥¦¥¹¤Îº¸¥Ü¥¿¥ó¤ò²¡¤·¤Ê¤¬¤é¥É¥é¥Ã¥°¤¹¤ë¤È¡¢Ê¸»ú¤¬
+ ȿž¤¹¤ë¤È¤³¤í¤Ë²£Àþ¾õ¤Î¥Î¥¤¥º¤¬½Ð¤Þ¤¹¡£
+ <ITEM>kterm¤Ëɽ¼¨¤µ¤ì¤ëʸ»ú¤Î¥É¥Ã¥È¤¬¾¯¤·Íî¤Á¤Þ¤¹¡£
+</itemize>
+
+<sect2>¤½¤Î¾<p>
+<itemize>
+¤Þ¤À½½Ê¬¤Ê¥Æ¥¹¥È¤¬¹Ô¤ï¤ì¤Æ¤¤¤Ê¤¤¤Î¤Çưºî¥ì¥Ý¡¼¥È¤ò¤ª´ê¤¤¤·¤Þ¤¹¡£
+</itemize>
+
+<sect2>´ØÏ¢<p>
+README.trident¤Ï¸½»þÅÀ(4.0)¤Ç¤Ï3.3.6ÍÑ¤ÎÆâÍÆ¤Ç¤¢¤ê¡¢¤³¤ì¤Ëµ­ºÜ¤µ¤ì¤Æ¤¤¤ë
+Option¤Î¿¤¯¤Ï»ÈÍѤǤ­¤Ê¤¤¤Î¤ÇÃí°Õ¤·¤Æ²¼¤µ¤¤¡£
+
+<sect>³ÆOSËè¤ÎÃí°Õ»ö¹à<p>
+<sect1>FreeBSD(98)¤Ç¤ÎÃí°Õ»ö¹à<p>
+<itemize>
+ <ITEM>VT switch¤¬¤Ç¤­¤Þ¤»¤ó¡£
+</itemize>
+
+<sect1>NetBSD/pc98¤Ç¤ÎÃí°Õ»ö¹à<p>
+<itemize>
+ <ITEM>¸½¾õ¤Ç¤ÏNetBSD/pc98 1.4.x¤ÇÍøÍѤǤ­¤Ê¤¯¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£Âкö
+ ½àÈ÷Ãæ¤Ç¤¹¤Î¤Ç¡¢»Ã¤¯¤ªÂÔ¤Á²¼¤µ¤¤¡£¤Ê¤ª¡¢NetBSD/i386¤Ç¤ÏÌäÂê¤Ï¤¢
+ ¤ê¤Þ¤»¤ó¡£
+</itemize>
+
+<sect1>PANIX for 98¤Ç¤ÎÃí°Õ»ö¹à<p>
+<itemize>
+ <ITEM>VT switch¤¬¤Ç¤­¤Þ¤»¤ó¡£
+</itemize>
+
+<sect1>Linux/98¤Ç¤ÎÃí°Õ»ö¹à<p>
+<itemize>
+ <ITEM>2.1.57¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢beta 14°Ê¹ß¤Ç¤Ê¤¤¤È¥µ¡¼¥Ð¤¬¥Ï¥ó¥°
+ ¥¢¥Ã¥×¤¹¤ë¤³¤È¤¬¤¢¤ê¤Þ¤¹¡£¤³¤ì¤òÈò¤±¤ë¤Ë¤Ï¡¢root¸¢¸Â¤Ë¤Ædmesg
+ -n 1¤ò¼Â¹Ô¤¹¤ë¤È¤¤¤¤¤è¤¦¤Ç¤¹¡£
+</itemize>
</article>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/LICENSE b/xc/programs/Xserver/hw/xfree86/doc/LICENSE
index 066e2fd97..19f1b6903 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/LICENSE
+++ b/xc/programs/Xserver/hw/xfree86/doc/LICENSE
@@ -595,4 +595,4 @@ For further information, contact:
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LICENSE.sgml,v 1.7 2000/03/06 22:59:23 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/LICENSE,v 1.9 2000/03/07 14:55:04 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/LICENSE,v 1.10 2000/06/17 17:44:20 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/OS2.Notes b/xc/programs/Xserver/hw/xfree86/doc/OS2.Notes
index 06f88af1e..86f8a2e00 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/OS2.Notes
+++ b/xc/programs/Xserver/hw/xfree86/doc/OS2.Notes
@@ -2,7 +2,7 @@
Holger Veit
- Last modified August 1st, 1999
+ Last modified March 8th, 2000
1. Preface
@@ -16,17 +16,17 @@ hints if you intend to rebuild the system from scratch under OS/2.
Please also read README.OS2 for end-user information, and set at least the
environment variables described there.
-At the current time, the most recent version available is XFree86-3.3.5.
-This is a full and unrestricted version which comes with complete source
-code. 3.3.5 is not only a bugfix release, but also supports new hardware,
-some of which might not even supported by OS/2 itself. See the RELEASE NOTES
-document for details.
+At the current time, the most recent version available is XFree86-4.0. This
+is a full and unrestricted version which comes with complete source code. 4.0
+is a highly experimental release, so many features that might have worked in
+earlier versions, may now no longer work, or work differently. Be aware that
+for OS/2, XFree86-4.0 is considered to be alpha software.
If you want to join the XFree86 developer team, e.g. to add support for cer-
tain hardware, please send a request to BOD@XFree86.org. Please think about
such a step carefully before, though, since much work is involved. Please use
-the XFree86-3.3.5 source code as a test example how to compile the system.
-The ability to manage that is a basic requirement for becoming a developer.
+the XFree86-4.0 source code as a test example how to compile the system. The
+ability to manage that is a basic requirement for becoming a developer.
2. Tools required
@@ -66,6 +66,8 @@ will need:
o bison GNU bison
+ o m4 GNU m4
+
o find GNU find (attention: incompatible tool with the same name in
OS/2)
@@ -75,7 +77,7 @@ tion which might still be available from some archives is NOT compatible.
Furthermore, you need the XFree86 sources. These are available from the com-
mon XFree86 repositories. Look into a directory which is often named
-/pub/XFree86/3.3.5/source.
+/pub/XFree86/4.0/source.
3. Compiling and Installing
@@ -219,9 +221,9 @@ installed them. Nor did I install the test subtree.
Well, you see, this was quite easy :-)
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml,v 3.6 1999/08/23 06:38:50 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml,v 3.7 2000/04/05 18:13:46 dawes Exp $
$XConsortium: OS2note.sgml /main/1 1996/02/24 10:08:59 kaleb $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/OS2.Notes,v 3.14 2000/03/01 01:48:02 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/OS2.Notes,v 3.16 2000/06/17 17:44:20 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README b/xc/programs/Xserver/hw/xfree86/doc/README
index 3a987b886..995f72a7c 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README
+++ b/xc/programs/Xserver/hw/xfree86/doc/README
@@ -1,97 +1,163 @@
- README for XFree86[tm] 4.0
+ README for XFree86[tm] 4.0.1
The XFree86 Project, Inc
- 26 February 2000
+ 30 June 2000
Abstract
- XFree86 is a port of X11R6.4 that supports several UNIX(R) and
- UNIX-like operating systems on Intel and other platforms.
-
-1. What is XFree86 4.0?
-
-XFree86 4.0 is the first
- full release of the new XFree86 4 series. The road to XFree86 4 began in
-mid 1997, with serious work starting in early 1998. The first pre-4.0 snap-
-shot was released in mid 1999, and 4.0 was released in early 2000. A lot has
-been completed in that time, and even more has been started since the "4.0"
-design was drafted. The result is that this release contains a lot of new
-features, some new drivers, and some significant performance improvements.
-This release contains components in various stages of development, ranging
-from stable and well tested to new and not-so-well tested. One the other
-side, there are drivers from the 3.3.x series that have not yet been ported
-to XFree86 4. Most of these are for old hardware. To find more information
-about which hardware is supported, see the Driver Status document.
-
-XFree86 4 uses a very modular design. We had hoped to finalise and fully
-document the driver module API/ABI in time for the 4.0 release, but instead
-we are planning to have this done for a subsequent release. We will try
-where possible to retain backward compatibility with the module interfaces in
-4.0 in future releases, but we can't make guarantees about that until the
-interfaces have been fully documented.
-
-Information on this release's features and their status can be found in the
-Release Notes.
-
-Information about obtaining and installing binary distributions of this
-release can be found in the Installation Document.
-
-Copyright and Licensing information for this release can be found in the
-License Document.
-
-2. Developers
-
-If you would like to work on the development of XFree86 4, then it is recom-
-mended that you join the XFree86 development team
-<URL:http://www.xfree86.org:/developer.html>. That way you will have access
-to the latest source and to other developers.
-
-3. How to get XFree86 4.0
-
-XFree86 4.0 can be found at the XFree86 ftp server
-<URL:ftp://ftp.xfree86.org/pub/XFree86/4.0/>, and at mirrors of this server.
-Information about obtaining and installing binary distributions of this
-release can be found in the Installation Document. Information about obtain-
-ing the release in source form is given below.
-
-The source for version 4.0 is split into three tarballs: X400src-1.tgz,
-X400src-2.tgz, X400src-3.tgz. The first contains everything except the fonts
+ XFree86 is the Open Source port of X.Org's X11R6.4 release that
+ supports several UNIX(R) and UNIX-like (such as Linux, the BSDs and
+ Solaris x86) operating systems on Intel and other platforms.
+
+1. What is XFree86 4.0.1?
+
+XFree86 4.0.1 is a the upgrade to the first full release in the new XFree86 4
+series. Release 4 is a major re-design of the basic architectural underpin-
+nings of XFree86's implementation of the original X Consortium's X Server.
+This re-design allows for a modular interaction between the hardware drivers
+and the XFree86 core X server. With 4.0, upgrades to the X server with new
+and unsupported hardware can be easily done and installed without undergoing
+the previous process of rebuilding a X server. All that is required is
+installing the new driver module and updating the configuration file.
+
+The road to XFree86 Release 4 began as an architectural concept in mid 1997,
+with the serious framework being implemented in code the beginning of 1998.
+There were several snapshots on the road to 4.0 which are now part of the 4.0
+base release. The 4.0.1 version is an upgrade to 4.0, which include more
+hardware ports, code enhancements and bug fixes.
+
+Release 4 also included the long-awaited integration of the DRI (Direct Ren-
+dering Infrastructure). This upgrade into the code base gives XFree86 the
+abilities of direct 3-D graphics rendering, used widely in games and other
+visualization programs.
+
+Many drivers used in the old 3.3.x series have not be converted over to the
+4.0 design and so check first whether your hardware is supported before
+upgrading to the 4.0 series in the Driver Status document.
+
+Specific release enhancements can be viewed in the Release Notes.
+
+Information about binary distributions and the attendant installation
+instructions can be found in the Installation Document.
+
+Copyright and Licensing information for this release and all XFree86 releases
+can be found in the License Document.
+
+2. Joining The Team
+
+2.1 Development
+
+If you would like to work on the development of XFree86 4, either by helping
+with the conversion of our older drivers to the new 4.0 design, or assisting
+in the addition of new drivers or platforms to the code base then send a
+request to to join the XFree86 development team
+<URL:http://www.xfree86.org:/developer.html>. This will give you direct
+access to the latest XFree86 related development topics and discussions.
+Include in your note, your name, email address, reason for joining (what you
+will work on) and, level of expertise (coder, DRI, core, specific driver) and
+area of interest.
+
+2.2 Documentation
+
+If instead your interests are on the Documentation side of the Project, or
+you want to contribute and are not ready for plunging into the code, you can
+join the Documentation Team (those hardy souls responsible for the content
+you are reading :-). Amongst the Doc Team's activities are converting our
+SGML based documentation into an XML based one and updating and creating
+technical documentation used by staff and public. If this sounds interesting
+then please send a request to join the XFree86 documentation team
+<URL:mailto:signup@xfree86.org>. Include in your note, you name, email
+address, reason for joining (what you will work on) and level of expertise
+and whether you are interested in the tools or content side of the group.
+
+3. The Public Mailing Lists
+
+3.1 Newbie
+
+For those who are new to XFree86 and want to learn more about our Project we
+recommend that you join our Newbie list, located at Public Mailing Lists
+<URL:http://www.xfree86.org/mailman/listinfo>, where this and other discus-
+sions occur with our senior all-volunteer staff. This is great forum to get
+introduced to XFree86 and ask for help on how to set up the XServer or
+whether your hardware is supported, and why not?, and make suggestions for
+future releases of XFree86. This list is supported by our volunteer staff
+who needs to know how you are using and interacting with XFree86 and what is
+wrong and could be better. Tell them, they want to know!
+
+3.2 Announce
+
+For those who just want to know the release schedule this is a good list to
+join.
+
+3.3 CVS Commit
+
+For those who want to see what has been committed recently to our CVS reposi-
+tory this is the list that will show you those updates. This list is updated
+dynamically every time the repository is updated after the the commit hap-
+pens.
+
+A followup to the commit list is the soon to be public, patch archives. This
+archive will be available on our web-site and will show what patches have
+been submitted and will soon be committed. This is helpful for people who
+are interested in a specific area and want to know what work is happening
+there. When this goes public we will announce it on our web site and our
+Announce mailing list, so keep watching.
+
+3.4 Xpert
+
+If instead you are the lone developer who is improving XFree86 on an ad hoc
+basis for your particular environment (I want to get my mouse or video card
+to work), and need a specific question asked then you should go over to our
+Xpert list where such questions are raised and answered by our technical
+development staff. Remember you do not have to be a member to write fixes to
+our code base and if your changes are discrete and self-contained the volume
+of developer mail may just be too noisy.
+
+Once your work is finished (coded, debugged and documented) please send your
+fix to <fixes@XFree86.org>. This will ensure that they are included in
+future releases. And thanks! You make this truly an Open group.
+
+4. How to get XFree86 4.0.1
+
+XFree86 4.0.1 can be found at the XFree86 ftp server
+<URL:ftp://ftp.xfree86.org/pub/XFree86/4.0.1/>, and at mirrors of this
+server. Information about obtaining and installing binary distributions of
+this release can be found in the Installation Document. Information about
+obtaining the release in source form is given below.
+
+The source for version 4.0.1 is split into three tarballs: X401src-1.tgz,
+X401src-2.tgz, X401src-3.tgz. The first contains everything except the fonts
and general X11 documentation. It is sufficient for building XFree86 is you
already have a set of fonts. The second contains the fonts and the source
for the general X11 documentation. The third contains the general X11 docu-
mentation in hardcopy format.
-A source patch relative to version 3.9.18 is also available. Because of its
-size, it is split into two parts. The patch files are 3.9.18-4.0.diff1.gz
-and 3.9.18-4.0.diff2.gz. These patches should be applied to a clean 3.9.18
-source tree, working from the directory containing the xc/ directory. The
-patches should be applied by running:
+A source patch relative to version 4.0 is also available. Because of its
+size, it is split into two parts. The patch files are 4.0-4.0.1.diff1.gz and
+4.0-4.0.1.diff2.gz. These patches should be applied to a clean 4.0 source
+tree, working from the directory containing the xc/ directory. The patches
+should be applied by running:
- gunzip < 3.9.18-4.0.diff1.gz | patch -p0 -E
- gunzip < 3.9.18-4.0.diff2.gz | patch -p0 -E
+ gunzip < 4.0-4.0.1.diff1.gz | patch -p0 -E
+ gunzip < 4.0-4.0.1.diff2.gz | patch -p0 -E
-The contrib part of the distribution has now been folded into the main source
+The contrib part of the distribution has been folded into the main source
tree, so a separate contrib tarball is no longer required.
-To format the XFree86 documentation, the latest version of our doctools pack-
-age. That is available as doctools-1.1.2.tgz.
+To format the XFree86 documentation use the latest version of our doctools
+package available as doctools-1.1.3.tgz.
-4. Reporting Bugs
+5. Reporting Bugs
Bugs should be reported to <XFree86@XFree86.org>. Before reporting bugs,
please check the X server log file, which can be found at
/var/log/XFree86.0.log on most platforms. If you can't resolve the problem
-yourself, send the entire log file with your bug report. Please don't edit
-out what you think might not be important. The information contained in the
-log file is there to make it easier for the developers to determine what is
-going wrong when there are problems.
+yourself, send the entire log file with your bug report but not the operating
+system core dump. Do not edit the log file as our developers use it to
+reproduce and debug your problem.
-If you have patches (bug fixes or enhancements, etc) that you'd like to sub-
-mit for inclusion in a future version of XFree86, please send them to
-<fixes@XFree86.org>.
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.106 2000/07/02 02:35:27 dawes Exp $
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.103 2000/03/08 20:36:43 dawes Exp $
-
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README,v 3.102 2000/03/08 20:39:21 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README,v 3.105 2000/07/02 02:46:26 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.DECtga b/xc/programs/Xserver/hw/xfree86/doc/README.DECtga
index 218c23ec4..6377a9a04 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.DECtga
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.DECtga
@@ -6,8 +6,8 @@
1. DEC 21030
- o The DEC 21030 is supported by XFree86 4.0. The driver is now partially
- accelerated. The built-in graphics on the Multia is supported in
+ o The DEC 21030 is supported by XFree86 4.0.1. The driver is now par-
+ tially accelerated. The built-in graphics on the Multia is supported in
8-plane mode, and PCI cards with 8 or 16 MB framebuffers are supported
in 24-plane mode. TGA2 (aka PowerStorm 3D30/4D20) cards are not cur-
rently supported.
@@ -65,4 +65,4 @@
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DECtga.sgml,v 3.9 2000/03/06 22:59:23 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DECtga,v 3.15 2000/03/07 14:55:05 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DECtga,v 3.16 2000/06/17 17:44:20 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.DRI b/xc/programs/Xserver/hw/xfree86/doc/README.DRI
index 468b6ef6d..a0ed3c6e0 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.DRI
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.DRI
@@ -1,8 +1,8 @@
- DRI Users Guide
+ DRI User Guide
Precision Insight, Inc.
- 6 March 2000
+ 18 May 2000
1. Preamble
@@ -24,8 +24,9 @@ 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. All other trademarks mentioned are the property of
-their respective owners.
+active, Incorporated. Matrox is a registered trademark of Matrox Electronic
+Systems Ltd. ATI Rage is a registered trademark of ATI Technologies, Inc.
+All other trademarks mentioned are the property of their respective owners.
2. Introduction
@@ -39,9 +40,11 @@ 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.0; it
+This document does not cover compilation or installation of XFree86 4.0. It
is assumed that you've already installed a Linux distribution which includes
-XFree86 4.0.
+XFree86 4.0 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
3. Supported Hardware
@@ -49,7 +52,8 @@ XFree86 4.0.
CPUs. Support for Alpha, and perhaps other CPUs, should be available in the
future.
-XFree86 4.0 includes 3D acceleration for the following graphics hardware:
+XFree86 4.0 (or later versions) includes 3D acceleration for the following
+graphics hardware:
o 3dfx:
@@ -70,24 +74,54 @@ XFree86 4.0 includes 3D acceleration for the following graphics hardware:
There are many configurations of 3dfx cards on the market. Not all have
been tested.
- o 3Dlabs Oxygen GMX 2000 (MX/Gamma based)
+ o Matrox:
-Support for the following hardware is underway:
+ o Matrox G200
+
+ o Matrox G400
o Intel i810
- o Matrox G400
+ o i810
+
+ o i810-dc100
+
+ o i810e
o ATI Rage 128
+ o Rage Fury AGP
+
+ o Rage Magnum AGP
+
+ o XPERT 2000 AGP
+
+ o XPERT 128 AGP
+
+ o XPERT 99 AGP
+
+ o All-in-Wonder 128 AGP
+
+ The PCI versions of these cards also have minimal support. Note that
+ there are also Rage 128 Pro based boards on the market, and these are
+ not yet supported.
+
+ o 3Dlabs Oxygen GMX 2000 (MX/Gamma based)
+
+Support for the following hardware is underway:
+
o 3dfx Voodoo4 and Voodoo5 series
4. Prerequisite Software
o XFree86 4.0
- o Linux kernel 2.2.x (later kernels will be supported in the near future,
- and may be required for some chipsets)
+ o For the 3dfx Voodoo3 driver, Linux kernel 2.2.x (later kernels will be
+ supported in the near future, and may be required for some chipsets)
+
+ o For the Matrox G200/G400, Linux kernel 2.3.51, with AGP support
+
+ o For the Intel i810, Linux kernel 2.3.99-pre6, with AGP support
Mesa 3.3 (beta) is included with XFree86 4.0; there is no need to download
the stand-alone Mesa distribution.
@@ -99,18 +133,16 @@ eration support.
5.1 Kernel module
-Before starting the X server you must install the correct kernel module for
-your hardware.
-
-This can be done by executing the following as root:
+XFree86 4.0.1 added automatic kernel module loading to the X server. On
+Linux, the X server uses modprobe to load kernel modules. The DRM kernel
+modules should be in /lib/modules/KERNEL-VERSION/misc/ for automatic loading
+to work.
- insmod XXX/drivername.o
+Optionally, DRM kernel modules can be loaded manually with insmod prior to
+starting the X server.
-For example, on 3dfx hardware, the kernel module is called tdfx.o so you you
-would type insmod XXX/tdfx.o
-
-Verify that the kernel module was installed by checking that /proc/dri/0
-exists.
+You can verify that the kernel module was installed with lsmod, checking the
+X server startup log, and checking that /proc/dri/0 exists.
5.2 XF86Config file
@@ -163,7 +195,9 @@ the DRI section, please also remove the /dev/dri directory with the rm -rf
/dev/dri command.]
Next, the Device section of the XF86Config file must describe your particular
-hardware. For example, here's the Device section for a 3dfx Voodoo3 card:
+hardware.
+
+For example, here's the Device section for a 3dfx Voodoo3 card:
Section "Device"
Identifier "Voodoo3"
@@ -171,6 +205,32 @@ hardware. For example, here's the Device section for a 3dfx Voodoo3 card:
Driver "tdfx"
EndSection
+Here's the Device section for a Matrox G400 card:
+
+ Section "Device"
+ Identifier "G400"
+ VendorName "Matrox"
+ Driver "mga"
+ VideoRam 32768
+ EndSection
+
+Here's the Device section for an ATI Rage 128 card:
+
+ Section "Device"
+ Identifier "Rage128"
+ VendorName "ATI"
+ Driver "r128"
+ EndSection
+
+Here's the Device section for an Intel i810 motherboard:
+
+ Section "Device"
+ Identifier "i810"
+ VendorName "Intel"
+ Driver "i810"
+ VideoRam 10000
+ EndSection
+
Finally, the Screen section of the XF86Config file may have to be specially
configured as well. For example, Voodoo3 hardware acceleration is only
available in 16bpp mode.
@@ -187,6 +247,10 @@ available in 16bpp mode.
EndSubsection
EndSection
+Replace Voodoo3 with G400 for Matrox G400.
+
+Replace Voodoo3 with Rage128 for ATI Rage 128.
+
If there are errors in the XF86Config file, the X server will log errors to
the file /var/log/XFree86.0.log
@@ -251,7 +315,22 @@ If you get an error message such as
if means that the libGL.so.1 file is not the right location. Proceed to the
trouble shooting section.
-6.4 glxinfo
+6.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.
+
+libOSMesa.so implements the OSMesa interface and 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 -L/usr/X11R6/lib -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.
+
+6.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
@@ -279,7 +358,7 @@ glxinfo also lists all of the GLX-enhanced visuals available. Here you can
determine which visuals may have depth buffers, stencil buffers, accumulation
buffers, etc.
-6.5 Environment Variables
+6.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
@@ -287,17 +366,20 @@ 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.
+ 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_DIR can be used to override the default directory which
- is searched for 3D drivers. In a typical XFree86 installation, the 3D
- drivers should be in /usr/X11R6/lib/modules/dri/. This environment
- variable can be used to specify a different directory. Note that this
- feature is disabled for set-uid programs.
+ 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.
Mesa-based drivers (this includes most of the drivers listed above) also
observe many of the existing Mesa environment variables. These include the
@@ -432,13 +514,47 @@ bleshooting.
8.1 3dfx Voodoo3
-8.1.1 Troubleshooting
+8.1.1 Configuration
+
+Your XF86Config file's device section must specify the tdfx device:
+
+ Section "Device"
+ Identifier "Voodoo3"
+ VendorName "3dfx"
+ Driver "tdfx"
+ EndSection
+
+The Screen section should then reference the Voodoo3 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
+
+The kernel module for the Voodoo3 is named tdfx.o and should be installed in
+/lib/modules/KERNEL-VERSION/misc/. It will be automatically loaded by the
+Xserver if needed.
+
+The DRI 3D driver for the Voodoo3 should be in /usr/X11R6/lib/mod-
+ules/dri/tdfx_dri.so. This will be automatically loaded by libGL.so.
+
+8.1.2 Troubleshooting
o 3D acceleration for 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.
-8.1.2 Performance
+ o The /dev/3dfx device is not used for DRI; it's only for Glide on older
+ 3dfx hardware.
+
+8.1.3 Performance
o Normally, buffer swapping in double-buffered applications is synchro-
nized to your monitor's refresh rate. This may be overridden by setting
@@ -452,17 +568,163 @@ bleshooting.
Performer Town demo, may become sluggish when falling back to software
rendering to render in that mode.
-8.1.3 Known Problems
+8.1.4 Known Problems
+
+ o Glide cannot be used directly; only OpenGL-based programs are supported
+ on the Voodoo3.
o SSystem has problems because of poorly set near and far clipping planes.
The office.unc Performer model also suffers from this problem.
8.2 Intel i810
-8.3 Matrox G400
+8.2.1 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"
+ 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/KERNEL-VERSION/misc/. 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.
+
+8.2.2 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.
+
+8.3 Matrox G200 and G400
+
+8.3.1 Configuration
+
+Your XF86Config file's device section must specify the mga device:
+
+ Section "Device"
+ Identifier "MGA"
+ VendorName "Matrox"
+ Driver "mga"
+ 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
+
+The kernel module for the G200/G400 is named mga.o and should be installed in
+/lib/modules/KERNEL-VERSION/misc/. 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.
+
+8.3.2 Troubleshooting
+
+ o 3D acceleration for the G200 and G400 is only supported in the 16
+ bit/pixel screen mode at this time. 32bpp will be supported in the
+ future. Use xdpyinfo to verify that all your visuals are depth 16.
+ Edit your XF86Config file if needed.
+
+8.3.3 Performance
+
+No data at this time.
+
+8.3.4 Known Problems
+
+ o Multitexture is currently disabled on the G400 to work around a hardware
+ lockup bug. This should be restored in a subsequent release.
8.4 ATI Rage 128
+8.4.1 Configuration
+
+Your XF86Config file's device section must specify the r128 device:
+
+ Section "Device"
+ Identifier "Rage128"
+ VendorName "ATI"
+ Driver "r128"
+ 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/KERNEL-VERSION/misc/. 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.
+
+8.4.2 Performance
+
+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.
+
+8.4.3 Known Problems
+
+DGA is not yet supported in the ATI Rage 128 X server. This feature will be
+added in a future release.
+
8.5 3DLabs Oxygen GMX 2000
The driver for this hardware was experimental and is no longer being devel-
@@ -501,7 +763,40 @@ 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.
-9.5 Bug Database
+9.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.
+
+9.6 Bug Database
The DRI bug database which includes bugs related to specific drivers is at
the SourceForge DRI Bug Database
@@ -529,16 +824,18 @@ forge.net/resources/resources.html
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.
+
10.3 Support
o The DRI-users mailing list at SourceForge is a forum for people to dis-
cuss DRI problems.
- o XXX IHV support?
-
- o XXX Linux distro support?
+ 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.3 2000/03/08 05:38:41 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.5 2000/06/17 00:03:17 martin Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRI,v 1.4 2000/03/08 20:39:22 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRI,v 1.6 2000/06/17 17:44:20 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp b/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp
new file mode 100644
index 000000000..1726dd18a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp
@@ -0,0 +1,417 @@
+ DRI Compilation Guide
+
+ Precision Insight, Inc.
+
+ 18 May 2000
+
+1. Preamble
+
+1.1 Copyright
+
+Copyright © 2000 by Precision Insight, Inc., Cedar Park, Texas. 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 is a registered trademark of ATI Technologies, Inc.
+All other trademarks mentioned are the property of their respective owners.
+
+2. Introduction
+
+This document describes how to download, compile and install the DRI project.
+This information is intended for experienced Linux developers. Beginners are
+probably better off installing precompiled packages.
+
+Edits, corrections and updates to this document may be mailed to brian@preci-
+sioninsight.com.
+
+3. Prerequisites
+
+You'll need the following:
+
+ o At least 400MB of free disk space. More is needed if you want to build
+ with debugging information or keep several build trees.
+
+ o A fast system. Using a PIII-550 it takes about 1/2 hour to build every-
+ thing.
+
+ o GCC compiler and related tools.
+
+ o ssh (secure shell) for registered developer downloading of the DRI
+ source tree
+
+For 3dfx Voodoo3 hardware, you'll also need:
+
+ o Glide3x headers and runtime library if you want to use the 3dfx driver.
+ These can be obtained from linux.3dfx.com.
+
+ o Linux kernel 2.2.x. The DRI developers have been using stock RedHat 6.1
+ systems (kernel 2.2.12-20). Later kernel versions will be supported in
+ the future.
+
+For Matrox G200/G400 hardware, you'll also need:
+
+ o Linux kernel 2.3.51. Older kernel versions will not work.
+
+For Intel i810 hardware, you'll also need:
+
+ o Linux kernel 2.3.99-pre6. Older kernel versions will not work.
+
+For ATI Rage hardware, you'll also need:
+
+ o Linux kernel 2.3.51. Other kernel versions may work but this one is
+ known to work.
+
+4. Kernel preparation
+
+You may have to upgrade your Linux kernel in order to use the DRI. This is
+because you need a kernel version which supports AGP. 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
+
+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.3.51
+ ln -s linux-2.3.51 linux
+ bzcat linux-2.3.51.tar.bz2 | tar xf -
+
+Now 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
+
+ o Go to Character devices
+
+ o Disable Direct Rendering Manager (XFree86 DRI support) since we'll use
+ the DRI module from the XFree86/DRI tree.
+
+ o Go to /dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)
+
+ o Hit SPACE twice
+
+ o Enable all chipsets' support for AGP
+
+It's recommended that you turn on MTRRs under Processor type and Features,
+but not required.
+
+Configure the rest of the kernel as required for your system (i.e. Ethernet,
+SCSI, etc)
+
+Exit, saving your kernel configuration.
+
+Edit your /etc/lilo.conf file. Make sure you have an image entry as follows
+(or similar):
+
+ image=/boot/vmlinuz
+ label=linux.2.3.51
+ 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.
+
+Now compile the new kernel:
+
+ cd /usr/src/linux-2.3.51
+ make dep ; make bzImage
+ make modules ; make modules_install
+ make install
+
+Note that the final part, make install, will automatically run lilo for you.
+
+Now reboot to use this new kernel.
+
+5. Downloading the XFree86/DRI CVS Sources
+
+The DRI project is hosted by VA Linux Systems' SourceForge. The DRI source
+code, which is a subset of the XFree86 source tree, is kept in a CVS reposi-
+tory 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.
+
+5.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.
+
+5.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 -dYOURID@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. 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. Compiling the XFree86/DRI tree
+
+7.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.
+
+7.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
+ #define DefaultGcc2i386Opt -O2
+ #define LibraryCDebugFlags -O2
+ #define BuildServersOnly YES
+ #define XF86CardDrivers vga tdfx mga r128 i810
+ #define LinuxDistribution LinuxRedHat
+ #define DefaultCCOptions -ansi GccWarningOptions -pipe
+ #define BuildXF86DRI YES
+ #define HasGlide3 YES
+ /* Optionally turn these on for debugging */
+ /* #define GlxBuiltInTdfx YES */
+ /* #define GlxBuiltInMga YES */
+ /* #define GlxBuiltInR128 YES */
+ /* #define DoLoadableServer NO */
+ #define SharedLibFont NO
+
+The ProjectRoot variable specifies where the XFree86 files will be installed.
+You probably don't want to use /usr/X11R6/ because that would overwrite your
+default X files. The following is recommended:
+
+ #define ProjectRoot /usr/XF86-main
+
+Especially note the XF86CardDrivers line to be sure your driver is listed.
+
+If you have 3dfx hardware be sure that the Glide 3x headers are installed in
+/usr/include/glide3/ and that the Glide 3x library is installed at
+/usr/lib/libglide3x.so.
+
+If you do not have 3dfx hardware comment out the HasGlide3 line in host.def.
+
+7.3 Compile
+
+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.
+
+7.4 Check for compilation errors
+
+Using your text editor, examine World.LOG for errors by searching for the
+pattern ***.
+
+Verify that the DRI kernel module(s) for your system were built:
+
+ cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+ ls
+
+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
+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.12-20 vs. 2.3.99-pre6), make will select the wrong
+kernel headers. This can be fixed by explicitly setting the value of TREE.
+If the path to your kernel source is /bigdisk/linux-2.3.99-pre6,
+
+ cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+ make TREE=/bigdisk/linux-2.3.99-pre6
+
+or alternatively, edit Makefile to include this change.
+
+After fixing the errors, do make World again. Later, you might just compile
+parts of the source tree but it's important that the whole tree will build
+first.
+
+8. Installing
+
+After the DRI tree has been compiled you can install the XFree86 headers,
+libraries, programs, etc for testing.
+
+8.1 X Installation
+
+As mentioned above, the install directory is specified by the ProjectRoot
+variable in the host.def file. Create that directory now if it doesn't
+already exist:
+
+ mkdir /usr/XF86-main
+
+You'll have to change to root since the install process puts several files in
+/etc/X11/ and sets the setuid flag on the X server executable.
+
+ cd ~/DRI-CVS/build/xc
+ su
+ make install
+
+Edit your /etc/ld.so.conf file and put /usr/XF86-main/lib as the first line.
+Continue with:
+
+ ldconfig
+ exit
+
+Look in /usr/XF86-main to be sure the files installed there.
+
+Strictly speaking, installing the DRI tree isn't required. It's possible to
+run and test the X server directly from the build directory but it's a bit
+error prone.
+
+8.2 Update Locale Information
+
+To update your X locale information do the following:
+
+ cd ~/DRI-CVS/build/xc/nls
+ xmkmf -a
+ make
+ make install
+
+This will prevent a locale error message from being printed when you run Xlib
+programs.
+
+9. X Server Configuration
+
+If your X server is currently running you'll have to stop it and return to a
+virtual terminal.
+
+First, setup your XF86Config file. It should load the GLX and DRI modules
+and specify the driver to use for your hardware. See the DRI User Guide for
+detailed information.
+
+You may want to make a backup copy of your existing /etc/X11/XF86Config file
+first.
+
+It's very important that you set the ModulePath option to point to your
+installation directory:
+
+ ModulePath "/usr/XF86-main/lib/modules"
+
+Double check with this:
+
+ grep ModulePath /etc/X11/XF86Config
+
+Next, your ~/.xinitrc file controls which clients will be launched when your
+X server starts. You might put the following in yours:
+
+ xset b off
+ xsetroot -solid "#004070"
+ xmodmap -e "clear mod4"
+ xrdb -merge ~/.Xdefaults
+ xterm -geometry +0+0 &
+ xterm -geometry +512+0 &
+ fvwm
+
+10. X Server Start-up
+
+The X server can be started with:
+
+ xinit -- /usr/XF86-main/bin/XFree86
+
+Automatic loading of DRM kernel modules was added to the X server in XFree86
+4.0.1. This feature, and manual loading of kernel modules, is documented in
+the DRI user guide.
+
+At this point your X server should be up and running with hardware-acceler-
+ated direct rendering. Please read the DRI User Guide for trouble shooting
+information.
+
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.3 2000/06/17 02:16:49 dawes Exp $
+
+
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.DRIcomp,v 3.1 2000/06/17 17:44:20 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.LynxOS b/xc/programs/Xserver/hw/xfree86/doc/README.LynxOS
index dd52cc624..7ff3816d1 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.LynxOS
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.LynxOS
@@ -1,4 +1,4 @@
- README for XFree86 4.0 on LynxOS
+ README for XFree86 4.0.1 on LynxOS
Thomas Mueller
@@ -13,29 +13,34 @@ ments as well as many bug fixes.
See the Copyright Notice.
-The sources for XFree86 4.0 are available by anonymous ftp from:
+The sources for XFree86 4.0.1 are available by anonymous ftp from:
-ftp://ftp.XFree86.org/pub/XFree86/4.0
+ftp://ftp.XFree86.org/pub/XFree86/4.0.1
Binaries of XFree86 for LynxOS x86 are available from:
-ftp://ftp.XFree86.org/pub/XFree86/4.0/binaries/LynxOS
+ftp://ftp.XFree86.org/pub/XFree86/4.0.1/binaries/LynxOS
A list of mirror sites is provided by ftp://ftp.XFree86.org/pub/XFree86/MIR-
RORS
The binaries on the FTP site were built on the latest released LynxOS version
-at the time XFree86 4.0 was released. In this case it is `LynxOS x86 3.0.1'.
-Because of changes made to the object format they don't run on LynxOS ver-
-sions earlier than 3.0.0.
+at the time XFree86 4.0.1 was released. In this case it is `LynxOS x86
+3.0.1'. Because of changes made to the object format they don't run on LynxOS
+versions earlier than 3.0.0.
Building of this XFree86 version has never been tested on LynxOS versions
earlier than 2.5.1.
-XFree86 4.0 supports LynxOS on the x86 and on the PowerPC platform. X servers
-are currently available only on the x86 platform. The X server may work with
-some PowerPC platforms supported by LynxOS though this has not (yet) been
-thoroughly tested.
+This release contains preliminary build support for `LynxOS 3.1.0'. Since
+this OS release was not available long enough for serious testing `LynxOS
+3.1.0' support has to be considered to be in `alpha state'. Initial tests
+were performed on LynxOS x86 only!
+
+XFree86 4.0.1 supports LynxOS on the x86 and on the PowerPC platform. X
+servers are currently available only on the x86 platform. The X server may
+work with some PowerPC platforms supported by LynxOS though this has not
+(yet) been thoroughly tested.
If you need binaries for other platforms than the one on the XFree86 FTP
server or if you have comments or suggestions about this document contact me
@@ -158,8 +163,8 @@ to
3.5 X Server debug diagnostics output and other VT peculiarities
Output made by the XFree86 X on its stdout or stderr will be lost after the
-server switches to graphics mode. The XFree86 4.0 server stores its output in
-/usr/adm/XFree86.n.log (where n is the screen number).
+server switches to graphics mode. The XFree86 4.0.1 server stores its output
+in /usr/adm/XFree86.n.log (where n is the screen number).
When the X server is running output made to other consoles will be lost.
After server shutdown the screen contents of other consoles may be inconsis-
@@ -258,7 +263,7 @@ duplicate entries:
sort /usr/X11R6/man/whatis | uniq > /tmp/tmpfile
mv /tmp/tmpfile /usr/X11R6/man/whatis
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml,v 3.19 2000/03/03 21:28:08 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml,v 3.20 2000/06/17 00:27:32 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.LynxOS,v 3.26 2000/03/04 00:51:29 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.LynxOS,v 3.27 2000/06/17 17:44:20 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.NetBSD b/xc/programs/Xserver/hw/xfree86/doc/README.NetBSD
index 802e64573..3dedb18df 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.NetBSD
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.NetBSD
@@ -1,8 +1,8 @@
- README for XFree86 4.0 on NetBSD
+ README for XFree86 4.0.1 on NetBSD
Rich Murphey, David Dawes, Marc Wandschneider, Mark Weaver, Matthieu Herrb
- Last modified on: 20 February 2000
+ Last modified on: 1 July 2000
1. What and Where is XFree86?
@@ -15,10 +15,10 @@ See the Copyright Notice.
The sources for XFree86 are available by anonymous ftp from:
-ftp://ftp.XFree86.org/pub/XFree86/4.0
+ftp://ftp.XFree86.org/pub/XFree86/4.0.1
Binaries for NetBSD 1.3 and later are available from:
-ftp://ftp.XFree86.org/pub/XFree86/4.0/binaries/NetBSD
+ftp://ftp.XFree86.org/pub/XFree86/4.0.1/binaries/NetBSD
A list of mirror sites is provided by ftp://ftp.XFree86.org/pub/XFree86/MIR-
RORS
@@ -35,18 +35,24 @@ if you have comments or suggestions about this file and we'll revise it.
3. New OS dependent features
-See the Release Notes for non-OS dependent new features in XFree86 4.0.
+See the Release Notes for non-OS dependent new features in XFree86 4.0.1.
-3.1 New OS dependent features in 4.0
+3.1 New OS dependent features in 4.0.1
+
+ o Support for NetBSD 1.5_ALPHA
+
+ o The Xsun server can be built on NetBSD/sparc
+
+3.2 New OS dependent features in 4.0
o Preliminary APM support.
-3.2 New OS dependent features in 3.9.18
+3.3 New OS dependent features in 3.9.18
o Soft-booting secondary cards through the int10 BIOS interface is now
possible using the x86emu real mode emulator.
-3.3 New OS dependent features in 3.9.17
+3.4 New OS dependent features in 3.9.17
o Support for silken mouse with the wsmouse protocol has been added.
@@ -87,10 +93,10 @@ Only standard PS/2 mice are supported by this driver. Newest PS/2 mice that
send more than three bytes at a time (especially Intellimouse, or MouseMan+
with a ``3D'' roller) are not supported yet.
-XFree86 4.0 also has support for the mouse driver included in the new wscons
-console driver introduced by NetBSD 1.4. Specify ``wsmouse'' as the protocol
-and ``/dev/wsmouse0'' as the device in /etc/XF86Config if you're using NetBSD
-1.4 with wscons.
+XFree86 4.0.1 also has support for the mouse driver included in the new
+wscons console driver introduced by NetBSD 1.4. Specify ``wsmouse'' as the
+protocol and ``/dev/wsmouse0'' as the device in /etc/XF86Config if you're
+using NetBSD 1.4 with wscons.
See README.mouse for general instruction on mouse configuration in XFree86.
@@ -194,14 +200,14 @@ By default NetBSD include the BSD 4.4 kernel security feature that disable
access to the /dev/mem device when in multi-users mode. But XFree86 servers
can take advantage (or require) linear access to the display memory.
-Most XFree86 4.0 card drivers require linear memory access. There are two
+Most XFree86 4.0.1 card drivers require linear memory access. There are two
ways to allow XFree86 to access linear memory:
The first way is to disable the kernel security feature by adding ``option
INSECURE'' in the kernel configuration file and build a new kernel.
The second way is to install the aperture driver, included in source form in
-xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar in the XFree86 4.0 source
+xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar in the XFree86 4.0.1 source
distribution. Unpack it in a new directory of your choice by running:
sh apNetBSD.shar
@@ -318,7 +324,7 @@ Many thanks to all people who contributed to make XFree86 work on *BSD, in
particular, David Dawes, Pace Willison, Amancio Hasty, Christoph Robitschko,
Nate Williams, Rod Grimes, Jack Velte and Michael Smith.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.55 2000/03/03 21:28:09 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.56 2000/07/02 02:35:27 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.NetBSD,v 3.68 2000/03/04 00:51:30 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.NetBSD,v 3.70 2000/07/02 02:46:27 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD b/xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD
index 728907d23..1e89a7e40 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD
@@ -1,8 +1,8 @@
- README for XFree86 4.0 on OpenBSD
+ README for XFree86 4.0.1 on OpenBSD
Matthieu Herrb
- Last modified on: 20 February 2000
+ Last modified on: 1 July 2000
1. What and Where is XFree86?
@@ -13,13 +13,13 @@ ments as well as many bug fixes.
See the Copyright Notice.
-The sources for XFree86 4.0 are available by anonymous ftp from:
+The sources for XFree86 4.0.1 are available by anonymous ftp from:
-ftp://ftp.XFree86.org/pub/XFree86/4.0
+ftp://ftp.XFree86.org/pub/XFree86/4.0.1
Binaries for OpenBSD/i386 2.6 and later are available from:
-ftp://ftp.XFree86.org/pub/XFree86/4.0/binaries/OpenBSD
+ftp://ftp.XFree86.org/pub/XFree86/4.0.1/binaries/OpenBSD
A list of mirror sites is provided by ftp://ftp.XFree86.org/pub/XFree86/MIR-
RORS
@@ -34,23 +34,42 @@ if you have comments or suggestions about this file and we'll revise it.
3. New OS dependent features
-See the Release Notes for non-OS dependent new features in XFree86 4.0.
+See the Release Notes for non-OS dependent new features in XFree86 4.0.1.
-3.1 New OS dependent features in 4.0
+3.1 New OS dependent features in 4.0.1
+
+ o Several features from the OpenBSD X11 tree were merged into xdm:
+
+ o support for Kerberos IV authentication
+
+ o use the arc4random(4) random number generator
+
+ o add a new resource "allowRootLogin", which can be used to disable
+ root logins through xdm
+
+ o log failed logins to syslogd
+
+ o verify that the shell is valid using /etc/shell
+
+ o verify that the account hasn't expired
+
+ o The Xsun server can be built again on OpenBSD/sparc.
+
+3.2 New OS dependent features in 4.0
o Multi-thread safe libraries are built by default on OpenBSD 2.6 and
later,
o Preliminary APM support.
-3.2 New OS dependent features in 3.9.18
+3.3 New OS dependent features in 3.9.18
o Support for USB mices has been added on OpenBSD.
o Soft-booting secondary cards through the int10 BIOS interface is now
possible using the x86emu real mode emulator.
-3.3 New OS dependent features in 3.9.17
+3.4 New OS dependent features in 3.9.17
o Silken mouse is supported for serial mices, and, under post 2.6 OpenBSD-
current for PS/2 mices.
@@ -229,7 +248,7 @@ Many thanks to all people who contributed to make XFree86 work on *BSD, in
particular, David Dawes, Pace Willison, Amancio Hasty, Christoph Robitschko,
Nate Williams, Rod Grimes, Jack Velte and Michael Smith.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.10 2000/03/03 21:28:10 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.11 2000/07/02 02:35:27 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD,v 1.11 2000/03/04 00:51:31 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.OpenBSD,v 1.13 2000/07/02 02:46:27 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.SiS b/xc/programs/Xserver/hw/xfree86/doc/README.SiS
index 1a0e3e210..17cd1ad79 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.SiS
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.SiS
@@ -113,4 +113,4 @@ Document based on 3.3 version written by Xavier Ducoin.
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/SiS.sgml,v 3.7 2000/03/06 22:59:24 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.SiS,v 3.14 2000/03/07 14:55:06 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.SiS,v 3.15 2000/06/17 17:44:21 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.apm b/xc/programs/Xserver/hw/xfree86/doc/README.apm
index 88e2f1ed4..99d9b03c3 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.apm
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.apm
@@ -111,4 +111,4 @@ be possible to add support for the 3210 chipset if someone needs it.
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/apm.sgml,v 1.3 2000/03/08 05:38:43 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.apm,v 1.6 2000/03/08 20:39:22 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.apm,v 1.7 2000/06/17 17:44:21 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.ati b/xc/programs/Xserver/hw/xfree86/doc/README.ati
index f7ee2cc3c..ec2c247a7 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.ati
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.ati
@@ -2,7 +2,7 @@
Marc Aurele La France
- 1999 October 25
+ 2000 June 15
Abstract
@@ -31,9 +31,9 @@ The driver will provide
o generic VGA support if a non-ATI VGA-capable adapter is detected and the
user has requested such support.
-Thus, the support provided not only depends on what the driver detects in the
-system, but also, on what the user specifies in the XF86Config file. See the
-``XF86Config specifications'' section below for details.
+Thus, the level of support provided not only depends on what the driver
+detects in the system, but also, on what the user specifies in the XF86Config
+file. See the ``XF86Config specifications'' section below for details.
If none of the above conditions are met, the ATI driver will essentially dis-
able itself to allow other drivers to examine the system.
@@ -75,13 +75,14 @@ sent:
264CT, 264ET, 264VT, 264GT (3D Rage), 264VT-B, 264VT3,
264VT4, 264GT-B (3D Rage II), 3D Rage IIc, 3D Rage Pro,
3D Rage LT, 3D Rage LT Pro, 3D Rage XL, 3D Rage XC,
- 3D Rage Mobility
+ 3D Rage Mobility (including the -M and -P variants)
The driver also supports 32K, 64K and 16M-colour modes on the 264xT and 3D
Rage series of adapters using the accelerator CRTC (but not the VGA CRTC).
-This support is as yet unaccelerated.
-The newer Rage 128 chips are not yet supported.
+The newer Rage 128 chips are not yet supported by this driver. Rage 128's
+are, however, supported by a separate driver, and Rage 128 owners should read
+the r128 driver's documentation for details.
Adapters based on the above chips have been marketed under a rather large
number of names over the years. Among them are:
@@ -105,6 +106,9 @@ number of names over the years. Among them are:
XPERT@Play 98, XPERT@Work, XPERT 98, XPERT LCD,
XPERT XL
+Also, a number of mainboards, laptops and notebooks harbour a Mach32 or
+Mach64 controller.
+
VGAWonder, Mach8 and Mach32 ISA adapters are available with or without a
mouse.
@@ -112,13 +116,14 @@ These adapters are available with a variety of clock generators and RAMDACs.
The 264xT and 3D Rage series of chips are integrated controllers, meaning
that they include a programmable clock generator and a RAMDAC.
-This driver still does not provide support for accelerated drawing to the
-screen. This means that all drawing is done by the CPU, rather than by any
-accelerator present in the system. This can make opaque moves, for example,
-quite ``jerky''. Also, given that IBM 8514/A and ATI Mach8 do not allow CPU
-access to their frame buffer, the driver will currently ignore these acceler-
-ators. Most Mach32 adapters provide both accelerated function and VGA func-
-tionality, but the driver currently only uses the VGA.
+For all but Mach64 adapters, this driver still does not provide support for
+accelerated drawing to the screen. This means that all drawing is done by
+the CPU, rather than by any accelerator present in the system. This can make
+opaque moves, for example, quite ``jerky''. Also, given that IBM 8514/A and
+ATI Mach8 do not allow CPU access to their frame buffer, the driver will cur-
+rently ignore these accelerators. Most Mach32 adapters provide both acceler-
+ated function and SuperVGA functionality, but the driver currently only uses
+the VGA.
The driver does however support the accelerator CRTC present in all ATI
Mach64 adapters. For 256-colour, and higher depth modes, this support will
@@ -126,9 +131,13 @@ be used by default, although an XF86Config option can be specified to use the
SuperVGA CRTC instead. A linear video memory aperture is also available in
256-colour and higher depth modes and enabled by default if a 264xT or 3D
Rage controller is detected or, on 88800 controllers, if the accelerator CRTC
-is used. An XF86Config option is available to disable this aperture, or (on
+is used. XF86Config options are available to disable this aperture, or (for
non-PCI adapters) enable it or move it to some other address.
+By default, the driver provides some acceleration for Mach64 if the accelera-
+tor CRTC is used. This support is as yet incomplete and can be disabled
+entirely with an XF86Config option.
+
4. Current implementation of generic VGA support for non-ATI adapters
Support for generic VGA with non-ATI adapters is also implemented, but has
@@ -155,9 +164,11 @@ VGA implementation:
o Interlaced modes are not available.
+ o Colour depths higher than 8 are not available.
+
5. XF86Config specifications
-The driver recognizes a number of XF86Config options. In general, all such
+The driver recognises a number of XF86Config options. In general, all such
options should be specified in a ``Device'' section, and affect only that
``Device'' section.
@@ -175,7 +186,7 @@ to the ``Device'' section which contains them.
5.1 Driver ``ati''
The use of this specification is highly recommended if the ``Device'' section
-is to be recognized by the driver. In fact, it is almost (but not quite)
+is to be recognised by the driver. In fact, it is almost (but not quite)
mandatory, particularly when using the loader server as it indicates what
driver is to be loaded and associated with the ``Device'' section.
@@ -188,7 +199,8 @@ to drive the screen. Otherwise, the driver will programme the adapter's
SuperVGA CRTC.
If ``ativga'' is specified instead, the driver will ignore any ATI accelera-
-tor it detects, but otherwise operate as if ``ati'' had been specified.
+tor it detects, but otherwise operate as if ``ati'' had been specified. This
+specification ensures the VGA CRTC is used.
A ChipSet name of ``ibmvga'' causes any VGA-capable adapter in the system to
be associated with the ``Device'' section. It enables the driver's generic
@@ -215,21 +227,24 @@ are otherwise equivalent to ``ati''.
These specifications will cause the driver to associate the ``Device'' sec-
tion only with an adapter having the same attributes, or an adapter whose PCI
-device ID the driver does not recognize. In the second case, these options
+device ID the driver does not recognise. In the second case, these options
cause the driver to treat the adapter as if it was one with the specified PCI
device ID or revision. ChipID can only be used with Mach32 or Mach64
-adapters. ChipRev is meaningful only with Mach64 adapters.
+adapters, and, thus, specifically excludes any other adapter from matching
+the ``Device'' section. ChipRev is meaningful only with Mach64 adapters, and
+then only if ChipID is also specified in the same ``Device'' section.
5.4 IOBase
This option limits the adapters that can be associated with the ``Device''
-section to those with the specified I/O base. This option only applies to
-Mach64 adapters.
+section to the one with the specified I/O base. This option only applies to
+Mach64 adapters and specifically excludes other adapters.
5.5 BusID
This option limits the adapters that can be associated with the ``Device''
-section to those with the specified PCI Bus ID.
+section to the one with the specified PCI Bus ID. This specification
+excludes non-PCI adapters.
5.6 Clocks
@@ -254,7 +269,7 @@ clock probe with the command ``X -probeonly''.
5.6.1 Clocks for supported programmable clock generators
-At bootup, video BIOS initialization programmes an initial set of frequen-
+At bootup, video BIOS initialisation programmes an initial set of frequen-
cies. Two of these are reserved to allow the setting of modes that do not
use a frequency from this initial set. One of these reserved slots is used
by the BIOS mode set routine, the other by the particular driver used (e.g.
@@ -273,7 +288,7 @@ ness.
In this situation, the driver will probe the adapter for clock frequencies
unless XF86Config clocks are already specified. In either case, the driver
-will then attempt to normalize the clocks to one of the following specifica-
+will then attempt to normalise the clocks to one of the following specifica-
tions:
BIOS setting 1:
@@ -374,26 +389,35 @@ ous XFree86 accelerated servers.
5.6.4 Clocks for non-ATI adapters
If no clocks are specified in the XF86Config, the driver will probe for four
-clocks, the second of which will be assumed to be 28.322MHz. You can include
-up to four clock frequencies in your XF86Config to specify the actual values
-used by the adapter. Any more will be ignored.
+clocks, the second of which will be assumed to be 28.322 MHz. The first
+clock will typically be 25.175 MHz, but there are exceptions. You can
+include up to four clock frequencies in your XF86Config to specify the actual
+values used by the adapter. Any more will be ignored.
5.7 Option ``crt_screen''
This specification is only effective when the driver detects that the
-adapter's BIOS has initialized both the digital flat panel and CRT inter-
+adapter's BIOS has initialised both the digital flat panel and CRT inter-
faces. In such a situation, the driver will normally drive the panel and
disable the CRT. This specification causes the driver to disable the digital
-flat panel and display the screen image on the CRT instead.
+flat panel and display the screen image on the CRT instead. This specifica-
+tion will be reworked in the near future.
+
+5.8 Option ``noaccel''
-5.8 Option ``nolinear''
+By default, the driver will accelerate draw operations if a Mach64 CRTC is
+used to drive the display. As implemented in this driver, acceleration does
+not require a linear video memory aperture. This option disables this accel-
+eration.
+
+5.9 Option ``nolinear''
By default, the driver will enable a linear video memory aperture for
256-colour and higher depth modes if it is also using a Mach64 accelerator
CRTC or an integrated Mach64 graphics chip. This option disables this linear
aperture.
-5.9 Option ``shadowfb''
+5.10 Option ``shadowfb''
If this option is enabled, the driver will cause the CPU to do each drawing
operation first into a shadow frame buffer in system virtual memory and then
@@ -406,11 +430,22 @@ default. For other bus types, the default behaviour is to disable this
option.
Note that, due to various limitations, this option is forcibly disabled when
-a linear video memory aperture is not enabled, or when the frame buffer depth
-is less than 8. The use of video acceleration, when implemented in a future
-driver release, will also disable frame buffer shadowing.
+a linear video memory aperture is not enabled, when the frame buffer depth is
+less than 8, or when acceleration is used.
+
+5.11 Option ``dpms''
+
+This option enables the driver's support for VESA's Display Power Management
+Specification.
-5.10 MemBase address
+5.12 Option ``backingstore''
+
+This is not specifically a driver option. It is used to enable the server's
+support for backing store, a mechanism by which pixel data for occluded win-
+dow regions is remembered by the server thereby alleviating the need to send
+expose events to X clients when the data needs to be redisplayed.
+
+5.13 MemBase address
This specification is only effective for non-PCI Mach64 adapters, and is used
to override the CPU address at which the adapter will map its video memory.
@@ -419,12 +454,36 @@ provided with the adapter. The MemBase option can also be used to enable the
linear aperture in those cases where ATI's utility was not, or can not be,
used.
-For PCI adapters, this address is determined at system bootup according to
-the PCI Plug'n'Play specification which arbitrates the resource requirements
-of most devices in the system. This means the driver can not easily change
-the linear aperture address.
-
-6. Known problems and limitations
+For PCI and AGP adapters, this address is determined at system bootup accord-
+ing to the PCI Plug'n'Play specification which arbitrates the resource
+requirements of most devices in the system. This means the driver can not
+easily change the linear aperture address.
+
+6. Video modes
+
+Mode timings can be derived from the information in XFree86's doc subdirec-
+tory. However, it is no longer required to specify such timings in an
+XF86Config's ``Monitor'' section(s), if only standard mode timings are to be
+used. The server automatically inserts VESA standard mode timings in every
+``Monitor'' section, and these modes will be checked first for mode con-
+straints (monitor sync tolerances, video memory size, etc.).
+
+Furthermore, it is also no longer required to specify mode names in ``Dis-
+play'' subsections. Should no mode names be specified (or those specified do
+not yield a usable mode), the server will automatically select as a default
+resolution the largest usable mode, whether or not the chosen mode is speci-
+fied in the corresponding ``Monitor'' section.
+
+For a CRT monitor, you should still specify horizontal sync and vertical
+refresh rates in the corresponding ``Monitor'' section. Otherwise, the
+server will default these to those of a VGA monitor, which will limit resolu-
+tions to not much more than 640x480 at 72 Hz. For a digital flat panel, any
+sync tolerances should be removed from the corresponding ``Monitor'' section.
+The driver will automatically calculate these from the mode that is active on
+server entry. The driver also inserts timings for a mode called "Native
+panel mode" that represents the panel's native resolution.
+
+7. Known problems and limitations
There are several known problems or limitations related to the XFree86 ATI
driver. They include:
@@ -432,15 +491,15 @@ driver. They include:
o A number of system lockups and blank screens have been reported when
using PCI Mach64 adapters. The great majority of these problems have
been found to be due to system aspects that are unrelated to this
- driver. As of this writing, these problems can be divided into three
- general areas:
+ driver. As of this writing, these problems can be divided into two gen-
+ eral areas:
Improper mouse protocol specification with some recent mice. Try dif-
ferent protocol specifications or another mouse.
A system conflict with APM. This problem is Linux-specific. There is a
bug in kernels 2.0.31 or earlier that prevents proper APM operation.
- Upgrade to a more recent kernel or disable APM support.
+ Upgrade to a more recent kernel or disable APM support in the kernel.
o When using a Mach64's accelerator CRTC, the virtual resolution must be
less than 8192 pixels wide. The VGA CRTC further limits the virtual
@@ -495,21 +554,30 @@ driver. They include:
Support for the following will be added in a future release:
- o Mach32 accelerator's CRTC. This support is the first step towards
+ o Mach32's accelerator CRTC. This support is the first step towards
accelerated support for Mach32's, Mach8's, 8514/A's and other clones.
- o Colour depth greater than 8, where permitted by the hardware.
+ o Colour depth greater than 8 on non-integrated controllers, where permit-
+ ted by the hardware.
- o Mach64, Mach32, Mach8 and 8514/A Draw Engines.
+ o Mach32, Mach8 and 8514/A Draw Engines.
o Hardware cursors.
-7. Reporting problems
+ o TVOut, i.e. the ability to use a television screen as a monitor.
+
+ o Motion Video, i.e. displaying an asynchronous data stream (TV signal,
+ DVD, etc.) in a window or full-screen.
+
+ o 3D operations.
+
+8. Reporting problems
If you are experiencing problems that are not already recorded in this docu-
ment, first ensure that you have the latest current release of this driver
-and XFree86. Check the server's stderr output and
-ftp://ftp.xfree86.org/pub/XFree86 if you are uncertain.
+and XFree86. Check the server's log (usually found in
+/var/log/XFree86.0.log) and ftp://ftp.xfree86.org/pub/XFree86 if you are
+uncertain.
Secondly, please check XFree86's doc directory for additional information.
@@ -519,12 +587,12 @@ Fourth, a scan through the comp.windows.x.i386unix and comp.os.linux.x news-
groups using your favourite archiving service can also prove useful in
resolving problems.
-If you are still experiencing problems, you can send me e-mail at <tsi@ual-
-berta.ca>. Please be as specific as possible when describing the problem(s),
-and include an unedited copy of the server's stderr and the XF86Config file
-used.
+If you are still experiencing problems, you can send me non-HTMLised e-mail
+at <tsi@ualberta.ca>. Please be as specific as possible when describing the
+problem(s), and include an unedited copy of the server's log and the XF86Con-
+fig file used.
-8. Driver history
+9. Driver history
The complete history of the driver is rather cloudy. The following is more
than likely to be incomplete and inaccurate.
@@ -538,24 +606,24 @@ Then Doug Evans (dje@cygnus.com) added support for the ATI VGA Wonder XL,
trying in the process to make the driver work with all other ATI adapters
available at the time.
-Rik Faith (faith@cs.unc.edu) obtained the X11R4 driver from Doug Evans in the
-summer of 1992 and ported the code to the X386 part of X11R5. This subse-
-quently became part of XFree86.
+Rik Faith (faith@precisioninsight.com) obtained the X11R4 driver from Doug
+Evans in the summer of 1992 and ported the code to the X386 part of X11R5.
+This subsequently became part of XFree86.
I (Marc Aurele La France) took over development and maintenance of the driver
in the fall of 1993 after Rik got rid of his VGA Wonder adapter.
-9. Driver versions
+10. Driver versions
Due to the introduction of loadable drivers in XFree86 4.0, it has become
-necessary to track driver versions separately. With this release of the
-driver, I am introducing the following version numbering scheme.
+necessary to track driver versions separately. Driver releases use the fol-
+lowing version numbering scheme.
Version 1 of this driver is the one I inherited from Rik Faith. This is the
version found in XFree86 2.0 and 2.1.
Version 2 is my first rewrite of this code which only ended up being a par-
-tially unsuccessful attempt at generalizing the driver for all VGA Wonder,
+tially unsuccessful attempt at generalising the driver for all VGA Wonder,
Mach32, and early Mach64 adapters. Various releases of this version of the
driver can be found in XFree86 2.1.1, 3.1, 3.1.1 and 3.1.2.
@@ -565,15 +633,13 @@ adapters and merged in the old ati_test debugging tool. This is the version
found in XFree86 3.2, 3.3 and 3.3.1.
Version 4 is a rather major restructuring of version 3, which became larger
-than I could comfortably handle in one source file. This version will make
-it quite a bit easier to introduce new function such as acceleration, addi-
-tional colour depths, and so on. This is the version found in XFree86 3.3.2,
-3.3.3, 3.3.3.1, 3.3.3.2 and 3.3.4.
+than I could comfortably handle in one source file. This is the version
+found in XFree86 3.3.2, 3.3.3, 3.3.3.1, 3.3.3.2, 3.3.4, 3.3.5 and 3.3.6.
-Version 5 is an almost complete restructuring of version 4 to fit in the new
-driver API of XFree86 4.0.
+Version 5 is an almost complete restructuring of version 4 to fit in the
+newer driver API of XFree86 4.0 and later.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.29 2000/02/18 12:19:08 tsi Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.31 2000/06/19 15:00:54 tsi Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.ati,v 3.46 2000/03/01 01:48:20 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.ati,v 3.49 2000/06/19 15:12:28 tsi Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.chips b/xc/programs/Xserver/hw/xfree86/doc/README.chips
index d1bded81c..6a752a173 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.chips
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.chips
@@ -3,11 +3,11 @@
David Bateman (<dbateman@club-internet.fr>),
Egbert Eich (<eich@xfree86.org>)
- 19th July 1999
+ 14th June 2000
1. Introduction
-With the release of XFree86 version 4.0, the Chips and Technologies driver
+With the release of XFree86 version 4.0.1, the Chips and Technologies driver
has been extensively rewritten and contains many new features. This driver
must be considered work in progress, and those users wanting stability are
encouraged to use the older XFree86 3.3.x versions. However this version of
@@ -25,6 +25,8 @@ might make users prefer to use this version. These features include
o Supports PsuedoColor overlays on 16bpp TrueColor screens for HiQV.
+ o Supports YUV colour space conversion with the XVideo extension.
+
o 32bpp pixmaps while using a framebuffer in 24bpp packed pixel mode.
o Heaps more acceleration.
@@ -112,10 +114,10 @@ architecture.
ct65550
This chip includes many new features, including improved BitBLT
- support (24bpp color expansion, wider maximum pitch, etc), Multi-
- media unit (video capture, zoom video port, etc) and 24bpp uncom-
- pressed true color (i.e 32bpp mode). Also memory mapped I/O is
- possible on all bus configurations. (Max Ram: 2Mb, Max Dclk:
+ support (24bpp colour expansion, wider maximum pitch, etc), Mul-
+ timedia unit (video capture, zoom video port, etc) and 24bpp
+ uncompressed true colour (i.e 32bpp mode). Also memory mapped I/O
+ is possible on all bus configurations. (Max Ram: 2Mb, Max Dclk:
80MHz@3.3V,100MHz@5V)
ct65554
@@ -381,15 +383,24 @@ Screen, Monitor, Device.
engine to its limit, and some manufacturers have set a default
memory clock that will cause pixel errors with this option. If
you get pixel error with this option try using the "SetMClk"
- option to slow the memory clock.
+ option to slow the memory clock. It should also be noted that the
+ XVideo extension uses the same capabilities of the HiQV chipsets
+ as the Overlays. So using this option disables the XVideo exten-
+ sion.
Option "ColorKey" "255"
- Normally the color transparency key for the overlay is the 8bpp
+ Normally the colour transparency key for the overlay is the 8bpp
lookup table entry 255. This might cause troubles with some
- applications, and so this option allows the color transparency
+ applications, and so this option allows the colour transparency
key to be set to some other value. Legal values are 2 to 255
inclusive.
+ Option "VideoKey" "255"
+ This sets the default pixel value for the YUV video overlay key.
+ Legal values for this key are depth dependent. That is from 0 to
+ 255 for 8bit depth, 0 to 32,767 for 15bit depth, etc. This option
+ might be used if the default video overlay key causes problems.
+
Option "XaaNoScreenToScreenCopy",
Option "XaaNoSolidFillRect", Option "XaaNoSolidHorVertLine",
Option "XaaNoMono8x8PatternFillRect", Option "XaaNoColor8x8Pat-
@@ -458,6 +469,12 @@ you'll needed to considered several points
width, so that the maximum dotclock will be similar to a 24bpp
mode.
+ * XVideo extension*
+ Like the overlays, the Xvideo extension uses a part of the video
+ memory for a second framebuffer. In this case enough memory needs
+ to be left for the largest unscaled video window that will be
+ displayed.
+
* VESA like modes
We recommend that you try and pick a mode that is similar to a
standard VESA mode. If you don't a suspend/resume or LCD/CRT
@@ -772,6 +789,12 @@ cause damage.
option. So with the "Overlay" option, using the "SetMClk" option
to reduce the speed of the memory clock is recommended.
+ The mpeg video playing with the XVideo extension has corrupted colours
+ The XVideo extension has only recently been added to the chips
+ driver. Some YUV to RGB colour have been noted at 15 and 16 bit
+ colour depths. However, 8 and 24 bit colour depths seem to work
+ fine.
+
I can't start X-windows with 16, 24 or 32bpp
Firstly, is your machine capable of 16/24/32bpp with the mode
specified. Many LCD displays are incapable of using a 24bpp mode.
@@ -788,7 +811,7 @@ cause damage.
startx -- -depth 24 -fbbpp 32 8-8-8 RGB truecolor
- however as XFree86 version 4.0 allows 32bpp pixmaps to be used
+ however as XFree86 version 4.0.1 allows 32bpp pixmaps to be used
with framebuffers operating in 24bpp, this mode of operating will
cost performance for no gain in functionality.
@@ -858,7 +881,7 @@ Contributors (In no particular order)
We also thank the many people on the net who have contributed by reporting
bugs and extensively testing this server.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.30 2000/03/05 16:59:11 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.31 2000/06/14 01:43:49 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.chips,v 3.30 2000/03/07 14:55:07 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.chips,v 3.32 2000/06/17 17:44:21 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.cyrix b/xc/programs/Xserver/hw/xfree86/doc/README.cyrix
index 76c583475..92bd56365 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.cyrix
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.cyrix
@@ -50,4 +50,4 @@ lowing Cyrix CPUs with integrated graphics:
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/cyrix.sgml,v 1.3 2000/03/08 05:38:43 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.cyrix,v 1.6 2000/03/08 20:39:23 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.cyrix,v 1.7 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.fonts b/xc/programs/Xserver/hw/xfree86/doc/README.fonts
index aac021b95..b7a4bf3f5 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.fonts
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.fonts
@@ -772,4 +772,4 @@ only provides support for horizontal writing.
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/fonts.sgml,v 1.7 2000/03/06 22:59:25 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.fonts,v 1.9 2000/03/07 14:55:08 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.fonts,v 1.10 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.i740 b/xc/programs/Xserver/hw/xfree86/doc/README.i740
index bbdafe1db..c422029e3 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.i740
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.i740
@@ -178,4 +178,4 @@ http://www.precisioninsight.com
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/i740.sgml,v 1.3 2000/03/04 00:26:30 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i740,v 1.6 2000/03/04 00:51:32 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i740,v 1.7 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.i810 b/xc/programs/Xserver/hw/xfree86/doc/README.i810
index 05b5759a8..b02c18bf9 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.i810
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.i810
@@ -107,4 +107,4 @@ http://www.precisioninsight.com
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/i810.sgml,v 1.2 2000/03/04 00:00:30 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i810,v 1.3 2000/03/04 00:51:32 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.i810,v 1.4 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.isc b/xc/programs/Xserver/hw/xfree86/doc/README.isc
index 43c6ff8a7..857379cda 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.isc
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.isc
@@ -489,4 +489,4 @@ tribute to this excellent piece of free software.
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/isc.sgml,v 3.24 2000/03/06 22:59:25 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.isc,v 3.37 2000/03/07 14:55:09 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.isc,v 3.38 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.mouse b/xc/programs/Xserver/hw/xfree86/doc/README.mouse
index 9f2678dd7..e491d69ec 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.mouse
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.mouse
@@ -6,7 +6,7 @@
1. Introduction
-This document describes mouse support in XFree86 4.0.
+This document describes mouse support in XFree86 4.0.1.
Mouse configuration has often been mysterious task for novice users. How-
ever, once you learn several basics, it is straightforward to write the mouse
@@ -928,4 +928,4 @@ wheel's movement will be reported as the buttons 6 and 7.
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/mouse.sgml,v 1.11 2000/03/01 00:25:23 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.mouse,v 1.9 2000/03/01 01:48:26 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.mouse,v 1.10 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.r128 b/xc/programs/Xserver/hw/xfree86/doc/README.r128
index ff7f6a56d..b8534be6b 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.r128
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.r128
@@ -2,7 +2,7 @@
Precision Insight, Inc., SuSE GmbH
- 12 November 1999
+ 13 June 2000
1. Supported Hardware
@@ -74,7 +74,7 @@ However, if you have problems with auto-detection, you can specify:
7. Known Limitations
- o DGA is not supported yet
+ o None
8. Authors
@@ -116,7 +116,7 @@ http://www.precisioninsight.com
http://www.suse.com
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml,v 1.7 2000/03/08 15:14:48 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml,v 1.8 2000/06/14 00:16:09 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.r128,v 1.10 2000/03/08 20:39:23 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.r128,v 1.12 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.rendition b/xc/programs/Xserver/hw/xfree86/doc/README.rendition
index 71411f8ba..62f0aff0f 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.rendition
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.rendition
@@ -1,8 +1,8 @@
- Information for Rendition Users
+ Information for Rendition (Micron) Verité Users
The XFree86 Project Inc.
- 12 December 1999
+ 9 June 2000, last update by Dejan Ilic <dejan.ilic@home.se>
1. Supported hardware
@@ -35,6 +35,11 @@ itations on V2x00 chipsets.
If you have problems with hardware cursor use the "sw_cursor" option to
revert back to software cursor.
+This is essentially a port of XFree86 3.3.x driver to the new XFree86 4.0
+API, and thus we have put most of effort in making a working driver with the
+most basic features. Support for multi-head support and acceleration are next
+on the list of features to be included.
+
4. Features
o Hardware acceleration
@@ -54,10 +59,10 @@ revert back to software cursor.
5. XF86Config Option
- Option "sw_cursor"
+ Option "SW_Cursor"
Disables use of the hardware cursor.
- Option "overclock_mem"
+ Option "Overclock_Mem"
Run the memory at a higher clock. Useful on some cards with dis-
play glitches at higher resolutions. But adds the risk to damage
the hardware. Use with caution.
@@ -70,8 +75,8 @@ revert back to software cursor.
Option "FramebufferWC"
If writecombine is disabled in BIOS, and you add this option in
- in configuration file, then the driver will try to request write-
- combined access to the framebuffer. This can drastically increase
+ configuration file, then the driver will try to request writecom-
+ bined access to the framebuffer. This can drastically increase
the performance on unaccelerated server. Requires that
"MTRR"-support is compiled into the OS-kernel.
@@ -101,19 +106,19 @@ revert back to software cursor.
"ShadowFB" and automatically enable it. It also disables the
acceleration. The option is not activated by default.
-6. News in this release
+6. News in this release (XFree86 4.1)
- o Acceleration! Disabled for the moment.
+ o DirectColor support
-7. Major changes in this release
+ o SilkenMouse support
- o ShadowFB support added
+7. Major changes in this release
- o To be determined before final release.
+ o Gamma works now for >8bpp
8. Bugfixes
- o 8bpp finally works correctly again
+ o Only some code cleanup done. No real bugfixes.
9. Known problems in current driver
@@ -129,13 +134,15 @@ revert back to software cursor.
around. V2x00 does not exhibit this problem. Probably a bug in the
driver rather than a limitation of the chip.
+ o Depth 15 & 16 has problems with colors when DirectColor is used.
+
10. Work in progress (not finished in time for release)
o Acceleration is disabled for the moment. If you want to play with it
enable the "USE_ACCEL" define in rendition.c file! Beware as it has sev-
eral bugs left to clear out before if is stable for general use.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml,v 1.8 2000/03/01 23:54:34 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml,v 1.12 2000/06/17 02:30:33 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.rendition,v 1.9 2000/03/04 00:51:33 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.rendition,v 1.11 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/README.s3virge b/xc/programs/Xserver/hw/xfree86/doc/README.s3virge
index 86449d4d8..07a1a4c50 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/README.s3virge
+++ b/xc/programs/Xserver/hw/xfree86/doc/README.s3virge
@@ -6,7 +6,7 @@
1. Supported hardware
-The s3virge driver in XFree86 4.0 supports the S3 ViRGE, ViRGE DX, GX, MX,
+The s3virge driver in XFree86 4.0.1 supports the S3 ViRGE, ViRGE DX, GX, MX,
MX+, and VX chipsets. A majority of testing is done on ViRGE DX chips, mak-
ing them the most stable to date. This release has improved support for 24
bit color depths and resolves all the known issues with Netscape and other
@@ -62,4 +62,4 @@ tact our support email address <XFree86@Xfree86.org>
Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/s3virge.sgml,v 1.2 1999/07/10 12:17:25 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.s3virge,v 1.4 2000/03/01 01:48:27 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/README.s3virge,v 1.5 2000/06/17 17:44:22 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/RELNOTES b/xc/programs/Xserver/hw/xfree86/doc/RELNOTES
index 1d5fc91a6..137f1c498 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/RELNOTES
+++ b/xc/programs/Xserver/hw/xfree86/doc/RELNOTES
@@ -1,79 +1,196 @@
- Release Notes for XFree86[tm] 4.0
+ Release Notes for XFree86[tm] 4.0.1
The XFree86 Project, Inc
- 7 March 2000
+ 30 June 2000
Abstract
This document contains some information about the features present
- in XFree86 4.0 and their status.
-
-1. Introduction
-
-XFree86 4.0 is the first official release of the new XFree86 4. XFree86 4
-represents a significant redesign of the XFree86 X server. It is very impor-
-tant to keep in mind that XFree86 4 is still very much in development, and it
-contains a lot of new work. That means two things: there is a lot of new
-exciting stuff to try, but being new code, it hasn't had nearly as much of a
-workout as the stable 3.3.x releases. If you're looking for a well-tested,
-stable release, and can't afford the inconveniences that new software can
-sometimes cause, then you are probably better off sticking with the 3.3.x
-releases for now. If you have the resources to try out the new version and
-investigate its features, or if you just like being on the bleeding edge,
-then please try 4.0!
-
-This release isn't quite as complete as we would have liked. The main miss-
-ing pieces are a nice configuration tool and support for some of the hardware
-that 3.3.x supports. The first point means that configuring the server might
-be more painful than usual. The second means that your hardware might not be
-supported by 4.0, or it might be supported at a lesser level (conversely,
-some hardware is better supported in 4.0). We've attempted to provide some
-information about the second point in our Driver Status document. Please
-check there first before trying 4.0. Unfortunately that document is still
-fairly basic, but it should at least give you an idea of whether you're
-likely to be able to use 4.0 at all or not.
+ in XFree86 4.0.1 and their status.
+
+1. Introduction to the 4.x Release Series
+
+XFree86 4.0 was the first official release of the new XFree86 4. XFree86 4
+represents a significant redesign of the XFree86 X server. Not all of the
+hardware drivers from 3.3.x have been ported to 4.x yet.
+
+1.1 Differences Between the 4.x series and the 3.3 series
+
+The 4.x release series is also missing a nice configuration tool. This means
+that configuring the Xserver might be trickier than usual. The second point
+is that is that your hardware might not be supported by 4.0.1, or it might be
+supported at a lesser level (conversely, some hardware is better supported in
+4.0.1). We've attempted to provide some information about the second point
+in our Driver Status document. Please check there first before downloading
+4.0.1.
On the subject of configuration, we have updated the basic text-based tool
-"xf86config" to generate config files in the format required by 4.0 (3.3.x
-config files won't really work with 4.0). We're also working on some other
+"xf86config" to generate config files in the format required by 4.0.1 (3.3.x
+config files won't really work with 4.0.1). We're also working on some other
configuration tools, including one that is built-in to the X server. An
early version of this is included in the release, and it works well for some
hardware. To try it out, just run (as root) "XFree86 -configure". Both of
-these configuration options will at worst give you a reasonable starting
-point for a suitable configuration file. We've put some effort into docu-
-menting the 4.0 config file format, and you can find that information in the
-XF86Config manual page. Please check that and the driver manual pages and
-related documentation for further information about that.
+these configuration options will give you a reasonable starting point for a
+suitable configuration file. We've put some effort into documenting the
+4.0.1 config file format, and you can find that information in the XF86Config
+manual page. Check that, the driver manual pages and the related documenta-
+tion for further information.
Oh, another thing you might notice is that our documentation is rather
patchy. Most of what is present should be in reasonable shape, but there are
gaps. We thought it better to leave out docs that were very out of date
-rather than providing inaccurate and misleading information.
+rather than providing inaccurate and misleading information. We are looking
+for people to also help fill those gaps in <hint hint :->.
Finally, before you download and install the binary distributions for this
release, please have a quick read through the Installation Document. It may
save you some time.
-If those cautionary notes haven't turned you away (and we certainly hope
-not), please read on... The sections below describe some of the new features
-and changes between 3.3.x and 4.0. There is a lot of new stuff, and we defi-
-nitely don't have enough space to cover it all here.
+The next section describes what is new in the latest version (4.0.1). The
+other sections below describe some of the new features and changes between
+3.3.x and 4.0. There is a lot of new features, and we definitely don't have
+enough space to cover it all here.
+
+2. Summary of new features in 4.0.1.
+
+2.1 X server
+
+ o New DRI drivers for Intel i810, Matrox G400 and G200 (AGP only) and the
+ ATI Rage 128, and updates to the 3Dfx DRI driver, including Voodoo5 sup-
+ port.
+
+ o The X server now runs on Linux/Sparc including drivers for many video
+ cards used on SUN hardware.
+
+ o DRI support for the Linux/Sparc implementation that allows 3D direct
+ rendering with Creator3D cards.
+
+ o Fixed recently publicized security issues.
+
+ o Update Mesa to the latest version.
+
+ o Xinerama updates and fixes.
+
+ o Xv updates and fixes.
+
+ o Mouse support in DGA 1.0 compatibility mode should now work correctly
+ for most games that make use of it.
+
+ o Some bugs with 8+24 overlay support have been fixed.
+
+ o Some XKEYBOARD extension problems have been fixed, including improve-
+ ments to the MouseKeys support.
+
+ o Add generic DGA support to the sis, neomagic and i810 drivers.
+
+ o xf86cfg, a new graphical configuration tool.
+
+2.2 X libraries and clients.
+
+ o Thread safety issues have been resolved in a few places in the
+ libraries. Upgrading to the latest libraries is essential for multi-
+ threaded X applications.
+
+ o Some fatal bugs in the big font support have been fixed. Upgrading to
+ the latest libraries will fix this too.
+
+ o Fixed recently publicized security issues in some of the X libraries.
+
+ o Updates and bug fixes for some clients, including xedit, xman, xcalc,
+ fstobdf, xdm.
+
+ o Fix some xfs problems.
+
+ o XTerm updates. These include:
+
+ o Improve logfile security.
-2. X server
+ o Workaround for fixed fonts which are generated from Unicode fonts:
+ they omit glyphs for some xterm's less-used line-drawing charac-
+ ters, which caused xterm to set a flag telling it to use only its
+ internal line-drawing characters.
+
+ o Limit numeric parameters of control sequences to 65535 to simplify
+ checks for numeric overflow.
+
+ o Change index into UDK list to unsigned to guard against numeric
+ overflow making the index negative.
+
+ o Add limit checks to ClearInLine(), ScrnInsertChar(), Scrn-
+ DeleteChar() to correct potential out-of-bounds indexing.
+
+ o Add a resource (limitResize) limiting resizing via the CSI 4 t and
+ CSI 8 t sequences.
+
+ o Ignore out-of-bounds resize requests, i.e., where sign-extension or
+ truncation of the parameters would occur.
+
+ o Change Sun function-keys resource name to sunFunctionKeys to work
+ around redefinition of the token sun by xrdb on Solaris. Simi-
+ larly, renamed resource sun keyboard to sunKeyboard. Change simi-
+ lar resource names for HP and SCO to avoid potential conflict with
+ xrdb symbols on other systems, as well as for consistency.
+
+ o Change line speed from 9600bd to 38400bd to accommodate users who
+ mistakenly use $TERM set to vt100, to reduce the effect of padding
+ associated with this terminal type.
+
+ o Fix a problem that caused the right scrollbar to be positioned
+ incorrectly when re-enabling it.
+
+ o Fix a problem with color support that showed up on some platforms.
+
+ o Modify logic for deleteIsDEL resource so it has internally 3
+ states: unspecified, true and false. If unspecified, the keyboard
+ type determines whether the Delete key transmits <esc>[3~ or \177,
+ and the popup menu entry reflects the internal state. Otherwise,
+ the popup menu entry overrides the keyboard type.
+
+ o Portability fixes for os390, AIX 4.2, Digital Unix 4.0 and IRIX
+ 6.5.
+
+2.3 Fonts and Internationalisation
+
+ o Many of the "misc" bdf fonts have been updated and extended, and a wider
+ range of ISO-8859 subsets have been added. Oblique/italic versions of
+ some of them have also been added.
+
+ o The converters in Xlib have been improved and reworked. UTF-8 support
+ has been added.
+
+ o Support for ISO-8859-13 has been added to Xlib and to the UTF-8 convert-
+ ers.
+
+ o XKB keyboard definitions have been added and updated for some countries.
+
+ o Locale support for Celtic languages has been updated, and a Compose file
+ for ISO-8859-14 added.
+
+2.4 Miscellaneous
+
+ o Preliminary support for Linux/mips (no X servers yet).
+
+ o Update support for BSD/OS.
+
+ o Update Linux/IA64 support.
+
+ o Support for LynxOS 3.1.0.
+
+3. The new X server
Unlike XFree86 3.3.x where there are multiple X server binaries, each of
-which drive different hardware, XFree86 4.0 has a single X server binary
+which drive different hardware, XFree86 4.0.1 has a single X server binary
called XFree86. This binary can either have one or more video drivers linked
in statically, or, more usually, dynamically load the video drivers and other
modules that are needed.
-XFree86 4.0 has X server support for most UNIX(R) and UNIX-like operating
-systems on Intel/x86 platforms, plus support for Linux on Alpha and PowerPC
-platforms. Work on support for additional architectures and operating sys-
-tems is in progress, and is planned for future releases.
+XFree86 4.0.1 has X server support for most UNIX(R) and UNIX-like operating
+systems on Intel/x86 platforms, plus support for Linux on Alpha, PowerPC and
+Sparc platforms. Work on support for additional architectures and operating
+systems is in progress, and is planned for future releases.
-2.1 Loader and Modules
+3.1 Loader and Modules
The XFree86 X server has a built-in run-time loader, donated by Metro Link
<URL:http://www.metrolink.com>. This loader can load normal object files and
@@ -81,39 +198,37 @@ libraries in most of the commonly used formats. Since the loader doesn't
rely on an operating system's native dynamic loader support, it works on
platforms that don't provide this feature, and makes it possible for the mod-
ules to be operating system independent (although not, of course, independent
-of CPU architecture). This means that, for example, a module compiled on
-Linux/x86 can be loaded by an X server running on Solaris/x86, or FreeBSD, or
-even OS/2. One of the main benefits of this is that when modules are
-updated, they don't need to be recompiled for each different operating sys-
-tem. We're planning to take advantage of this to provide more frequent
-driver module updates in between major releases.
+of CPU architecture). This means that a module compiled on Linux/x86 can be
+loaded by an X server running on Solaris/x86, or FreeBSD, or even OS/2.
+
+One of the main benefits of this loader is that when modules are updated,
+they do not need to be recompiled for every different operating system. In
+the future we plan to take advantage of this to provide more frequent driver
+module updates in between major releases.
-The loader in version 4.0 has support for Intel (x86), Alpha and PowerPC
-platforms. It also has preliminary support for Sparc platforms but this
-isn't used yet.
+The loader in version 4.0.1 has support for Intel (x86), Alpha and PowerPC
+platforms. It also has preliminary support for Sparc platforms.
The X server makes use of modules for video drivers, X server extensions,
font rasterisers, input device drivers, framebuffer layers (like mfb, cfb,
etc), and internal components used by some drivers (like XAA),
The module interfaces (API and ABI) used in this release is still subject to
-change without notice. While we'll attempt to provide backward compatibility
-for the module interfaces as of the 4.0 release (meaning that 4.0 modules
-will work with future core X server binaries), we can't guarantee that this
-will be the case. We are planning to fully document and stabilise the module
-interfaces in a future release, and at that point backward compatibility will
-be easier to achieve.
+change without notice. While we will attempt to provide backward compatibil-
+ity for the module interfaces as of the 4.0 release (meaning that 4.0 modules
+will work with future core X server binaries), we cannot guarantee this.
Note about module security
- The XFree86 X server runs with root privileges, which means that
- the X server loadable modules also run with these privileges. For
- this reason we recommend that all users be careful to only use
- loadable modules from reliable sources. We hope to have a mecha-
- nism for signing/verifying the modules that we provide available in
- a future release.
+ The XFree86 X server runs with root privileges, i.e. the X server
+ loadable modules also run with these privileges. For this reason
+ we recommend that all users be careful to only use loadable modules
+ from reliable sources, otherwise the introduction of viruses and
+ contaminated code can occur and wreak havoc on your system. We
+ hope to have a mechanism for signing/verifying the modules that we
+ provide available in a future release.
-2.2 Configuration File
+3.2 Configuration File
The X server configuration file format has been extended to handle some of
the new functionality. The xf86config utility can be used to generate a
@@ -198,11 +313,12 @@ page for more comprehensive information:
o The Keyboard, Pointer and XInput sections have been replaced by a more
general InputDevice section. The old Keyboard and Pointer sections are
- still recognised for compatibility purposes, but they are deprecated and
- support for them may be dropped in future releases. The old XInput sec-
- tions are no longer recognised. The keywords from the old sections are
- expressed as Options in the InputDevice sections. The following example
- shows typical InputDevice sections for the core mouse and keyboard.
+ still recognised for compatibility purposes, but they are discommended
+ and support for them may be dropped in future releases. The old XInput
+ sections are no longer recognised. The keywords from the old sections
+ are expressed as Options in the InputDevice sections. The following
+ example shows typical InputDevice sections for the core mouse and key-
+ board.
Section "InputDevice"
Identifier "Keyboard 1"
@@ -273,7 +389,7 @@ The config file search patch has been extended, with the directories /etc/X11
and /usr/X11R6/etc/X11 being added. The full search path details are docu-
mented in the XF86Config manual page.
-2.3 Command Line Options
+3.3 Command Line Options
The following new X server command line options have been added:
@@ -384,13 +500,13 @@ The following X server command line options have been changed since 3.3.x:
This makes it possible for users to choose from multiple
config files that the the sysadmin has provided.
-2.4 XAA
+3.4 XAA
The XFree86 Acceleration Architecture (XAA) has been completely rewritten
from scratch. Most drivers implement acceleration by making use of the XAA
module.
-2.5 Multi-head
+3.5 Multi-head
Some multi-head configurations are supported in this release, primarily with
multiple PCI/AGP cards. However, this is an area that is still being worked
@@ -406,7 +522,7 @@ to be resolved. Some combinations can be made to work better by changing
which card is the primary card (either by using a different PCI slot, or by
changing the system BIOS's preference for the primary card).
-2.6 Xinerama
+3.6 Xinerama
Xinerama is an X server extension that allows multiple physical screens to
behave as a single screen. With traditional multi-head in X11, windows can-
@@ -428,19 +544,19 @@ Known problems:
way. This is an issue that needs to be dealt with in the individual
window managers, and isn't specifically an XFree86 problem.
-2.7 XVideo extension
+3.7 XVideo extension
The XVideo extension is included in this release, but nobody seems interested
in writing up some information about it.
-2.8 DGA version 2
+3.8 DGA version 2
DGA 2.0 is nearly completed but still not implemented by all drivers. Pre-
liminary documentation for the client libraries can be found in the xc/pro-
grams/Xserver/hw/xfree86/DGA document. Some degree of backwards compatibil-
ity with version 1.0 is provided. This information is out of date.
-2.9 DDC
+3.9 DDC
The VESA(R) Display Data Channel (DDC[tm]) standard allows the monitor to
tell the video card (or on some cases the computer directly) about itself;
@@ -462,7 +578,7 @@ to the and non-DDC default value 75 with the -dpi 75 command line option for
the X server, or by specifying appropriate screen dimensions with the "Dis-
playSize" keyword in the "Monitor" section of the config file.
-2.10 GLX and the Direct Rendering Infrastructure (DRI)
+3.10 GLX and the Direct Rendering Infrastructure (DRI)
Precision Insight <URL:http://www.precisioninsight.com> has been provided
with funding and support from Red Hat <URL:http://www.redhat.com>, SGI
@@ -483,7 +599,7 @@ of 2000. Updated information on DRI compatible drivers can be found at the
DRI Project <URL:http://dri.sourceforge.net> on SourceForge
<URL:http://www.sourceforge.net>.
-2.11 X-Video Extension (Xv)
+3.11 X-Video Extension (Xv)
An XvQueryPortAttributes function has been added as well as support for XvIm-
ages. XvImages are XImages in alternate color spaces such as YUV and can be
@@ -491,7 +607,7 @@ passed to the server through shared memory segments. This allows clients to
display YUV data with high quality hardware scaling and filtering. XvImages
are only supported by the Matrox G200/G400 cards at the moment.
-2.12 Other extensions
+3.12 Other extensions
The XFree86-Misc extension has not been fully ported to the new server archi-
tecture yet. This should be completed in a future release.
@@ -504,41 +620,50 @@ The new xgamma utility makes use of this feature. Compatibility with the
3.3.x version of the extension is provided. The missing parts of this exten-
sion and some new features should be completed in a future release.
-2.13 Drivers
-
-XFree86 4.0 includes the following drivers:
-
- +------------+----------------------+
- |Driver Name | Description |
- +------------+----------------------+
- |apm | Alliance Pro Motion |
- |ati | ATI |
- |chips | Chips & Technologies |
- |cirrus | Cirrus Logic |
- |cyrix (*) | Cyrix MediaGX |
- |fbdev | Linux fbdev |
- |glide | Glide2x (3Dfx) |
- |glint | 3Dlabs, TI |
- |i740 | Intel i740 |
- |i810 | Intel i810 |
- |mga | Matrox |
- |neomagic | NeoMagic |
- |nv | NVIDIA |
- |r128 | ATI Rage 128 |
- |rendition | Rendition |
- |s3virge | S3 ViRGE |
- |sis | SiS |
- |tdfx | 3Dfx |
- |tga | DEC TGA |
- |trident | Trident |
- |tseng | Tseng Labs |
- |vga | Generic VGA |
- +------------+----------------------+
+3.13 Drivers
+
+XFree86 4.0.1 includes the following drivers:
+
+ +------------+-------------------------------------+
+ |Driver Name | Description |
+ +------------+-------------------------------------+
+ |apm | Alliance Pro Motion |
+ |ati | ATI |
+ |chips | Chips & Technologies |
+ |cirrus | Cirrus Logic |
+ |cyrix (*) | Cyrix MediaGX |
+ |fbdev | Linux fbdev |
+ |glide | Glide2x (3Dfx) |
+ |glint | 3Dlabs, TI |
+ |i740 | Intel i740 |
+ |i810 | Intel i810 |
+ |mga | Matrox |
+ |neomagic | NeoMagic |
+ |nv | NVIDIA |
+ |r128 | ATI Rage 128 |
+ |rendition | Rendition |
+ |s3virge | S3 ViRGE |
+ |sis | SiS |
+ |sunbw2 (+) | Sun bw2 |
+ |suncg14 (+) | Sun cg14 |
+ |suncg3 (+) | Sun cg3 |
+ |suncg6 (+) | Sun GX and Turbo GX |
+ |sunffb (+) | Sun Creator, Creator3D and Elite 3D |
+ |sunleo (+) | Sun Leo (ZX) |
+ |suntcx (+) | Sun TCX |
+ |tdfx | 3Dfx |
+ |tga | DEC TGA |
+ |trident | Trident |
+ |tseng | Tseng Labs |
+ |vga | Generic VGA |
+ +------------+-------------------------------------+
Drivers marked with (*) are present in a preliminary form in this release,
but are not complete and/or stable yet.
-2.13.1 APM
+Drivers marked with (+) are for Linux/Sparc only.
+
+3.13.1 APM
This is the driver for Alliance AT3D/AT25 and AT24 chips. There is a rather
complete support for the functions with acceleration at 8,15,16,24 and 32
@@ -548,11 +673,11 @@ driver is almost ok. The Rush extension for glide2x works, with some addi-
tions, including overlay of the result. DGA and DGA2 have been tested ok.
Further information can be found in README.apm.
-2.13.2 Chips & Technologies
+3.13.2 Chips & Technologies
Information about the C&T driver can be found in README.chips.
-2.13.3 s3virge
+3.13.3 s3virge
The s3virge driver is a port of the 3.3.x SVGA S3 ViRGE driver. As such it
should be as stable and functional as previous XFree86 releases. There are a
@@ -580,13 +705,13 @@ Outstanding items not implemented or fully tested:
Further information can be found in README.s3virge.
-2.13.4 TGA
+3.13.4 TGA
The TGA driver is now accelerated and supports both 8 and 32 plane frame-
buffers. It is known to work under Linux/Alpha. Please see the
README.DECtga file for further information.
-2.13.5 Matrox
+3.13.5 Matrox
The MGA driver supports the same range or hardware as XFree86 3.3.4, but has
a number of enhancements including multi-head support and support for (non-
@@ -605,20 +730,20 @@ improved memory autodetection support.
Further information can be found in the mga man page.
-2.13.6 ATI
+3.13.6 ATI
Information about the ATI driver can be found in README.ati <URL:ati.html>.
The current version is not accelerated. Acceleration support is planned for
a future release.
-2.13.7 NVIDIA
+3.13.7 NVIDIA
The "nv" driver supports all Riva TNT accelerators as well as the new GeForce
and Quadro accelerators. DGA 2.0 support is included.
Further information can be found in the nv man page.
-2.13.8 Glide
+3.13.8 Glide
This driver is for Voodoo 1 and Voodoo 2 boards. It runs X on top of the 3DFX
Glide API (where this is available, like for Linux). You need to have Glide
@@ -639,7 +764,7 @@ man page.
For Voodoo Banshee and Voodoo 3 boards or later: Please use the tdfx driver
which talks directly to the hardware and is much faster.
-2.13.9 GLINT
+3.13.9 GLINT
The "glint" driver supports most 3Dlabs/Texas Instruments GLINT/Permedia
chips. There is a rather complete support (better than in 3.3.x) for acceler-
@@ -649,9 +774,9 @@ ation at 8, 15, 16, and 24 bit depths (limited by some chips at some depths).
Further information about this driver can be found in the 'glint' driver man
page.
-3. X libraries and clients
+4. X libraries and clients
-3.1 Xaw
+4.1 Xaw
Two versions of the Xaw library are provided in this release. A version with
bug fixes and a few binary compatible improvements and a new version with
@@ -710,11 +835,11 @@ Bug fixes:
o Several bugs were fixed in the text code, while some code was rewritten
from scratch.
-3.2 Xpm
+4.2 Xpm
Version 3.4k of the Xpm (X pixmap) library is now integrated into XFree86.
-3.3 xterm
+4.3 xterm
New Features:
@@ -891,7 +1016,7 @@ Bug fixes/improvements:
o Various improvements to configure script, e.g., tests for utmp.
-3.4 xedit
+4.4 xedit
Xedit have been changed to use most of the new features added to the new ver-
sion of the Xaw library, and some xedit only features were added. Emacs users
@@ -930,18 +1055,18 @@ xedit. These include:
o C-mode: this mode is expected to be stable, and fully usable.
-4. Fonts and Internationalisation
+5. Fonts and Internationalisation
Details about the font support in this version of XFree86 can be found in the
README.fonts document.
-4.1 TrueType support
+5.1 TrueType support
This version of XFree86 comes with two TrueType backends, known as `xfsft'
(the "freetype" module) and `X-TrueType' (the "xtt" module). Both of these
backends are based on the FreeType library.
-4.2 CID font support
+5.2 CID font support
Support for CID-keyed fonts is included in this version of XFree86. The CID-
keyed font format was designed by Adobe Systems <URL:http://www.adobe.com>
@@ -949,7 +1074,7 @@ for fonts with large character sets. The CID-keyed font support in XFree86
was donated by SGI <URL:http://www.sgi.com>. See the LICENSE document for a
copy of the CID Font Code Public License.
-4.3 Internationalisation of the scalable font backends
+5.3 Internationalisation of the scalable font backends
A new ``fontenc'' layer has been added to allow the scalable font backends to
use a common method of font re-encoding. This re-encoding makes it possible
@@ -958,14 +1083,14 @@ layer is used by the Type1 and Speedo backends and the `xfsft' version of the
TrueType backend. The `X-TrueType' version of the TrueType backend uses a
different re-encoding method based on loadable encoding modules.
-4.4 Large font optimisation
+5.4 Large font optimisation
The glyph metrics array, which all the X clients using a particular font have
access to, is now placed in shared memory, so as to reduce redundant memory
consumption. For non-local clients, the glyph metrics array is transmitted
in a compressed format.
-4.5 Unicode/ISO 10646 support
+5.5 Unicode/ISO 10646 support
What is included:
@@ -1015,7 +1140,7 @@ Known problems:
and 18x18ja) is not yet supported by xterm (will be needed for CJK
scripts).
-4.6 Lucidux fonts from Bigelow and Holmes
+5.6 Lucidux fonts from Bigelow and Holmes
XFree86 now includes the ``Lucidux'' family of professionally hinted Type 1
fonts. This family consists of the fonts ``Lucidux Serif'', ``Lucidux Sans''
@@ -1028,9 +1153,9 @@ Blenda Horn from Y&Y, Inc. For more information, please contact
<design@bigelowandholmes.com> or <sales@yandy.com>, or consult Y&Y's web site
<URL:http://www.yandy.com>.
-5. Miscellaneous
+6. Miscellaneous
-5.1 Directory rearrangements
+6.1 Directory rearrangements
Some changes to the installed XFree86 directory structure have been imple-
mented for 4.0. One important change is a modified search path for the X
@@ -1041,7 +1166,7 @@ location pointing to the new location. Some run-time generated files are now
located under the appropriate subdirectories of /var, again with the relevant
symbolic links in the old location.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.37 2000/03/08 20:11:55 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.41 2000/07/02 02:35:27 dawes Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/RELNOTES,v 3.82 2000/03/08 20:39:24 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/RELNOTES,v 3.84 2000/07/02 02:46:27 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/Status b/xc/programs/Xserver/hw/xfree86/doc/Status
index 6e04e1887..5bea5ef15 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/Status
+++ b/xc/programs/Xserver/hw/xfree86/doc/Status
@@ -1,4 +1,4 @@
- Driver Status for XFree86[tm] 4.0
+ Driver Status for XFree86[tm] 4.0.1
The XFree86 Project, Inc
@@ -7,17 +7,17 @@
Abstract
This document provides information about the status of the driver
- and hardware support in XFree86 4.0 compared with that in XFree86
+ and hardware support in XFree86 4.0.1 compared with that in XFree86
3.3.6. Please send updates for this document to
<fixes@xfree86.org>
1. Introduction
This document contains one section per vendor (organised alphabetically) for
-each chipset family that is supported in XFree86 3.3.6 or XFree86 4.0. It
+each chipset family that is supported in XFree86 3.3.6 or XFree86 4.0.1. It
includes information about the status of the drivers and the hardware they
support, including a comparison of the level of support between versions
-3.3.6 and 4.0.
+3.3.6 and 4.0.1.
NOTE: Status information needs to be checked carefully and expanded where
possible. E.g., include information about acceleration, multi-head, known
@@ -31,7 +31,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support is provided by the XF86_SVGA server with the tdfx
driver).
- 4.0:
+ 4.0.1:
Support for Voodoo 1 and Voodoo 2 via glide on platforms where
glide is available (Linux and FreeBSD(?)). Support is provided
by the "glide" driver (requires Glide 2x).
@@ -40,7 +40,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support is provided by the "tdfx" driver.
Summary:
- All hardware supported in 3.3.6 is also supported in 4.0.
+ All hardware supported in 3.3.6 is also supported in 4.0.1.
3. 3Dlabs
@@ -50,13 +50,13 @@ architectures known to work on (e.g., Alpha, PPC), etc.
ramdacs), Permedia with IBM RGB526 ramdac, Permedia 2, 2a, 2v.
Support is provided by the XF86_3DLabs server.
- 4.0:
+ 4.0.1:
Support (including acceleration) for Permedia, Permedia 2, 2v
(and 2a??) GLINT 500TX, GLINT MX, GLINT Gamma, and Glint Delta
coproc. Support is provided by the "glint" driver.
Summary:
- All hardware supported in 3.3.6 is also supported in 4.0.
+ All hardware supported in 3.3.6 is also supported in 4.0.1.
4. Alliance
@@ -64,14 +64,14 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support (including acceleration) for the AT24, AP6422, AT3D.
Support is provided by the XF86_SVGA server with the apm driver.
- 4.0:
+ 4.0.1:
Support (including acceleration?) for the AT24, AT25 and AT3D.
This support is provided by the "apm" driver. This driver cur-
rently has only incomplete support for the AP6422.
Summary:
- The AP6422 is supported in 3.3.6 but not fully in 4.0. The AT25
- is supported in 4.0 but not in 3.3.6.
+ The AP6422 is supported in 3.3.6 but not fully in 4.0.1. The
+ AT25 is supported in 4.0.1 but not in 3.3.6.
5. ARK Logic
@@ -80,12 +80,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
and ARK2000MT. Support is provided by the XF86_SVGA server with
the ark driver.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No ARK Logic chips are supported in 4.0.
+ No ARK Logic chips are supported in 4.0.1.
6. ATI
@@ -103,16 +103,18 @@ architectures known to work on (e.g., Alpha, PPC), etc.
driver. Accelerated support is provided for the Rage 128 chips
by the XF86_SVGA server with the r128 driver.
- 4.0:
+ 4.0.1:
Accelerated support is provided for the Rage 128 chips by the
- "r128" driver. Unaccelerated support is provided for all of the
- others except the Mach8 and some early Mach32 chips by the "ati"
- driver.
+ "r128" driver. Accelerated support is provided for the Mach64
+ Rage variants by the "ati" driver. Unaccelerated support is pro-
+ vided for all of the others except the Mach8 and some early
+ Mach32 chips by the "ati" driver.
Summary:
- All chips supported in 3.3.6 are supported in 4.0 except for
- Mach8 and some old Mach32 chips. The support in 4.0 is, however,
- unaccelerated for all chips except the Rage 128.
+ All chips supported in 3.3.6 are supported in 4.0.1 except for
+ Mach8 and some old Mach32 chips. The support in 4.0.1 is, how-
+ ever, unaccelerated for all chips except the Mach64, Rage and
+ Rage 128 variants.
7. Avance Logic
@@ -124,12 +126,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
don't have any recent test reports, and these drivers have no
maintainer.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old drivers
have not been ported.
Summary:
- No Avance Logic chips are supported in 4.0.
+ No Avance Logic chips are supported in 4.0.1.
8. Chips and Technologies
@@ -139,13 +141,13 @@ architectures known to work on (e.g., Alpha, PPC), etc.
64300. This support is provided by the XF86_SVGA server with the
chips driver.
- 4.0:
+ 4.0.1:
Support (accelerated) for the 65520, 65525, 65530, 65535, 65540,
65545, 65546, 65548, 65550, 65554, 65555, 68554, 69000, 64200 and
64300. This support is provided by the "chips" driver.
Summary:
- All chips supported in 3.3.6 are also supported in 4.0.
+ All chips supported in 3.3.6 are also supported in 4.0.1.
9. Cirrus Logic
@@ -157,15 +159,15 @@ architectures known to work on (e.g., Alpha, PPC), etc.
7541, 7542, 7543, 7548, 7555 and 7556 is provided by the
XF86_SVGA server with the cirrus driver.
- 4.0:
+ 4.0.1:
Support (accelerated) for the Alpine (5430, 5434, 5436, 5446,
5480), and Laguna (5462, 5464, 5465) chips is provided by the
"cirrus" driver.
Summary:
- The following chips are supported in 3.3.6 but not in 4.0: 6410,
- 6412, 6420, 6440, 5420, 5422, 5424, 5426, 5428, 5429, 6205, 6215,
- 6225, 6235, 7541, 7542, 7543, 7548, 7555 and 7556.
+ The following chips are supported in 3.3.6 but not in 4.0.1:
+ 6410, 6412, 6420, 6440, 5420, 5422, 5424, 5426, 5428, 5429, 6205,
+ 6215, 6225, 6235, 7541, 7542, 7543, 7548, 7555 and 7556.
10. Compaq/Digital
@@ -179,7 +181,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
24 plane 3D chips (on Alpha platforms) is provided by the
XF86_TGA server.
- 4.0:
+ 4.0.1:
No support for the Compaq AVGA (driver hasn't been ported).
Support (accelerated) for the DEC 21030 TGA 8 plane, 24 plane and
@@ -187,8 +189,8 @@ architectures known to work on (e.g., Alpha, PPC), etc.
the "tga" driver.
Summary:
- No Compaq AVGA support in 4.0. DEC TGA support is equivalent in
- both versions.
+ No Compaq AVGA support in 4.0.1. DEC TGA support is equivalent
+ in both versions.
11. Cyrix
@@ -196,12 +198,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support (accelerated) for the Cyrix MediaGX is provided by the
XF86_SVGA server with the cyrix driver.
- 4.0:
+ 4.0.1:
A preliminary port of the driver is available, but it isn't ready
for widespread use.
Summary:
- No Cyrix chips are well-supported in 4.0.
+ No Cyrix chips are well-supported in 4.0.1.
12. Epson
@@ -209,12 +211,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support (accelerated) for the Epson SPC8110 is provided by the
XF86_SVGA server with the spc8100 driver.
- 4.0:
+ 4.0.1:
No native support for this chipset, because the old driver has
not been ported.
Summary:
- No Epson chips are supported in 4.0.
+ No Epson chips are supported in 4.0.1.
13. Genoa
@@ -224,12 +226,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
because we don't have any recent test reports, and this driver
has no maintainer.
- 4.0:
+ 4.0.1:
No native support for this chipset, because the old driver has
not been ported.
Summary:
- No Genoa chips are supported in 4.0.
+ No Genoa chips are supported in 4.0.1.
14. IBM
@@ -244,7 +246,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support for the IBM XGA-2 chip is provided by the XF86_AGX
server.
- 4.0:
+ 4.0.1:
Support for the standard IBM VGA chip (and compatibles) is pro-
vided by the "vga" driver.
@@ -253,7 +255,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Summary:
The standard VGA core is supported in both versions, but there is
- no support for the 8514/A or XGA-2 in 4.0.
+ no support for the 8514/A or XGA-2 in 4.0.1.
15. IIT
@@ -261,12 +263,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support (accelerated) for the AGX-016, AGX-015 and AGX-014 is
provided by the XF86_AGX server..
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No IIT chips are supported in 4.0.
+ No IIT chips are supported in 4.0.1.
16. Intel
@@ -277,7 +279,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Linux, and requires the agpgart.o kernel module in order to use
modes that require more than 1MB of video memory.
- 4.0:
+ 4.0.1:
Support (accelerated) for the Intel i740 is provided by the
"i740" driver, and support for the Intel i810 is provided by the
"i810" driver. The "i810" driver is currently Linux-only, and
@@ -294,13 +296,13 @@ architectures known to work on (e.g., Alpha, PPC), etc.
(Mystique), MGA2164W (Millennium II) (PCI and AGP), G100, G200
and G400 is provided by the XF86_SVGA server with the mga driver.
- 4.0:
+ 4.0.1:
Support (accelerated) for the MGA2064W (Millennium I), MGA1064SG
(Mystique), MGA2164W (Millennium II) (PCI and AGP), G100, G200
and G400 is provided by the "mga" driver.
Summary:
- All chips supported in 3.3.6 are also supported in 4.0.
+ All chips supported in 3.3.6 are also supported in 4.0.1.
18. MX (???)
@@ -310,12 +312,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
is unknown because we don't have any recent test reports, and
this driver has no maintainer.
- 4.0:
+ 4.0.1:
No native support for this chipset, because the old driver has
not been ported.
Summary:
- No MX (???) chips are supported in 4.0.
+ No MX (???) chips are supported in 4.0.1.
19. NCR
@@ -324,12 +326,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
XF86_SVGA server and the ncr77c22 driver. The status of this
support is unknown because we don't have any recent test reports.
- 4.0:
+ 4.0.1:
No native support for this chipset, because the old driver has
not been ported.
Summary:
- No NCR chips are supported in 4.0.
+ No NCR chips are supported in 4.0.1.
20. NeoMagic
@@ -338,29 +340,29 @@ architectures known to work on (e.g., Alpha, PPC), etc.
NM2097, NM2160 and NM2200 chipsets is provided by the XF86_SVGA
server with the neo driver.
- 4.0:
+ 4.0.1:
Support (accelerated) for the NeoMagic NM2070, NM2090, NM2093,
NM2097, NM2160 and NM2200 chipsets is provided by the "neomagic"
driver.
Summary:
- All chips supported in 3.3.6 are also supported in 4.0.
+ All chips supported in 3.3.6 are also supported in 4.0.1.
21. NVIDIA
3.3.6:
Support (accelerated) for the NV1, Riva 128, 128ZX, TNT, TNT2
- (Ultra, Vanta, M64), GeForce (DDR) and Quadro is provided by the
- XF86_SVGA server and the nv driver.
+ (Ultra, Vanta, M64), GeForce (DDR, 256) and Quadro is provided by
+ the XF86_SVGA server and the nv driver.
- 4.0:
+ 4.0.1:
Support (accelerated) for the Riva 128, 128ZX, TNT, TNT2 (Ultra,
- Vanta, M64), GeForce (DDR) and Quadro is provided by the
- XF86_SVGA server and the nv driver.
+ Vanta, M64), GeForce (DDR, 256) and Quadro is provided by the nv
+ driver.
Summary:
All chipsets supported in 3.3.6 except the NV1 are also supported
- in 4.0.
+ in 4.0.1.
22. Number Nine
@@ -368,12 +370,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support (accelerated) for the Imagine 128, Ticket 2 Ride, Revolu-
tion 3D and Revolution IV is provided by the XF86_I128 server.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No Number Nine chips are supported in 4.0.
+ No Number Nine chips are supported in 4.0.1.
23. Oak Technologies Inc
@@ -382,12 +384,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
acceleration) is provided by the XF86_SVGA server and the oak
driver.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No Oak chips are supported in 4.0.
+ No Oak chips are supported in 4.0.1.
24. Paradise/Western Digital
@@ -398,12 +400,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
port for some of these chipsets is uncertain because we don't
have any recent test reports, and this driver has no maintainer.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No Paradise/Western Digital chips are supported in 4.0.
+ No Paradise/Western Digital chips are supported in 4.0.1.
25. RealTek
@@ -413,12 +415,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
unknown because we don't have any recent test reports, and this
driver has no maintainer.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No RealTek chips are supported in 4.0.
+ No RealTek chips are supported in 4.0.1.
26. Rendition/Micron
@@ -426,12 +428,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Support for the Verite 1000, 2100 and 2200 is provided by the
XF86_SVGA server with the rendition driver.
- 4.0:
+ 4.0.1:
Support for the Verite 1000, 2100 and 2200 is provided by the
"rendition" driver.
Summary:
- All chips supported in 3.3.6 are also supported in 4.0.
+ All chips supported in 3.3.6 are also supported in 4.0.1.
27. S3
@@ -449,15 +451,15 @@ architectures known to work on (e.g., Alpha, PPC), etc.
by the XF86_SVGA server with the s3_savage driver (CHECK: is this
support Linux-only?).
- 4.0:
+ 4.0.1:
Support (accelerated) for the ViRGE, ViRGE/VX, ViRGE/DX,
ViRGE/GX, ViRGE/GX2, ViRGE/MX, ViRGE/MX+, Trio3D and Trio3D/2X is
provided by the "s3virge" driver. Support for the other S3
chipsets has not yet been ported.
Summary:
- Only the ViRGE and Trio3D chipsets are supported in 4.0. All of
- the other chipsets are only supported in 3.3.6.
+ Only the ViRGE and Trio3D chipsets are supported in 4.0.1. All
+ of the other chipsets are only supported in 3.3.6.
28. Silicon Integrated Systems (SiS)
@@ -466,7 +468,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
86C225, 5597, 5598, 6326, 530, 620, 300, 630 and 540 is provided
by the XF86_SVGA server with the sis driver.
- 4.0:
+ 4.0.1:
Support (accelerated) for the SiS
530, 620, 6326 is provided by the "sis" driver. The 630, 300,
and 540 are also supported, but this code is new and there are
@@ -483,12 +485,13 @@ architectures known to work on (e.g., Alpha, PPC), etc.
LynxEM+ and Lynx3DM chips is provided by the XF86_SVGA server
with the smi driver.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the driver has not
been ported.
Summary:
- No SMI chips are supported in 4.0.
+ No SMI chips are supported in 4.0.1, but the fbdev driver is
+ reported to work on Linux.
30. Trident Microsystems
@@ -503,7 +506,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
CyberBlade/DSTN/i7 and CyberBlade/i1 is provided by the XF86_SVGA
server with the tvga8900 driver.
- 4.0:
+ 4.0.1:
Support (accelerated where the chip supports it) for the
TVGA8900D, TGUI9420DGi, TGUI9440AGi, TGUI9660, TGUI9680, ProVidia
9682, ProVidia 9685, Cyber9320, Cyber9382, Cyber9385, Cyber9388,
@@ -513,7 +516,7 @@ architectures known to work on (e.g., Alpha, PPC), etc.
Summary:
The following (older) chipsets that are supported in 3.3.6 are
- not supported in 4.0: TVGA8200LX, TVGA8800CS, TVGA8900B,
+ not supported in 4.0.1: TVGA8200LX, TVGA8800CS, TVGA8900B,
TVGA8900C, TVGA8900CL, TVGA9000, TVGA9000i, TVGA9100B,
TVGA9200CXr, TGUI9400CXi, TGUI9420, TGUI9430DGi.
@@ -527,14 +530,14 @@ architectures known to work on (e.g., Alpha, PPC), etc.
driver. Support (accelerated) for the ET4000/W32 series and the
ET6000 is also provided by the deprecated XF86_W32 server.
- 4.0:
+ 4.0.1:
Support for the ET4000AX, and accelerated support for the
ET4000/W32, ET4000/W32i, ET4000/W32p, ET6000 and ET6100 is pro-
vided by the "tseng" driver.
Summary:
- All cards supported by 3.3.6 are also supported by 4.0 except for
- the old ET3000.
+ All cards supported by 3.3.6 are also supported by 4.0.1 except
+ for the old ET3000.
32. Video 7
@@ -544,12 +547,12 @@ architectures known to work on (e.g., Alpha, PPC), etc.
unknown because we don't have any recent test reports, and this
driver has no maintainer.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old driver has
not been ported.
Summary:
- No Video 7 chips are supported in 4.0.
+ No Video 7 chips are supported in 4.0.1.
33. Weitek
@@ -558,14 +561,14 @@ architectures known to work on (e.g., Alpha, PPC), etc.
server and accelerated support for the P9100 is provided by the
XF86_SVGA server with the p9x00 driver.
- 4.0:
+ 4.0.1:
No native support for these chipsets, because the old drivers
have not been ported.
Summary:
- No Weitek chips are supported in 4.0.
+ No Weitek chips are supported in 4.0.1.
- Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.15 2000/03/03 21:28:10 dawes Exp $
+ Generated from XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.17 2000/06/19 15:00:54 tsi Exp $
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/Status,v 1.11 2000/03/04 00:51:35 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/Status,v 1.13 2000/06/19 15:12:27 tsi Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/VideoBoard98 b/xc/programs/Xserver/hw/xfree86/doc/VideoBoard98
index 68e3ba756..b49fb013d 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/VideoBoard98
+++ b/xc/programs/Xserver/hw/xfree86/doc/VideoBoard98
@@ -1,4 +1,4 @@
-DATE:000220
+DATE:000616
XFree86 PC98 Server
Video System List
@@ -57,18 +57,18 @@ NEC
|PC9821St15 |MGA2064W |Ti3026 |Ti3026 |4| o? |O|
|PC9821St20 |MGA2064W |Ti3026 |Ti3026 |4| o? |O|
|PC9821Xa |MGA II |Ti3020 |Ti3020 |2| X | |
-|PC9821Xa7/C,K |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821Xa9/C,K |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821Xa10/C,K |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821Xa12/C,K |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821Xa13/C,K |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821Xa13/W |TGUI9682 | B/I | B/I |2| X |O|
-|PC9821Xa16/R |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821Xa16/W |TGUI9682 | B/I | B/I |2| X |O|
-|PC9821Xa20/D,W |TGUI9682 | B/I | B/I |2| X |O|
-|PC9821Xa200/D,W |TGUI9682 | B/I | B/I |2| X |O|
+|PC9821Xa7/C,K |TGUI9680 | B/I | B/I |2| o |O|
+|PC9821Xa9/C,K |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821Xa10/C,K |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821Xa12/C,K |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821Xa13/C,K |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821Xa13/W |TGUI9682 | B/I | B/I |2| o? |O|
+|PC9821Xa16/R |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821Xa16/W |TGUI9682 | B/I | B/I |2| o? |O|
+|PC9821Xa20/D,W |TGUI9682 | B/I | B/I |2| o? |O|
+|PC9821Xa200/D,W |TGUI9682 | B/I | B/I |2| o? |O|
|PC9821Xb10 |CLGD5440 | B/I | B/I |1| X |X|
-|PC9821Xc13/M,S |TGUI9680 | B/I | B/I |2| X |O|
+|PC9821Xc13/M,S |TGUI9680 | B/I | B/I |2| o? |O|
|PC9821Xc13/S5 |CLGD5446 | B/I | B/I |1| X |X|
|PC9821Xc16/M,S |CLGD5446 | B/I | B/I |2| X |X|
|PC9821Xc200/M,S |CLGD5446 | B/I | B/I |2| X |X|
@@ -79,7 +79,7 @@ NEC
|PC9821Xs |S3-864 |S3-SDAC|S3-SDAC |2| X |O|
|PC9821Xe |CLGD5430 | B/I | B/I |1| X |X|
|PC9821Xe10 |CLGD5430 | B/I | B/I |1| X |X|
-|PC9821Xv13/R |TGUI9680 | B/I | B/I |2| X |O|
+|PC9821Xv13/R |TGUI9680 | B/I | B/I |2| o? |O|
|PC9821Xv13/W |MGA2064W |Ti3026 |Ti3026 |2| o? |O|
|PC9821Xv20/W |MGA2064W |Ti3026 |Ti3026 |4| o? |O|
+------------------------+---------------+-------+--------+-+-------+-+
@@ -90,9 +90,9 @@ NEC
|PC9821V16/S |CLGD5440 | B/I | B/I |1| X |X|
|PC9821V16/S5V,P |CLGD5446 | B/I | B/I |2| X |X|
|PC9821V20/S7 |CLGD5440 | B/I | B/I |1| X |X|
-|PC9821V13/M7 |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821V16/M7 |TGUI9680 | B/I | B/I |2| X |O|
-|PC9821V20/M7 |TGUI9680 | B/I | B/I |2| X |O|
+|PC9821V13/M7 |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821V16/M7 |TGUI9680 | B/I | B/I |2| o? |O|
+|PC9821V20/M7 |TGUI9680 | B/I | B/I |2| o? |O|
|PC9821V166/S |MGA1064SG | B/I | B/I |2| o? |O|
|PC9821V200/S |MGA1064SG | B/I | B/I |2| o? |O|
|PC9821V200/M7 |MGA1064SG | B/I | B/I |4| o |O|
@@ -120,16 +120,16 @@ NEC
|PC9821Cu16/H |ProVidia9685 | B/I | B/I |2| X |X|
|PC9821Ct20/A |ProVidia9685 | B/I | B/I |2| X |X|
+------------------------+---------------+-------+--------+-+-------+-+
-|PC9821Ra18/N |TGUI9682 | B/I | B/I |2| X |O|
-|PC9821Ra20/N |TGUI9682 | B/I | B/I |2| X |O|
-|PC9821Ra266/D,N,W |TGUI9682 | B/I | B/I |2| X |O|
+|PC9821Ra18/N |TGUI9682 | B/I | B/I |2| o? |O|
+|PC9821Ra20/N |TGUI9682 | B/I | B/I |2| o |O|
+|PC9821Ra266/D,N,W |TGUI9682 | B/I | B/I |2| o? |O|
|PC9821Rv20/N20 |MGA2064W |Ti3026 |Ti3026 |4| o |O|
+------------------------+---------------+-------+--------+-+-------+-+
-|PC9821RaII23/N,W |TGUI9682 | B/I | B/I |2| X |O|
+|PC9821RaII23/N,W |TGUI9682 | B/I | B/I |2| o? |O|
|PC9821RvII26/N20 |MGA2064W |Ti3026 |Ti3026 |4| o |O|
+------------------------+---------------+-------+--------+-+-------+-+
-|PC9821Rs20/B20 |TGUI9682 | B/I | B/I |2| X |O|
-|PC9821RsII26/B40 |TGUI9682 | B/I | B/I |2| X |O|
+|PC9821Rs20/B20 |TGUI9682 | B/I | B/I |2| o? |O|
+|PC9821RsII26/B40 |TGUI9682 | B/I | B/I |2| o? |O|
+------------------------+---------------+-------+--------+-+-------+-+
|PC9821C166/C |3Dimage975 | | |4| X | |
|PC9821C166/D |ProVidia9685 | B/I | B/I |2| X | |
@@ -262,7 +262,7 @@ Canopus
|Power WindowDX |S3-ViRGE/DX | B/I | B/I |4| X | |
|Power WindowDX/4MC |S3-ViRGE/DX | B/I | B/I |4| X | |
|Power WindowGX/4VC |S3-ViRGE/GX | B/I | B/I |4| X | |
-|Power WindowGMX |GLINT MX |RGB526 | |8| X | |
+|Power WindowGMX |GLINT MX |RGB526 | |8| ? | |
+------------------------+---------------+-------+--------+-+-------+-+
@@ -311,14 +311,14 @@ IO DATA
|GA-98NB IV |CLGD5434 | B/I | B/I |4| X |X|
|GA-DR2/98 |TGUI9660 | B/I | B/I |2| X |X|
|GA-DR4/98 |TGUI9660 | B/I | B/I |4| X |X|
-|GA-DR2/PCI |TGUI9660 | B/I | B/I |2| X | |
-|GA-DR4/PCI |TGUI9660 | B/I | B/I |4| X | |
+|GA-DR2/PCI |TGUI9660 | B/I | B/I |2| ? | |
+|GA-DR4/PCI |TGUI9660 | B/I | B/I |4| ? | |
|GA-DRV2/98 |TGUI9680 | B/I | B/I |2| X |X|
|GA-DRV4/98 |TGUI9680 | B/I | B/I |4| X |X|
-|GA-DRV2/PCI |TGUI9680 | B/I | B/I |2| X | |
-|GA-DRV4/PCI |TGUI9680 | B/I | B/I |4| X | |
-|GA-DRTV2/98PCI |TGUI9682 | B/I | B/I |2| X | |
-|GA-DRTV4/98PCI |TGUI9682 | B/I | B/I |4| X | |
+|GA-DRV2/PCI |TGUI9680 | B/I | B/I |2| ? | |
+|GA-DRV4/PCI |TGUI9680 | B/I | B/I |4| ? | |
+|GA-DRTV2/98PCI |TGUI9682 | B/I | B/I |2| ? | |
+|GA-DRTV4/98PCI |TGUI9682 | B/I | B/I |4| ? | |
|GA-968V2/98PCI |S3-968 |RGB524 | RGB524 |2| X |O|
|GA-968V4/98PCI |S3-968 |RGB524 | RGB524 |4| X |O|
|GA-PGDX2/98PCI |S3-ViRGE/DX | B/I | B/I |2| X | |
@@ -327,10 +327,10 @@ IO DATA
|GA-PG3D4/98PCI |S3-ViRGE | B/I | B/I |4| X | |
|GA-PG3DVX4/98PCI |S3-ViRGE/VX | B/I | B/I |4| X | |
|GA-PG3DVX8/98PCI |S3-ViRGE/VX | B/I | B/I |8| X | |
-|GA-PII8/PCI |PERMEDIA2 | | |8| o? |O|
-|GA-PIIH8/PCI |PERMEDIA2 | | |8| o? |O|
-|GA-RUSH6/PCI |Promotion AT25 | | |4| o | |
-| |Voodoo RUSH | | |2| | |
+|GA-PII8/PCI |PERMEDIA2 | | |8| O? |O|
+|GA-PIIH8/PCI |PERMEDIA2 | | |8| O? |O|
+|GA-RUSH6/PCI |Promotion AT25 | | |4| o |o|
+| |Voodoo RUSH | | |2| - | |
+------------------------+---------------+-------+--------+-+-------+-+
@@ -384,4 +384,4 @@ Force
|WinFrame928 |S3-928 | | |2| X | |
+------------------------+---------------+-------+--------+-+-------+-+
-/* $XFree86: xc/programs/Xserver/hw/xfree86/doc/VideoBoard98,v 1.3 2000/02/21 18:05:46 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/doc/VideoBoard98,v 1.5 2000/06/20 20:07:58 dawes Exp $ */
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml
index 857afc1da..98cb80428 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml
@@ -27,7 +27,7 @@
<title>XFree86 X server ``New Design'' (DRAFT)
<author>The XFree86 Project, Inc
-<date>Last modified 15 February 2000
+<date>Last modified 1 May 2000
@@ -36,7 +36,7 @@
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.23 2000/02/15 18:00:57 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DESIGN.sgml,v 1.30 2000/06/19 15:00:52 tsi Exp $
</ident>
@@ -181,8 +181,8 @@ changes:
<code>
Section "ServerLayout"
Identifier "Main Layout"
- Screen "Screen 1" 0 "" "" "" "Screen 2"
- Screen "Screen 2" 1
+ Screen 0 "Screen 1" "" "" "" "Screen 2"
+ Screen 1 "Screen 2"
Screen "Screen 3"
EndSection
</code>
@@ -199,8 +199,8 @@ changes:
<code>
Section "ServerLayout"
Identifier "Main Layout"
- Screen "Screen 1" 0 Absolute 0 0
- Screen "Screen 2" 1 Absolute 1024 0
+ Screen 0 "Screen 1" Absolute 0 0
+ Screen 1 "Screen 2" Absolute 1024 0
Screen "Screen 3" Absolute 2048 0
EndSection
</code>
@@ -224,8 +224,8 @@ changes:
<code>
Section "ServerLayout"
Identifier "Main Layout"
- Screen "Screen 1" 0
- Screen "Screen 2" 1 RightOf "Screen 1"
+ Screen 0 "Screen 1"
+ Screen 1 "Screen 2" RightOf "Screen 1"
Screen "Screen 3" Relative "Screen 1" 2048 0
EndSection
</code>
@@ -620,8 +620,8 @@ is what &s.code;InitOutput()&e.code; does:
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;xf86ConfigActivePciEntity()&e.code; helper function
- for PCI and &s.code;xf86ConfigActiveIsaEntity()&e.code; for ISA
+ 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;
@@ -638,12 +638,16 @@ is what &s.code;InitOutput()&e.code; does:
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 instance of the
+ 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. The &s.code;xf86AllocateScreen()&e.code;
- function must be used to allocate the &s.code;ScrnInfoRec&e.code;,
- and it takes care of initialising fields to defined ``unused''
- values.
+ 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.
@@ -842,11 +846,13 @@ is what &s.code;InitOutput()&e.code; does:
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. The &s.code;xf86LoadSubModule()&e.code; function
- should be used to load modules. A driver may unload a module
- within this function if it was only needed temporarily, and the
- &s.code;UnloadSubModule()&e.code; function should be used to do
- that. Otherwise there is no need to explicitly unload modules
+ 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.
@@ -922,6 +928,8 @@ is what &s.code;InitOutput()&e.code; does:
<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
@@ -929,15 +937,16 @@ is what &s.code;InitOutput()&e.code; does:
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;UnloadSubModule()&e.code; when unloading.
+ &s.code;xf86UnloadSubModule()&e.code; when unloading.
</quote>
- &s.code;void UnloadSubModule(pointer module)&e.code;
+ &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;.
+ by &s.code;xf86LoadSubModule()&e.code; or
+ &s.code;xf86LoadDrvSubModule()&e.code; .
</quote>
</quote>
@@ -2021,21 +2030,28 @@ available at the driver level:
Two helper functions are provided to aid configuring entities:
<quote><p>
- &s.code;Bool xf86ConfigActivePciEntity(ScrnInfoPtr pScrn, int entityIndex,
- &f.indent;PciChipsets *p_chip, resList res,
- &f.indent;EntityProc init, EntityProc enter,
- &f.indent;EntityProc leave, pointer private)&e.code;
+ &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;Bool xf86ConfigActiveIsaEntity(ScrnInfoPtr pScrn, int entityIndex,
- &f.indent;IsaChipsets *i_chip, resList res,
- &f.indent;EntityProc init, EntityProc enter,
- &f.indent;EntityProc leave, pointer private)&e.code;
+ &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. The
+ 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:
@@ -2047,8 +2063,8 @@ Two helper functions are provided to aid configuring entities:
They are passed the entity index and a pointer to a private scratch
area. This are can be set up during &s.code;Probe()&e.code; and
its address can be passed to
- &s.code;xf86ConfigActiveIsaEntity()&e.code;
- &s.code;xf86ConfigActivePciEntity()&e.code; as the last argument.
+ &s.code;xf86ConfigIsaEntity()&e.code;
+ &s.code;xf86ConfigPciEntity()&e.code; as the last argument.
</quote>
</quote>
@@ -2241,9 +2257,19 @@ The function &s.code;xf86FixPciResource()&e.code; can be used to do this:
The driver may replace the generic access control functions for an entity
by it's own ones. This is done with the &s.code;xf86SetAccessFuncs()&e.code;:
<quote><p>
- &s.code;void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86AccessPtr p_io,
- &f.indent;xf86AccessPtr p_mem, xf86AccessPtr p_io_mem,
- &f.indent;xf86AccessPtr *ppAccessOld)&e.code;
+ &s.code;void xf86SetAccessFuncs(EntityInfoPtr pEnt,
+ &f.indent;xf86SetAccessFuncPtr funcs,
+ &f.indent;xf86SetAccessFuncPtr oldFuncs)&e.code;
+ with:
+
+ <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
@@ -2453,6 +2479,12 @@ Next, the higher level functions that most drivers would use.
&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>
@@ -2503,9 +2535,8 @@ Next, the higher level functions that most drivers would use.
&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 a static array of
- &s.code;OptionInfoRecs&e.code; with the &s.code;token&e.code;,
- &s.code;name&e.code;, and &s.code;type&e.code; fields initialised.
+ 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
@@ -2664,6 +2695,7 @@ The following include files are typically required by video drivers:
<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>
@@ -3263,6 +3295,13 @@ typedef struct {
</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 **/
@@ -3279,7 +3318,7 @@ typedef struct {
Bool (*SetMode)(ScrnInfoPtr pScrn, DGAModePtr pMode);
void (*SetViewport)(ScrnInfoPtr pScrn, int x, int y, int flags);
int (*GetViewport)(ScrnInfoPtr pScrn);
- void (*Flush)(ScrnInfoPtr);
+ void (*Sync)(ScrnInfoPtr);
void (*FillRect)(
ScrnInfoPtr pScrn,
int x, int y, int w, int h,
@@ -3395,7 +3434,7 @@ typedef struct {
</quote>
- &s.code;void Flush (pScrn)&e.code;
+ &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
@@ -3746,7 +3785,7 @@ typedef struct {
&s.code;typedef void (* StopVideoFuncPtr)(ScrnInfoPtr pScrn,
&f.indent;pointer data, Bool cleanup)&e.code;
<quote><p>
- This indicates the the driver should stop displaying the video.
+ 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
@@ -4172,7 +4211,7 @@ XFree86 common layer.
parameter passing in other situations.
When loading ``external'' modules (modules that don't
- have the the standard entry point, for example a
+ 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
@@ -4494,15 +4533,16 @@ as
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.
+ &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.
@@ -6183,6 +6223,7 @@ visible symbols.
<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>
@@ -6386,6 +6427,8 @@ static OptionInfoRec ZZZOptions[] = {
{ OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
+
+#define nZZZOptions (sizeof(ZZZOptions) / sizeof(ZZZOptions[0]))
</code>
<p>
</itemize>
@@ -6558,27 +6601,26 @@ ZZZProbe(DriverPtr drv, int flags)
numDevSections, drv, &amp;usedChips);
for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
-
- /* Allocate a ScrnInfoRec */
- pScrn = xf86AllocateScreen(drv, 0);
- 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 */
- xf86ConfigActivePciEntity(pScrn, usedChips[i],
- ZZZPciChipsets, NULL, NULL, NULL, NULL, NULL);
-
+ 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 */
+ }
}
if (numUsed > 0)
xfree(usedChips);
@@ -6593,23 +6635,24 @@ ZZZProbe(DriverPtr drv, int flags)
ZZZIsaChipsets, drv, ZZZFindIsaDevice,
devSections, numDevSections, &amp;usedChips);
for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
-
- 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;
- xf86ConfigActiveIsaEntity(pScrn, usedChips[i], ZZZIsaChipsets,
- NULL, NULL, NULL, NULL, NULL);
+ 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;
+ }
}
if (numUsed > 0)
xfree(usedChips);
@@ -6668,6 +6711,8 @@ ZZZProbe(DriverPtr drv, int flags)
static Bool
ZZZPreInit(ScrnInfoPtr pScrn, int flags)
{
+ OptionInfoRec options[nZZZOptions];
+
/* Fill in the monitor field */
pScrn->monitor = pScrn->confScreen->monitor;
@@ -6746,9 +6791,10 @@ ZZZPreInit(ScrnInfoPtr pScrn, int flags)
/*
* Process the options based on the information in ZZZOptions.
- * The results are written to ZZZOptions.
+ * The results are written to options.
*/
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ZZZOptions);
+ (void)memcpy(options, ZZZOptions, sizeof(ZZZOptions));
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, options);
/*
* Set various fields of ScrnInfoRec and/or ZZZRec based on
@@ -6756,25 +6802,25 @@ ZZZPreInit(ScrnInfoPtr pScrn, int flags)
*/
from = X_DEFAULT;
pZzz->hwCursor = FALSE;
- if (xf86IsOptionSet(ZZZOptions, OPTION_HW_CURSOR)) {
+ if (xf86IsOptionSet(options, OPTION_HW_CURSOR)) {
from = X_CONFIG;
pZzz->hwCursor = TRUE;
}
xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
pZzz->hwCursor ? "HW" : "SW");
- if (xf86IsOptionSet(ZZZOptions, OPTION_NOACCEL)) {
+ if (xf86IsOptionSet(options, OPTION_NOACCEL)) {
pZzz->noAccel = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"Acceleration disabled\n");
} else {
pZzz->noAccel = FALSE;
}
- if (xf86IsOptionSet(ZZZOptions, OPTION_PCI_RETRY)) {
+ if (xf86IsOptionSet(options, OPTION_PCI_RETRY)) {
pZzz->UsePCIRetry = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n");
}
pZzz->fooHack = 0;
- if (xf86GetOptValInteger(ZZZOptions, OPTION_FOO_HACK,
+ if (xf86GetOptValInteger(options, OPTION_FOO_HACK,
&amp;pZzz->fooHack)) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Foo Hack set to %d\n",
pZzz->fooHack);
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml
index 895ce09a7..9a5d2a8dc 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml
@@ -3,17 +3,17 @@
]>
<!-- Created: Mon Feb 28 13:00:00 2000 by brian@precisioninsight.com -->
-<!-- Revised: Mon Mar 6 20:10:02 2000 by kevin@precisioninsight.com -->
+<!-- Revised: Fri May 19 09:41:48 2000 by martin@valinux.com -->
<article>
- <title>DRI Users Guide
+ <title>DRI User Guide
<author><htmlurl url="http://www.precisioninsight.com/"
name="Precision Insight, Inc.">
- <date>6 March 2000
+ <date>18 May 2000
<ident>
- $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.3 2000/03/08 05:38:41 dawes Exp $
+ $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRI.sgml,v 1.5 2000/06/17 00:03:17 martin Exp $
</ident>
<toc>
@@ -25,7 +25,7 @@
<bf>Copyright &copy; 2000 by Precision Insight, Inc.,
Cedar Park, Texas.
All Rights Reserved.</bf>
- <p>
+<p>
<bf>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.</bf>
@@ -43,6 +43,8 @@
trademarks of 3Dlabs Inc. Ltd.
3dfx, Voodoo3, Voodoo4, and Voodoo5 are registered trademarks of
3dfx Interactive, Incorporated.
+ Matrox is a registered trademark of Matrox Electronic Systems Ltd.
+ ATI Rage is a registered trademark of ATI Technologies, Inc.
All other trademarks mentioned are the property of their
respective owners.
@@ -60,9 +62,13 @@
software downloads.
<p>
This document does not cover compilation or installation of
- XFree86 4.0;
- it is assumed that you've already installed a Linux distribution which
- includes XFree86 4.0.
+ XFree86 4.0.
+ It is assumed that you've already installed a Linux distribution which
+ includes XFree86 4.0 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 <htmlurl url="http://dri.sourceforge.net/DRIcompile.html"
+ name="http://dri.sourceforge.net/DRIcompile.html">
<sect>Supported Hardware
<p>
@@ -71,8 +77,8 @@
Support for Alpha, and perhaps other CPUs, should be available in the
future.
<p>
- XFree86 4.0 includes 3D acceleration for the following
- graphics hardware:
+ XFree86 4.0 (or later versions) includes 3D acceleration for the
+ following graphics hardware:
<itemize>
<item>3dfx:
@@ -87,15 +93,35 @@
</itemize>
There are many configurations of 3dfx cards on the market.
Not all have been tested.
+ <item>Matrox:
+ <itemize>
+ <item>Matrox G200
+ <item>Matrox G400
+ </itemize>
+ <item>Intel i810
+ <itemize>
+ <item>i810
+ <item>i810-dc100
+ <item>i810e
+ </itemize>
+ <item>ATI Rage 128
+ <itemize>
+ <item>Rage Fury AGP
+ <item>Rage Magnum AGP
+ <item>XPERT 2000 AGP
+ <item>XPERT 128 AGP
+ <item>XPERT 99 AGP
+ <item>All-in-Wonder 128 AGP
+ </itemize>
+ The PCI versions of these cards also have minimal support.
+ Note that there are also Rage 128 Pro based boards on the
+ market, and these are not yet supported.
<item>3Dlabs Oxygen GMX 2000 (MX/Gamma based)
</itemize>
<p>
Support for the following hardware is underway:
<itemize>
- <item>Intel i810
- <item>Matrox G400
- <item>ATI Rage 128
<item>3dfx Voodoo4 and Voodoo5 series
</itemize>
@@ -104,8 +130,11 @@
<p>
<itemize>
<item>XFree86 4.0
- <item>Linux kernel 2.2.x (later kernels will be supported in
+ <item>For the 3dfx Voodoo3 driver, Linux kernel 2.2.x (later
+ kernels will be supported in
the near future, and may be required for some chipsets)
+ <item>For the Matrox G200/G400, Linux kernel 2.3.51, with AGP support
+ <item>For the Intel i810, Linux kernel 2.3.99-pre6, with AGP support
</itemize>
<p>
Mesa 3.3 (beta) is included with XFree86 4.0; there is no need to
@@ -119,20 +148,17 @@
<sect1>Kernel module
<p>
- Before starting the X server you must install the correct kernel
- module for your hardware.
- <p>
- This can be done by executing the following as root:
- <verb>
- insmod XXX/drivername.o
- </verb>
- <p>
- For example, on 3dfx hardware, the kernel module is called tdfx.o
- so you you would type insmod XXX/tdfx.o
-
- <p>
- Verify that the kernel module was installed by checking that
- /proc/dri/0 exists.
+ XFree86 4.0.1 added automatic kernel module loading to the X server.
+ On Linux, the X server uses modprobe to load kernel modules.
+ The DRM kernel modules should be in /lib/modules/KERNEL-VERSION/misc/
+ for automatic loading to work.
+<p>
+ Optionally, DRM kernel modules can be loaded manually with insmod
+ prior to starting the X server.
+<p>
+ You can verify that the kernel module was installed with lsmod,
+ checking the X server startup log, and checking that /proc/dri/0
+ exists.
<sect1>XF86Config file
<p>
@@ -199,6 +225,7 @@
<p>
Next, the Device section of the XF86Config file must describe your
particular hardware.
+ <p>
For example, here's the Device section for a 3dfx Voodoo3 card:
<verb>
@@ -210,6 +237,37 @@
</verb>
<p>
+ Here's the Device section for a Matrox G400 card:
+ <verb>
+ Section "Device"
+ Identifier "G400"
+ VendorName "Matrox"
+ Driver "mga"
+ VideoRam 32768
+ EndSection
+ </verb>
+
+ <p>
+ Here's the Device section for an ATI Rage 128 card:
+ <verb>
+ Section "Device"
+ Identifier "Rage128"
+ VendorName "ATI"
+ Driver "r128"
+ EndSection
+ </verb>
+
+ Here's the Device section for an Intel i810 motherboard:
+ <verb>
+ Section "Device"
+ Identifier "i810"
+ VendorName "Intel"
+ Driver "i810"
+ VideoRam 10000
+ EndSection
+ </verb>
+
+ <p>
Finally, the Screen section of the XF86Config file may have to be
specially configured as well.
For example, Voodoo3 hardware acceleration is only available
@@ -227,7 +285,10 @@
EndSubsection
EndSection
</verb>
-
+ <p>
+ Replace <em>Voodoo3</em> with <em>G400</em> for Matrox G400.
+ <p>
+ Replace <em>Voodoo3</em> with <em>Rage128</em> for ATI Rage 128.
<p>
If there are errors in the XF86Config file, the X server will
log errors to the file /var/log/XFree86.0.log
@@ -301,6 +362,25 @@
if means that the libGL.so.1 file is not the right location.
Proceed to the trouble shooting section.
+ <sect1>libOSMesa.so
+<p>
+ 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.
+<p>
+ libOSMesa.so implements the OSMesa interface and must be linked
+ with your application if you want to use the OSMesa functions.
+ You must also link with libGL.so. For example:
+ <verb>
+ gcc osdemo.c -L/usr/X11R6/lib -lOSMesa -lGLU -lGL -o osdemo
+ </verb>
+<p>
+ 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.
+<p>
+
<sect1>glxinfo
<p>
glxinfo is a useful program for checking which version of
@@ -346,20 +426,25 @@
<enum>
<item>
<tt/LIBGL_DEBUG/, if defined will cause libGL.so to print error
- and diagnostic messages. This can help to solve problems.
+ and diagnostic messages.
+ This can help to solve problems.
+ Setting <tt/LIBGL_DEBUG/ to <tt/verbose/ may provide additional
+ information.
<item>
<tt/LIBGL_ALWAYS_INDIRECT/, if defined this will force libGL.so
to always use indirect rendering instead of hardware
- acceleration.
+ acceleration.
This can be useful to isolate rendering errors.
<item>
- <tt/LIBGL_DRIVERS_DIR/ can be used to override the default
- directory which is searched for 3D drivers.
+ <tt/LIBGL_DRIVERS_PATH/ can be used to override the default
+ directories which are searched for 3D drivers.
+ The value is one or more paths separated by colons.
In a typical XFree86 installation, the 3D drivers should be in
- /usr/X11R6/lib/modules/dri/.
- This environment variable can be used to specify a different
- directory.
+ /usr/X11R6/lib/modules/dri/ and <tt/LIBGL_DRIVERS_PATH/ need
+ not be defined.
Note that this feature is disabled for set-uid programs.
+ This variable replaces the <tt/LIBGL_DRIVERS_DIR/ env var used
+ in XFree86 4.0.
</enum>
<p>
Mesa-based drivers (this includes most of the drivers listed
@@ -531,6 +616,40 @@
<sect1>3dfx Voodoo3
<p>
+ <sect2>Configuration
+<p>
+ Your XF86Config file's device section must specify the
+ <tt>tdfx</tt> device:
+ <verb>
+ Section "Device"
+ Identifier "Voodoo3"
+ VendorName "3dfx"
+ Driver "tdfx"
+ EndSection
+ </verb>
+ The Screen section should then reference the Voodoo3 device:
+ <verb>
+ 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
+ </verb>
+ <p>
+ The kernel module for the Voodoo3 is named <tt>tdfx.o</tt> and
+ should be installed in /lib/modules/KERNEL-VERSION/misc/.
+ It will be automatically loaded by the Xserver if needed.
+ <p>
+ The DRI 3D driver for the Voodoo3 should be in
+ <tt>/usr/X11R6/lib/modules/dri/tdfx_dri.so</tt>.
+ This will be automatically loaded by libGL.so.
+
<sect2>Troubleshooting
<p>
<itemize>
@@ -539,6 +658,9 @@
bit/pixel screen mode.
Use <tt/xdpyinfo/ to verify that all your visuals are depth 16.
Edit your XF86Config file if needed.
+ <item>
+ The <tt>/dev/3dfx</tt> device is not used for DRI; it's only for
+ Glide on older 3dfx hardware.
</itemize>
<sect2>Performance
@@ -565,6 +687,9 @@
<p>
<itemize>
<item>
+ Glide cannot be used directly; only OpenGL-based programs are
+ supported on the Voodoo3.
+ <item>
SSystem has problems because of poorly set near and far
clipping planes.
The office.unc Performer model also suffers from this problem.
@@ -573,10 +698,182 @@
<sect1>Intel i810
<p>
- <sect1>Matrox G400
+ <sect2>Configuration
+<p>
+ Your XF86Config file's device section must specify the
+ <tt>i810</tt> device, and specify a usable amount of video
+ ram to reserve.
+ <verb>
+ Section "Device"
+ Identifier "i810"
+ VendorName "Intel"
+ Driver "i810"
+ VideoRam 10000
+ EndSection
+ </verb>
+ The Screen section should then reference the i810 device:
+ <verb>
+ 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
+ </verb>
+ <p>
+ The kernel module for the i810 is named <tt>i810.o</tt> and
+ should be installed in /lib/modules/KERNEL-VERSION/misc/.
+ It will be automatically loaded by the Xserver if needed.
+ <p>
+ The DRI 3D driver for the i810 should be in
+ <tt>/usr/X11R6/lib/modules/dri/i810_dri.so</tt>.
+ This will be automatically loaded by libGL.so.
+
+ <sect2>Troubleshooting
+<p>
+ <itemize>
+ <item>
+ 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 <tt/xdpyinfo/ to verify that all your visuals are depth 16.
+ Edit your XF86Config file if needed.
+ <item>
+ 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
+ number 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.
+ </itemize>
+
+<p>
+
+ <sect1>Matrox G200 and G400
+<p>
+ <sect2>Configuration
<p>
+ Your XF86Config file's device section must specify the
+ <tt>mga</tt> device:
+ <verb>
+ Section "Device"
+ Identifier "MGA"
+ VendorName "Matrox"
+ Driver "mga"
+ EndSection
+ </verb>
+ The Screen section should then reference the MGA device:
+ <verb>
+ 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
+ </verb>
+ <p>
+ The kernel module for the G200/G400 is named <tt>mga.o</tt> and
+ should be installed in /lib/modules/KERNEL-VERSION/misc/.
+ It will be automatically loaded by the Xserver if needed.
+ <p>
+ The DRI 3D driver for the G200/G400 should be in
+ <tt>/usr/X11R6/lib/modules/dri/mga_dri.so</tt>.
+ This will be automatically loaded by libGL.so.
+
+ <sect2>Troubleshooting
+<p>
+ <itemize>
+ <item>
+ 3D acceleration for the G200 and G400 is only supported in the 16
+ bit/pixel screen mode at this time. 32bpp will be supported
+ in the future.
+ Use <tt/xdpyinfo/ to verify that all your visuals are depth 16.
+ Edit your XF86Config file if needed.
+ </itemize>
+
+ <sect2>Performance
+<p>
+ No data at this time.
+
+ <sect2>Known Problems
+<p>
+ <itemize>
+ <item>
+ Multitexture is currently disabled on the G400 to work
+ around a hardware lockup bug. This should be restored in
+ a subsequent release.
+ </itemize>
+
+
<sect1>ATI Rage 128
<p>
+ <sect2>Configuration
+<p>
+ Your XF86Config file's device section must specify the
+ <tt>r128</tt> device:
+ <verb>
+ Section "Device"
+ Identifier "Rage128"
+ VendorName "ATI"
+ Driver "r128"
+ EndSection
+ </verb>
+ The Screen section should then reference the Rage 128 device:
+ <verb>
+ 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
+ </verb>
+ <p>
+ The kernel module for the Rage 128 is named <tt>r128.o</tt> and
+ should be installed in /lib/modules/KERNEL-VERSION/misc/.
+ It will be automatically loaded by the Xserver if needed.
+ <p>
+ The DRI 3D driver for the Rage 128 should be in
+ <tt>/usr/X11R6/lib/modules/dri/r128_dri.so</tt>.
+ This will be automatically loaded by libGL.so.
+ <p>
+ You may also set your screen depth to 32 for 32bpp mode.
+ <p>
+
+ <sect2>Performance
+<p>
+ 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.
+
+ <sect2>Known Problems
+<p>
+ DGA is not yet supported in the ATI Rage 128 X server. This
+ feature will be added in a future release.
+
+
<sect1>3DLabs Oxygen GMX 2000
<p>
The driver for this hardware was experimental and is no longer being
@@ -621,6 +918,50 @@
which will be addressed in the future.
+ <sect1>libGL.so and dlopen()
+<p>
+ 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.
+<p>
+ 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:
+ <itemize>
+ <item>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_Context is undefined when libGL.so
+ tries to open a hardware-specific driver.
+ Without this flag, <em>nested</em> opening of dynamic libraries
+ does not work.
+ <item>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.
+ <item>
+ Your application should link with -lpthread.
+ On Linux, libGL.so uses the pthreads library in order to provide
+ thread safety.
+ There is apparently 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.
+ </itemize>
+
+ 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.
+
+
<sect1>Bug Database
<p>
The DRI bug database which includes bugs related to specific
@@ -654,6 +995,9 @@
<item>Visit the <htmlurl url="http://dri.sourceforge.net"
name="DRI project on SourceForge.net"> for the latest development
news about the DRI and 3D drivers.
+ <item>The <htmlurl url="http://dri.sourceforge.net/DRIcompile.html"
+ name="DRI Compilation Guide"> explains how to download, compile
+ and install the DRI for yourself.
</itemize>
<sect1>Support
@@ -664,54 +1008,13 @@
<htmlurl url="http://sourceforge.net/mail/?group_id=387"
name="SourceForge"> is a forum for people to discuss DRI problems.
<item>
- XXX IHV support?
- <item>
- XXX Linux distro support?
+ In the future there may be IHV and Linux vendor support resources
+ for the DRI.
</itemize>
</article>
-<!--
-1. Introduction
-2. Supported Hardware
-3. Prerequisite Software
-4. Start-Up
-5. Using 3D Acceleration
- 5.1 libGL.so
- 5.2 glxinfo
- 5.3 Environment variables
-6. General Trouble Shooting
-7. Hardware-Specific Information
- 7.1 3dfx
- 7.2 Intel i810
- 7.3 Matrox G400
- 7.4 ATI Rage 128
- 7.5 3DLabs Gamma
-8. Limitation and Known Bugs
- 8.1 OpenGL
- 8.2 GLX
- 8.3 Signal Handling
- 8.4 Scheduling
- 8.5 Bug Database
-9. Resources
- 9.1 Software Resources
- GLU
- GLUT
- Glide3
- Utilities and demos
- Sample XF86Config files
- 9.2 Documentation
- www.XFree86.org
- www.opengl.org
- www.linux.com
- www.precisioninsight.com
- sourceforge.net
- 9.3 Support
- IHVs
- RedHat
- -->
-
<!-- Local Variables: -->
<!-- fill-column: 72 -->
<!-- End: -->
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
new file mode 100644
index 000000000..b6790741a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml
@@ -0,0 +1,490 @@
+<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN" [
+<!ENTITY % defs SYSTEM "defs.ent"> %defs;
+]>
+
+<!-- Created: Sun Mar 12 13:00:00 2000 by brian@precisioninsight.com -->
+<!-- Revised: Fri May 19 09:36:02 2000 by martin@valinux.com -->
+
+ <article>
+
+ <title>DRI Compilation Guide
+ <author>
+ <htmlurl url="http://www.precisioninsight.com/"
+ name="Precision Insight, Inc.">
+ <date>18 May 2000
+
+ <ident>
+ $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/DRIcomp.sgml,v 1.3 2000/06/17 02:16:49 dawes Exp $
+ </ident>
+
+ <toc>
+
+ <sect>Preamble <p>
+ <sect1>Copyright <p>
+ <bf>Copyright &copy; 2000 by Precision Insight, Inc.,
+ Cedar Park, Texas.
+ All Rights Reserved.</bf>
+ <p>
+ <bf>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.</bf>
+
+ <sect1>Trademarks <p>
+ 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 Interactive, Incorporated.
+ Matrox is a registered trademark of Matrox Electronic Systems Ltd.
+ ATI Rage is a registered trademark of ATI Technologies, Inc.
+ All other trademarks mentioned are the property of their
+ respective owners.
+
+
+ <sect>Introduction <p>
+ This document describes how to download, compile and install the
+ DRI project.
+ This information is intended for experienced Linux developers.
+ Beginners are probably better off installing precompiled packages.
+ <p>
+ Edits, corrections and updates to this document may be mailed
+ to brian@precisioninsight.com.
+
+
+ <sect>Prerequisites <p>
+ You'll need the following:
+ <itemize>
+ <item>At least 400MB of free disk space. More is needed if you want
+ to build with debugging information or keep several build trees.
+ <item>A fast system. Using a PIII-550 it takes about 1/2 hour to
+ build everything.
+ <item>GCC compiler and related tools.
+ <item>ssh (secure shell) for registered developer downloading of the
+ DRI source tree
+ </itemize>
+
+ <p>
+ For 3dfx Voodoo3 hardware, you'll also need:
+ <itemize>
+ <item>Glide3x headers and runtime library if you want to use the
+ 3dfx driver.
+ These can be obtained from
+ <htmlurl url="http://linux.3dfx.com/open_source/glide_kit.htm"
+ name="linux.3dfx.com">.
+ <item>Linux kernel 2.2.x.
+ The DRI developers have been using stock RedHat 6.1 systems
+ (kernel 2.2.12-20).
+ Later kernel versions will be supported in the future.
+ </itemize>
+
+ <p>
+ For Matrox G200/G400 hardware, you'll also need:
+ <itemize>
+ <item>Linux kernel 2.3.51. Older kernel versions will not work.
+ </itemize>
+
+ <p>
+ For Intel i810 hardware, you'll also need:
+ <itemize>
+ <item>Linux kernel 2.3.99-pre6. Older kernel versions will not work.
+ </itemize>
+
+ <p>
+ For ATI Rage hardware, you'll also need:
+ <itemize>
+ <item>Linux kernel 2.3.51. Other kernel versions may work but
+ this one is known to work.
+ </itemize>
+
+
+ <sect>Kernel preparation <p>
+ You may have to upgrade your Linux kernel in order to use the DRI.
+ This is because you need a kernel version which supports AGP.
+ 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.
+ <p>
+ Linux kernels can be downloaded from
+ <htmlurl url="http://www.kernel.org/pub/linux/kernel/"
+ name="www.kernel.org">
+ <p>
+ Download the needed kernel and put it in /usr/src.
+ Create a directory for the source and unpack it.
+ For example:
+ <verb>
+ cd /usr/src
+ rm -f linux
+ mkdir linux-2.3.51
+ ln -s linux-2.3.51 linux
+ bzcat linux-2.3.51.tar.bz2 | tar xf -
+ </verb>
+ <p>
+ Now configure your kernel.
+ You might, for example, use <tt>make menuconfig</tt> and do the
+ following:
+
+ <itemize>
+ <item>Go to <em>Code maturity level options</em>
+ <item>Enable <em>Prompt for development and/or incomplete
+ code/drivers</em>
+ <item>hit ESC
+ <item>Go to <em>Character devices</em>
+ <item>Disable <em>Direct Rendering Manager (XFree86 DRI support)</em>
+ since we'll use the DRI module from the XFree86/DRI tree.
+ <item>Go to <em>/dev/agpgart (AGP Support) (EXPERIMENTAL) (NEW)</em>
+ <item>Hit SPACE twice
+ <item>Enable all chipsets' support for AGP
+ </itemize>
+
+ <p>It's recommended that you turn on MTRRs under <em>Processor type
+ and Features</em>, but not required.
+
+ <p>
+ Configure the rest of the kernel as required for your system
+ (i.e. Ethernet, SCSI, etc)
+ <p>
+ Exit, saving your kernel configuration.
+ <p>
+ Edit your /etc/lilo.conf file.
+ Make sure you have an image entry as follows (or similar):
+ <verb>
+ image=/boot/vmlinuz
+ label=linux.2.3.51
+ read-only
+ root=/dev/hda1
+ </verb>
+ <p>
+ 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.
+
+ <p>
+ Now compile the new kernel:
+
+ <verb>
+ cd /usr/src/linux-2.3.51
+ make dep ; make bzImage
+ make modules ; make modules_install
+ make install
+ </verb>
+ Note that the final part, make install, will automatically run
+ lilo for you.
+ <p>
+ Now reboot to use this new kernel.
+
+
+ <sect>Downloading the XFree86/DRI CVS Sources <p>
+ The DRI project is hosted by VA Linux Systems'
+ <htmlurl url="http://sourceforge.net/project/?group_id=387"
+ name="SourceForge">.
+ The DRI source code, which is a subset of the XFree86 source tree,
+ is kept in a CVS repository there.
+ <p>
+ 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.
+
+ <sect1>Anonymous CVS download: <p>
+ <enum>
+ <item>Create a directory to store the CVS files:
+ <p>
+ <verb>
+ cd ~
+ mkdir DRI-CVS
+ </verb>
+ You could put your CVS directory in a different place but we'll
+ use <tt>~/DRI-CVS/</tt> here.
+ <p>
+ <item>Check out the CVS sources:
+ <p>
+ <verb>
+ 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
+ </verb>
+ <p>
+ The -z3 flag causes compression to be used in order to reduce
+ the download time.
+ </enum>
+
+
+ <sect1>Registered CVS download: <p>
+ <enum>
+ <item>Create a directory to store the CVS files:
+ <p>
+ <verb>
+ cd ~
+ mkdir DRI-CVS
+ </verb>
+ You could put your CVS directory in a different place but we'll
+ use <tt>~/DRI-CVS/</tt> here.
+ <p>
+ <item>Set the CVS_RSH environment variable:
+ <p>
+ <verb>
+ setenv CVS_RSH ssh // if using csh or tcsh
+ export CVS_RSH=ssh // if using sh or bash
+ </verb>
+ <item>Check out the CVS sources:
+ <p>
+ <verb>
+ cd ~/DRI-CVS
+ cvs -z3 -dYOURID@cvs.dri.sourceforge.net:/cvsroot/dri co xc
+ </verb>
+ Replace <tt>YOURID</tt> with your CVS login name.
+ You'll be prompted to enter your sourceforge password.
+ <p>
+ The -z3 flag causes compression to be used in order to reduce
+ the download time.
+ </enum>
+
+
+ <sect>Updating your CVS sources <p>
+ 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:
+ <verb>
+ cd ~/DRI-CVS
+ cvs -z3 update -dA xc
+ </verb>
+ The -d flag causes any new subdirectories to be created and -A causes
+ most recent trunk sources to be fetched, not branch sources.
+
+
+ <sect>Compiling the XFree86/DRI tree <p>
+ <sect1>Make a build tree <p>
+ Rather than placing object files and library files right in the
+ source tree, they're instead put into a parallel <em>build</em> tree.
+ The build tree is made with the <tt>lndir</tt> command:
+ <verb>
+ cd ~/DRI-CVS
+ ln -s xc XFree40
+ mkdir build
+ cd build
+ lndir -silent -ignorelinks ../XFree40
+ </verb>
+ <p>
+ The build tree will be populated with symbolic links which point
+ back into the CVS source tree.
+ <p>
+ Advanced users may have several build trees for compiling and
+ testing with different options.
+
+ <sect1>Edit the host.def file <p>
+ The <tt>~/DRI-CVS/build/xc/config/cf/host.def</tt> 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
+ <p>
+ The default <tt>host.def</tt> file will look something like this:
+ <verb>
+ #define DefaultCCOptions -Wall
+ #define DefaultGcc2i386Opt -O2
+ #define LibraryCDebugFlags -O2
+ #define BuildServersOnly YES
+ #define XF86CardDrivers vga tdfx mga r128 i810
+ #define LinuxDistribution LinuxRedHat
+ #define DefaultCCOptions -ansi GccWarningOptions -pipe
+ #define BuildXF86DRI YES
+ #define HasGlide3 YES
+ /* Optionally turn these on for debugging */
+ /* #define GlxBuiltInTdfx YES */
+ /* #define GlxBuiltInMga YES */
+ /* #define GlxBuiltInR128 YES */
+ /* #define DoLoadableServer NO */
+ #define SharedLibFont NO
+ </verb>
+ The <tt>ProjectRoot</tt> variable specifies where the XFree86 files
+ will be installed.
+ You probably don't want to use <tt>/usr/X11R6/</tt> because that
+ would overwrite your default X files.
+ The following is recommended:
+ <verb>
+ #define ProjectRoot /usr/XF86-main
+ </verb>
+ <p>
+ Especially note the <em>XF86CardDrivers</em> line to be sure your
+ driver is listed.
+ <p>
+ If you have 3dfx hardware be sure that the Glide 3x headers are
+ installed in <tt>/usr/include/glide3/</tt> and that the Glide 3x
+ library is installed at <tt>/usr/lib/libglide3x.so</tt>.
+ <p>
+ If you do not have 3dfx hardware comment out the <tt>HasGlide3</tt>
+ line in <tt>host.def</tt>.
+ <p>
+
+ <sect1>Compile <p>
+ To compile the complete DRI tree:
+ <verb>
+ cd ~/DRI-CVS/build/xc/
+ make World >& World.LOG
+ </verb>
+ Or if you want to watch the compilation progress:
+ <verb>
+ cd ~/DRI-CVS/build/xc/
+ make World >& World.LOG &
+ tail -f World.LOG
+ </verb>
+ With the default compilation flags it's normal to get a lot of
+ warnings during compilation.
+ <p>
+ Building will take some time so you may want to go check your
+ email or visit slashdot.
+
+ <sect1>Check for compilation errors <p>
+ Using your text editor, examine <tt>World.LOG</tt> for errors
+ by searching for the pattern <tt>***</tt>.
+ <p>
+ Verify that the DRI kernel module(s) for your system were built:
+ <verb>
+ cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+ ls
+ </verb>
+ <p>
+ For the 3dfx Voodoo, you should see <em>tdfx.o</em>.
+ For the Matrox G200/G400, you should see <em>mga.o</em>.
+ For the ATI Rage 128, you should see <em>r128.o</em>.
+ For the Intel i810, you should see <em>i810.o</em>.
+ <p>
+ 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.
+ <p>
+ If your build machine is running a different version of the kernel
+ than your target machine (i.e. 2.2.12-20 vs. 2.3.99-pre6), make will
+ select the wrong kernel headers. This can be fixed by explicitly
+ setting the value of <tt>TREE</tt>.
+ If the path to your kernel source is
+ <tt>/bigdisk/linux-2.3.99-pre6</tt>,
+ <verb>
+ cd ~/DRI-CVS/build/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel
+ make TREE=/bigdisk/linux-2.3.99-pre6
+ </verb>
+ or alternatively, edit Makefile to include this change.
+ <p>
+ After fixing the errors, do <tt>make World</tt> again.
+ Later, you might just compile parts of the source tree but it's
+ important that the whole tree will build first.
+
+
+ <sect>Installing <p>
+ After the DRI tree has been compiled you can install the XFree86
+ headers, libraries, programs, etc for testing.
+
+ <sect1>X Installation <p>
+ As mentioned above, the install directory is specified by the
+ <tt>ProjectRoot</tt> variable in the <tt>host.def</tt> file.
+ Create that directory now if it doesn't already exist:
+ <verb>
+ mkdir /usr/XF86-main
+ </verb>
+ <p>
+ You'll have to change to root since the install process puts
+ several files in <tt>/etc/X11/</tt> and sets the setuid flag on
+ the X server executable.
+ <verb>
+ cd ~/DRI-CVS/build/xc
+ su
+ make install
+ </verb>
+ Edit your <tt>/etc/ld.so.conf</tt> file and put
+ <tt>/usr/XF86-main/lib</tt> as the first line.
+ Continue with:
+ <verb>
+ ldconfig
+ exit
+ </verb>
+ <p>
+ Look in <tt>/usr/XF86-main</tt> to be sure the files installed
+ there.
+ <P>
+ Strictly speaking, installing the DRI tree isn't required.
+ It's possible to run and test the X server directly from the
+ build directory but it's a bit error prone.
+
+ <sect1>Update Locale Information <p>
+ To update your X locale information do the following:
+ <verb>
+ cd ~/DRI-CVS/build/xc/nls
+ xmkmf -a
+ make
+ make install
+ </verb>
+ This will prevent a locale error message from being printed
+ when you run Xlib programs.
+
+ <sect>X Server Configuration <p>
+ If your X server is currently running you'll have to stop it
+ and return to a virtual terminal.
+ <p>
+ First, setup your XF86Config file.
+ It should load the GLX and DRI modules and specify the driver to
+ use for your hardware.
+ See the <htmlurl url="http://dri.sourceforge.net/DRIuserguide.html"
+ name="DRI User Guide"> for detailed information.
+ <p>
+ You may want to make a backup copy of your existing
+ <tt>/etc/X11/XF86Config</tt> file first.
+ <p>
+ It's very important that you set the <tt>ModulePath</tt> option to
+ point to your installation directory:
+ <verb>
+ ModulePath "/usr/XF86-main/lib/modules"
+ </verb>
+ <p>
+ Double check with this:
+ <verb>
+ grep ModulePath /etc/X11/XF86Config
+ </verb>
+ <p>
+ Next, your <tt>~/.xinitrc</tt> file controls which clients will be
+ launched when your X server starts.
+ You might put the following in yours:
+ <verb>
+ xset b off
+ xsetroot -solid "#004070"
+ xmodmap -e "clear mod4"
+ xrdb -merge ~/.Xdefaults
+ xterm -geometry +0+0 &
+ xterm -geometry +512+0 &
+ fvwm
+ </verb>
+ <p>
+
+ <sect>X Server Start-up <p>
+ The X server can be started with:
+ <p>
+ <verb>
+ xinit -- /usr/XF86-main/bin/XFree86
+ </verb>
+ <p>
+ Automatic loading of DRM kernel modules was added to the X server
+ in XFree86 4.0.1.
+ This feature, and manual loading of kernel modules, is documented
+ in the DRI user guide.
+ <p>
+ At this point your X server should be up and running with
+ hardware-accelerated direct rendering.
+ Please read the
+ <htmlurl url="http://dri.sourceforge.net/DRIuserguide.html"
+ name="DRI User Guide"> for trouble shooting information.
+
+
+ </article>
+
+
+ <!-- Local Variables: -->
+ <!-- fill-column: 72 -->
+ <!-- End: -->
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml
index 89c1eedb5..1596263a3 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml
@@ -237,6 +237,13 @@ by default with the syscons driver. To configure your kernel similarly
it should have a line like this in <tt>/usr/src/sys/i386/conf/GENERIC</tt>:
<tscreen><verb>
+ device sc0 at isa? tty
+</verb></tscreen>
+
+The above example is for FreeBSD version 3.1 or later. If you are running
+earlier versions, use the following line instead.
+
+<tscreen><verb>
device sc0 at isa? port "IO_KBD" tty irq 1 vector scintr
</verb></tscreen>
@@ -272,6 +279,13 @@ The bus mouse driver and the PS/2 mouse driver may not be included, or
may be included but disabled in your kernel. If you intend to use
these mice, verify the following lines in the kernel configuration file:
+<tscreen><verb>
+ device mse0 at isa? port 0x23c tty irq 5
+ device psm0 at isa? tty irq 12
+</verb></tscreen>
+
+The above example is for FreeBSD version 3.1 or later. If you are running
+earlier versions, use the following lines instead.
<tscreen><verb>
device mse0 at isa? port 0x23c tty irq 5 vector mseintr
@@ -352,7 +366,7 @@ Many thanks to:
</itemize>
<verb>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml,v 3.30 2000/02/10 22:33:36 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/FreeBSD.sgml,v 3.31 2000/03/31 22:55:36 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile b/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile
index b5f23d1c4..7fab6a1ce 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile
@@ -3,16 +3,17 @@ XCOMM $XConsortium: Imakefile /main/16 1996/10/28 05:13:04 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile,v 3.61 2000/03/08 05:38:42 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Imakefile,v 3.64 2000/06/17 02:16:49 dawes Exp $
#include <Server.tmpl>
#include <lnxdoc.rules>
SGMLDEPENDS = defs.ent
+MANSGMLDEPENDS = mdefs.ent
INDEXLIST = README.sgml RELNOTES.sgml Status.sgml LICENSE.sgml Install.sgml \
DESIGN.sgml \
- mouse.sgml fonts.sgml DRI.sgml \
- isc.sgml LynxOS.sgml NetBSD.sgml OpenBSD.sgml \
+ mouse.sgml fonts.sgml DRI.sgml DRIcomp.sgml \
+ isc.sgml LynxOS.sgml NetBSD.sgml OpenBSD.sgml OS2note.sgml \
apm.sgml ati.sgml chips.sgml cyrix.sgml DECtga.sgml \
i740.sgml i810.sgml \
r128.sgml rendition.sgml s3virge.sgml SiS.sgml
@@ -33,7 +34,9 @@ LinuxDocReadmeTarget(NetBSD)
LinuxDocReadmeTarget(OpenBSD)
#ifdef OUTOFDATE
LinuxDocReadmeTarget(OS2)
+#endif
LinuxDocTargetLong(OS2note.sgml,OS2.Notes,OS2Notes)
+#ifdef OUTOFDATE
LinuxDocReadmeTarget(SCO)
LinuxDocReadmeTarget(SOLX86)
LinuxDocReadmeTarget(SVR4)
@@ -108,9 +111,21 @@ LinuxDocTargetLong(VidModes.sgml,VideoModes.doc,VideoModes)
LinuxDocTarget(xinput)
#endif
LinuxDocReadmeTarget(DRI)
+LinuxDocReadmeTarget(DRIcomp)
+
+SGMLMANDEFS=-D__drivermansuffix__='"$(DRIVERMANSUFFIX)"' \
+ -D__filemansuffix__='"$(FILEMANSUFFIX)"' \
+ -D__miscmansuffix__='"$(MISCMANSUFFIX)"'
+
+#if BuildHtmlManPages
+HTMLMANDEFS=-DHTML_MANPAGES
+#endif
+
+AllTarget(mdefs.ent)
+CppRawFileTarget(mdefs.ent,mdefs.cpp,$(SGMLMANDEFS) $(HTMLMANDEFS),NullParameter)
/* Generate the documentation index */
-index.sgml: $(INDEXLIST) index.pre index.post add.sh Imakefile $(SGMLDEPENDS)
+index.sgml: $(INDEXLIST) index.pre index.post add.sh Imakefile $(SGMLDEPENDS) $(MANSGMLDEPENDS)
RemoveFile(index.sgml)
cat index.pre > index.sgml
echo "<!-- This file is auto-generated. Do not edit! -->" >> index.sgml
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml
index 8aebef382..726e481b4 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml
@@ -6,16 +6,15 @@
<title>Installation Details for XFree86&trade; &relvers;
<author>The XFree86 Project, Inc
-<date>29 February 2000
+<date>30 June 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.4 2000/02/29 18:01:17 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Install.sgml,v 1.6 2000/07/02 02:35:27 dawes Exp $
</ident>
<abstract>
-This document contains information about installing
-XFree86 &relvers;.
+How to install XFree86.
</abstract>
@@ -23,21 +22,19 @@ XFree86 &relvers;.
<sect>Introduction
<p>
-This document contains information about installing XFree86 &relvers;
-binary distributions as provided by The XFree86 Project. The installation
-procedures for binary distributions provided by others may be different.
-
-The XFree86 binary distributions that we provide for UNIX-like OSs are
-packaged in the platform-independent gzipped tar format (referred to as
-"tarballs"). Our tarballs can be identified by the "<tt>.tgz</tt>"
-suffix. We do not provide binaries in RPM format or any other platform
-specific package format. If you need them in such a format, you should
-contact your OS vendor. Together with the binary distributions, we
-provide a customised version of GNU tar called "extract", and an
-installation script. We recommend that these be used to install the
-binary distributions.
-
-<sect>How to get the XFree86 &relvers; binary distributions
+This document contains information about installing the XFree86 binaries
+as provided by The XFree86 Project.
+
+<p>
+The XFree86 binaries that we provide for UNIX-like OS's (Linux, the BSDs
+and Solaris) are packaged in a platform-independent gzipped format (aka
+"tarballs" identified by the <tt>.tgz</tt> suffix). Along with the
+binaries we provide a customized version of the GNU tar utility called
+"extract" and an installation script. We recommend that these be
+used to install the binaries.
+
+
+<sect>Downloading the XFree86 &relvers; binaries
<p>
We, The XFree86 Project, provide XFree86 &relvers; binaries for a range
of operating systems at our
@@ -49,78 +46,82 @@ url="ftp://ftp.xfree86.org/pub/XFree86/snapshots/&relvers/binaries/">.
<url name="ftp site"
url="ftp://ftp.xfree86.org/pub/XFree86/&relvers/binaries/">.
]]>
-Our ftp site is also mirrored by many sites around the world. There is
-a sub-directory for each OS/platform that we have binaries for. The
-first thing you need to do is to decide which of these suits you. In
-most cases, the choice is straightforward. In some cases (e.g., Linux)
-there may be a number of choices depending on what architecture or libc
-version you are using. We recommend that you first download the
-<tt>Xinstall.sh</tt> script, and run it as follows to find out which
-binary distribution you should download.
+Often during releases, our ftp site is heavily loaded. Instead of
+downloading directly from us we recommend that instead you use one of
+our mirror sites. Another advantage of using our mirror sites is that
+some of them support http access (ours does not).
+
+<p>
+Our binaries are organized by sub-directories which correspond to each
+of the OS/platforms for which we provide binaries. First go to the
+sub-directory that represents your OS Platform. In some cases (e.g.,
+Linux) there may be a number of choices depending on the architecture
+or libc version your platform uses. In all case we recommend that you
+first download the <tt>Xinstall.sh</tt> script, and run it as in the
+following example to find out which binary distribution you should
+download.
<tscreen><verb>
sh Xinstall.sh -check
</verb></tscreen>
-This should tell you which binary distribution is the correct one for
-your system. Getting this right may save from wasting time downloading
-the wrong distribution.
+The output of this utility tells you which is the correct set of binaries
+for you to download. If you are careful with this step you will save
+yourself a lot time and trouble from NOT downloading an incompatible
+distribution.
-The next step is to download the necessary files. The mandatory files
-for all installations are listed below. All of them must be downloaded
-to do the installation. The installer script will complain if they are not
-all present.
+Once that is done download the necessary files. The twelve (12)
+mandatory files for all installations are listed below. If you have
+not downloaded all of the files, the installer script will complain.
<quote><verb>
-Xinstall.sh The installer script
-extract The utility for extracting tarballs
-Xbin.tgz X clients/utilities and run-time libraries
-Xlib.tgz Some data files required at run-time
-Xman.tgz Manual pages
-Xdoc.tgz XFree86 documentation
-Xfnts.tgz Base set of fonts
-Xfenc.tgz Base set of font encoding data
-Xetc.tgz Run-time configuration files
-Xvar.tgz Run-time data
-Xxserv.tgz XFree86 X server
-Xmod.tgz XFree86 X server modules
+1. Xinstall.sh The installer script
+2. extract The utility for extracting tarballs
+3. Xbin.tgz X clients/utilities and run-time libraries
+4. Xlib.tgz Some data files required at run-time
+5. Xman.tgz Manual pages
+6. Xdoc.tgz XFree86 documentation
+7. Xfnts.tgz Base set of fonts
+8. Xfenc.tgz Base set of font encoding data
+9. Xetc.tgz Run-time configuration files
+10. Xvar.tgz Run-time data
+11. Xxserv.tgz XFree86 X server
+12. Xmod.tgz XFree86 X server modules
</verb></quote>
NOTES:
<itemize>
<item>Some web browsers have a problem downloading the <tt>extract</tt>
utility correctly. If you encounter this problem, download the
- version called <tt>extract.exe</tt> instead. The "<tt>.exe</tt>"
- suffix is only there to make the troublesome web browsers do
- the right thing. It is not a DOS/Windows executable.
+ version called <tt>extract.exe</tt> instead. This should fix the
+ problem. (This is not a DOS/Windows executable.)
<item>A few distributions don't have or require the <tt>Xvar.tgz</tt>
tarball. If it is present in the <tt>binaries</tt> sub-directory
for your platform, then it is required.
- <item>Some distributions may have additional mandatory tarballs. This
- is rare. In these cases, the installer script will tell you
- if any are missing.
+ <item>Some distributions may have additional mandatory tarballs.
+ While rare, the installer script will tell you if any are missing.
</itemize>
-The following tarballs are optional. You should download the ones you
-want to install.
+The following thirteen (13) tarballs are optional. You should download
+the ones you want to install.
<quote><verb>
-Xfsrv.tgz Font server
-Xnest.tgz Nested X server
-Xprog.tgz X header files, config files and compile-time libs
-Xprt.tgz X Print server
-Xvfb.tgz Virtual framebuffer X server
-Xf100.tgz 100dpi fonts
-Xfcyr.tgz Cyrillic fonts
-Xflat2.tgz Latin-2 fonts
-Xfnon.tgz Some large bitmap fonts
-Xfscl.tgz Scalable fonts (Speedo and Type1)
-Xhtml.tgz HTML version of the documentation
-Xps.tgz PostScript version of the documentation
-Xjdoc.tgz Documentation in Japanese
+1. Xfsrv.tgz Font server
+2. Xnest.tgz Nested X server
+3. Xprog.tgz X header files, config files and compile-time libs
+4. Xprt.tgz X Print server
+5. Xvfb.tgz Virtual framebuffer X server
+6. Xf100.tgz 100dpi fonts
+7. Xfcyr.tgz Cyrillic fonts
+8. Xflat2.tgz Latin-2 fonts
+9. Xfnon.tgz Some large bitmap fonts
+10. Xfscl.tgz Scalable fonts (Speedo and Type1)
+11. Xhtml.tgz HTML version of the documentation
+12. Xps.tgz PostScript version of the documentation
+13. Xjdoc.tgz Documentation in Japanese
</verb></quote>
NOTES:
@@ -129,34 +130,34 @@ NOTES:
</itemize>
-If you miss some and want to install them later, you can do so by following
-the appropriate part of the section that describes manual installation.
+If you miss some and want to install them later, go to the
+<ref id="manual-install" name="Manual Installation"> section.
<sect>Installing XFree86 &relvers; using the <tt>Xinstall.sh</tt> script
<p>
-We strongly recommend that our XFree86 &relvers; binary distributions
-be installed using the <tt>Xinstall.sh</tt> script that we provide.
-The main reason that we make this recommendation is that there are a lot
-of steps in the manual installation process, and those steps can vary
-according to the situation. There is, however, a description of the
-manual installation process for the most common cases below for those who
-might need it.
-
-Put all of the downloaded files into a single directory (choose some
-temporary location with enough space). Become the super user (root),
-cd to that directory, then run the installer script as follows:
+We strongly recommend that our XFree86 &relvers; binaries be installed
+using the <tt>Xinstall.sh</tt> script that we provide. There are a lot of
+steps in the manual installation process, and those steps can vary
+according to the platform and hardware setup. There is a description of
+the manual installation process for the most common cases <ref
+id="manual-install" name="below">.
+
+You must login as the super user (root) to run the installer script.
+Place all of the downloaded files into a single directory (choose a
+temporary location with enough space). Use the cd command to change to
+that directory and then run the installer script as follows:
<tscreen><verb>
sh Xinstall.sh
</verb></tscreen>
-Answer the prompts that come up. If you are missing something that is
-required to run this version of XFree86, the installer may tell you to
-install it before trying again. If you don't have all of the mandatory
-files listed above, then the installer will tell you which ones are
-missing and ask you to download them before trying again.
+Answer the prompts as they come up. If you are missing something that
+is required, the installer may tell you to install it before trying
+again. If the problem is that you did not download all of mandatory
+files aforementioned, then the installer will tell you which ones are
+missing and ask you to download them before proceeding.
-<sect1>Answering the questions that the installer may ask
+<sect1>Questions the installer may ask
<p>
The installer asks some questions that may not have obvious answers. The
information here should help you answer them. In most cases, apart from
@@ -196,13 +197,14 @@ the existing ones for you and create the necessary symbolic links. If
you don't want to have these configuration files under <tt>/etc/X11</tt>,
then you should answer "no" when asked about it. Answering "no" here
also means that the new configuration files will be installed in the
-old <tt>/usr/X11R6/lib/X11</tt> location. Note: for the rare systems
-that don't have symbolic links, this question will not be asked.
-The default answer is "yes" because that is best for most situations.
-It is our new default. It makes it easier to share the <tt>/usr/X11R6</tt>
-directory between multiple hosts, and allows it to be mounted read-only.
-If you don't need these features, then you can safely answer "no" if you
-don't want them moved.
+old <tt>/usr/X11R6/lib/X11</tt> location.
+
+Note: for the rare systems that don't have symbolic links, this question
+will not be asked. The default answer is "yes" because that is best
+for most situations. It is our new default. It makes it easier to
+share the <tt>/usr/X11R6</tt> directory between multiple hosts, and
+allows it to be mounted read-only. If you don't need these features,
+then you can safely answer "no" if you don't want them moved.
When installing over an existing version, you will be prompted before
each set of configuration files is installed. If you haven't made any
@@ -210,9 +212,10 @@ customisations to your existing configuration files, then you can safely
answer "yes" for each of these. If you have made customisations, you
can try answering "no". If you run into problems later, you may need
to manually merge your customisations into the the new version of the
-configuration files. The configuration files can all be found in
-the <tt>Xetc.tgz</tt> tarball. See the section below about manual
-installation for information about extracting them separately.
+configuration files. The configuration files can all be found in the
+<tt>Xetc.tgz</tt> tarball. See the <ref id="manual-install" name="section
+below"> about manual installation for information about extracting them
+separately.
After the configuration files have been dealt with, the other mandatory
components of the binary distribution will be installed. This should
@@ -230,12 +233,23 @@ that the newly installed shared libraries are accessible. Then
the <tt>fonts.dir</tt> files in some directories are updated so that
the fonts can be accessed correctly. Next, the installer checks to
see if your system has a termcap file or terminfo files. If it finds
-the former, it tells you how my may update the entries in that file.
+the former, it tells you how you may update the entries in that file.
If it finds the latter, it asks you if you want it to update them
for you.
+You may be asked if you want to create links for the GL libraries and
+header files. The OpenGL standard on some platforms (Linux in particular)
+says that these should be installed in the standard system locations
+(<tt>/usr/lib</tt> and <tt>/usr/include</tt>), so the installer offers
+to create the appropriate links. If you're running Linux, you should
+probably answer yes. For other platforms it is your choice. If you
+already have another version of libGL in /usr/lib, answering "yes" will
+remove it and replace it with a link to the version we supply. The
+installer will show you a listing of any existing versions before asking
+if they should be replaced.
+
Finally, the installer asks you if you want a link created for the
-<tt>rstart</tt> utility. On most modern systems, the link isn't essential,
+<tt>rstart</tt> utility. On most modern systems the link isn't essential,
so the default answer is "no". Answer "yes" if you know that you need
it. If you find later that you need it, you can create it easily by
running:
@@ -268,7 +282,7 @@ operation of the new X server, you can safely remove the old
After the X server configuration is done, it may be advisable to reboot,
especially if you run xdm (or equivalent) or the font server (xfs).
-<sect>Installing XFree86 &relvers; manually
+<sect>Installing XFree86 &relvers; manually<label id="manual-install">
<p>
This section describes how to manually install the XFree86 &relvers; binary
distributions. You should only use this method if you know what you're
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml
index 9b65056e3..94684b580 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml
@@ -8,7 +8,7 @@
<date>25 February 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml,v 3.19 2000/03/03 21:28:08 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/LynxOS.sgml,v 3.20 2000/06/17 00:27:32 dawes Exp $
</ident>
<toc>
@@ -44,6 +44,11 @@ don't run on LynxOS versions earlier than 3.0.0.
Building of this XFree86 version has never been tested on LynxOS versions
earlier than 2.5.1.
+This release contains preliminary build support for `LynxOS 3.1.0'.
+Since this OS release was not available long enough for serious testing
+`LynxOS 3.1.0' support has to be considered to be in `alpha state'.
+Initial tests were performed on LynxOS x86 only!
+
XFree86 &relvers; supports LynxOS on the x86 and on
the PowerPC platform. X servers are currently available only on the
x86 platform. The X server may work with some PowerPC platforms
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml
index f2ad0e480..fc45c29eb 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml
@@ -9,10 +9,10 @@ David Dawes,
Marc Wandschneider,
Mark Weaver,
Matthieu Herrb
-<Date>Last modified on: 20 February 2000
+<Date>Last modified on: 1 July 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.55 2000/03/03 21:28:09 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/NetBSD.sgml,v 3.56 2000/07/02 02:35:27 dawes Exp $
</ident>
<toc>
@@ -60,6 +60,13 @@ this file and we'll revise it.
See the <htmlurl url="RELNOTES.html" name="Release Notes"> for
non-OS dependent new features in XFree86 &relvers;.
+<sect1>New OS dependent features in 4.0.1
+<p>
+<itemize>
+<item>Support for NetBSD 1.5_ALPHA
+<item>The Xsun server can be built on NetBSD/sparc
+</itemize>
+
<sect1>New OS dependent features in 4.0
<p>
<itemize>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml
index daf7d7a76..e370ad3a3 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml
@@ -3,7 +3,7 @@
<title>Notes on Rebuilding XFree86/OS2 from Scratch
<author>Holger Veit
-<date>Last modified August 1st, 1999
+<date>Last modified March 8th, 2000
<toc>
@@ -20,16 +20,16 @@ from scratch under OS/2.
Please also read <htmlurl name=README.OS2 url=OS2.html> for end-user
information, and set at least the environment variables described there.
<p>
-At the current time, the most recent version available is XFree86-3.3.5.
+At the current time, the most recent version available is XFree86-4.0.
This is a full and unrestricted version which comes with complete source
-code. 3.3.5 is not only a bugfix release, but also supports new hardware,
-some of which might not even supported by OS/2 itself. See the RELEASE NOTES
-document for details.
+code. 4.0 is a highly experimental release, so many features that might
+have worked in earlier versions, may now no longer work, or work differently.
+Be aware that for OS/2, XFree86-4.0 is considered to be alpha software.
If you want to join the XFree86 developer team, e.g. to add support for
certain hardware, please send a request to BOD@XFree86.org. Please
think about such a step carefully before, though, since much work is
-involved. Please use the XFree86-3.3.5 source code as a test example how
+involved. Please use the XFree86-4.0 source code as a test example how
to compile the system. The ability to manage that is a basic requirement
for becoming a developer.
@@ -59,6 +59,7 @@ via anonymous FTP. The following shopping list shows what you will need:
<item>make GNU make 3.71/3.72 (use the one from Xprog.zip!)
<item>flex GNU flex
<item>bison GNU bison
+<item>m4 GNU m4
<item>find GNU find (attention: incompatible tool with the same name in OS/2)
</itemize>
@@ -68,7 +69,7 @@ which might still be available from some archives is NOT compatible.
Furthermore, you need the XFree86 sources. These are available from
the common XFree86 repositories. Look into a directory which is
-often named /pub/XFree86/3.3.5/source.
+often named /pub/XFree86/4.0/source.
<sect>Compiling and Installing
<p>
@@ -201,7 +202,7 @@ Well, you see, this was quite easy :-)
<verb>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml,v 3.6 1999/08/23 06:38:50 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OS2note.sgml,v 3.7 2000/04/05 18:13:46 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml
index a7b70c75d..15f131d8e 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml
@@ -6,10 +6,10 @@
<title>README for XFree86 &relvers; on OpenBSD
<author>
Matthieu Herrb
-<Date>Last modified on: 20 February 2000
+<Date>Last modified on: 1 July 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.10 2000/03/03 21:28:10 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/OpenBSD.sgml,v 1.11 2000/07/02 02:35:27 dawes Exp $
</ident>
<toc>
@@ -57,6 +57,22 @@ this file and we'll revise it.
See the <htmlurl url="RELNOTES.html" name="Release Notes"> for
non-OS dependent new features in XFree86 &relvers;.
+<sect1>New OS dependent features in 4.0.1
+<p>
+<itemize>
+<item>Several features from the OpenBSD X11 tree were merged into xdm:
+<itemize>
+<item> support for Kerberos IV authentication
+<item>use the arc4random(4) random number generator
+<item>add a new resource "allowRootLogin", which can be used to disable
+ root logins through xdm
+<item>log failed logins to syslogd
+<item>verify that the shell is valid using /etc/shell
+<item>verify that the account hasn't expired
+</itemize>
+<item>The Xsun server can be built again on OpenBSD/sparc.
+</itemize>
+
<sect1>New OS dependent features in 4.0
<p>
<itemize>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml
index 4cc3953fd..cccfddb14 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml
@@ -10,15 +10,16 @@
<title>README for XFree86&tm; &relvers;
<author>The XFree86 Project, Inc
-<date>26 February 2000
+<date>30 June 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.103 2000/03/08 20:36:43 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/README.sgml,v 3.106 2000/07/02 02:35:27 dawes Exp $
</ident>
<abstract>
-XFree86 is a port of X11R6.4 that supports several UNIX(R) and UNIX-like
+XFree86 is the Open Source port of X.Org's X11R6.4 release that supports
+several UNIX(R) and UNIX-like (such as Linux, the BSDs and Solaris x86)
operating systems on Intel and other platforms.
</abstract>
@@ -53,38 +54,45 @@ well developed and reasonably stable, while others are not.
<![ %release [
XFree86 &relvers; is <![ %firstrel; [the first]]>
-<![ %laterrel; [a]]> full release of the <![ %earlyrel; [new]]> XFree86 4
-series.
-The road to XFree86 4 began in mid 1997, with serious work starting in
-early 1998. The first pre-4.0 snapshot was released in mid 1999, and
-4.0 was released in early 2000. A lot has been completed in that time,
-and even more has been started since the "4.0" design was drafted. The
-result is that this release contains a lot of new features, some new
-drivers, and some significant performance improvements. This release
-contains components in various stages of development, ranging from stable
-and well tested to new and not-so-well tested. One the other side,
-there are drivers from the 3.3.x series that have not yet been ported
-to XFree86 4. Most of these are for old hardware. To find more
-information about which hardware is supported, see the <htmlurl
-name="Driver Status document" url="Status.html">.
-
-XFree86 4 uses a very modular design. We had hoped to finalise and fully
-document the driver module API/ABI in time for the 4.0 release, but instead
-we are planning to have this done for a subsequent release. We will try
-where possible to retain backward compatibility with the module interfaces
-in 4.0 in future releases, but we can't make guarantees about that until
-the interfaces have been fully documented.
+<![ %laterrel; [a]]> the upgrade to the first full release in the <![ %earlyrel; [new]]> XFree86 4
+series. Release 4 is a major re-design of the basic architectural
+underpinnings of XFree86's implementation of the original X Consortium's
+X Server. This re-design allows for a modular interaction between the
+hardware drivers and the XFree86 core X server. With 4.0, upgrades to
+the X server with new and unsupported hardware can be easily done and
+installed without undergoing the previous process of rebuilding a X
+server. All that is required is installing the new driver module and
+updating the configuration file.
+
+The road to XFree86 Release 4 began as an architectural concept in mid
+1997, with the serious framework being implemented in code the beginning
+of 1998. There were several snapshots on the road to 4.0 which are now
+part of the 4.0 base release. The &relvers; version is an upgrade to
+&prevrelvers;, which include more hardware ports, code enhancements and
+bug fixes.
+
+Release 4 also included the long-awaited integration of the DRI (Direct
+Rendering Infrastructure). This upgrade into the code base gives XFree86
+the abilities of direct 3-D graphics rendering, used widely in games
+and other visualization programs.
+
+Many drivers used in the old 3.3.x series have not be converted over to
+the 4.0 design and so check first whether your hardware is supported
+before upgrading to the 4.0 series in the <htmlurl name="Driver Status
+document" url="Status.html">.
+
]]>
-Information on this release's features and their status can be found in
-the <htmlurl name="Release Notes" url="RELNOTES.html">.
+Specific release enhancements can be viewed in the
+<htmlurl name="Release Notes" url="RELNOTES.html">.
-Information about obtaining and installing binary distributions of this
-release can be found in the <htmlurl name="Installation Document"
+Information about binary distributions and the attendant installation
+instructions can be found in the <htmlurl name="Installation Document"
url="Install.html">.
-Copyright and Licensing information for this release can be found in
-the <htmlurl name="License Document" url="LICENSE.html">.
+Copyright and Licensing information for this release and all XFree86
+releases can be found in the <htmlurl name="License Document"
+url="LICENSE.html">.
<![ %snapshot [
<sect>Redistribution of the Snapshots
@@ -97,17 +105,98 @@ you make it clear that people using then should contact you for support
and not XFree86.
]]>
-<sect>Developers
+<sect>Joining The Team
+<sect1> Development
<p>
-If you would like to work on the development of XFree86 4, then it is
-recommended that you <url name="join the XFree86 development team"
-url="http://www.xfree86.org:/developer.html">. That way you will have
-access to the latest source and to other developers.
+If you would like to work on the development of XFree86 4, either by
+helping with the conversion of our older drivers to the new 4.0 design,
+or assisting in the addition of new drivers or platforms to the code base
+then send a request to to <url name="join the XFree86 development team"
+url="http://www.xfree86.org:/developer.html">. This will give you direct
+access to the latest XFree86 related development topics and discussions.
+Include in your note, your name, email address, reason for joining (what
+you will work on) and, level of expertise (coder, DRI, core, specific
+driver) and area of interest.
-<sect>How to get XFree86 &relvers;
+</sect1>
+
+
+<sect1> Documentation
+<p>
+If instead your interests are on the Documentation side of the Project,
+or you want to contribute and are not ready for plunging into the code,
+you can join the Documentation Team (those hardy souls responsible for
+the content you are reading :-). Amongst the Doc Team's activities are
+converting our SGML based documentation into an XML based one and updating
+and creating technical documentation used by staff and public. If this
+sounds interesting then please send a request to <url name="join the
+XFree86 documentation team" url="mailto:signup@xfree86.org">.
+Include in your note, you name, email address, reason for joining (what
+you will work on) and level of expertise and whether you are interested
+in the tools or content side of the group.
+
+</sect1>
+</sect>
+
+<sect> The Public Mailing Lists
+<sect1> Newbie
+<p>
+For those who are new to XFree86 and want to learn more about our
+Project we recommend that you join our Newbie list, located at <url name
+= "Public Mailing Lists" url = "http://www.xfree86.org/mailman/listinfo">,
+where this and other discussions occur with our senior all-volunteer
+staff. This is great forum to get introduced to XFree86 and ask for
+help on how to set up the XServer or whether your hardware is supported,
+and why not?, and make suggestions for future releases of XFree86.
+This list is supported by our volunteer staff who needs to know how you
+are using and interacting with XFree86 and what is wrong and could be
+better. Tell them, they want to know!
+
+</sect1>
+
+<sect1> Announce
<p>
+For those who just want to know the release schedule
+this is a good list to join.
+
+<sect1> CVS Commit
+<p>
+For those who want to see what has been committed recently to our CVS
+repository this is the list that will show you those updates. This list
+is updated dynamically every time the repository is updated after the
+the commit happens.
+
+<p>
+A followup to the commit list is the soon to be public, patch archives.
+This archive will be available on our web-site and will show what patches
+have been submitted and will soon be committed. This is helpful for
+people who are interested in a specific area and want to know what work
+is happening there. When this goes public we will announce it
+on our web site and our Announce mailing list, so keep watching.
+
+<sect1> Xpert
+<p>
+If instead you are the lone developer who is improving XFree86 on an
+ad hoc basis for your particular environment (I want to get my mouse or
+video card to work), and need a specific question asked then you should
+go over to our Xpert list where such questions are raised and answered
+by our technical development staff. Remember you do not have to be a
+member to write fixes to our code base and if your changes are discrete
+and self-contained the volume of developer mail may just be too noisy.
+
+
+Once your work is finished (coded, debugged and documented) please send
+your fix to <email>fixes@XFree86.org</email>. This will ensure that
+they are included in future releases. And thanks! You make this truly
+an Open group.
+
+</sect1>
+</sect>
+
+<sect>How to get XFree86 &relvers;
+<p>
<![ %snapshot; [
XFree86 &relvers; can be found at the <url name="XFree86 ftp server"
url="ftp://ftp.xfree86.org/pub/XFree86/snapshots/&relvers;/">, and at
@@ -135,10 +224,10 @@ contains the general X11 documentation in hardcopy format.
<![ %onediff; [
A source patch relative to version &prevrelvers; is also available.
-The patch file is <tt>&prevrelvers;-&relvers;.diff.gz</tt>. This patch should
-be applied to a clean &prevrelvers; source tree, working from the directory
-containing the <tt>xc/</tt> directory. The patch should be applied by
-running:
+The patch file is <tt>&prevrelvers;-&relvers;.diff.gz</tt>. This patch
+should be applied to a clean &prevrelvers; source tree, working from
+the directory containing the <tt>xc/</tt> directory. The patch should
+be applied by running:
<tscreen><verb>
gunzip &lt; &prevrelvers;-&relvers;.diff.gz | patch -p0 -E
@@ -177,26 +266,21 @@ gunzip &lt; &prevrelvers;-&relvers;.diff3.gz | patch -p0 -E
</verb></tscreen>
]]>
-The contrib part of the distribution has now been folded into the main
+The contrib part of the distribution has been folded into the main
source tree, so a separate contrib tarball is no longer required.
-To format the XFree86 documentation, the latest version of our doctools
-package. That is available as <tt>doctools-1.1.2.tgz</tt>.
+To format the XFree86 documentation use the latest version of our doctools
+package available as <tt>doctools-1.1.3.tgz</tt>.
<sect>Reporting Bugs
<p>
Bugs should be reported to <email>XFree86@XFree86.org</email>. Before
reporting bugs, please check the X server log file, which can be found
-at <tt>/var/log/XFree86.0.log</tt> on most platforms. If you can't resolve
-the problem yourself, send the entire log file with your bug report. Please
-don't edit out what you think might not be important. The information
-contained in the log file is there to make it easier for the developers
-to determine what is going wrong when there are problems.
-
-If you have patches (bug fixes or enhancements, etc) that you'd like to
-submit for inclusion in a future version of XFree86, please send them
-to <email>fixes@XFree86.org</email>.
+at <tt>/var/log/XFree86.0.log</tt> on most platforms. If you can't
+resolve the problem yourself, send the entire log file with your bug
+report but not the operating system core dump. Do not edit the log
+file as our developers use it to reproduce and debug your problem.
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml
index a90c11317..8d0a43cc3 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml
@@ -6,10 +6,10 @@
<title>Release Notes for XFree86&trade; &relvers;
<author>The XFree86 Project, Inc
-<date>7 March 2000
+<date>30 June 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.37 2000/03/08 20:11:55 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/RELNOTES.sgml,v 1.41 2000/07/02 02:35:27 dawes Exp $
</ident>
<abstract>
@@ -21,32 +21,23 @@ in XFree86 &relvers; and their status.
<toc>
-<sect>Introduction
+<sect>Introduction to the 4.x Release Series
<p>
-XFree86 4.0 is the first official release of the new XFree86 4. XFree86
-4 represents a significant redesign of the XFree86 X server. It is very
-important to keep in mind that XFree86 4 is still very much in development,
-and it contains a lot of new work. That means two things: there is a
-lot of new exciting stuff to try, but being new code, it hasn't had
-nearly as much of a workout as the stable 3.3.x releases. If you're
-looking for a well-tested, stable release, and can't afford the
-inconveniences that new software can sometimes cause, then you are
-probably better off sticking with the 3.3.x releases for now. If you
-have the resources to try out the new version and investigate its
-features, or if you just like being on the bleeding edge, then please
-try &relvers;!
-
-This release isn't quite as complete as we would have liked. The main
-missing pieces are a nice configuration tool and support for some of
-the hardware that 3.3.x supports. The first point means that configuring
-the server might be more painful than usual. The second means that your
-hardware might not be supported by &relvers;, or it might be supported at a
-lesser level (conversely, some hardware is better supported in &relvers;).
-We've attempted to provide some information about the second point in
-our <htmlurl name="Driver Status document" url="Status.html">. Please
-check there first before trying &relvers;. Unfortunately that document is
-still fairly basic, but it should at least give you an idea of whether
-you're likely to be able to use &relvers; at all or not.
+XFree86 4.0 was the first official release of the new XFree86 4. XFree86
+4 represents a significant redesign of the XFree86 X server.
+Not all of the hardware drivers from 3.3.x have been ported to 4.x yet.
+
+<sect1>Differences Between the 4.x series and the 3.3 series
+<p>
+The 4.x release series is also missing
+a nice configuration tool.
+This means that configuring the Xserver might be trickier than usual.
+The second point is that is that your hardware might not
+be supported by &relvers;, or it
+might be supported at a lesser level (conversely, some hardware is better
+supported in &relvers;). We've attempted to provide some information
+about the second point in our <htmlurl name="Driver Status document"
+url="Status.html">. Please check there first before downloading &relvers;.
On the subject of configuration, we have updated the basic text-based
tool "<tt>xf86config</tt>" to generate config files in the format required
@@ -55,150 +46,197 @@ working on some other configuration tools, including one that is built-in
to the X server. An early version of this is included in the release,
and it works well for some hardware. To try it out, just run (as root)
"<tt>XFree86 -configure</tt>". Both of these configuration options will
-at worst give you a reasonable starting point for a suitable configuration
+give you a reasonable starting point for a suitable configuration
file. We've put some effort into documenting the &relvers; config file format,
-and you can find that information in the XF86Config manual page. Please
-check that and the driver manual pages and related documentation for
-further information about that.
+and you can find that information in the XF86Config manual page. Check
+that, the driver manual pages and the related documentation for
+further information.
Oh, another thing you might notice is that our documentation is rather
patchy. Most of what is present should be in reasonable shape, but
-there are gaps. We thought it better to leave out docs that were
-very out of date rather than providing inaccurate and misleading
-information.
+there are gaps. We thought it better to leave out docs that were very
+out of date rather than providing inaccurate and misleading information.
+We are looking for people to also help fill those gaps in &lt;hint hint
+:-&gt;.
Finally, before you download and install the binary distributions for
this release, please have a quick read through the <htmlurl
name="Installation Document" url="Install.html">. It may save you some
time.
-If those cautionary notes haven't turned you away (and we certainly hope
-not), please read on... The sections below describe some of the new
-features and changes between 3.3.x and &relvers;. There is a lot of new
-stuff, and we definitely don't have enough space to cover it all here.
+The next section describes what is new in the latest version (&relvers;).
+The other sections below describe some of the new features and changes
+between 3.3.x and 4.0. There is a lot of new features, and we definitely
+don't have enough space to cover it all here.
-<!--
-<sect>Summary of new features in &relvers; compared with &prevrelvers;.
-<p>
--->
+</sect>
-<!--
-<sect>Summary of new features in 3.9.18 compared with 3.9.17.
+<sect>Summary of new features in &relvers;.
+<p>
+<sect1>X server
<p>
-This section contains a brief summary of what has changed since the
-previous snapshot. Unfortunately, only a small number of changes are
-listed here. For detailed information, refer to the <tt>CHANGELOG</tt>
-file in the <tt>xc/programs/Xserver/hw/xfree86</tt> directory in the
-source tree. The sections that follow this one have details of features
-that are new to the pre-4.0 snapshot series.
-
<itemize>
- <item>The NVIDIA (nv) driver now uses MMIO for VGA port access and has
- DDC support.
+ <item>New DRI drivers for Intel i810, Matrox G400 and G200 (AGP only) and
+ the ATI Rage 128, and updates to the 3Dfx DRI driver, including
+ Voodoo5 support.
+
+ <item>The X server now runs on Linux/Sparc including drivers for many
+ video cards used on SUN hardware.
+
+ <item>DRI support for the Linux/Sparc implementation that allows 3D direct
+ rendering with Creator3D cards.
- <item>The 8+24 support used by the Matrox (mga) and 3Dlabs (glint)
- drivers is now a non-destructive overlay.
+ <item>Fixed recently publicized security issues.
- <item>The Xinerama extension has been completely rewritten for improved
- performance and correctness.
+ <item>Update Mesa to the latest version.
- <item>The server can now load/initialise extension modules that it
- doesn't have built-in knowledge of.
+ <item>Xinerama updates and fixes.
- <item>More PS/2 mice (Microsoft IntelliMouse Explorer, Genius NetScroll
- Mouse Optical, IBM ScrollPoint) and serial PnP mice (A4 Tech 4D/4D+,
- MouseSystems SmartScroll, Logitech Cordless MouseMan Wheel, 8D
- Scroll mouse) are recognized and supported. USB mice support is
- also available in FreeBSD and OpenBSD.
+ <item>Xv updates and fixes.
- <item>A DPS extension for XFree86 is currently under development. The DPS
- client library is now part of the XFree86 source tree; the extension
- code itself, however, cannot be integrated for licensing reasons and
- is distributed separately. For more information, please consult
- the
- <url name="DPS site at SourceForge" url="http://dps.sourceforge.net">.
+ <item>Mouse support in DGA 1.0 compatibility mode should now work correctly
+ for most games that make use of it.
- <item>The "apm" driver (Alliance Pro Motion) has been updated. Support
- for the AT24 has been added in this release, and acceleration has
- been improved. Further details can be found in the
- <ref id="apm" name="APM section"> below.
+ <item>Some bugs with 8+24 overlay support have been fixed.
- <item>Preliminary support has been added to the X server for the extended
- keys on some "Internet" keyboards.
+ <item>Some XKEYBOARD extension problems have been fixed, including
+ improvements to the MouseKeys support.
- <item>A new X server extension has been added for optimising access to
- metric data for large fonts.
+ <item>Add generic DGA support to the sis, neomagic and i810 drivers.
+
+ <item><tt>xf86cfg</tt>, a new graphical configuration tool.
</itemize>
+</sect1>
-<sect>Summary of new features in 3.9.17 compared with 3.9.16.
+<sect1>X libraries and clients.
<p>
-
<itemize>
- <item>The 3dfx driver is now supported by the DRI.
- <item>Tiny-X for the Itsy has been added.
- <item>Significant font and font server enhancements.
- <item>New driver for ATI Rage 128. The driver is called "r128".
- <item>Xterm enhancements and fixes.
- <item>DPS support hooks have been added.
- Display Postscript support is being maintained outside of the
- server tree due to licensing issues. A web page for DPS resources
- under XFree86 will be available shortly.
- <item>DRI enhancements including Mesa update to version 3.2, full support
- and fifo code for 3dfx hardware, and device driver updates for
- Linux 2.3 kernels.
- <item>Significant enhancements to Xv including support for XvImages
- (YUV XImages).
- <item>Add initial VESA VBE support including initialization and DDC.
- <item>Several PCI enhancements.
- <item>"SilkenMouse" (asynchronous pointer handling) for smoother mouse movement.
- <item>Add GeForce/Quadro support to the NVIDIA driver.
- <item>Int10 "soft-booting" support for Linux.
- <item>Resource allocation infrastructure added.
- <item>Syntax of the layout section has changed to make multi-head configuration easier.
- <item>Some Xinerama bug fixes.
- <item>The DGA 2.0 interface is mostly finalized and includes some preliminary documentation.
- <item>ViRGE MX Melco BIOS support has been added.
- <item>Keyboard AutoRepeat now works correctly on Linux. This means
- that the AutoRepeat keyword in XF86Config is now obeyed; you may be
- more comfortable using "250 30" rather than the default setting of
- "500 5".
+ <item>Thread safety issues have been resolved in a few places in the
+ libraries. Upgrading to the latest libraries is essential for
+ multi-threaded X applications.
+
+ <item>Some fatal bugs in the big font support have been fixed. Upgrading
+ to the latest libraries will fix this too.
+
+ <item>Fixed recently publicized security issues in some of the X libraries.
+
+ <item>Updates and bug fixes for some clients, including xedit, xman,
+ xcalc, fstobdf, xdm.
+ <item>Fix some xfs problems.
+
+ <item>XTerm updates. These include:
+ <itemize>
+ <item>Improve logfile security.
+
+ <item>Workaround for fixed fonts which are generated from
+ Unicode fonts: they omit glyphs for some xterm's
+ less-used line-drawing characters, which caused xterm
+ to set a flag telling it to use only its internal
+ line-drawing characters.
+
+ <item>Limit numeric parameters of control sequences to 65535
+ to simplify checks for numeric overflow.
+
+ <item>Change index into UDK list to unsigned to guard against
+ numeric overflow making the index negative.
+
+ <item>Add limit checks to ClearInLine(), ScrnInsertChar(),
+ ScrnDeleteChar() to correct potential out-of-bounds
+ indexing.
+
+ <item>Add a resource (limitResize) limiting resizing via the
+ <tt>CSI 4 t</tt> and <tt>CSI 8 t</tt> sequences.
+
+ <item>Ignore out-of-bounds resize requests, i.e., where
+ sign-extension or truncation of the parameters would
+ occur.
+
+ <item>Change Sun function-keys resource name to sunFunctionKeys
+ to work around redefinition of the token sun by xrdb on
+ Solaris. Similarly, renamed resource sun keyboard to
+ sunKeyboard. Change similar resource names for HP and
+ SCO to avoid potential conflict with xrdb symbols on
+ other systems, as well as for consistency.
+
+ <item>Change line speed from 9600bd to 38400bd to accommodate
+ users who mistakenly use $TERM set to vt100, to reduce
+ the effect of padding associated with this terminal
+ type.
+
+ <item>Fix a problem that caused the right scrollbar to be
+ positioned incorrectly when re-enabling it.
+
+ <item>Fix a problem with color support that showed up on some
+ platforms.
+
+ <item>Modify logic for deleteIsDEL resource so it has internally
+ 3 states: unspecified, true and false. If unspecified,
+ the keyboard type determines whether the Delete key
+ transmits <tt>&lt;esc&gt;[3~</tt> or <tt>\177</tt>, and
+ the popup menu entry reflects the internal state.
+ Otherwise, the popup menu entry overrides the keyboard
+ type.
+
+ <item>Portability fixes for os390, AIX 4.2, Digital Unix 4.0
+ and IRIX 6.5.
+
+ </itemize>
</itemize>
-<sect>Summary of new features in 3.9.16 compared with 3.9.15.
+<sect1>Fonts and Internationalisation
<p>
+<itemize>
+ <item>Many of the "misc" bdf fonts have been updated and extended, and
+ a wider range of ISO-8859 subsets have been added. Oblique/italic
+ versions of some of them have also been added.
+
+ <item>The converters in Xlib have been improved and reworked. UTF-8
+ support has been added.
+
+ <item>Support for ISO-8859-13 has been added to Xlib and to the UTF-8
+ converters.
+
+ <item>XKB keyboard definitions have been added and updated for some
+ countries.
+
+ <item>Locale support for Celtic languages has been updated, and a Compose
+ file for ISO-8859-14 added.
+</itemize>
+</sect1>
+
+<sect1>Miscellaneous
+<p>
<itemize>
- <item>The "apm" driver has been updated.
- See the <ref id="apm" name="APM section"> below.
- <item>A driver for NVIDIA chipsets is now included. The driver is called
- "nv". Some very basic information can be found in the nv(4) man
- page.
- <item>The default xdm config file now has a line to disable listening for
- XDMCP requests. This is fine when xdm is only managing a local
- X server. The line must be commented out when xdm is used to manage
- external X servers (e.g., X terminals).
- <item>New driver for Intel i740. The driver is called "i740".
- <item>New driver for 3Dfx Banshee and Voodoo 3. The driver is called "tdfx".
- <item>Some work on adding WYSIWYG capabilities to the Xaw text widget.
- <item>Some preliminary support for programming modes has been added to xedit.
+ <item>Preliminary support for Linux/mips (no X servers yet).
+
+ <item>Update support for BSD/OS.
+
+ <item>Update Linux/IA64 support.
+
+ <item>Support for LynxOS 3.1.0.
+
</itemize>
--->
+</sect1>
-<sect>X server
+</sect>
+
+<sect>The new X server
<p>
Unlike XFree86 3.3.x where there are multiple X server binaries, each
-of which drive different hardware, XFree86 &relvers; has a single X server
-binary called <tt>XFree86</tt>. This binary can either have one or
-more video drivers linked in statically, or, more usually, dynamically
+of which drive different hardware, XFree86 &relvers; has a single X
+server binary called <tt>XFree86</tt>. This binary can either have one
+or more video drivers linked in statically, or, more usually, dynamically
load the video drivers and other modules that are needed.
XFree86 &relvers; has X server support for most UNIX(R) and UNIX-like
operating systems on Intel/x86 platforms, plus support for Linux on
-Alpha and PowerPC platforms. Work on support for additional architectures
-and operating systems is in progress, and is planned for future releases.
+Alpha, PowerPC and Sparc platforms. Work on support for additional
+architectures and operating systems is in progress, and is planned for
+future releases.
<sect1>Loader and Modules
<p>
@@ -209,35 +247,36 @@ Since the loader doesn't rely on an operating system's native dynamic
loader support, it works on platforms that don't provide this feature,
and makes it possible for the modules to be operating system independent
(although not, of course, independent of CPU architecture). This means
-that, for example, a module compiled on Linux/x86 can be loaded by an
-X server running on Solaris/x86, or FreeBSD, or even OS/2. One of the
-main benefits of this is that when modules are updated, they don't need
-to be recompiled for each different operating system. We're planning to
-take advantage of this to provide more frequent driver module updates in
-between major releases.
+that a module compiled on Linux/x86 can be loaded by an
+X server running on Solaris/x86, or FreeBSD, or even OS/2.
+<p>
+One of the
+main benefits of this loader is that when modules are updated, they do not need
+to be recompiled for every different operating system. In the future
+we plan to take advantage of this to provide more frequent driver module
+updates in between major releases.
The loader in version &relvers; has support for Intel (x86), Alpha and
-PowerPC platforms. It also has preliminary support for Sparc platforms
-but this isn't used yet.
+PowerPC platforms. It also has preliminary support for Sparc platforms.
The X server makes use of modules for video drivers, X server extensions,
font rasterisers, input device drivers, framebuffer layers (like mfb,
cfb, etc), and internal components used by some drivers (like XAA),
The module interfaces (API and ABI) used in this release is still subject
-to change without notice. While we'll attempt to provide backward
+to change without notice. While we will attempt to provide backward
compatibility for the module interfaces as of the 4.0 release (meaning
-that 4.0 modules will work with future core X server binaries), we can't
-guarantee that this will be the case. We are planning to fully document
-and stabilise the module interfaces in a future release, and at that
-point backward compatibility will be easier to achieve.
+that 4.0 modules will work with future core X server binaries), we cannot
+guarantee this.
<bf>Note about module security</bf>
<quote><p>
- The XFree86 X server runs with root privileges, which means that
+ The XFree86 X server runs with root privileges, i.e.
the X server loadable modules also run with these privileges.
For this reason we recommend that all users be careful to only
- use loadable modules from reliable sources. We hope to have a
+ use loadable modules from reliable sources, otherwise the
+ introduction of viruses and contaminated code can occur and wreak
+ havoc on your system. We hope to have a
mechanism for signing/verifying the modules that we provide
available in a future release.
@@ -346,7 +385,7 @@ EndSection
<item>The Keyboard, Pointer and XInput sections have been replaced by a
more general InputDevice section. The old Keyboard and Pointer
sections are still recognised for compatibility purposes, but
- they are deprecated and support for them may be dropped in future
+ they are discommended and support for them may be dropped in future
releases. The old XInput sections are no longer recognised.
The keywords from the old sections are expressed as Options in
the InputDevice sections. The following example shows typical
@@ -753,6 +792,13 @@ XFree86 &relvers; includes the following drivers:
<tabrow><tt>rendition</tt><colsep>Rendition</tabrow>
<tabrow><tt>s3virge</tt><colsep>S3 ViRGE</tabrow>
<tabrow><tt>sis</tt><colsep>SiS</tabrow>
+ <tabrow><tt>sunbw2</tt> (+)<colsep>Sun bw2</tabrow>
+ <tabrow><tt>suncg14</tt> (+)<colsep>Sun cg14</tabrow>
+ <tabrow><tt>suncg3</tt> (+)<colsep>Sun cg3</tabrow>
+ <tabrow><tt>suncg6</tt> (+)<colsep>Sun GX and Turbo GX</tabrow>
+ <tabrow><tt>sunffb</tt> (+)<colsep>Sun Creator, Creator3D and Elite 3D</tabrow>
+ <tabrow><tt>sunleo</tt> (+)<colsep>Sun Leo (ZX)</tabrow>
+ <tabrow><tt>suntcx</tt> (+)<colsep>Sun TCX</tabrow>
<tabrow><tt>tdfx</tt><colsep>3Dfx</tabrow>
<tabrow><tt>tga</tt><colsep>DEC TGA</tabrow>
<tabrow><tt>trident</tt><colsep>Trident</tabrow>
@@ -763,6 +809,9 @@ XFree86 &relvers; includes the following drivers:
Drivers marked with (*) are present in a preliminary form in this release,
but are not complete and/or stable yet.
+<p>
+
+Drivers marked with (+) are for Linux/Sparc only.
<sect2>APM <label id="apm">
<p>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml
index 36f767175..38439e234 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml
@@ -9,7 +9,7 @@
<date>3 March 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.15 2000/03/03 21:28:10 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/Status.sgml,v 1.17 2000/06/19 15:00:54 tsi Exp $
</ident>
<abstract>
@@ -133,15 +133,16 @@ dependencies/limitations, other architectures known to work on
<tag>&relvers;:</tag>
Accelerated support is provided for the Rage 128 chips by the
- "r128" driver. Unaccelerated support is provided for all of the
- others except the Mach8 and some early Mach32 chips by the "ati"
- driver.
+ "r128" driver. Accelerated support is provided for the Mach64
+ Rage variants by the "ati" driver. Unaccelerated support is
+ provided for all of the others except the Mach8 and some early
+ Mach32 chips by the "ati" driver.
<tag>Summary:</tag>
All chips supported in &legacyvers; are supported in &relvers;
except for Mach8 and some old Mach32 chips. The support in
&relvers; is, however, unaccelerated for all chips except the
- Rage 128.
+ Mach64, Rage and Rage 128 variants.
</descrip>
@@ -428,13 +429,13 @@ dependencies/limitations, other architectures known to work on
<descrip>
<tag>&legacyvers;:</tag>
Support (accelerated) for the NV1, Riva 128, 128ZX, TNT, TNT2
- (Ultra, Vanta, M64), GeForce (DDR) and Quadro is provided by
+ (Ultra, Vanta, M64), GeForce (DDR, 256) and Quadro is provided by
the XF86_SVGA server and the nv driver.
<tag>&relvers;:</tag>
Support (accelerated) for the Riva 128, 128ZX, TNT, TNT2 (Ultra,
- Vanta, M64), GeForce (DDR) and Quadro is provided by the XF86_SVGA
- server and the nv driver.
+ Vanta, M64), GeForce (DDR, 256) and Quadro is provided by
+ the nv driver.
<tag>Summary:</tag>
All chipsets supported in &legacyvers; except the NV1 are also
@@ -592,7 +593,8 @@ dependencies/limitations, other architectures known to work on
has not been ported.
<tag>Summary:</tag>
- No SMI chips are supported in &relvers;.
+ No SMI chips are supported in &relvers;, but the fbdev driver is
+ reported to work on Linux.
</descrip>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml
index 6927a0c41..662b6d744 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml
@@ -8,10 +8,10 @@
<title>ATI Adapters README file
<author>Marc Aurele La France
-<date>1999 October 25
+<date>2000 June 15
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.29 2000/02/18 12:19:08 tsi Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/ati.sgml,v 3.31 2000/06/19 15:00:54 tsi Exp $
</ident>
<abstract>
@@ -41,8 +41,8 @@ otherwise
<item>generic VGA support if a non-ATI VGA-capable adapter is detected
<it>and</it> the user has requested such support.
</itemize>
-Thus, the support provided not only depends on what the driver detects in the
-system, but also, on what the user specifies in the XF86Config file.
+Thus, the level of support provided not only depends on what the driver detects
+in the system, but also, on what the user specifies in the XF86Config file.
See the <bf>``XF86Config specifications''</bf> section below for details.<p>
If none of the above conditions are met, the ATI driver will essentially
disable itself to allow other drivers to examine the system.<p>
@@ -80,11 +80,12 @@ VGAWonder series: 18800, 18800-1, 28800-2, 28800-4, 28800-5, 28800-6
264CT, 264ET, 264VT, 264GT (3D Rage), 264VT-B, 264VT3,
264VT4, 264GT-B (3D Rage II), 3D Rage IIc, 3D Rage Pro,
3D Rage LT, 3D Rage LT Pro, 3D Rage XL, 3D Rage XC,
- 3D Rage Mobility</verb>
+ 3D Rage Mobility (including the -M and -P variants)</verb>
The driver also supports 32K, 64K and 16M-colour modes on the 264xT and 3D Rage
-series of adapters using the accelerator CRTC (but not the VGA CRTC).
-This support is as yet unaccelerated.<p>
-The newer Rage 128 chips are not yet supported.<p>
+series of adapters using the accelerator CRTC (but not the VGA CRTC).<p>
+The newer Rage 128 chips are not yet supported by this driver.
+Rage 128's are, however, supported by a separate driver, and Rage 128 owners
+should read the r128 driver's documentation for details.<p>
Adapters based on the above chips have been marketed under a rather large
number of names over the years.
Among them are:
@@ -107,20 +108,22 @@ VGAWonder series: VGAWonder V3, VGAWonder V4, VGAWonder V5, VGAWonder+,
All-In-Wonder PRO, 3D Pro Turbo, XPERT@Play,
XPERT@Play 98, XPERT@Work, XPERT 98, XPERT LCD,
XPERT XL</verb>
+Also, a number of mainboards, laptops and notebooks harbour a Mach32 or Mach64
+controller.<p>
VGAWonder, Mach8 and Mach32 ISA adapters are available with or without a
mouse.<p>
These adapters are available with a variety of clock generators and RAMDACs.
The 264xT and 3D Rage series of chips are integrated controllers, meaning that
they include a programmable clock generator and a RAMDAC.<p>
-This driver still does not provide support for accelerated drawing to the
-screen.
+For all but Mach64 adapters, this driver still does not provide support for
+accelerated drawing to the screen.
This means that all drawing is done by the CPU, rather than by any accelerator
present in the system.
This can make opaque moves, for example, quite ``jerky''.
Also, given that IBM 8514/A and ATI Mach8 do not allow CPU access to their
frame buffer, the driver will currently ignore these accelerators.
-Most Mach32 adapters provide both accelerated function and VGA functionality,
-but the driver currently only uses the VGA.<p>
+Most Mach32 adapters provide both accelerated function and SuperVGA
+functionality, but the driver currently only uses the VGA.<p>
The driver <it>does</it> however support the accelerator CRTC present in all
ATI Mach64 adapters.
For 256-colour, and higher depth modes, this support will be used by default,
@@ -129,8 +132,12 @@ instead.
A linear video memory aperture is also available in 256-colour and higher depth
modes and enabled by default if a 264xT or 3D Rage controller is detected or,
on 88800 controllers, if the accelerator CRTC is used.
-An XF86Config option is available to disable this aperture, or (on non-PCI
+XF86Config options are available to disable this aperture, or (for non-PCI
adapters) enable it or move it to some other address.<p>
+By default, the driver provides some acceleration for Mach64 if the accelerator
+CRTC is used.
+This support is as yet incomplete and can be disabled entirely with an
+XF86Config option.<p>
<sect>Current implementation of generic VGA support for non-ATI adapters<p>
Support for generic VGA with non-ATI adapters is also implemented, but has
undergone only limited testing.
@@ -151,9 +158,10 @@ VGA implementation:
<item>Video memory is limited to 256kB in monochrome and 16-colour modes.
<item>Video memory is limited to 64kB in 256-colour modes.
<item>Interlaced modes are not available.
+<item>Colour depths higher than 8 are not available.
</itemize>
<sect>XF86Config specifications<p>
-The driver recognizes a number of XF86Config options.
+The driver recognises a number of XF86Config options.
In general, all such options should be specified in a ``Device'' section, and
affect only that ``Device'' section.<p>
Those options that affect how the driver associates adapters with ``Device''
@@ -168,7 +176,7 @@ Other options affect the driver's operation once an adapter has been assigned
to the ``Device'' section which contains them.<p>
<sect1>Driver ``ati''<p>
The use of this specification is highly recommended if the ``Device'' section
-is to be recognized by the driver.
+is to be recognised by the driver.
In fact, it is almost (but not quite) mandatory, particularly when using the
loader server as it indicates what driver is to be loaded and associated with
the ``Device'' section.<p>
@@ -180,7 +188,8 @@ CRTC will be used to drive the screen.
Otherwise, the driver will programme the adapter's SuperVGA CRTC.<p>
If ``<it>ativga</it>'' is specified instead, the driver will ignore any ATI
accelerator it detects, but otherwise operate as if ``<it>ati</it>'' had been
-specified.<p>
+specified.
+This specification ensures the VGA CRTC is used.<p>
A ChipSet name of ``<it>ibmvga</it>'' causes any VGA-capable adapter in the
system to be associated with the ``Device'' section.
It enables the driver's generic VGA support, but only for non-ATI adapters.
@@ -206,18 +215,22 @@ They are otherwise equivalent to ``<it>ati</it>''.<p>
<sect1>ChipID & ChipRev specifications<p>
These specifications will cause the driver to associate the ``Device'' section
only with an adapter having the same attributes, or an adapter whose PCI device
-ID the driver does not recognize.
+ID the driver does not recognise.
In the second case, these options cause the driver to treat the adapter as if
it was one with the specified PCI device ID or revision.
-ChipID can only be used with Mach32 or Mach64 adapters.
-ChipRev is meaningful only with Mach64 adapters.<p>
+ChipID can only be used with Mach32 or Mach64 adapters, and, thus, specifically
+excludes any other adapter from matching the ``Device'' section.
+ChipRev is meaningful only with Mach64 adapters, and then only if ChipID is
+also specified in the same ``Device'' section.<p>
<sect1>IOBase<p>
This option limits the adapters that can be associated with the ``Device''
-section to those with the specified I/O base.
-This option only applies to Mach64 adapters.<p>
+section to the one with the specified I/O base.
+This option only applies to Mach64 adapters and specifically excludes other
+adapters.<p>
<sect1>BusID<p>
This option limits the adapters that can be associated with the ``Device''
-section to those with the specified PCI Bus ID.<p>
+section to the one with the specified PCI Bus ID.
+This specification excludes non-PCI adapters.<p>
<sect1>Clocks<p>
For the purpose of specifying a clock line in your XF86Config, one of four
different situations can occur, as follows.<p>
@@ -236,7 +249,7 @@ used on the great majority of Mach64 adapters.<p>
If you are uncertain which situation applies to your adapter, you can run a
clock probe with the command ``<tt>X -probeonly</tt>''.<p>
<sect2>Clocks for supported programmable clock generators<p>
-At bootup, video BIOS initialization programmes an initial set of frequencies.
+At bootup, video BIOS initialisation programmes an initial set of frequencies.
Two of these are reserved to allow the setting of modes that do not use a
frequency from this initial set.
One of these reserved slots is used by the BIOS mode set routine, the other by
@@ -253,7 +266,7 @@ This case is unlikely to occur, but is documented for the sake of
completeness.<p>
In this situation, the driver will probe the adapter for clock frequencies
unless XF86Config clocks are already specified.
-In either case, the driver will then attempt to normalize the clocks to one of
+In either case, the driver will then attempt to normalise the clocks to one of
the following specifications:
<verb>
BIOS setting 1:
@@ -345,17 +358,25 @@ Mach32 and Mach64 owners should note that this order is different than what
they would use for previous XFree86 accelerated servers.<p>
<sect2>Clocks for non-ATI adapters<p>
If no clocks are specified in the XF86Config, the driver will probe for four
-clocks, the second of which will be assumed to be 28.322MHz.
+clocks, the second of which will be assumed to be 28.322 MHz.
+The first clock will typically be 25.175 MHz, but there are exceptions.
You can include up to four clock frequencies in your XF86Config to specify the
actual values used by the adapter.
Any more will be ignored.<p>
<sect1>Option <it>``crt_screen''</it><p>
This specification is only effective when the driver detects that the adapter's
-BIOS has initialized both the digital flat panel and CRT interfaces.
+BIOS has initialised both the digital flat panel and CRT interfaces.
In such a situation, the driver will normally drive the panel and disable the
CRT.
This specification causes the driver to disable the digital flat panel and
-display the screen image on the CRT instead.<p>
+display the screen image on the CRT instead.
+This specification will be reworked in the near future.<p>
+<sect1>Option <it>``noaccel''</it><p>
+By default, the driver will accelerate draw operations if a Mach64 CRTC is used
+to drive the display.
+As implemented in this driver, acceleration does not require a linear video
+memory aperture.
+This option disables this acceleration.<p>
<sect1>Option <it>``nolinear''</it><p>
By default, the driver will enable a linear video memory aperture for
256-colour and higher depth modes if it is also using a Mach64 accelerator CRTC
@@ -373,10 +394,17 @@ This is normally the case for PCI or AGP adapters, and, so, this option is
enabled by default.
For other bus types, the default behaviour is to disable this option.<p>
Note that, due to various limitations, this option is forcibly disabled when a
-linear video memory aperture is not enabled, or when the frame buffer depth is
-less than 8.
-The use of video acceleration, when implemented in a future driver release,
-will also disable frame buffer shadowing.<p>
+linear video memory aperture is not enabled, when the frame buffer depth is
+less than 8, or when acceleration is used.<p>
+<sect1>Option <it>``dpms''</it><p>
+This option enables the driver's support for VESA's Display Power Management
+Specification.<p>
+<sect1>Option <it>``backingstore''</it><p>
+This is not specifically a driver option.
+It is used to enable the server's support for backing store, a mechanism by
+which pixel data for occluded window regions is remembered by the server
+thereby alleviating the need to send expose events to X clients when the data
+needs to be redisplayed.<p>
<sect1>MemBase <it>address</it><p>
This specification is only effective for non-PCI Mach64 adapters, and is used
to override the CPU address at which the adapter will map its video memory.
@@ -384,10 +412,33 @@ Normally, for non-PCI adapters, this address is set by a DOS install utility
provided with the adapter.
The MemBase option can also be used to enable the linear aperture in those
cases where ATI's utility was not, or can not be, used.<p>
-For PCI adapters, this address is determined at system bootup according to the
-PCI Plug'n'Play specification which arbitrates the resource requirements of
-most devices in the system.
+For PCI and AGP adapters, this address is determined at system bootup according
+to the PCI Plug'n'Play specification which arbitrates the resource requirements
+of most devices in the system.
This means the driver can not easily change the linear aperture address.<p>
+<sect>Video modes<p>
+Mode timings can be derived from the information in XFree86's doc subdirectory.
+However, it is no longer required to specify such timings in an XF86Config's
+``Monitor'' section(s), if only standard mode timings are to be used.
+The server automatically inserts VESA standard mode timings in every
+``Monitor'' section, and these modes will be checked first for mode constraints
+(monitor sync tolerances, video memory size, etc.).<p>
+Furthermore, it is also no longer required to specify mode names in ``Display''
+subsections.
+Should no mode names be specified (or those specified do not yield a usable
+mode), the server will automatically select as a default resolution the largest
+usable mode, whether or not the chosen mode is specified in the corresponding
+``Monitor'' section.<p>
+For a CRT monitor, you should still specify horizontal sync and vertical
+refresh rates in the corresponding ``Monitor'' section.
+Otherwise, the server will default these to those of a VGA monitor, which will
+limit resolutions to not much more than 640x480 at 72 Hz.
+For a digital flat panel, any sync tolerances should be removed from the
+corresponding ``Monitor'' section.
+The driver will automatically calculate these from the mode that is active on
+server entry.
+The driver also inserts timings for a mode called <it>"Native panel mode"</it>
+that represents the panel's native resolution.<p>
<sect>Known problems and limitations<p>
There are several known problems or limitations related to the XFree86 ATI
driver.
@@ -397,13 +448,13 @@ They include:<p>
using PCI Mach64 adapters.
The great majority of these problems have been found to be due to system
aspects that are unrelated to this driver.
-As of this writing, these problems can be divided into three general areas:<p>
+As of this writing, these problems can be divided into two general areas:<p>
Improper mouse protocol specification with some recent mice.
Try different protocol specifications or another mouse.<p>
A system conflict with APM.
This problem is Linux-specific.
There is a bug in kernels 2.0.31 or earlier that prevents proper APM operation.
-Upgrade to a more recent kernel or disable APM support.<p>
+Upgrade to a more recent kernel or disable APM support in the kernel.<p>
<item>When using a Mach64's accelerator CRTC, the virtual resolution must be
less than 8192 pixels wide.
The VGA CRTC further limits the virtual resolution width to less than 4096
@@ -453,18 +504,23 @@ This will be fixed in a future release.
</itemize>
Support for the following will be added in a future release:
<itemize>
-<item>Mach32 accelerator's CRTC.
+<item>Mach32's accelerator CRTC.
This support is the first step towards accelerated support for Mach32's,
Mach8's, 8514/A's and other clones.
-<item>Colour depth greater than 8, where permitted by the hardware.
-<item>Mach64, Mach32, Mach8 and 8514/A Draw Engines.
+<item>Colour depth greater than 8 on non-integrated controllers, where
+permitted by the hardware.
+<item>Mach32, Mach8 and 8514/A Draw Engines.
<item>Hardware cursors.
+<item>TVOut, i.e. the ability to use a television screen as a monitor.
+<item>Motion Video, i.e. displaying an asynchronous data stream (TV signal,
+DVD, etc.) in a window or full-screen.
+<item>3D operations.
</itemize>
<sect>Reporting problems<p>
If you are experiencing problems that are not already recorded in this
document, first ensure that you have the latest current release of this driver
and XFree86.
-Check the server's stderr output and <htmlurl
+Check the server's log (usually found in /var/log/XFree86.0.log) and <htmlurl
name="ftp://ftp.xfree86.org/pub/XFree86"
url="ftp://ftp.xfree86.org/pub/XFree86"> if you are uncertain.<p>
Secondly, please check XFree86's doc directory for additional information.<p>
@@ -473,10 +529,10 @@ url="http://www.xfree86.org/FAQ">.<p>
Fourth, a scan through the comp.windows.x.i386unix and comp.os.linux.x
newsgroups using your favourite archiving service can also prove useful in
resolving problems.<p>
-If you are still experiencing problems, you can send me e-mail at
-<email>tsi@ualberta.ca</email>.
+If you are still experiencing problems, you can send me <it>non-HTMLised</it>
+e-mail at <email>tsi@ualberta.ca</email>.
Please be as specific as possible when describing the problem(s), and include
-an unedited copy of the server's stderr and the XF86Config file used.<p>
+an <it>unedited</it> copy of the server's log and the XF86Config file used.<p>
<sect>Driver history<p>
The complete history of the driver is rather cloudy.
The following is more than likely to be incomplete and inaccurate.<p>
@@ -487,20 +543,19 @@ driver written by Thomas Roell (currently of Xi Graphics).<p>
Then Doug Evans (<it>dje@cygnus.com</it>) added support for the ATI VGA Wonder
XL, trying in the process to make the driver work with all other ATI adapters
available at the time.<p>
-Rik Faith (<it>faith@cs.unc.edu</it>) obtained the X11R4 driver from Doug Evans
-in the summer of 1992 and ported the code to the X386 part of X11R5.
+Rik Faith (<it>faith@precisioninsight.com</it>) obtained the X11R4 driver from
+Doug Evans in the summer of 1992 and ported the code to the X386 part of X11R5.
This subsequently became part of XFree86.<p>
I (Marc Aurele La France) took over development and maintenance of the driver
in the fall of 1993 after Rik got rid of his VGA Wonder adapter.<p>
<sect>Driver versions<p>
Due to the introduction of loadable drivers in XFree86 4.0, it has become
necessary to track driver versions separately.
-With this release of the driver, I am introducing the following version
-numbering scheme.<p>
+Driver releases use the following version numbering scheme.<p>
Version 1 of this driver is the one I inherited from Rik Faith.
This is the version found in XFree86 2.0 and 2.1.<p>
Version 2 is my first rewrite of this code which only ended up being a
-partially unsuccessful attempt at generalizing the driver for all VGA Wonder,
+partially unsuccessful attempt at generalising the driver for all VGA Wonder,
Mach32, and early Mach64 adapters.
Various releases of this version of the driver can be found in XFree86 2.1.1,
3.1, 3.1.1 and 3.1.2.<p>
@@ -511,10 +566,8 @@ in the old ati_test debugging tool.
This is the version found in XFree86 3.2, 3.3 and 3.3.1.<p>
Version 4 is a rather major restructuring of version 3, which became larger
than I could comfortably handle in one source file.
-This version will make it quite a bit easier to introduce new function such as
-acceleration, additional colour depths, and so on.
-This is the version found in XFree86 3.3.2, 3.3.3, 3.3.3.1, 3.3.3.2 and
-3.3.4.<p>
-Version 5 is an almost complete restructuring of version 4 to fit in the new
-driver API of XFree86 4.0.<p>
+This is the version found in XFree86 3.3.2, 3.3.3, 3.3.3.1, 3.3.3.2, 3.3.4,
+3.3.5 and 3.3.6.<p>
+Version 5 is an almost complete restructuring of version 4 to fit in the newer
+driver API of XFree86 4.0 and later.<p>
</article>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml
index cda9a90df..1ecbb4d53 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml
@@ -8,10 +8,10 @@
<title> Information for Chips and Technologies Users
<author> David Bateman (<email>dbateman@club-internet.fr</email>),
Egbert Eich (<email>eich@xfree86.org</email>)
-<date> 19th July 1999
+<date> 14th June 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.30 2000/03/05 16:59:11 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/chips.sgml,v 3.31 2000/06/14 01:43:49 dawes Exp $
</ident>
<!-- Table of contents -->
@@ -35,6 +35,7 @@ to use this version. These features include
<item>Gamma correction at all depths and DirectColor visuals for depths of
15 or greater with the HiQV series of chipsets.
<item>Supports PsuedoColor overlays on 16bpp TrueColor screens for HiQV.
+<item>Supports YUV colour space conversion with the XVideo extension.
<item>32bpp pixmaps while using a framebuffer in 24bpp packed pixel mode.
<item>Heaps more acceleration.
<item>1/4bpp support.
@@ -115,9 +116,9 @@ HiQV architecture.
<descrip>
<tag>ct65550</tag>
This chip includes many new features, including improved BitBLT
- support (24bpp color expansion, wider maximum pitch, etc), Multimedia
+ support (24bpp colour expansion, wider maximum pitch, etc), Multimedia
unit (video capture, zoom video port, etc) and 24bpp uncompressed true
- color (i.e 32bpp mode). Also memory mapped I/O is possible on all bus
+ colour (i.e 32bpp mode). Also memory mapped I/O is possible on all bus
configurations.
(Max Ram: 2Mb, Max Dclk: 80MHz@3.3V,100MHz@5V)
<tag>ct65554</tag>
@@ -414,15 +415,25 @@ Option "Overlay"
multimedia engine to its limit, and some manufacturers have set a
default memory clock that will cause pixel errors with this option.
If you get pixel error with this option try using the
- "<tt>SetMClk</tt>" option to slow the memory clock.
+ "<tt>SetMClk</tt>" option to slow the memory clock. It should also
+ be noted that the XVideo extension uses the same capabilities of the
+ HiQV chipsets as the Overlays. So using this option disables the
+ XVideo extension.
<tag>
Option "ColorKey" "255"
</tag>
- Normally the color transparency key for the overlay is the 8bpp lookup
+ Normally the colour transparency key for the overlay is the 8bpp lookup
table entry 255. This might cause troubles with some applications, and
- so this option allows the color transparency key to be set to some
+ so this option allows the colour transparency key to be set to some
other value. Legal values are 2 to 255 inclusive.
<tag>
+Option "VideoKey" "255"
+</tag>
+ This sets the default pixel value for the YUV video overlay key. Legal
+ values for this key are depth dependent. That is from 0 to 255 for
+ 8bit depth, 0 to 32,767 for 15bit depth, etc. This option might be used
+ if the default video overlay key causes problems.
+<tag>
Option "XaaNoScreenToScreenCopy",
Option "XaaNoSolidFillRect",
Option "XaaNoSolidHorVertLine",
@@ -494,6 +505,11 @@ driver you'll needed to considered several points
is therefore similar to a 24bpp mode. The overlay consumes memory
bandwidth, so that the maximum dotclock will be similar to a 24bpp
mode.
+<tag> * XVideo extension* </tag>
+ Like the overlays, the Xvideo extension uses a part of the
+ video memory for a second framebuffer. In this case enough memory
+ needs to be left for the largest unscaled video window that will be
+ displayed.
<tag> * VESA like modes </tag>
We recommend that you try and pick a mode that is similar
to a standard VESA mode. If you don't a suspend/resume or LCD/CRT
@@ -811,6 +827,10 @@ video processor beyond it capabilities won't cause damage.
that is too high for use with the "<tt>Overlay</tt>" option. So with
the "<tt>Overlay</tt>" option, using the "<tt>SetMClk</tt>" option to
reduce the speed of the memory clock is recommended.
+<tag> The mpeg video playing with the XVideo extension has corrupted colours </tag>
+ The XVideo extension has only recently been added to the chips driver.
+ Some YUV to RGB colour have been noted at 15 and 16 bit colour depths.
+ However, 8 and 24 bit colour depths seem to work fine.
<tag> I can't start X-windows with 16, 24 or 32bpp</tag>
Firstly, is your machine capable of 16/24/32bpp with the mode
specified. Many LCD displays are incapable of using a 24bpp
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent b/xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent
index 17c8c740f..ffe0e624a 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent
@@ -1,12 +1,12 @@
-<!-- $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent,v 1.11 2000/03/08 18:04:15 dawes Exp $ -->
+<!-- $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/defs.ent,v 1.13 2000/06/30 16:54:28 dawes Exp $ -->
<!-- shared entity definitions for the XFree86 documentation -->
<!-- XFree86 version string -->
-<!ENTITY relvers CDATA "4.0">
-<!ENTITY prevrelvers CDATA "3.9.18">
-<!ENTITY srcvers CDATA "400">
-<!ENTITY prevsrcvers CDATA "3918">
+<!ENTITY relvers CDATA "4.0.1">
+<!ENTITY prevrelvers CDATA "4.0">
+<!ENTITY srcvers CDATA "401">
+<!ENTITY prevsrcvers CDATA "400">
<!-- Version of the most recent 3.3.x release -->
<!ENTITY legacyvers CDATA "3.3.6">
@@ -19,7 +19,7 @@
<!ENTITY % latersnap 'INCLUDE'>
<!ENTITY % snapshot 'IGNORE'>
<!ENTITY % release 'INCLUDE'>
-<!ENTITY % firstrel 'INCLUDE'>
+<!ENTITY % firstrel 'IGNORE'>
<!ENTITY % earlyrel 'INCLUDE'>
-<!ENTITY % laterrel 'IGNORE'>
+<!ENTITY % laterrel 'INCLUDE'>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/index.post b/xc/programs/Xserver/hw/xfree86/doc/sgml/index.post
index f349b8099..17e6c2f43 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/index.post
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/index.post
@@ -1,8 +1,22 @@
</itemize>
+<![ %manpages; [
+<p>
+Manual pages:
+<itemize>
+<item><htmlurl name="Section 1" url="manindex1.html">: Commands
+<item><htmlurl name="Section 3" url="manindex3.html">: Library Functions
+<item><htmlurl name="Section &drvsuffix;" url="manindex&drvsuffix;.html">: Drivers
+<item><htmlurl name="Section &filesuffix;" url="manindex&filesuffix;.html">: Files and file formats
+<item><htmlurl name="Section &miscsuffix;" url="manindex&miscsuffix;.html">: Miscellaneous
+</itemize>
+<p>
+]]>
+
+
</article>
<!--
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/index.post,v 1.1 1999/08/24 11:24:09 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/index.post,v 1.2 2000/03/21 19:57:10 dawes Exp $
-->
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre b/xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre
index 2330554b5..fd174e9f0 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre
@@ -1,5 +1,6 @@
<!DOCTYPE linuxdoc PUBLIC "-//XFree86//DTD linuxdoc//EN"[
<!ENTITY % defs SYSTEM "defs.ent"> %defs;
+<!ENTITY % mdefs SYSTEM "mdefs.ent"> %mdefs;
]>
<article>
@@ -7,10 +8,10 @@
<!-- Title information -->
<title>Documentation for XFree86&trade; version &relvers;
<author>The XFree86 Project, Inc
-<date>8 March 2000
+<date>30 June 2000
<!--
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre,v 1.6 2000/03/08 05:38:44 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/index.pre,v 1.8 2000/06/30 22:09:37 dawes Exp $
-->
<p>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/mdefs.cpp b/xc/programs/Xserver/hw/xfree86/doc/sgml/mdefs.cpp
new file mode 100644
index 000000000..ecf654037
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/mdefs.cpp
@@ -0,0 +1,14 @@
+<!-- $XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/mdefs.cpp,v 1.1 2000/03/21 19:57:11 dawes Exp $ -->
+
+<!-- entity definitions for man pages -->
+
+#ifdef HTML_MANPAGES
+<!ENTITY % manpages 'INCLUDE'>
+#else
+<!ENTITY % manpages 'IGNORE'>
+#endif
+
+<!ENTITY drvsuffix CDATA __drivermansuffix__ >
+<!ENTITY filesuffix CDATA __filemansuffix__ >
+<!ENTITY miscsuffix CDATA __miscmansuffix__ >
+
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml
index 18fdb4a5e..db1ef8af4 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml
@@ -5,10 +5,10 @@
<article>
<title>Information for ATI Rage 128 Users
<author>Precision Insight, Inc., SuSE GmbH
-<date>12 November 1999
+<date>13 June 2000
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml,v 1.7 2000/03/08 15:14:48 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/r128.sgml,v 1.8 2000/06/14 00:16:09 dawes Exp $
</ident>
<toc>
@@ -86,7 +86,7 @@ However, if you have problems with auto-detection, you can specify:
<sect>Known Limitations
<p>
<itemize>
- <item>DGA is not supported yet
+ <item>None
</itemize>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml
index f8a923a1c..71100bf8f 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml
@@ -3,12 +3,12 @@
]>
<article>
-<title>Information for Rendition Users
+<title>Information for Rendition (Micron) Verité Users
<author>The XFree86 Project Inc.
-<date>12 December 1999
+<date>9 June 2000, last update by Dejan Ilic <email>dejan.ilic@home.se</email>
<ident>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml,v 1.8 2000/03/01 23:54:34 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/rendition.sgml,v 1.12 2000/06/17 02:30:33 dawes Exp $
</ident>
<toc>
@@ -29,6 +29,11 @@ Some V1000-based video cards are known to lock up the computer if you have write
If you have problems with hardware cursor use the "sw_cursor" option to revert back to software cursor.<p>
+This is essentially a port of XFree86 3.3.x driver to the new XFree86
+4.0 API, and thus we have put most of effort in making a working driver
+with the most basic features. Support for multi-head support and
+acceleration are next on the list of features to be included.<p>
+
<sect>Features <p>
<itemize>
<item>Hardware acceleration
@@ -44,16 +49,16 @@ If you have problems with hardware cursor use the "sw_cursor" option to revert b
<sect>XF86Config Option <p>
<descrip>
-<tag>Option "sw_cursor"</tag>
+<tag>Option "SW_Cursor"</tag>
Disables use of the hardware cursor.
-<tag>Option "overclock_mem"</tag>
+<tag>Option "Overclock_Mem"</tag>
Run the memory at a higher clock. Useful on some cards with display glitches
at higher resolutions. But adds the risk to damage the hardware. Use with
caution.
<tag>DacSpeed "MHz"</tag>
Set custom ramdac limit. We have currently no way of knowing if the v2x00 chip is a v2100 (170MHz) or v2200 (203MHz and 230MHz) so we assume the lowest. Use this option to manually override the value.
<tag>Option "FramebufferWC"</tag>
-If writecombine is disabled in BIOS, and you add this option in in configuration file, then the driver will try to request writecombined access to the framebuffer. This can drastically increase the performance on unaccelerated server. Requires that "MTRR"-support is compiled into the OS-kernel.
+If writecombine is disabled in BIOS, and you add this option in configuration file, then the driver will try to request writecombined access to the framebuffer. This can drastically increase the performance on unaccelerated server. Requires that "MTRR"-support is compiled into the OS-kernel.
<tag>Option "NoDDC"</tag>
Disable probing of DDC-information from your monitor. This information is not used yet and is only there for informational purposes. This might change before final XFree86 4.0 release. Safe to disable if you experience problems during startup of X-server.
<tag>Option "ShadowFB"</tag>
@@ -72,20 +77,20 @@ Notice that this option requires "ShadowFB" and automatically enable it. It also
The option is not activated by default.
</descrip>
-<sect>News in this release <p>
+<sect>News in this release (XFree86 4.1)<p>
<itemize>
-<item>Acceleration! Disabled for the moment.
+<item>DirectColor support
+<item>SilkenMouse support
</itemize>
<sect>Major changes in this release <p>
<itemize>
-<item>ShadowFB support added
-<item>To be determined before final release.
+<item>Gamma works now for >8bpp
</itemize>
<sect>Bugfixes<p>
<itemize>
-<item>8bpp finally works correctly again
+<item>Only some code cleanup done. No real bugfixes.
</itemize>
<sect>Known problems in current driver<p>
@@ -94,6 +99,7 @@ The option is not activated by default.
<item>DDC-probing does not work correctly yet. No DDC information is found.
<item>Switching from display to VC and back to display can lock up V2x00 cards.
<item>When scrolling the virtual display on a V1000 card parts of the screen will become distorted. Problem disappears when you continue moving around. V2x00 does not exhibit this problem. Probably a bug in the driver rather than a limitation of the chip.
+<item>Depth 15 & 16 has problems with colors when DirectColor is used.
</itemize>
<sect>Work in progress (not finished in time for release) <p>
diff --git a/xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml b/xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml
index 32afbcc51..f0c8f39a6 100644
--- a/xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml
+++ b/xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml
@@ -3,20 +3,17 @@
<title> Information for Trident Chipset Users
<author> The XFree86 Project, Inc.
-<date> June 25 1999
+<date> March 7th 2000
<toc>
<sect> Supported chipsets <p>
-The Trident driver has undergone some slight work for XFree86 3.3.3.
-Because of this work, all of the Trident SVGA chipsets, except
-the very first one, are supported by both the color and monochrome servers.
+The Trident driver has the following list of chipsets supported for &relvers;
+
<quote><bf>
-8800CS 8200LX
-8900B 8900C 8900CL/D 9000 9000i 9100B
-9200CXr 9320LCD 9400CXi 9420 9420DGi 9430DGi 9440AGi 9660XGi 9680
-ProVidia9682 ProVidia9685 Cyber9382 Cyber9385 Cyber9385-1 Cyber9388
-Cyber9397 Cyber9520 Cyber9525 3DImage975(PCI) 3DImage975(AGP)
-3DImage985(AGP) Blade3D CyberBlade
+8900CL/D 9440AGi 9660XGi 9680 ProVidia9682 Pro-Vidia9685
+Cyber9382 Cyber9385 Cyber9385-1 Cyber9388 Cyber9397
+Cyber9520 Cyber9525 Cyber9540 3DImage975(PCI) 3DImage975(AGP)
+3DImage985(AGP) Blade3D CyberBlade/i7 CyberBlade/i1 CyberBlade/e4/128
</bf></quote>
It must be noted that the 9000i chipset is treated as a 9000 by the server.
Additionally the 9100B is treated
@@ -157,7 +154,7 @@ in the <tt>XF86Config</tt> file, these lockups are overcome. But it may
be worth checking wait states etc. on the card and in the BIOS setup.
<verb>
-$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml,v 3.24 1999/08/23 06:38:54 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/doc/sgml/trident.sgml,v 3.25 2000/03/19 16:43:51 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile
index 088c2ba5b..721370a12 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile,v 1.17 2000/03/03 01:05:33 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/Imakefile,v 1.19 2000/06/30 18:27:02 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -20,12 +20,14 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
-I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \
-I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \
+ -I$(XF86SRC)/xf24_32bpp \
-I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \
-I$(XF86SRC)/rac -I$(XF86SRC)/int10 \
-I$(XF86SRC)/shadowfb \
-I$(XF86SRC)/i2c -I$(XF86SRC)/ddc \
-I$(SERVERSRC)/Xext -I$(EXTINCSRC) \
- -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC)
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(XF86OSSRC)/vbe -I$(FONTINCSRC)
#endif
#if MakeHasPosixVariableSubstitutions
@@ -54,6 +56,7 @@ InstallDriverSDKNonExecFile(apm_dga.c,$(DRIVERSDKDIR)/drivers/apm)
InstallDriverSDKNonExecFile(apm_driver.c,$(DRIVERSDKDIR)/drivers/apm)
InstallDriverSDKNonExecFile(apm_i2c.c,$(DRIVERSDKDIR)/drivers/apm)
InstallDriverSDKNonExecFile(apm_funcs.c,$(DRIVERSDKDIR)/drivers/apm)
+InstallDriverSDKNonExecFile(apm_video.c,$(DRIVERSDKDIR)/drivers/apm)
#if BuildXF86RushExt
InstallDriverSDKNonExecFile(apm_rush.c,$(DRIVERSDKDIR)/drivers/apm)
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp
index ee527418f..d105ba52f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp,v 1.1 2000/03/03 01:05:33 dawes Exp $
-.TH APM __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.cpp,v 1.4 2000/06/14 02:13:07 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH APM __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
apm \- Alliance ProMotion video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""apm"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qapm\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B apm
is an XFree86 driver for Alliance ProMotion video cards.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h
index 00801bc6f..efc8533f7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h
@@ -1,9 +1,6 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h,v 1.13 2000/02/29 03:09:17 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm.h,v 1.15 2000/06/30 18:27:02 dawes Exp $ */
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -11,6 +8,9 @@
/* All drivers need this */
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* This is used for module versioning */
#include "xf86Version.h"
@@ -44,6 +44,7 @@
#include "cfb16.h"
#include "cfb24.h"
#include "cfb32.h"
+#include "cfb24_32.h"
/* Drivers using the XAA interface ... */
#include "xaa.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c
index 921be3cd1..f79042607 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c,v 1.13 2000/02/14 19:20:45 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_accel.c,v 1.14 2000/06/30 18:27:02 dawes Exp $ */
#include "apm.h"
@@ -203,6 +203,23 @@ ApmCopyAreaPixmap(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC,
dstx, dsty);
}
+void ApmAccelReserveSpace(ApmPtr pApm)
+{
+ memType mem, ScratchMemOffset;
+
+ mem = xf86Screens[pApm->pScreen->myNum]->videoRam << 10;
+ /*
+ * Reserve at least four lines for mono to color expansion
+ */
+ ScratchMemOffset = ((mem - pApm->OffscreenReserved) /
+ pApm->CurrentLayout.bytesPerScanline - 4) *
+ pApm->CurrentLayout.bytesPerScanline;
+ pApm->ScratchMemSize= mem - ScratchMemOffset - pApm->OffscreenReserved;
+ pApm->ScratchMemPtr = pApm->ScratchMemOffset
+ = (memType)pApm->FbBase + ScratchMemOffset;
+ pApm->ScratchMemEnd = (memType)pApm->FbBase + mem - pApm->OffscreenReserved;
+}
+
/*********************************************************************************************/
int
@@ -212,23 +229,15 @@ ApmAccelInit(ScreenPtr pScreen)
APMDECL(pScrn);
XAAInfoRecPtr pXAAinfo;
BoxRec AvailFBArea;
- int mem, ScratchMemOffset, i, stat;
+ memType mem, ScratchMemOffset;
+ int i, stat;
pApm->AccelInfoRec = pXAAinfo = XAACreateInfoRec();
if (!pXAAinfo)
return FALSE;
mem = pScrn->videoRam << 10;
- /*
- * Reserve at least four lines for mono to color expansion
- */
- ScratchMemOffset = ((mem - pApm->OffscreenReserved) /
- pApm->CurrentLayout.bytesPerScanline - 4) *
- pApm->CurrentLayout.bytesPerScanline;
- pApm->ScratchMemSize= mem - ScratchMemOffset - pApm->OffscreenReserved;
- pApm->ScratchMemPtr = pApm->ScratchMemOffset
- = (memType)pApm->FbBase + ScratchMemOffset;
- pApm->ScratchMemEnd = (memType)pApm->FbBase + mem - pApm->OffscreenReserved;
+ ScratchMemOffset = pApm->ScratchMemOffset - (memType)pApm->FbBase;
switch (pApm->CurrentLayout.bitsPerPixel) {
case 8:
case 24:
@@ -457,14 +466,14 @@ void ApmSetupXAAInfo(ApmPtr pApm, XAAInfoRecPtr pXAAinfo)
pXAAinfo->WritePixmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
LEFT_EDGE_CLIPPING_NEGATIVE_X;
XAA(WritePixmap);
- pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
- LEFT_EDGE_CLIPPING_NEGATIVE_X |
- BIT_ORDER_IN_BYTE_LSBFIRST;
- XAA(WriteBitmap);
pXAAinfo->FillImageWriteRectsFlags =
LEFT_EDGE_CLIPPING | NO_PLANEMASK |
LEFT_EDGE_CLIPPING_NEGATIVE_X;
XAA(FillImageWriteRects);
+ pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
+ LEFT_EDGE_CLIPPING_NEGATIVE_X |
+ BIT_ORDER_IN_BYTE_LSBFIRST;
+ XAA(WriteBitmap);
pXAAinfo->TEGlyphRendererFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
LEFT_EDGE_CLIPPING_NEGATIVE_X;
XAA(TEGlyphRenderer);
@@ -545,14 +554,14 @@ void ApmSetupXAAInfo(ApmPtr pApm, XAAInfoRecPtr pXAAinfo)
pXAAinfo->WritePixmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
LEFT_EDGE_CLIPPING_NEGATIVE_X;
XAA(WritePixmap);
- pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
- LEFT_EDGE_CLIPPING_NEGATIVE_X |
- BIT_ORDER_IN_BYTE_LSBFIRST;
- XAA(WriteBitmap);
pXAAinfo->FillImageWriteRectsFlags =
LEFT_EDGE_CLIPPING | NO_PLANEMASK |
LEFT_EDGE_CLIPPING_NEGATIVE_X;
XAA(FillImageWriteRects);
+ pXAAinfo->WriteBitmapFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
+ LEFT_EDGE_CLIPPING_NEGATIVE_X |
+ BIT_ORDER_IN_BYTE_LSBFIRST;
+ XAA(WriteBitmap);
pXAAinfo->TEGlyphRendererFlags = LEFT_EDGE_CLIPPING | NO_PLANEMASK |
LEFT_EDGE_CLIPPING_NEGATIVE_X;
XAA(TEGlyphRenderer);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c
index 05c78d28b..4bf0f989b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c,v 1.12 2000/02/14 19:20:45 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_cursor.c,v 1.14 2000/06/30 18:27:02 dawes Exp $ */
#include "X.h"
@@ -11,11 +11,7 @@
#include "servermd.h"
#include "windowstr.h"
#include "mfb.h"
-#include "compiler.h"
-#include "xf86.h"
#include "mipointer.h"
-#include "xf86Priv.h"
-#include "xf86_ansic.h"
#include "apm.h"
@@ -55,6 +51,14 @@ WaitForFifo(ApmPtr pApm, int slots)
}
}
+void ApmHWCursorReserveSpace(ApmPtr pApm)
+{
+ pApm->OffscreenReserved += 2 * CURSORALIGN;
+ pApm->DisplayedCursorAddress = pApm->BaseCursorAddress =
+ pApm->CursorAddress = 1024 * xf86Screens[pApm->pScreen->myNum]->videoRam -
+ pApm->OffscreenReserved;
+}
+
int ApmHWCursorInit(ScreenPtr pScreen)
{
@@ -68,9 +72,6 @@ int ApmHWCursorInit(ScreenPtr pScreen)
return FALSE;
pApm->CursorInfoRec = infoPtr;
- pApm->OffscreenReserved += 2 * CURSORALIGN;
- pApm->DisplayedCursorAddress = pApm->BaseCursorAddress =
- pApm->CursorAddress = 1024 * pScrn->videoRam - pApm->OffscreenReserved;
infoPtr->MaxWidth = CURSORWIDTH;
infoPtr->MaxHeight = CURSORHEIGHT;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c
index 6f5415c77..d0956d30c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c,v 1.38 2000/03/08 19:25:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_driver.c,v 1.44 2000/06/30 18:34:18 dawes Exp $ */
#include "apm.h"
@@ -7,8 +7,7 @@
#include "xf86Resources.h"
#include "xf86int10.h"
#include "xf86RAC.h"
-
-#include "compiler.h"
+#include "vbe.h"
#ifdef DPMSExtension
#include "opaque.h"
@@ -53,10 +52,12 @@ static void ApmDisplayPowerManagementSet(ScrnInfoPtr pScrn,
int PowerManagementMode,
int flags);
#endif
+static void ApmProbeDDC(ScrnInfoPtr pScrn, int index);
int ApmPixmapIndex = -1;
static int ApmGeneration = -1;
+static int pix24bpp = 0;
DriverRec APM = {
VERSION,
@@ -199,6 +200,7 @@ static const char *cfbSymbols[] = {
"cfb16ScreenInit",
"cfb24ScreenInit",
"cfb32ScreenInit",
+ "cfb24_32ScreenInit",
NULL
};
@@ -372,7 +374,6 @@ ApmProbe(DriverPtr drv, int flags)
int numDevSections, numUsed, i;
GDevPtr *DevSections = NULL;
int *usedChips;
- EntityInfoPtr pEnt;
int foundScreen = FALSE;
/*
@@ -399,25 +400,22 @@ ApmProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
- pEnt = xf86GetEntityInfo(usedChips[i]);
-
- if (pEnt && pEnt->active) {
- ScrnInfoPtr pScrn;
-
- /*
- * Allocate a ScrnInfoRec and claim the slot
- */
- pScrn = xf86AllocateScreen(drv, 0);
-
+ ScrnInfoPtr pScrn;
+
+ /*
+ * Allocate a ScrnInfoRec and claim the slot
+ */
+ pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ ApmPciChipsets, NULL,
+ NULL,NULL,NULL,NULL))){
+
/*
* Fill in what we can of the ScrnInfoRec
*/
ApmAssignFPtr(pScrn);
- xf86ConfigActivePciEntity(pScrn, usedChips[i], ApmPciChipsets,
- NULL, NULL, NULL, NULL, NULL);
foundScreen = TRUE;
}
- xfree(pEnt);
}
}
@@ -429,21 +427,20 @@ ApmProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
-
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn, 0, usedChips[i],
+ ApmIsaChipsets, NULL, NULL, NULL,
+ NULL, NULL))) {
/*
* Fill in what we can of the ScrnInfoRec
*/
ApmAssignFPtr(pScrn);
foundScreen = TRUE;
- xf86ConfigActiveIsaEntity(pScrn, usedChips[i], ApmIsaChipsets,
- NULL, NULL, NULL, NULL, NULL);
+ }
}
}
-#if 0 /* This causes problems with -configure? */
if (DevSections)
xfree(DevSections);
-#endif
return foundScreen;
}
@@ -471,7 +468,7 @@ static unsigned int
ddc1Read(ScrnInfoPtr pScrn)
{
APMDECL(pScrn);
- unsigned char tmp;
+ unsigned char tmp;
tmp = RDXB_IOP(0xD0);
WRXB_IOP(0xD0, tmp & 0x07);
@@ -480,6 +477,19 @@ ddc1Read(ScrnInfoPtr pScrn)
return (STATUS_IOP() & STATUS_SDA) != 0;
}
+extern xf86MonPtr ConfiguredMonitor;
+
+static void
+ApmProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+ vbeInfoPtr pVbe;
+
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ pVbe = VBEInit(NULL, index);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+ }
+}
+
static Bool
ApmPreInit(ScrnInfoPtr pScrn, int flags)
{
@@ -492,8 +502,6 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
xf86MonPtr MonInfo = NULL;
double real;
- if (flags & PROBE_DETECT) return FALSE;
-
/*
* Note: This function is only called once at server startup, and
* not at the start of each server generation. This means that
@@ -507,6 +515,33 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
* AllocateScreenPrivateIndex() from the ScreenInit() function.
*/
+ /* Check the number of entities, and fail if it isn't one. */
+ if (pScrn->numEntities != 1)
+ return FALSE;
+
+ /* Allocate the ApmRec driverPrivate */
+ if (!ApmGetRec(pScrn)) {
+ return FALSE;
+ }
+ pApm = APMPTR(pScrn);
+
+ /* Get the entity */
+ pEnt = pApm->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+ if (pEnt->location.type == BUS_PCI) {
+ pApm->PciInfo = xf86GetPciInfoForEntity(pEnt->index);
+ pApm->PciTag = pciTag(pApm->PciInfo->bus, pApm->PciInfo->device,
+ pApm->PciInfo->func);
+ }
+ else {
+ pApm->PciInfo = NULL;
+ pApm->PciTag = 0;
+ }
+
+ if (flags & PROBE_DETECT) {
+ ApmProbeDDC(pScrn, pEnt->index);
+ return TRUE;
+ }
+
/* The vgahw module should be allocated here when needed */
if (!xf86LoadSubModule(pScrn, "vgahw"))
return FALSE;
@@ -577,24 +612,6 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
/* We use a programamble clock */
pScrn->progClock = TRUE;
- /* Allocate the ApmRec driverPrivate */
- if (!ApmGetRec(pScrn)) {
- return FALSE;
- }
- pApm = APMPTR(pScrn);
-
- /* Get the entity */
- pEnt = pApm->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
- if (pEnt->location.type == BUS_PCI) {
- pApm->PciInfo = xf86GetPciInfoForEntity(pEnt->index);
- pApm->PciTag = pciTag(pApm->PciInfo->bus, pApm->PciInfo->device,
- pApm->PciInfo->func);
- }
- else {
- pApm->PciInfo = NULL;
- pApm->PciTag = 0;
- }
-
/* Collect all of the relevant option flags (fill in pScrn->options) */
xf86CollectOptions(pScrn, NULL);
@@ -927,6 +944,23 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
break;
+ case AP6422:
+ switch(pScrn->bitsPerPixel)
+ {
+ case 4:
+ case 8:
+ pApm->MaxClock = 135000;
+ break;
+ case 16:
+ pApm->MaxClock = 75000;
+ break;
+ case 32:
+ pApm->MaxClock = 60000;
+ break;
+ default:
+ return FALSE;
+ }
+ break;
default:
pApm->MaxClock = 135000;
break;
@@ -939,7 +973,7 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = (ClockRangePtr)xnfalloc(sizeof(ClockRange));
+ clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pApm->MinClock;
clockRanges->maxClock = pApm->MaxClock;
@@ -1019,8 +1053,13 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
req = "cfb16ScreenInit";
break;
case 24:
- mod = "cfb24";
- req = "cfb24ScreenInit";
+ if (pix24bpp == 24) {
+ mod = "cfb24";
+ req = "cfb24ScreenInit";
+ } else {
+ mod = "xf24_32bpp";
+ req = "cfb24_32ScreenInit";
+ }
break;
case 32:
mod = "cfb32";
@@ -1062,8 +1101,8 @@ ApmPreInit(ScrnInfoPtr pScrn, int flags)
xf86LoaderReqSymLists(shadowSymbols, NULL);
}
- pApm->CurrentLayout.displayWidth = pScrn->display->virtualX;
- pApm->CurrentLayout.displayHeight = pScrn->display->virtualY;
+ pApm->CurrentLayout.displayWidth = pScrn->virtualX;
+ pApm->CurrentLayout.displayHeight = pScrn->virtualY;
pApm->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel;
pApm->CurrentLayout.bytesPerScanline= (pApm->CurrentLayout.displayWidth * pApm->CurrentLayout.bitsPerPixel) >> 3;
pApm->CurrentLayout.depth = pScrn->depth;
@@ -1817,6 +1856,10 @@ ApmScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
FbBase = pApm->FbBase;
}
+ /* Reserve memory */
+ ApmHWCursorReserveSpace(pApm);
+ ApmAccelReserveSpace(pApm);
+
switch (pScrn->bitsPerPixel) {
case 1:
ret = xf1bppScreenInit(pScreen, FbBase,
@@ -1841,9 +1884,16 @@ ApmScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
pScrn->displayWidth);
break;
case 24:
- ret = cfb24ScreenInit(pScreen, FbBase, pScrn->virtualX,
- pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth);
+ if (pix24bpp == 24)
+ ret = cfb24ScreenInit(pScreen, FbBase,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth);
+ else
+ ret = cfb24_32ScreenInit(pScreen, FbBase,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth);
break;
case 32:
ret = cfb32ScreenInit(pScreen, FbBase, pScrn->virtualX,
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c
index 3f5c52581..01f1be5d3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c,v 1.12 2000/02/12 18:26:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_funcs.c,v 1.13 2000/06/30 18:27:02 dawes Exp $ */
#define FASTER
#ifndef PSZ
@@ -1187,7 +1187,7 @@ A(SyncBlt)(ApmPtr pApm)
while (!(STATUS() & STATUS_HOSTBLTBUSY))
;
}
- while (again--); /* See remarc in Sync6422 */
+ while (again--); /* See remark in Sync6422 */
}
static void
A(WritePixmap)(ScrnInfoPtr pScrn, int x, int y, int w, int h,
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c
index 9c4d5c792..6794718e8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c
@@ -1,11 +1,6 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c,v 1.4 2000/02/12 02:54:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_i2c.c,v 1.5 2000/04/04 19:25:04 dawes Exp $ */
-#include "xf86.h"
-#include "xf86_OSproc.h"
-#include "xf86_ansic.h"
-#include "compiler.h"
-
#include "apm.h"
#include "apm_regs.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c
index 10fbb0f1b..09b8b0feb 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c,v 1.6 2000/02/29 03:09:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/apm/apm_video.c,v 1.7 2000/06/30 18:27:02 dawes Exp $ */
#if PSZ != 24
#include "dixstruct.h"
@@ -382,8 +382,8 @@ ApmClipVideo(BoxPtr dst, INT32 *x1, INT32 *x2, INT32 *y1, INT32 *y2,
if (dst->y2 - dst->y1 < *y2 - *y1)
dst->y2 = dst->y1 + *y2 - *y1;
- *x1 <<= 16; *x2 <<= 16;
- *y1 <<= 16; *y2 <<= 16;
+ *x1 <<= 12; *x2 <<= 16;
+ *y1 <<= 12; *y2 <<= 16;
hscale = (*x2 - *x1) / (dst->x2 - dst->x1);
vscale = (*y2 - *y1) / (dst->y2 - dst->y1);
@@ -412,11 +412,11 @@ ApmClipVideo(BoxPtr dst, INT32 *x1, INT32 *x2, INT32 *y1, INT32 *y2,
if (*x2 - *x1 == 0x10000 * (dst->x2 - dst->x1)) /* Shrinking */
*scalex = 0;
else
- *scalex = ((*x2 - *x1 - 0x1000) / (dst->x2 - dst->x1 - 1)) >> 4;
+ *scalex = ((*x2 - *x1) / (dst->x2 - dst->x1)) >> 4;
if (*y2 - *y1 == 0x10000 * (dst->y2 - dst->y1)) /* Shrinking */
*scaley = 0;
else
- *scaley = ((*y2 - *y1 - 0x1000) / (dst->y2 - dst->y1 - 1)) >> 4;
+ *scaley = ((*y2 - *y1) / (dst->y2 - dst->y1)) >> 4;
}
#endif
@@ -570,8 +570,8 @@ A(ReputImage)(ScrnInfoPtr pScrn, short drw_x, short drw_y,
pPriv->drw_x = drw_x;
pPriv->drw_y = drw_y;
A(WaitForFifo)(pApm, 2);
- WRXW(pPriv->reg + 0x06, 0xFFF - (((pPriv->scalex * pPriv->x10) & 0xFFF000) >> 12));
- WRXW(pPriv->reg + 0x0A, 0xFFF - (((pPriv->scaley * pPriv->y1) & 0xFFF000) >> 12));
+ WRXW(pPriv->reg + 0x06, 0xFFF - ((pPriv->scalex * pPriv->x10) & 0xFFF));
+ WRXW(pPriv->reg + 0x0A, 0xFFF - ((pPriv->scaley * pPriv->y1) & 0xFFF));
pPriv0 = (ApmPortPrivPtr)pApm->adaptor->pPortPrivates[0].ptr;
pPriv1 = (ApmPortPrivPtr)pApm->adaptor->pPortPrivates[1].ptr;
reg0 = &pPriv0->clip;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile
index 4c5b293aa..79bdb9fb3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.13 2000/03/03 01:05:34 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/Imakefile,v 1.15 2000/06/19 15:00:55 tsi Exp $
XCOMM
XCOMM Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
XCOMM
@@ -34,14 +34,14 @@ ATIMODOBJ = atimodule.o
#endif
SRCS = ati.c atiadapter.c atiadjust.c atibank.c atibios.c atibus.c atichip.c \
- aticlock.c aticonsole.c atidac.c atidsp.c atiident.c atiio.c atilock.c \
- atimach64.c $(ATIMODSRC) atioption.c atipreinit.c atiprint.c \
+ aticlock.c aticonsole.c atidac.c atidga.c atidsp.c atiident.c atiio.c \
+ atilock.c atimach64.c $(ATIMODSRC) atioption.c atipreinit.c atiprint.c \
atiprobe.c atiscreen.c atiutil.c ativalid.c ativga.c atividmem.c \
atiwonder.c
OBJS = ati.o atiadapter.o atiadjust.o atibank.o atibios.o atibus.o atichip.o \
- aticlock.o aticonsole.o atidac.o atidsp.o atiident.o atiio.o atilock.o \
- atimach64.o $(ATIMODOBJ) atioption.o atipreinit.o atiprint.o \
+ aticlock.o aticonsole.o atidac.o atidga.o atidsp.o atiident.o atiio.o \
+ atilock.o atimach64.o $(ATIMODOBJ) atioption.o atipreinit.o atiprint.o \
atiprobe.o atiscreen.o atiutil.o ativalid.o ativga.o atividmem.o \
atiwonder.o
@@ -49,11 +49,13 @@ OBJS = ati.o atiadapter.o atiadjust.o atibank.o atibios.o atibus.o atichip.o \
INCLUDES = -I. -I../../include
#else
INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86SRC) \
- -I$(XF86SRC)/rac -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xaa \
+ -I$(XF86OSSRC)/vbe -I$(XF86SRC)/int10 \
+ -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86SRC)/rac \
+ -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xaa \
-I$(XF86SRC)/xf4bpp -I$(XF86SRC)/xf1bpp \
-I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \
-I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
- -I$(XINCLUDESRC) -I$(FONTINCSRC)
+ -I$(SERVERSRC)/Xext -I$(XINCLUDESRC) -I$(FONTINCSRC)
#endif
#if MakeHasPosixVariableSubstitutions
@@ -95,6 +97,8 @@ InstallDriverSDKNonExecFile(aticonsole.h,$(DRIVERSDKDIR)/drivers/ati)
InstallDriverSDKNonExecFile(aticrtc.h,$(DRIVERSDKDIR)/drivers/ati)
InstallDriverSDKNonExecFile(atidac.c,$(DRIVERSDKDIR)/drivers/ati)
InstallDriverSDKNonExecFile(atidac.h,$(DRIVERSDKDIR)/drivers/ati)
+InstallDriverSDKNonExecFile(atidga.c,$(DRIVERSDKDIR)/drivers/ati)
+InstallDriverSDKNonExecFile(atidga.h,$(DRIVERSDKDIR)/drivers/ati)
InstallDriverSDKNonExecFile(atidsp.c,$(DRIVERSDKDIR)/drivers/ati)
InstallDriverSDKNonExecFile(atidsp.h,$(DRIVERSDKDIR)/drivers/ati)
InstallDriverSDKNonExecFile(atiident.c,$(DRIVERSDKDIR)/drivers/ati)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c
index 722cf881f..ed9c0315c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c,v 1.9 2000/02/18 12:19:10 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.c,v 1.12 2000/05/11 18:14:29 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -35,7 +35,7 @@
* Thomas Roell, roell@informatik.tu-muenchen.de
* Per Lindqvist, pgd@compuram.bbt.se
* Doug Evans, dje@cygnus.com
- * Rik Faith, faith@cs.unc.edu
+ * Rik Faith, faith@precisioninsight.com
* Arthur Tateishi, ruhtra@turing.toronto.edu
* Alain Hebert, aal@broue.rot.qc.ca
* Ton van Rosmalen, ton@stack.urc.tue.nl
@@ -54,10 +54,12 @@
* James Fast Kane, jfk2@engr.uark.edu
* Randall Hopper, rhh@ct.picker.com
* W. Marcus Miller, marcus@llnl.gov
- * Henrik Harmsen, ervhch@erv.ericsson.se (ShadowFB support)
- * Christian Lupien <lupien@physics.utoronto.ca>
+ * Henrik Harmsen, ervhch@erv.ericsson.se
+ * Christian Lupien, lupien@physics.utoronto.ca
* Precision Insight Incorporated
* Mark Vojkovich, mvojkovich@valinux.com
+ * Huw D M Davies, h.davies1@physics.ox.ac.uk
+ * Andrew C Aitchison, A.C.Aitchison@dpmms.cam.ac.uk
*
* ... and, many, many others from around the world.
*
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp
index 28ba4ed72..22d90daab 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp
@@ -1,19 +1,19 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp,v 1.1 2000/03/03 01:05:34 dawes Exp $
-.TH ATI __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ati.cpp,v 1.5 2000/06/19 15:00:55 tsi Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH ATI __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
ati \- ATI video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""ati"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qati\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
-.B ati
+.B ati
is an XFree86 driver for ATI video cards.
THIS MAN PAGE NEEDS TO BE FILLED IN.
.SH SUPPORTED HARDWARE
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c
index 2d4de4ea2..64a104356 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c,v 1.5 2000/02/18 12:19:11 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadapter.c,v 1.12 2000/06/19 15:00:55 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -75,7 +75,7 @@ ATICopyVGAMemory
for (iBank = 0; iBank < pATIHW->nBank; iBank++)
{
(*pATIHW->SetBank)(pATI, iBank);
- (void) memcpy(*to, *from, 0x00010000U);
+ (void)memcpy(*to, *from, 0x00010000U);
*saveptr = (char *)(*saveptr) + 0x00010000U;
}
}
@@ -260,27 +260,36 @@ ATIAdapterPreInit
)
{
CARD32 lcd_index;
+ int HDisplay, VDisplay;
if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
{
/* Fill in VGA data */
- ATIVGAPreInit(pScreenInfo, pATI, pATIHW);
+ ATIVGAPreInit(pATI, pATIHW);
/* Fill in VGA Wonder data */
if (pATI->CPIO_VGAWonder)
- ATIVGAWonderPreInit(pScreenInfo, pATI, pATIHW);
+ ATIVGAWonderPreInit(pATI, pATIHW);
}
/* Fill in Mach64 data */
if (pATI->Chip >= ATI_CHIP_88800GXC)
ATIMach64PreInit(pScreenInfo, pATI, pATIHW);
- /* Ensure proper VCLK source */
if (pATI->Chip >= ATI_CHIP_264CT)
{
+ /* Ensure proper VCLK source */
pATIHW->pll_vclk_cntl = ATIGetMach64PLLReg(PLL_VCLK_CNTL) |
(PLL_VCLK_SRC_SEL | PLL_VCLK_RESET);
+ /* Set provisional values for other PLL registers */
+ pATIHW->pll_vclk_post_div = ATIGetMach64PLLReg(PLL_VCLK_POST_DIV);
+ pATIHW->pll_vclk0_fb_div = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV);
+ pATIHW->pll_vclk1_fb_div = ATIGetMach64PLLReg(PLL_VCLK1_FB_DIV);
+ pATIHW->pll_vclk2_fb_div = ATIGetMach64PLLReg(PLL_VCLK2_FB_DIV);
+ pATIHW->pll_vclk3_fb_div = ATIGetMach64PLLReg(PLL_VCLK3_FB_DIV);
+ pATIHW->pll_xclk_cntl = ATIGetMach64PLLReg(PLL_XCLK_CNTL);
+
/* For now disable extended reference and feedback dividers */
if (pATI->Chip >= ATI_CHIP_264LT)
pATIHW->pll_ext_vpll_cntl = ATIGetMach64PLLReg(PLL_EXT_VPLL_CNTL) &
@@ -313,9 +322,9 @@ ATIAdapterPreInit
}
pATIHW->lcd_gen_ctrl &=
- ~(CRT_ON | LCD_ON | HORZ_DIVBY2_EN | DISABLE_PCLK_RESET |
- DIS_HOR_CRT_DIVBY2 | VCLK_DAC_PM_EN | XTALIN_PM_EN |
- CRTC_RW_SELECT | USE_SHADOWED_VEND | USE_SHADOWED_ROWCUR |
+ ~(HORZ_DIVBY2_EN | DISABLE_PCLK_RESET | DIS_HOR_CRT_DIVBY2 |
+ VCLK_DAC_PM_EN | XTALIN_PM_EN | CRTC_RW_SELECT |
+ USE_SHADOWED_VEND | USE_SHADOWED_ROWCUR |
SHADOW_EN | SHADOW_RW_EN);
pATIHW->lcd_gen_ctrl |= DONT_SHADOW_VPAR | LOCK_8DOT;
@@ -324,132 +333,114 @@ ATIAdapterPreInit
/*
* Use primary CRTC to drive the CRT. Turn off panel interface.
*/
+ pATIHW->lcd_gen_ctrl &= ~LCD_ON;
pATIHW->lcd_gen_ctrl |= CRT_ON;
}
else
{
- /*
- * Use primary CRTC to drive the panel. Turn off CRT interface.
- */
+ /* Use primary CRTC to drive the panel */
pATIHW->lcd_gen_ctrl |= LCD_ON;
- if (!pATI->OptionSync)
+ /*
+ * Determine porch data. The following is inaccurate (but still
+ * good enough) when BIOS initialisation has set things up so that
+ * the registers read here are not the ones actually in use by the
+ * panel.
+ */
+ if (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN)
{
- int HDisplay, VDisplay;
-
- /*
- * XXX
- *
- * Determine porch data. This is ugly and will be removed when
- * a more panel-friendly mode validation scheme is finalised.
- * The intent here is to produce stretched modes that
- * approximate the horizontal sync and vertical refresh rates
- * of the mode on server entry (which, BTW, hasn't been saved
- * yet). The following is inaccurate (but still good enough)
- * when BIOS initialisation has set things up so that the
- * registers read here are not the ones actually in use by the
- * panel.
- */
- if (inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN)
- {
- pATIHW->crtc_h_total_disp =
- inl(pATI->CPIO_CRTC_H_TOTAL_DISP);
- pATIHW->crtc_h_sync_strt_wid =
- inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID);
- pATIHW->crtc_v_total_disp =
- inl(pATI->CPIO_CRTC_V_TOTAL_DISP);
- pATIHW->crtc_v_sync_strt_wid =
- inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID);
-
- HDisplay = GetBits(pATIHW->crtc_h_total_disp, CRTC_H_DISP);
- VDisplay = GetBits(pATIHW->crtc_v_total_disp, CRTC_V_DISP);
-
- pATI->LCDHSyncStart =
- (GetBits(pATIHW->crtc_h_sync_strt_wid,
- CRTC_H_SYNC_STRT_HI) *
- (MaxBits(CRTC_H_SYNC_STRT) + 1)) +
- GetBits(pATIHW->crtc_h_sync_strt_wid,
- CRTC_H_SYNC_STRT) -
- HDisplay;
- pATI->LCDHSyncWidth =
- GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_WID);
- pATI->LCDHBlankWidth =
- GetBits(pATIHW->crtc_h_total_disp, CRTC_H_TOTAL) -
- HDisplay;
- pATI->LCDVSyncStart =
- GetBits(pATIHW->crtc_v_sync_strt_wid,
- CRTC_V_SYNC_STRT) -
- VDisplay;
- pATI->LCDVSyncWidth =
- GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_WID);
- pATI->LCDVBlankWidth =
- GetBits(pATIHW->crtc_v_total_disp, CRTC_V_TOTAL) -
- VDisplay;
- }
- else
- {
- pATIHW->crt[0] = GetReg(CRTX(pATI->CPIO_VGABase), 0x00U);
- pATIHW->crt[1] = GetReg(CRTX(pATI->CPIO_VGABase), 0x01U);
- pATIHW->crt[4] = GetReg(CRTX(pATI->CPIO_VGABase), 0x04U);
- pATIHW->crt[5] = GetReg(CRTX(pATI->CPIO_VGABase), 0x05U);
- pATIHW->crt[6] = GetReg(CRTX(pATI->CPIO_VGABase), 0x06U);
- pATIHW->crt[7] = GetReg(CRTX(pATI->CPIO_VGABase), 0x07U);
- pATIHW->crt[16] = GetReg(CRTX(pATI->CPIO_VGABase), 0x10U);
- pATIHW->crt[17] = GetReg(CRTX(pATI->CPIO_VGABase), 0x11U);
- pATIHW->crt[18] = GetReg(CRTX(pATI->CPIO_VGABase), 0x12U);
-
- HDisplay = pATIHW->crt[1] + 1;
- VDisplay = (((pATIHW->crt[7] << 3) & 0x0200U) |
- ((pATIHW->crt[7] << 7) & 0x0100U) |
- pATIHW->crt[18]) + 1;
-
- pATI->LCDHSyncStart = pATIHW->crt[4] - HDisplay;
- pATI->LCDHSyncWidth =
- (pATIHW->crt[5] - pATIHW->crt[4]) & 0x1FU;
- pATI->LCDHBlankWidth = pATIHW->crt[0] + 5 - HDisplay;
- pATI->LCDVSyncStart = (((pATIHW->crt[7] << 2) & 0x0200U) |
- ((pATIHW->crt[7] << 6) & 0x0100U) |
- pATIHW->crt[16]) - VDisplay;
- pATI->LCDVSyncWidth =
- (pATIHW->crt[17] - pATIHW->crt[16]) & 0x0FU;
- pATI->LCDVBlankWidth = (((pATIHW->crt[7] << 4) & 0x0200U) |
- ((pATIHW->crt[7] << 8) & 0x0100U) |
- pATIHW->crt[6]) + 2 - VDisplay;
- }
+ pATIHW->crtc_h_total_disp =
+ inl(pATI->CPIO_CRTC_H_TOTAL_DISP);
+ pATIHW->crtc_h_sync_strt_wid =
+ inl(pATI->CPIO_CRTC_H_SYNC_STRT_WID);
+ pATIHW->crtc_v_total_disp =
+ inl(pATI->CPIO_CRTC_V_TOTAL_DISP);
+ pATIHW->crtc_v_sync_strt_wid =
+ inl(pATI->CPIO_CRTC_V_SYNC_STRT_WID);
+
+ HDisplay = GetBits(pATIHW->crtc_h_total_disp, CRTC_H_DISP);
+ VDisplay = GetBits(pATIHW->crtc_v_total_disp, CRTC_V_DISP);
+
+ pATI->LCDHSyncStart =
+ (GetBits(pATIHW->crtc_h_sync_strt_wid,
+ CRTC_H_SYNC_STRT_HI) *
+ (MaxBits(CRTC_H_SYNC_STRT) + 1)) +
+ GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_STRT) -
+ HDisplay;
+ pATI->LCDHSyncWidth =
+ GetBits(pATIHW->crtc_h_sync_strt_wid, CRTC_H_SYNC_WID);
+ pATI->LCDHBlankWidth =
+ GetBits(pATIHW->crtc_h_total_disp, CRTC_H_TOTAL) - HDisplay;
+ pATI->LCDVSyncStart =
+ GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_STRT) -
+ VDisplay;
+ pATI->LCDVSyncWidth =
+ GetBits(pATIHW->crtc_v_sync_strt_wid, CRTC_V_SYNC_WID);
+ pATI->LCDVBlankWidth =
+ GetBits(pATIHW->crtc_v_total_disp, CRTC_V_TOTAL) - VDisplay;
+ }
+ else
+ {
+ pATIHW->crt[0] = GetReg(CRTX(pATI->CPIO_VGABase), 0x00U);
+ pATIHW->crt[1] = GetReg(CRTX(pATI->CPIO_VGABase), 0x01U);
+ pATIHW->crt[4] = GetReg(CRTX(pATI->CPIO_VGABase), 0x04U);
+ pATIHW->crt[5] = GetReg(CRTX(pATI->CPIO_VGABase), 0x05U);
+ pATIHW->crt[6] = GetReg(CRTX(pATI->CPIO_VGABase), 0x06U);
+ pATIHW->crt[7] = GetReg(CRTX(pATI->CPIO_VGABase), 0x07U);
+ pATIHW->crt[16] = GetReg(CRTX(pATI->CPIO_VGABase), 0x10U);
+ pATIHW->crt[17] = GetReg(CRTX(pATI->CPIO_VGABase), 0x11U);
+ pATIHW->crt[18] = GetReg(CRTX(pATI->CPIO_VGABase), 0x12U);
+
+ HDisplay = pATIHW->crt[1] + 1;
+ VDisplay = (((pATIHW->crt[7] << 3) & 0x0200U) |
+ ((pATIHW->crt[7] << 7) & 0x0100U) |
+ pATIHW->crt[18]) + 1;
+
+ pATI->LCDHSyncStart = pATIHW->crt[4] - HDisplay;
+ pATI->LCDHSyncWidth = (pATIHW->crt[5] - pATIHW->crt[4]) & 0x1FU;
+ pATI->LCDHBlankWidth = pATIHW->crt[0] + 5 - HDisplay;
+ pATI->LCDVSyncStart = (((pATIHW->crt[7] << 2) & 0x0200U) |
+ ((pATIHW->crt[7] << 6) & 0x0100U) |
+ pATIHW->crt[16]) - VDisplay;
+ pATI->LCDVSyncWidth =
+ (pATIHW->crt[17] - pATIHW->crt[16]) & 0x0FU;
+ pATI->LCDVBlankWidth = (((pATIHW->crt[7] << 4) & 0x0200U) |
+ ((pATIHW->crt[7] << 8) & 0x0100U) |
+ pATIHW->crt[6]) + 2 - VDisplay;
+ }
- HDisplay <<= 3;
- pATI->LCDHSyncStart <<= 3;
- pATI->LCDHSyncWidth <<= 3;
- pATI->LCDHBlankWidth <<= 3;
+ HDisplay <<= 3;
+ pATI->LCDHSyncStart <<= 3;
+ pATI->LCDHSyncWidth <<= 3;
+ pATI->LCDHBlankWidth <<= 3;
- /* If the mode on entry wasn't stretched, adjust timings */
- if (!(pATIHW->horz_stretching & HORZ_STRETCH_EN) &&
- ((HDisplay = pATI->LCDHorizontal - HDisplay) > 0))
- {
- if ((pATI->LCDHSyncStart -= HDisplay) < 0)
- pATI->LCDHSyncStart = 0;
- pATI->LCDHBlankWidth -= HDisplay;
- HDisplay = pATI->LCDHSyncStart + pATI->LCDHSyncWidth;
- if (pATI->LCDHBlankWidth < HDisplay)
- pATI->LCDHBlankWidth = HDisplay;
- }
+ /* If the mode on entry wasn't stretched, adjust timings */
+ if (!(pATIHW->horz_stretching & HORZ_STRETCH_EN) &&
+ ((HDisplay = pATI->LCDHorizontal - HDisplay) > 0))
+ {
+ if ((pATI->LCDHSyncStart -= HDisplay) < 0)
+ pATI->LCDHSyncStart = 0;
+ pATI->LCDHBlankWidth -= HDisplay;
+ HDisplay = pATI->LCDHSyncStart + pATI->LCDHSyncWidth;
+ if (pATI->LCDHBlankWidth < HDisplay)
+ pATI->LCDHBlankWidth = HDisplay;
+ }
- if (!(pATIHW->vert_stretching & VERT_STRETCH_EN) &&
- ((VDisplay = pATI->LCDVertical - VDisplay) > 0))
- {
- if ((pATI->LCDVSyncStart -= VDisplay) < 0)
- pATI->LCDVSyncStart = 0;
- pATI->LCDVBlankWidth -= VDisplay;
- VDisplay = pATI->LCDVSyncStart + pATI->LCDVSyncWidth;
- if (pATI->LCDVBlankWidth < VDisplay)
- pATI->LCDVBlankWidth = VDisplay;
- }
+ if (!(pATIHW->vert_stretching & VERT_STRETCH_EN) &&
+ ((VDisplay = pATI->LCDVertical - VDisplay) > 0))
+ {
+ if ((pATI->LCDVSyncStart -= VDisplay) < 0)
+ pATI->LCDVSyncStart = 0;
+ pATI->LCDVBlankWidth -= VDisplay;
+ VDisplay = pATI->LCDVSyncStart + pATI->LCDVSyncWidth;
+ if (pATI->LCDVBlankWidth < VDisplay)
+ pATI->LCDVBlankWidth = VDisplay;
}
}
}
/* Set RAMDAC data */
- ATIDACPreInit(pScreenInfo, pATIHW);
+ ATIDACPreInit(pScreenInfo, pATI, pATIHW);
}
/*
@@ -477,6 +468,12 @@ ATIAdapterSave
{
pATIHW->pll_vclk_cntl = ATIGetMach64PLLReg(PLL_VCLK_CNTL) |
PLL_VCLK_RESET;
+ pATIHW->pll_vclk_post_div = ATIGetMach64PLLReg(PLL_VCLK_POST_DIV);
+ pATIHW->pll_vclk0_fb_div = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV);
+ pATIHW->pll_vclk1_fb_div = ATIGetMach64PLLReg(PLL_VCLK1_FB_DIV);
+ pATIHW->pll_vclk2_fb_div = ATIGetMach64PLLReg(PLL_VCLK2_FB_DIV);
+ pATIHW->pll_vclk3_fb_div = ATIGetMach64PLLReg(PLL_VCLK3_FB_DIV);
+ pATIHW->pll_xclk_cntl = ATIGetMach64PLLReg(PLL_XCLK_CNTL);
if (pATI->Chip >= ATI_CHIP_264LT)
pATIHW->pll_ext_vpll_cntl = ATIGetMach64PLLReg(PLL_EXT_VPLL_CNTL);
}
@@ -616,14 +613,16 @@ ATIAdapterCalculate
)
{
CARD32 lcd_index;
- int Index;
+ int Index, ECPClock;
/* Clobber mode timings */
- if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT && !pATI->OptionSync &&
- !pMode->CrtcHAdjusted && !pMode->CrtcVAdjusted)
+ if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT &&
+ !pMode->CrtcHAdjusted && !pMode->CrtcVAdjusted &&
+ (!pATI->OptionSync || (pMode->type & M_T_BUILTIN)))
{
int VScan;
+ pMode->Clock = pATI->LCDClock;
pMode->Flags &= ~(V_DBLSCAN | V_INTERLACE | V_CLKDIV2);
/*
@@ -671,7 +670,7 @@ ATIAdapterCalculate
/* Fill in VGA Wonder data */
if (pATI->CPIO_VGAWonder)
- ATIVGAWonderCalculate(pScreenInfo, pATI, pATIHW, pMode);
+ ATIVGAWonderCalculate(pATI, pATIHW, pMode);
if (pATI->Chip >= ATI_CHIP_88800GXC)
{
@@ -721,7 +720,7 @@ ATIAdapterCalculate
pATIHW->crtc_gen_cntl |= CRTC_INTERLACE_EN;
if ((pMode->Flags & (V_CSYNC | V_PCSYNC)) || pATI->OptionCSync)
pATIHW->crtc_gen_cntl |= CRTC_CSYNC_EN;
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
pATIHW->crtc_gen_cntl |= CRTC_EN | CRTC_CNT_EN;
else
pATIHW->crtc_gen_cntl |=
@@ -731,7 +730,7 @@ ATIAdapterCalculate
case ATI_CRTC_MACH64:
/* Fill in Mach64 data */
- ATIMach64Calculate(pScreenInfo, pATI, pATIHW, pMode);
+ ATIMach64Calculate(pATI, pATIHW, pMode);
break;
default:
@@ -806,7 +805,21 @@ ATIAdapterCalculate
}
/* Fill in clock data */
- return ATIClockCalculate(pScreenInfo, pATI, pATIHW, pMode);
+ if (!ATIClockCalculate(pScreenInfo, pATI, pATIHW, pMode))
+ return FALSE;
+
+ /* Setup ECP clock divider */
+ if (pATI->Chip >= ATI_CHIP_264VT)
+ {
+ pATIHW->pll_vclk_cntl &= ~PLL_ECP_DIV;
+ /* XXX Don't do this for TVOut! */
+ ECPClock = pMode->SynthClock;
+ for (Index = 0; (ECPClock > 125000) && (Index < 2); Index++)
+ ECPClock >>= 1;
+ pATIHW->pll_vclk_cntl |= SetBits(Index, PLL_ECP_DIV);
+ }
+
+ return TRUE;
}
/*
@@ -831,10 +844,16 @@ ATIAdapterSet
if (pATI->Chip >= ATI_CHIP_264CT)
{
ATIPutMach64PLLReg(PLL_VCLK_CNTL, pATIHW->pll_vclk_cntl);
- ATIPutMach64PLLReg(PLL_VCLK_CNTL,
- pATIHW->pll_vclk_cntl & ~PLL_VCLK_RESET);
+ ATIPutMach64PLLReg(PLL_VCLK_POST_DIV, pATIHW->pll_vclk_post_div);
+ ATIPutMach64PLLReg(PLL_VCLK0_FB_DIV, pATIHW->pll_vclk0_fb_div);
+ ATIPutMach64PLLReg(PLL_VCLK1_FB_DIV, pATIHW->pll_vclk1_fb_div);
+ ATIPutMach64PLLReg(PLL_VCLK2_FB_DIV, pATIHW->pll_vclk2_fb_div);
+ ATIPutMach64PLLReg(PLL_VCLK3_FB_DIV, pATIHW->pll_vclk3_fb_div);
+ ATIPutMach64PLLReg(PLL_XCLK_CNTL, pATIHW->pll_xclk_cntl);
if (pATI->Chip >= ATI_CHIP_264LT)
ATIPutMach64PLLReg(PLL_EXT_VPLL_CNTL, pATIHW->pll_ext_vpll_cntl);
+ ATIPutMach64PLLReg(PLL_VCLK_CNTL,
+ pATIHW->pll_vclk_cntl & ~PLL_VCLK_RESET);
}
/* Load LCD registers */
@@ -1059,7 +1078,7 @@ ATIAdapterAccelInit
switch (pATI->Adapter)
{
case ATI_ADAPTER_MACH64:
- if (ATIMach64AccelInit(pScreenInfo, pScreen, pATI, pATI->pXAAInfo))
+ if (ATIMach64AccelInit(pATI, pATI->pXAAInfo))
break;
default:
@@ -1069,9 +1088,11 @@ ATIAdapterAccelInit
}
ScreenArea.x1 = ScreenArea.y1 = 0;
- ScreenArea.x2 = pScreenInfo->displayWidth;
- ScreenArea.y2 = pScreenInfo->videoRam * 1024 * 8 /
- pScreenInfo->displayWidth / pScreenInfo->bitsPerPixel;
+ ScreenArea.x2 = pATI->displayWidth;
+ ScreenArea.y2 = pScreenInfo->videoRam * 1024 * 8 / pATI->displayWidth /
+ pATI->bitsPerPixel;
+ if ((unsigned)ScreenArea.y2 > ATIMach64MaxY)
+ ScreenArea.y2 = ATIMach64MaxY;
xf86InitFBManager(pScreen, &ScreenArea);
if (XAAInit(pScreen, pATI->pXAAInfo))
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c
index cfa1da278..5b94998a0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c,v 1.5 2000/02/18 12:19:12 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.c,v 1.6 2000/06/19 15:00:55 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -45,26 +45,23 @@
void
ATIAdjustPreInit
(
- ScrnInfoPtr pScreenInfo,
ATIPtr pATI
)
{
- DisplayModePtr pMode;
- unsigned long MaxBase = 0;
- int MinX, MinY;
+ unsigned long MaxBase;
if ((pATI->CPIO_VGAWonder) &&
(pATI->Chip <= ATI_CHIP_18800_1) &&
(pATI->VideoRAM == 256) &&
- (pScreenInfo->depth >= 8))
+ (pATI->depth >= 8))
{
/* Strange, to say the least ... */
- pATI->AdjustDepth = (pScreenInfo->bitsPerPixel + 3) >> 2;
+ pATI->AdjustDepth = (pATI->bitsPerPixel + 3) >> 2;
pATI->AdjustMask = (unsigned long)(-32);
}
else
{
- pATI->AdjustDepth = (pScreenInfo->bitsPerPixel + 7) >> 3;
+ pATI->AdjustDepth = (pATI->bitsPerPixel + 7) >> 3;
pATI->AdjustMask = 64;
while (pATI->AdjustMask % (unsigned long)(pATI->AdjustDepth))
@@ -79,49 +76,32 @@ ATIAdjustPreInit
case ATI_CRTC_VGA:
if (pATI->Chip >= ATI_CHIP_264CT)
{
- MaxBase = MaxBits(CRTC_OFFSET_VGA) << 2;
- if (pScreenInfo->depth <= 4)
- MaxBase <<= 1;
+ pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET_VGA) << 2;
+ if (pATI->depth <= 4)
+ pATI->AdjustMaxBase <<= 1;
}
else if (!pATI->CPIO_VGAWonder)
- MaxBase = 0xFFFFU << 3;
+ pATI->AdjustMaxBase = 0xFFFFU << 3;
else if (pATI->Chip <= ATI_CHIP_28800_6)
- MaxBase = 0x03FFFFU << 3;
+ pATI->AdjustMaxBase = 0x03FFFFU << 3;
else /* Mach32 & Mach64 */
- MaxBase = 0x0FFFFFU << 3;
+ pATI->AdjustMaxBase = 0x0FFFFFU << 3;
break;
case ATI_CRTC_MACH64:
- MaxBase = MaxBits(CRTC_OFFSET) << 3;
+ pATI->AdjustMaxBase = MaxBits(CRTC_OFFSET) << 3;
break;
- }
- MaxBase = (MaxBase / (unsigned long)pATI->AdjustDepth) | ~pATI->AdjustMask;
+ default:
+ pATI->AdjustMaxBase = 0;
+ break;
+ }
- pATI->AdjustMaxX = MaxBase % pScreenInfo->displayWidth;
- pATI->AdjustMaxY = MaxBase / pScreenInfo->displayWidth;
+ MaxBase = (pATI->AdjustMaxBase / (unsigned long)pATI->AdjustDepth) |
+ ~pATI->AdjustMask;
- /*
- * Warn about modes that are too small, or not aligned, to scroll to the
- * bottom right corner of the virtual screen.
- */
- MinX = pScreenInfo->virtualX - pATI->AdjustMaxX;
- MinY = pScreenInfo->virtualY - pATI->AdjustMaxY;
-
- pMode = pScreenInfo->modes;
- do
- {
- if ((pMode->VDisplay <= MinY) &&
- ((pMode->VDisplay < MinY) || (pMode->HDisplay < MinX)))
- xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
- "Mode \"%s\" too small to scroll to bottom right corner of"
- " virtual resolution.\n", pMode->name);
- else if ((pMode->HDisplay & ~pATI->AdjustMask) / pScreenInfo->xInc)
- xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
- "Mode \"%s\" cannot scroll to bottom right corner of virtual"
- " resolution.\n Horizontal dimension not a multiple of %d.\n",
- pMode->name, ~pATI->AdjustMask + 1);
- } while ((pMode = pMode->next) != pScreenInfo->modes);
+ pATI->AdjustMaxX = MaxBase % pATI->displayWidth;
+ pATI->AdjustMaxY = MaxBase / pATI->displayWidth;
}
/*
@@ -155,7 +135,7 @@ ATIAdjustFrame
y--;
}
- Base = ((((y * pScreenInfo->displayWidth) + x) & pATI->AdjustMask) *
+ Base = ((((y * pATI->displayWidth) + x) & pATI->AdjustMask) *
pATI->AdjustDepth) >> 3;
/* Unlock registers */
@@ -193,10 +173,10 @@ ATIAdjustFrame
* setting the CRTC's offset register to more than 256k needs to be
* done through the accelerator port.
*/
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
{
outl(pATI->CPIO_CRTC_OFF_PITCH,
- SetBits(pScreenInfo->displayWidth >> 4, CRTC_PITCH) |
+ SetBits(pATI->displayWidth >> 4, CRTC_PITCH) |
SetBits(Base, CRTC_OFFSET));
}
else
@@ -204,7 +184,7 @@ ATIAdjustFrame
if (pATI->NewHW.crtc == ATI_CRTC_VGA)
Base <<= 1; /* LSBit must be zero */
outl(pATI->CPIO_CRTC_OFF_PITCH,
- SetBits(pScreenInfo->displayWidth >> 3, CRTC_PITCH) |
+ SetBits(pATI->displayWidth >> 3, CRTC_PITCH) |
SetBits(Base, CRTC_OFFSET));
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h
index 33cac5c6a..2dcc37e85 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h,v 1.4 2000/02/18 12:19:12 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiadjust.h,v 1.5 2000/06/19 15:00:55 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -26,9 +26,8 @@
#include "atipriv.h"
#include "atiproto.h"
-#include "xf86str.h"
-extern void ATIAdjustPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr));
+extern void ATIAdjustPreInit FunctionPrototype((ATIPtr));
extern void ATIAdjustFrame FunctionPrototype((int, int, int, int));
#endif /* ___ATIADJUST_H___ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c
index fc356b56c..64d175c11 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.5 2000/02/18 12:19:13 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibank.c,v 1.6 2000/03/22 03:08:09 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -197,7 +197,7 @@ ATIx8800SetRead
unsigned int iBank
)
{
- (void) ATIV4V5SetRead(pScreen, iBank);
+ (void)ATIV4V5SetRead(pScreen, iBank);
ATIModifyExtReg(ATIPTR(XF86SCRNINFO(pScreen)), 0xAEU, -1, (CARD8)(~0x0CU),
SetBits(GetBits(iBank, 0x30U), 0x0CU));
return 0;
@@ -215,7 +215,7 @@ ATIx8800SetWrite
unsigned int iBank
)
{
- (void) ATIV4V5SetWrite(pScreen, iBank);
+ (void)ATIV4V5SetWrite(pScreen, iBank);
ATIModifyExtReg(ATIPTR(XF86SCRNINFO(pScreen)), 0xAEU, -1, (CARD8)(~0x03U),
SetBits(GetBits(iBank, 0x30U), 0x03U));
return 0;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c
index 788fa1fb8..0d44a5c0d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c,v 1.6 2000/02/18 12:19:14 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atibus.c,v 1.8 2000/05/03 00:44:03 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -21,13 +21,12 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include "ati.h"
#include "atiadapter.h"
#include "atibus.h"
#include "atichip.h"
#include "atiio.h"
#include "ativersion.h"
-#include "xf86Resources.h"
-#include "xf86.h"
/*
* Definitions related to an adapter's system bus interface.
@@ -93,6 +92,9 @@ ATIClaimResources
Resources[0].rMask = 0xF3FEU;
xf86ClaimFixedResources(Resources, pATI->iEntity);
+
+ (void)memcpy(pATI->VGAWonderResources,
+ Resources, SizeOf(Resources));
}
}
@@ -131,6 +133,7 @@ ATIClaimResources
ATI_NAME ": Unable to register the following resources"
" for inactive adapter:\n");
xf86PrintResList(1, pResources);
+ xf86FreeResList(pResources);
}
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c
index c8464f413..c50cf1641 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c,v 1.9 2000/02/18 12:19:15 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.c,v 1.11 2000/04/20 21:28:28 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -72,6 +72,7 @@ const char *ATIChipNames[] =
"ATI unknown Mach64",
"ATI Rage 128 GL",
"ATI Rage 128 Pro",
+ "ATI Rage 128 Mobility",
"ATI unknown Rage 128"
};
@@ -399,7 +400,23 @@ ATIChipID
return ATI_CHIP_68800AX;
case OldChipID('G', 'X'): case NewChipID('G', 'X'):
- return ATI_CHIP_88800GX;
+ switch (ChipRev)
+ {
+ case 0x00U:
+ return ATI_CHIP_88800GXC;
+
+ case 0x01U:
+ return ATI_CHIP_88800GXD;
+
+ case 0x02U:
+ return ATI_CHIP_88800GXE;
+
+ case 0x03U:
+ return ATI_CHIP_88800GXF;
+
+ default:
+ return ATI_CHIP_88800GX;
+ }
case OldChipID('C', 'X'): case NewChipID('C', 'X'):
return ATI_CHIP_88800CX;
@@ -503,6 +520,10 @@ ATIChipID
case OldChipID('S', 'M'): case NewChipID('S', 'M'):
return ATI_CHIP_RAGE128PRO;
+ case OldChipID('L', 'E'): case NewChipID('L', 'E'):
+ case OldChipID('L', 'F'): case NewChipID('L', 'F'):
+ return ATI_CHIP_RAGE128MOBILITY;
+
default:
/*
* I'd say it's a Rage128 here, except that I don't support them
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h
index e9b46c370..395602062 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h,v 1.9 2000/02/18 12:19:16 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atichip.h,v 1.10 2000/03/30 15:41:17 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -34,46 +34,47 @@
typedef enum
{
ATI_CHIP_NONE = 0,
- ATI_CHIP_VGA, /* Generic VGA */
+ ATI_CHIP_VGA, /* Generic VGA */
ATI_CHIP_18800,
ATI_CHIP_18800_1,
ATI_CHIP_28800_2,
ATI_CHIP_28800_4,
ATI_CHIP_28800_5,
ATI_CHIP_28800_6,
- ATI_CHIP_8514A, /* 8514/A */
- ATI_CHIP_CT480, /* 8514/A clone */
- ATI_CHIP_38800_1, /* Mach8 */
- ATI_CHIP_68800, /* Mach32 */
- ATI_CHIP_68800_3, /* Mach32 */
- ATI_CHIP_68800_6, /* Mach32 */
- ATI_CHIP_68800LX, /* Mach32 */
- ATI_CHIP_68800AX, /* Mach32 */
- ATI_CHIP_88800GXC, /* Mach64 */
- ATI_CHIP_88800GXD, /* Mach64 */
- ATI_CHIP_88800GXE, /* Mach64 */
- ATI_CHIP_88800GXF, /* Mach64 */
- ATI_CHIP_88800GX, /* Mach64 */
- ATI_CHIP_88800CX, /* Mach64 */
- ATI_CHIP_264CT, /* Mach64 */
- ATI_CHIP_264ET, /* Mach64 */
- ATI_CHIP_264VT, /* Mach64 */
- ATI_CHIP_264GT, /* Mach64 */
- ATI_CHIP_264VTB, /* Mach64 */
- ATI_CHIP_264GTB, /* Mach64 */
- ATI_CHIP_264VT3, /* Mach64 */
- ATI_CHIP_264GTDVD, /* Mach64 */
- ATI_CHIP_264LT, /* Mach64 */
- ATI_CHIP_264VT4, /* Mach64 */
- ATI_CHIP_264GT2C, /* Mach64 */
- ATI_CHIP_264GTPRO, /* Mach64 */
- ATI_CHIP_264LTPRO, /* Mach64 */
- ATI_CHIP_264XL, /* Mach64 */
- ATI_CHIP_MOBILITY, /* Mach64 */
- ATI_CHIP_Mach64, /* Mach64 */
- ATI_CHIP_RAGE128GL, /* Rage128 */
- ATI_CHIP_RAGE128PRO,/* Rage128 */
- ATI_CHIP_Rage128 /* Rage128 */
+ ATI_CHIP_8514A, /* 8514/A */
+ ATI_CHIP_CT480, /* 8514/A clone */
+ ATI_CHIP_38800_1, /* Mach8 */
+ ATI_CHIP_68800, /* Mach32 */
+ ATI_CHIP_68800_3, /* Mach32 */
+ ATI_CHIP_68800_6, /* Mach32 */
+ ATI_CHIP_68800LX, /* Mach32 */
+ ATI_CHIP_68800AX, /* Mach32 */
+ ATI_CHIP_88800GXC, /* Mach64 */
+ ATI_CHIP_88800GXD, /* Mach64 */
+ ATI_CHIP_88800GXE, /* Mach64 */
+ ATI_CHIP_88800GXF, /* Mach64 */
+ ATI_CHIP_88800GX, /* Mach64 */
+ ATI_CHIP_88800CX, /* Mach64 */
+ ATI_CHIP_264CT, /* Mach64 */
+ ATI_CHIP_264ET, /* Mach64 */
+ ATI_CHIP_264VT, /* Mach64 */
+ ATI_CHIP_264GT, /* Mach64 */
+ ATI_CHIP_264VTB, /* Mach64 */
+ ATI_CHIP_264GTB, /* Mach64 */
+ ATI_CHIP_264VT3, /* Mach64 */
+ ATI_CHIP_264GTDVD, /* Mach64 */
+ ATI_CHIP_264LT, /* Mach64 */
+ ATI_CHIP_264VT4, /* Mach64 */
+ ATI_CHIP_264GT2C, /* Mach64 */
+ ATI_CHIP_264GTPRO, /* Mach64 */
+ ATI_CHIP_264LTPRO, /* Mach64 */
+ ATI_CHIP_264XL, /* Mach64 */
+ ATI_CHIP_MOBILITY, /* Mach64 */
+ ATI_CHIP_Mach64, /* Mach64 */
+ ATI_CHIP_RAGE128GL, /* Rage128 */
+ ATI_CHIP_RAGE128PRO, /* Rage128 */
+ ATI_CHIP_RAGE128MOBILITY, /* Rage128 */
+ ATI_CHIP_Rage128 /* Rage128 */
} ATIChipType;
extern const char *ATIChipNames[];
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c
index e1a5c3a10..5cd0604c2 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c,v 1.9 2000/02/18 12:19:16 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticlock.c,v 1.10 2000/06/19 15:00:55 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -197,7 +197,6 @@
#include "atichip.h"
#include "atidac.h"
#include "atidsp.h"
-#include "atividmem.h"
/*
* Definitions related to non-programmable clock generators.
@@ -816,7 +815,6 @@ ProbeClocks:
* cannot reliably be prevented from enabling frequencies that are
* greater than what the adapter can handle.
*/
- ATIMapApertures(pScreenInfo, pATI);
ATIAdapterSave(pScreenInfo, pATI, &pATI->OldHW);
}
@@ -844,7 +842,6 @@ ProbeClocks:
{
/* Restore video state */
ATIAdapterSet(pScreenInfo, pATI, &pATI->OldHW);
- ATIUnmapApertures(pScreenInfo, pATI);
xfree(pATI->OldHW.frame_buffer);
pATI->OldHW.frame_buffer = NULL;
}
@@ -1182,7 +1179,7 @@ ATIClockCalculate
if ((pATI->Chip >= ATI_CHIP_264VTB) &&
(pATI->CPIODecoding == BLOCK_IO))
- ATIDSPCalculate(pScreenInfo, pATI, pATIHW, pMode);
+ ATIDSPCalculate(pATI, pATIHW, pMode);
}
/* Set clock select bits, after remapping them */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c
index 141d3ac10..c0682036f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.10 2000/02/18 12:19:19 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.c,v 1.12 2000/06/19 15:00:56 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -75,6 +75,44 @@ ATISaveScreen
}
/*
+ * ATISetDPMSMode --
+ *
+ * This function sets the adapter's VESA Display Power Management Signaling
+ * mode.
+ */
+void
+ATISetDPMSMode
+(
+ ScrnInfoPtr pScreenInfo,
+ int DPMSMode,
+ int flags
+)
+{
+ ATIPtr pATI;
+
+ if (!pScreenInfo || !pScreenInfo->vtSema)
+ return;
+
+ pATI = ATIPTR(pScreenInfo);
+
+ switch (pATI->Adapter)
+ {
+ case ATI_ADAPTER_MACH64:
+ ATIMach64SetDPMSMode(pATI, DPMSMode);
+ break;
+
+ case ATI_ADAPTER_NONE:
+ case ATI_ADAPTER_8514A:
+ case ATI_ADAPTER_MACH8:
+ break;
+
+ default: /* Assume EGA/VGA */
+ ATIVGASetDPMSMode(pATI, DPMSMode);
+ break;
+ }
+}
+
+/*
* ATIEnterGraphics --
*
* This function sets the hardware to a graphics video state.
@@ -149,7 +187,8 @@ ATILeaveGraphics
ATILock(pATI);
/* Unmap apertures */
- ATIUnmapApertures(pScreenInfo, pATI);
+ if (!pATI->Closeable || !pATI->nDGAMode)
+ ATIUnmapApertures(pScreenInfo, pATI);
SetTimeSinceLastInputEvent();
}
@@ -176,7 +215,10 @@ ATISwitchMode
/* Set new hardware state */
if (pScreenInfo->vtSema)
+ {
+ pScreenInfo->currentMode = pMode;
ATIAdapterSet(pScreenInfo, pATI, &pATI->NewHW);
+ }
SetTimeSinceLastInputEvent();
@@ -275,6 +317,8 @@ ATIFreeScreen
xfree(pATI->pShadow);
+ xfree(pATI->pDGAMode);
+
xfree(pATI);
pScreenInfo->driverPrivate = NULL;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h
index 4442ee599..11d6e96c7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h,v 1.4 2000/02/18 12:19:20 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/aticonsole.h,v 1.5 2000/03/22 03:08:11 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -29,6 +29,7 @@
#include "xf86str.h"
extern Bool ATISaveScreen FunctionPrototype((ScreenPtr, int));
+extern void ATISetDPMSMode FunctionPrototype((ScrnInfoPtr, int, int));
extern Bool ATIEnterGraphics FunctionPrototype((ScreenPtr, ScrnInfoPtr,
ATIPtr));
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c
index 47e9cafef..aaf65b95f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c,v 1.6 2000/02/18 12:19:20 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.c,v 1.8 2000/06/19 15:00:56 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -106,10 +106,10 @@ ATIGetDACCmdReg
ATIPtr pATI
)
{
- (void) inb(pATI->CPIO_DAC_WRITE); /* Reset to PEL mode */
- (void) inb(pATI->CPIO_DAC_MASK);
- (void) inb(pATI->CPIO_DAC_MASK);
- (void) inb(pATI->CPIO_DAC_MASK);
+ (void)inb(pATI->CPIO_DAC_WRITE); /* Reset to PEL mode */
+ (void)inb(pATI->CPIO_DAC_MASK);
+ (void)inb(pATI->CPIO_DAC_MASK);
+ (void)inb(pATI->CPIO_DAC_MASK);
return inb(pATI->CPIO_DAC_MASK);
}
@@ -122,6 +122,7 @@ void
ATIDACPreInit
(
ScrnInfoPtr pScreenInfo,
+ ATIPtr pATI,
ATIHWPtr pATIHW
)
{
@@ -134,7 +135,7 @@ ATIDACPreInit
/*
* Set colour lookup table. The first entry has already been zeroed out.
*/
- if (pScreenInfo->depth > 8)
+ if (pATI->depth > 8)
for (Index = 1; Index < (NumberOf(pATIHW->lut) / 3); Index++)
{
Index2 = Index * 3;
@@ -158,7 +159,7 @@ ATIDACPreInit
pATIHW->lut[Index2 + 2] = maxColour;
}
- if (pScreenInfo->depth == 1)
+ if (pATI->depth == 1)
{
rgb blackColour = pScreenInfo->display->whiteColour,
whiteColour = pScreenInfo->display->whiteColour;
@@ -291,9 +292,9 @@ ATILoadPalette
int greens = pVisual->greenMask >> pVisual->offsetGreen;
int blues = pVisual->blueMask >> pVisual->offsetBlue;
- int redShift = 8 - pScreenInfo->weight.red;
- int greenShift = 8 - pScreenInfo->weight.green;
- int blueShift = 8 - pScreenInfo->weight.blue;
+ int redShift = 8 - pATI->weight.red;
+ int greenShift = 8 - pATI->weight.green;
+ int blueShift = 8 - pATI->weight.blue;
int redMult = 3 << redShift;
int greenMult = 3 << greenShift;
@@ -323,7 +324,7 @@ ATILoadPalette
Colours[Index].blue << minShift;
}
- if (pScreenInfo->vtSema)
+ if (pScreenInfo->vtSema || pATI->currentMode)
{
/* Rewrite LUT entries that could have been changed */
i = 1 << minShift;
@@ -357,7 +358,7 @@ ATILoadPalette
LUTEntry[1] = Colours[Index].green;
LUTEntry[2] = Colours[Index].blue;
- if (pScreenInfo->vtSema)
+ if (pScreenInfo->vtSema || pATI->currentMode)
{
outb(pATI->CPIO_DAC_WRITE, Index);
DACDelay;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h
index c2ea2602d..868dbd502 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h,v 1.5 2000/02/18 12:19:21 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidac.h,v 1.6 2000/06/19 15:00:56 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -78,7 +78,7 @@ extern const DACRec ATIDACDescriptors[];
extern void ATISetDACIOPorts FunctionPrototype((ATIPtr, ATICRTCType));
extern CARD8 ATIGetDACCmdReg FunctionPrototype((ATIPtr));
-extern void ATIDACPreInit FunctionPrototype((ScrnInfoPtr, ATIHWPtr));
+extern void ATIDACPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr));
extern void ATIDACSave FunctionPrototype((ATIPtr, ATIHWPtr));
extern void ATIDACSet FunctionPrototype((ATIPtr, ATIHWPtr));
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c
new file mode 100644
index 000000000..9e8f91c48
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c
@@ -0,0 +1,342 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.c,v 1.1 2000/06/19 15:02:24 tsi Exp $ */
+/*
+ * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
+ *
+ * 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 "ati.h"
+#include "atiadapter.h"
+#include "atiadjust.h"
+#include "atidac.h"
+#include "atidga.h"
+#include "dgaproc.h"
+
+/*
+ * ATIDGAOpenFramebuffer --
+ *
+ * This function returns various framebuffer attributes to a DGA client.
+ */
+static Bool
+ATIDGAOpenFramebuffer
+(
+ ScrnInfoPtr pScreenInfo,
+ char **DeviceName,
+ unsigned char **ApertureBase,
+ int *ApertureSize,
+ int *ApertureOffset,
+ int *flags
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+
+ *DeviceName = NULL; /* No special device */
+ *ApertureBase = (unsigned char *)(pATI->LinearBase);
+ *ApertureSize = pScreenInfo->videoRam * 1024;
+ *ApertureOffset = 0; /* Always */
+ *flags = 0; /* Root premissions OS-dependent */
+
+ return TRUE;
+}
+
+static int
+BitsSet
+(
+ unsigned long data
+)
+{
+ unsigned long mask = 1;
+ int set = 0;
+
+ for (; mask; mask <<= 1)
+ if (data & mask)
+ set++;
+
+ return set;
+}
+
+/*
+ * ATIDGASetMode --
+ *
+ * This function sets a graphics mode for a DGA client.
+ */
+static Bool
+ATIDGASetMode
+(
+ ScrnInfoPtr pScreenInfo,
+ DGAModePtr pDGAMode
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+ DisplayModePtr pMode;
+ int scrnIndex = pScreenInfo->pScreen->myNum;
+ int frameX0, frameY0;
+
+ if (pDGAMode)
+ {
+ pMode = pDGAMode->mode;
+ pATI->depth = pDGAMode->depth;
+ pATI->bitsPerPixel = pDGAMode->bitsPerPixel;
+ pATI->displayWidth =
+ pDGAMode->bytesPerScanline * 8 / pATI->bitsPerPixel;
+ pATI->weight.red = BitsSet(pDGAMode->red_mask);
+ pATI->weight.green = BitsSet(pDGAMode->green_mask);
+ pATI->weight.blue = BitsSet(pDGAMode->blue_mask);
+ frameX0 = frameY0 = 0;
+ if (!pATI->currentMode)
+ pATI->currentMode = pScreenInfo->currentMode;
+ }
+ else
+ {
+ if (!(pMode = pATI->currentMode))
+ return TRUE;
+
+ pATI->depth = pScreenInfo->depth;
+ pATI->bitsPerPixel = pScreenInfo->bitsPerPixel;
+ pATI->displayWidth = pScreenInfo->displayWidth;
+ pATI->weight = pScreenInfo->weight;
+ frameX0 = pScreenInfo->frameX0;
+ frameY0 = pScreenInfo->frameY0;
+ }
+
+ pATI->XModifier = pATI->bitsPerPixel / UnitOf(pATI->bitsPerPixel);
+ ATIAdjustPreInit(pATI);
+ ATIAdapterPreInit(pScreenInfo, pATI, &pATI->NewHW);
+
+ if (!(*pScreenInfo->SwitchMode)(scrnIndex, pMode, 0))
+ return FALSE;
+ if (!pDGAMode)
+ pATI->currentMode = NULL;
+ (*pScreenInfo->AdjustFrame)(scrnIndex, frameX0, frameY0, 0);
+
+ return TRUE;
+}
+
+/*
+ * ATIDGASetViewport --
+ *
+ * This function sets the display start address for a DGA client.
+ */
+static void
+ATIDGASetViewport
+(
+ ScrnInfoPtr pScreenInfo,
+ int x,
+ int y,
+ int flags
+)
+{
+ (*pScreenInfo->AdjustFrame)(pScreenInfo->pScreen->myNum, x, y, flags);
+}
+
+/*
+ * ATIDGAGetViewport --
+ *
+ * This function returns the current status of prior DGA requests to set the
+ * adapter's display start address.
+ */
+static int
+ATIDGAGetViewport
+(
+ ScrnInfoPtr pScreenInfo
+)
+{
+ return 0; /* There are never any pending requests */
+}
+
+static DGAFunctionRec ATIDGAFunctions =
+{
+ ATIDGAOpenFramebuffer,
+ NULL, /* CloseFramebuffer */
+ ATIDGASetMode,
+ ATIDGASetViewport,
+ ATIDGAGetViewport,
+ NULL, /* Sync */
+ NULL, /* FillRect */
+ NULL, /* BlitRect */
+ NULL, /* BlitTransRect */
+};
+
+/*
+ * ATIDGAAddModes --
+ *
+ * This function translates DisplayModeRec's into DGAModeRec's.
+ */
+static void
+ATIDGAAddModes
+(
+ ScrnInfoPtr pScreenInfo,
+ ATIPtr pATI,
+ int depth,
+ int bitsPerPixel,
+ int redMask,
+ int greenMask,
+ int blueMask,
+ int visualClass
+)
+{
+ DisplayModePtr pMode = pScreenInfo->modes;
+ DGAModePtr pDGAMode;
+ int displayWidth = pScreenInfo->displayWidth;
+ int videoBits = pScreenInfo->videoRam * 1024 * 8;
+ int xViewportStep = 64 / UnitOf(bitsPerPixel);
+ int modePitch, bitsPerScanline, maxViewportY;
+
+ if (bitsPerPixel != pScreenInfo->bitsPerPixel)
+ displayWidth = 0;
+
+ while (1)
+ {
+ /* Weed out multiscanned modes */
+ if ((pMode->VScan <= 1) ||
+ ((pMode->VScan == 2) && !(pMode->Flags & V_DBLSCAN)))
+ {
+ /*
+ * For code simplicity, ensure DGA mode pitch is a multiple of 64
+ * bytes.
+ */
+ if (!(modePitch = displayWidth))
+ {
+ modePitch = ((64 * 8) / UnitOf(bitsPerPixel)) - 1;
+ modePitch = (pMode->HDisplay + modePitch) & ~modePitch;
+ }
+
+ /* Ensure the mode fits in video memory */
+ if ((modePitch * bitsPerPixel * pMode->VDisplay) <= videoBits)
+ {
+ /* Stop generating modes on out-of-memory conditions */
+ pDGAMode = xrealloc(pATI->pDGAMode,
+ (pATI->nDGAMode + 1) * SizeOf(DGAModeRec));
+ if (!pDGAMode)
+ break;
+
+ pATI->pDGAMode = pDGAMode;
+ pDGAMode += pATI->nDGAMode;
+ pATI->nDGAMode++;
+ (void)memset(pDGAMode, 0, SizeOf(DGAModeRec));
+
+ /* Fill in the mode structure */
+ pDGAMode->mode = pMode;
+ if (bitsPerPixel == pScreenInfo->bitsPerPixel)
+ {
+ pDGAMode->flags |= DGA_PIXMAP_AVAILABLE;
+ pDGAMode->address = pATI->pMemory;
+ }
+ if ((pMode->Flags & V_DBLSCAN) || (pMode->VScan > 1))
+ pDGAMode->flags |= DGA_DOUBLESCAN;
+ if (pMode->Flags & V_INTERLACE)
+ pDGAMode->flags |= DGA_INTERLACED;
+
+ pDGAMode->byteOrder = pScreenInfo->imageByteOrder;
+ pDGAMode->depth = depth;
+ pDGAMode->bitsPerPixel = bitsPerPixel;
+ pDGAMode->red_mask = redMask;
+ pDGAMode->green_mask = greenMask;
+ pDGAMode->blue_mask = blueMask;
+ pDGAMode->visualClass = visualClass;
+
+ pDGAMode->viewportWidth = pMode->HDisplay;
+ pDGAMode->viewportHeight = pMode->VDisplay;
+ pDGAMode->xViewportStep = xViewportStep;
+ pDGAMode->yViewportStep = 1;
+
+ bitsPerScanline = modePitch * bitsPerPixel;
+ pDGAMode->bytesPerScanline = bitsPerScanline / 8;
+ pDGAMode->imageWidth = pDGAMode->pixmapWidth = modePitch;
+ pDGAMode->imageHeight = pDGAMode->pixmapHeight =
+ videoBits / bitsPerScanline;
+
+ pDGAMode->maxViewportX =
+ pDGAMode->imageWidth - pDGAMode->viewportWidth;
+ pDGAMode->maxViewportY =
+ pDGAMode->imageHeight - pDGAMode->viewportHeight;
+ maxViewportY =
+ ((((pATI->AdjustMaxBase * 8) / bitsPerPixel) +
+ xViewportStep) / modePitch) - 1;
+ if (maxViewportY < pDGAMode->maxViewportY)
+ pDGAMode->maxViewportY = maxViewportY;
+ }
+ }
+
+ if ((pMode = pMode->next) == pScreenInfo->modes)
+ {
+ if (!displayWidth)
+ break;
+
+ displayWidth = 0;
+ }
+ }
+}
+
+/*
+ * ATIDGAInit --
+ *
+ * This function initialises the driver's support for the DGA extension.
+ */
+Bool
+ATIDGAInit
+(
+ ScrnInfoPtr pScreenInfo,
+ ScreenPtr pScreen,
+ ATIPtr pATI
+)
+{
+ if (!pATI->nDGAMode)
+ {
+ /*
+ * Contrary to previous extension versions, DGA 2 does not support
+ * banked framebuffers. Also, disable DGA when non-DGA server modes
+ * are planar.
+ */
+ if (pATI->BankInfo.BankSize || (pScreenInfo->depth <= 4))
+ return FALSE;
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 8, 8, 0, 0, 0, PseudoColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 15, 16, 0x7C00U, 0x03E0U, 0x001FU, TrueColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 16, 16, 0xF800U, 0x07E0U, 0x001FU, TrueColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 24, 24, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 24, 32, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, TrueColor);
+
+ if (pATI->DAC != ATI_DAC_INTERNAL) /* Not first revision */
+ {
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 15, 16, 0x7C00U, 0x03E0U, 0x001FU, DirectColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 16, 16, 0xF800U, 0x07E0U, 0x001FU, DirectColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 24, 24, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor);
+
+ ATIDGAAddModes(pScreenInfo, pATI,
+ 24, 32, 0x00FF0000U, 0x0000FF00U, 0x000000FFU, DirectColor);
+ }
+ }
+
+ return DGAInit(pScreen, &ATIDGAFunctions, pATI->pDGAMode, pATI->nDGAMode);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h
new file mode 100644
index 000000000..b84b1aaba
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h
@@ -0,0 +1,33 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidga.h,v 1.1 2000/06/19 15:02:24 tsi Exp $ */
+/*
+ * Copyright 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
+ *
+ * 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.
+ */
+
+#ifndef ___ATIDGA_H___
+#define ___ATIDGA_H___ 1
+
+#include "atipriv.h"
+#include "atiproto.h"
+#include "xf86str.h"
+
+extern Bool ATIDGAInit FunctionPrototype((ScrnInfoPtr, ScreenPtr, ATIPtr));
+
+#endif /* ___ATIDGA_H___ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c
index 4ff9e5a7a..ba121f99e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c,v 1.8 2000/02/18 12:19:21 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.c,v 1.10 2000/06/19 15:00:56 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -42,14 +42,11 @@ ATIDSPPreInit
)
{
CARD32 IOValue, dsp_config, dsp_on_off, vga_dsp_config, vga_dsp_on_off;
- CARD16 CPIO_VGA_DSP_CONFIG, CPIO_VGA_DSP_ON_OFF;
int trp;
/* Set DSP register port numbers */
pATI->CPIO_DSP_CONFIG = ATIIOPort(DSP_CONFIG);
pATI->CPIO_DSP_ON_OFF = ATIIOPort(DSP_ON_OFF);
- CPIO_VGA_DSP_CONFIG = ATIIOPort(VGA_DSP_CONFIG);
- CPIO_VGA_DSP_ON_OFF = ATIIOPort(VGA_DSP_ON_OFF);
/*
* VT-B's and later have additional post-dividers that are not powers of
@@ -145,14 +142,15 @@ ATIDSPPreInit
/* Allow BIOS to override */
dsp_config = inl(pATI->CPIO_DSP_CONFIG);
dsp_on_off = inl(pATI->CPIO_DSP_ON_OFF);
- vga_dsp_config = inl(CPIO_VGA_DSP_CONFIG);
- vga_dsp_on_off = inl(CPIO_VGA_DSP_ON_OFF);
+ vga_dsp_config = inl(ATIIOPort(VGA_DSP_CONFIG));
+ vga_dsp_on_off = inl(ATIIOPort(VGA_DSP_ON_OFF));
if (dsp_config)
pATI->DisplayLoopLatency = GetBits(dsp_config, DSP_LOOP_LATENCY);
- if ((dsp_on_off == vga_dsp_on_off) &&
- (!dsp_config || !((dsp_config ^ vga_dsp_config) & DSP_XCLKS_PER_QW)))
+ if (!dsp_on_off ||
+ ((dsp_on_off == vga_dsp_on_off) &&
+ (!dsp_config || !((dsp_config ^ vga_dsp_config) & DSP_XCLKS_PER_QW))))
{
if (ATIDivide(GetBits(vga_dsp_on_off, VGA_DSP_OFF),
GetBits(vga_dsp_config, VGA_DSP_XCLKS_PER_QW), 5, 1) > 23)
@@ -195,7 +193,6 @@ ATIDSPSave
void
ATIDSPCalculate
(
- ScrnInfoPtr pScreenInfo,
ATIPtr pATI,
ATIHWPtr pATIHW,
DisplayModePtr pMode
@@ -212,8 +209,8 @@ ATIDSPCalculate
Multiplier = pATI->XCLKFeedbackDivider *
pATI->ClockDescriptor.PostDividers[pATIHW->PostDivider];
Divider = pATIHW->FeedbackDivider * pATI->XCLKReferenceDivider;
- if (pScreenInfo->depth >= 8)
- Divider *= pScreenInfo->bitsPerPixel / 4;
+ if (pATI->depth >= 8)
+ Divider *= pATI->bitsPerPixel / 4;
/* Start by assuming a display FIFO width of 32 bits */
vshift = (5 - 2) - pATI->XCLKPostDivider;
if (pATIHW->crtc != ATI_CRTC_VGA)
@@ -230,7 +227,7 @@ ATIDSPCalculate
}
/* Determine dsp_precision first */
- tmp = ATIDivide(Multiplier * pATI->DisplayFIFODepth, Divider, vshift, 1);
+ tmp = ATIDivide(Multiplier * pATI->DisplayFIFODepth, Divider, vshift, -1);
for (dsp_precision = -5; tmp; dsp_precision++)
tmp >>= 1;
if (dsp_precision < 0)
@@ -264,6 +261,9 @@ ATIDSPCalculate
ATIDivide(pATI->XCLKPageFaultDelay, 1, xshift, 1);
}
+ if (dsp_on >= dsp_off)
+ dsp_on = dsp_off - ATIDivide(Multiplier, Divider, vshift, -1);
+
/* Last but not least: dsp_xclks */
dsp_xclks = ATIDivide(Multiplier, Divider, vshift + 5, 1);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h
index 29657be49..4cbbb6ad0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h,v 1.5 2000/02/18 12:19:22 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atidsp.h,v 1.6 2000/06/19 15:00:56 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -30,7 +30,7 @@
extern Bool ATIDSPPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr));
extern void ATIDSPSave FunctionPrototype((ATIPtr, ATIHWPtr));
-extern void ATIDSPCalculate FunctionPrototype((ScrnInfoPtr, ATIPtr, ATIHWPtr,
+extern void ATIDSPCalculate FunctionPrototype((ATIPtr, ATIHWPtr,
DisplayModePtr));
extern void ATIDSPSet FunctionPrototype((ATIPtr, ATIHWPtr));
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h
index ec2240b74..4c09b8dec 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h,v 1.6 2000/03/01 16:00:57 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiio.h,v 1.7 2000/03/30 15:41:17 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -28,7 +28,6 @@
#define NO_COMPILER_H_EXTRAS
#endif
-#include "atiregs.h"
#include "atistruct.h"
#include "compiler.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c
index c69d77a21..75c0e0485 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c,v 1.5 2000/03/07 16:13:34 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atilock.c,v 1.6 2000/03/22 03:08:13 tsi Exp $ */
/*
* Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -111,9 +111,8 @@ ATIUnlock
outl(pATI->CPIO_GEN_TEST_CNTL, tmp | GEN_GUI_EN);
outl(pATI->CPIO_GEN_TEST_CNTL, tmp);
outl(pATI->CPIO_GEN_TEST_CNTL, tmp | GEN_GUI_EN);
- pATI->LockData.crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) &
+ tmp = pATI->LockData.crtc_gen_cntl = inl(pATI->CPIO_CRTC_GEN_CNTL) &
~(CRTC_EN | CRTC_LOCK_REGS);
- tmp = pATI->LockData.crtc_gen_cntl & ~CRTC_EN;
if (pATI->Chip >= ATI_CHIP_264XL)
tmp = (tmp & ~CRTC_INT_ENS_X) | CRTC_INT_ACKS_X;
outl(pATI->CPIO_CRTC_GEN_CNTL, tmp | CRTC_EN);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c
index 4e8fdd07b..2d53d1629 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.12 2000/03/03 04:47:13 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.c,v 1.21 2000/06/19 15:00:56 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -44,17 +44,22 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "ati.h"
#include "atibus.h"
#include "atichip.h"
#include "atiio.h"
#include "atimach64.h"
+#include "miline.h"
+
+#define DPMS_SERVER
+#include "extensions/dpms.h"
/*
- * Only 32-bit MMIO is needed here.
+ * Note: Only 32-bit MMIO is needed here.
*/
-#define inm(_Register) \
- MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \
+#define inm(_Register) \
+ MMIO_IN32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \
(_Register) & MM_IO_SELECT)
/*
@@ -108,24 +113,47 @@ ATIMach64PollEngineStatus
pATI->nAvailableFIFOEntries = Count;
}
-
-#define outm(_Register, _Value) \
- do \
- { \
- while (!pATI->nAvailableFIFOEntries--) \
- ATIMach64PollEngineStatus(pATI); \
- MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \
- (_Register) & MM_IO_SELECT, _Value); \
- pATI->EngineIsBusy = TRUE; \
+/*
+ * MMIO cache definitions.
+ */
+#define CacheByte(___Register) pATI->MMIOCached[CacheSlotOf(___Register) >> 3]
+#define CacheBit(___Register) (0x80U >> (CacheSlotOf(___Register) & 0x07U))
+
+#define RegisterIsCached(__Register) \
+ (CacheByte(__Register) & CacheBit(__Register))
+#define CacheRegister(__Register) \
+ CacheByte(__Register) |= CacheBit(__Register)
+#define UncacheRegister(__Register) \
+ CacheByte(__Register) &= ~CacheBit(__Register)
+
+#define CacheSlot(__Register) pATI->MMIOCache[CacheSlotOf(__Register)]
+
+/* This would be quite a bit slower as a function */
+#define outm(_Register, _Value) \
+ do \
+ { \
+ CARD32 _IOValue = (_Value); \
+ \
+ if (!RegisterIsCached(_Register) || \
+ (_IOValue != CacheSlot(_Register))) \
+ { \
+ while (!pATI->nAvailableFIFOEntries--) \
+ ATIMach64PollEngineStatus(pATI); \
+ MMIO_OUT32(pATI->pBlock[GetBits(_Register, BLOCK_SELECT)], \
+ (_Register) & MM_IO_SELECT, _IOValue); \
+ CacheSlot(_Register) = _IOValue; \
+ pATI->EngineIsBusy = TRUE; \
+ } \
} while (0)
+/* This is no longer as critical, especially for _n == 1 */
#define ATIMach64WaitForFIFO(_n) \
while ((pATI->nAvailableFIFOEntries < (_n)) && \
(pATI->nAvailableFIFOEntries < pATI->nFIFOEntries)) \
ATIMach64PollEngineStatus(pATI)
-#define ATIMach64WaitForIdle() \
- while (pATI->EngineIsBusy) \
+#define ATIMach64WaitForIdle() \
+ while (pATI->EngineIsBusy) \
ATIMach64PollEngineStatus(pATI)
/*
@@ -165,15 +193,16 @@ ATIMach64PreInit
ATIHWPtr pATIHW
)
{
- if (pScreenInfo->depth <= 4)
- pATIHW->crtc_off_pitch =
- SetBits(pScreenInfo->displayWidth >> 4, CRTC_PITCH);
+ CARD32 bus_cntl, config_cntl;
+ int tmp;
+
+ if (pATI->depth <= 4)
+ pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 4, CRTC_PITCH);
else
- pATIHW->crtc_off_pitch =
- SetBits(pScreenInfo->displayWidth >> 3, CRTC_PITCH);
+ pATIHW->crtc_off_pitch = SetBits(pATI->displayWidth >> 3, CRTC_PITCH);
- pATIHW->bus_cntl = (inl(pATI->CPIO_BUS_CNTL) & ~BUS_HOST_ERR_INT_EN) |
- BUS_HOST_ERR_INT;
+ bus_cntl = inl(pATI->CPIO_BUS_CNTL);
+ pATIHW->bus_cntl = (bus_cntl & ~BUS_HOST_ERR_INT_EN) | BUS_HOST_ERR_INT;
if (pATI->Chip < ATI_CHIP_264VTB)
{
pATIHW->bus_cntl &= ~(BUS_FIFO_ERR_INT_EN | BUS_ROM_DIS);
@@ -192,13 +221,11 @@ ATIMach64PreInit
SetBits(pATIHW->nPlane, MEM_VGA_RPS1);
pATIHW->dac_cntl = inl(pATI->CPIO_DAC_CNTL) &
- ~(DAC1_CLK_SEL | DAC_PALETTE_ACCESS_CNTL);
- if ((pScreenInfo->depth > 8) || (pScreenInfo->rgbBits == 8))
+ ~(DAC1_CLK_SEL | DAC_PALETTE_ACCESS_CNTL | DAC_8BIT_EN);
+ if ((pATI->depth > 8) || (pScreenInfo->rgbBits == 8))
pATIHW->dac_cntl |= DAC_8BIT_EN;
- else
- pATIHW->dac_cntl &= ~DAC_8BIT_EN;
- pATIHW->config_cntl = inl(pATI->CPIO_CONFIG_CNTL);
+ pATIHW->config_cntl = config_cntl = inl(pATI->CPIO_CONFIG_CNTL);
if (pATI->UseSmallApertures)
pATIHW->config_cntl |= CFG_MEM_VGA_AP_EN;
else
@@ -219,9 +246,9 @@ ATIMach64PreInit
/* Draw engine setup */
if (pATI->OptionAccel)
{
- /* Don't treat 24bpp as a special case */
- pATI->PitchModifier =
- pScreenInfo->bitsPerPixel / UnitOf(pScreenInfo->bitsPerPixel);
+ /* Ensure apertures are enabled */
+ outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl);
+ outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl);
/*
* When possible, max out command FIFO size.
@@ -231,8 +258,7 @@ ATIMach64PreInit
/* Initialise destination registers */
pATIHW->dst_off_pitch =
- SetBits((pScreenInfo->displayWidth * pATI->PitchModifier) >> 3,
- DST_PITCH);
+ SetBits((pATI->displayWidth * pATI->XModifier) >> 3, DST_PITCH);
pATIHW->dst_cntl = DST_X_DIR | DST_Y_DIR | DST_LAST_PEL;
/* Initialise source registers */
@@ -242,24 +268,25 @@ ATIMach64PreInit
pATIHW->src_cntl = SRC_LINE_X_DIR;
/* Initialise scissor, allowing for offscreen areas */
- pATIHW->sc_right =
- (pScreenInfo->displayWidth * pATI->PitchModifier) - 1;
- pATIHW->sc_bottom =
- (pScreenInfo->videoRam * 1024 * 8 / pScreenInfo->displayWidth /
- pScreenInfo->bitsPerPixel) - 1;
+ pATIHW->sc_right = (pATI->displayWidth * pATI->XModifier) - 1;
+ tmp = (pScreenInfo->videoRam * (1024 * 8) /
+ pATI->displayWidth / pATI->bitsPerPixel) - 1;
+ if (tmp > ATIMach64MaxY)
+ tmp = ATIMach64MaxY;
+ pATIHW->sc_bottom = tmp;
/* Initialise data path */
pATIHW->dp_frgd_clr = (CARD32)(-1);
pATIHW->dp_write_mask = (CARD32)(-1);
- switch (pScreenInfo->depth)
+ switch (pATI->depth)
{
case 8:
pATIHW->dp_chain_mask = DP_CHAIN_8BPP;
pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */
SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) |
SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) |
- SetBits(PIX_WIDTH_8BPP, DP_HOST_PIX_WIDTH);
+ SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH);
break;
case 15:
@@ -267,7 +294,7 @@ ATIMach64PreInit
pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */
SetBits(PIX_WIDTH_15BPP, DP_DST_PIX_WIDTH) |
SetBits(PIX_WIDTH_15BPP, DP_SRC_PIX_WIDTH) |
- SetBits(PIX_WIDTH_15BPP, DP_HOST_PIX_WIDTH);
+ SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH);
break;
case 16:
@@ -275,17 +302,17 @@ ATIMach64PreInit
pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */
SetBits(PIX_WIDTH_16BPP, DP_DST_PIX_WIDTH) |
SetBits(PIX_WIDTH_16BPP, DP_SRC_PIX_WIDTH) |
- SetBits(PIX_WIDTH_16BPP, DP_HOST_PIX_WIDTH);
+ SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH);
break;
case 24:
- if (pScreenInfo->bitsPerPixel == 24)
+ if (pATI->bitsPerPixel == 24)
{
pATIHW->dp_chain_mask = DP_CHAIN_24BPP_888;
pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */
SetBits(PIX_WIDTH_8BPP, DP_DST_PIX_WIDTH) |
SetBits(PIX_WIDTH_8BPP, DP_SRC_PIX_WIDTH) |
- SetBits(PIX_WIDTH_8BPP, DP_HOST_PIX_WIDTH);
+ SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH);
}
else
{
@@ -293,7 +320,7 @@ ATIMach64PreInit
pATIHW->dp_pix_width = /* DP_BYTE_PIX_ORDER | */
SetBits(PIX_WIDTH_32BPP, DP_DST_PIX_WIDTH) |
SetBits(PIX_WIDTH_32BPP, DP_SRC_PIX_WIDTH) |
- SetBits(PIX_WIDTH_32BPP, DP_HOST_PIX_WIDTH);
+ SetBits(PIX_WIDTH_1BPP, DP_HOST_PIX_WIDTH);
}
break;
@@ -303,12 +330,15 @@ ATIMach64PreInit
pATIHW->dp_mix = SetBits(MIX_SRC, DP_FRGD_MIX) |
SetBits(MIX_DST, DP_BKGD_MIX);
- pATIHW->dp_src = SetBits(DP_MONO_SRC_ALLONES, DP_MONO_SRC) |
- SetBits(SRC_FRGD, DP_FRGD_SRC) |
- SetBits(SRC_BKGD, DP_BKGD_SRC);
+ pATIHW->dp_src = DP_MONO_SRC_ALLONES |
+ SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC);
/* Initialise colour compare */
pATIHW->clr_cmp_msk = (CARD32)(-1);
+
+ /* Restore aperture enablement */
+ outl(pATI->CPIO_BUS_CNTL, bus_cntl);
+ outl(pATI->CPIO_CONFIG_CNTL, config_cntl);
}
}
@@ -352,11 +382,15 @@ ATIMach64Save
/* Save draw engine state */
if (pATI->OptionAccel && (pATIHW == &pATI->OldHW))
{
+ /* Ensure apertures are enabled */
+ outl(pATI->CPIO_BUS_CNTL, pATI->NewHW.bus_cntl);
+ outl(pATI->CPIO_CONFIG_CNTL, pATI->NewHW.config_cntl);
+
ATIMach64WaitForIdle();
/* Save FIFO size */
if (pATI->Chip >= ATI_CHIP_264VT4)
- pATIHW->gui_cntl = inm(GUI_STAT);
+ pATIHW->gui_cntl = inm(GUI_CNTL);
/* Save destination registers */
pATIHW->dst_off_pitch = inm(DST_OFF_PITCH);
@@ -410,6 +444,10 @@ ATIMach64Save
/* Save context */
pATIHW->context_mask = inm(CONTEXT_MASK);
+
+ /* Restore aperture enablement */
+ outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl);
+ outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl);
}
}
@@ -421,7 +459,6 @@ ATIMach64Save
void
ATIMach64Calculate
(
- ScrnInfoPtr pScreenInfo,
ATIPtr pATI,
ATIHWPtr pATIHW,
DisplayModePtr pMode
@@ -539,7 +576,7 @@ ATIMach64Calculate
CRTC_VGA_TEXT_132 | CRTC_CUR_B_TEST);
pATIHW->crtc_gen_cntl |=
CRTC_EXT_DISP_EN | CRTC_EN | CRTC_VGA_LINEAR | CRTC_CNT_EN;
- switch (pScreenInfo->depth)
+ switch (pATI->depth)
{
case 1:
pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_1BPP, CRTC_PIX_WIDTH);
@@ -557,13 +594,13 @@ ATIMach64Calculate
pATIHW->crtc_gen_cntl |= SetBits(PIX_WIDTH_16BPP, CRTC_PIX_WIDTH);
break;
case 24:
- if (pScreenInfo->bitsPerPixel == 24)
+ if (pATI->bitsPerPixel == 24)
{
pATIHW->crtc_gen_cntl |=
SetBits(PIX_WIDTH_24BPP, CRTC_PIX_WIDTH);
break;
}
- if (pScreenInfo->bitsPerPixel != 32)
+ if (pATI->bitsPerPixel != 32)
break;
/* Fall through */
case 32:
@@ -586,7 +623,7 @@ ATIMach64Calculate
/*
* ATIMach64Set --
*
- * This function is called to load a Mach64's accelerator CRTC.
+ * This function is called to load a Mach64's accelerator CRTC and draw engine.
*/
void
ATIMach64Set
@@ -621,19 +658,16 @@ ATIMach64Set
/* Finalise CRTC setup and turn on the screen */
outl(pATI->CPIO_CRTC_GEN_CNTL, pATIHW->crtc_gen_cntl);
- /* Aperture setup */
- outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl);
-
- outl(pATI->CPIO_MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel);
- outl(pATI->CPIO_MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel);
-
- outl(pATI->CPIO_DAC_CNTL, pATIHW->dac_cntl);
-
- outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl);
-
/* Load draw engine */
if (pATI->OptionAccel)
{
+ /* Clobber MMIO cache */
+ (void)memset(pATI->MMIOCached, 0, SizeOf(pATI->MMIOCached));
+
+ /* Ensure apertures are enabled */
+ outl(pATI->CPIO_BUS_CNTL, pATI->NewHW.bus_cntl);
+ outl(pATI->CPIO_CONFIG_CNTL, pATI->NewHW.config_cntl);
+
pATI->EngineIsBusy = TRUE; /* Force engine poll */
ATIMach64WaitForIdle();
@@ -645,6 +679,9 @@ ATIMach64Set
ATIMach64PollEngineStatus(pATI);
}
+ /* Set FIFO depth */
+ pATI->nFIFOEntries = pATI->nAvailableFIFOEntries;
+
/* Load destination registers */
ATIMach64WaitForFIFO(7);
outm(DST_OFF_PITCH, pATIHW->dst_off_pitch);
@@ -705,7 +742,46 @@ ATIMach64Set
outm(CONTEXT_MASK, pATIHW->context_mask);
ATIMach64WaitForIdle();
+
+ if (pATI->OptionMMIOCache)
+ {
+ /*
+ * Enable write caching for selected MMIO registers. This can only
+ * be done for those registers whose value does not change without
+ * driver intervention.
+ */
+
+ CacheRegister(SRC_CNTL);
+
+ CacheRegister(HOST_CNTL);
+
+ CacheRegister(PAT_REG0);
+ CacheRegister(PAT_REG1);
+ CacheRegister(PAT_CNTL);
+
+ CacheRegister(SC_LEFT_RIGHT);
+ CacheRegister(SC_TOP_BOTTOM);
+
+ CacheRegister(DP_BKGD_CLR);
+ CacheRegister(DP_FRGD_CLR);
+ CacheRegister(DP_WRITE_MASK);
+ CacheRegister(DP_MIX);
+
+ CacheRegister(CLR_CMP_CLR);
+ CacheRegister(CLR_CMP_MSK);
+ CacheRegister(CLR_CMP_CNTL);
+ }
}
+
+ /* Aperture setup */
+ outl(pATI->CPIO_BUS_CNTL, pATIHW->bus_cntl);
+
+ outl(pATI->CPIO_MEM_VGA_WP_SEL, pATIHW->mem_vga_wp_sel);
+ outl(pATI->CPIO_MEM_VGA_RP_SEL, pATIHW->mem_vga_rp_sel);
+
+ outl(pATI->CPIO_DAC_CNTL, pATIHW->dac_cntl);
+
+ outl(pATI->CPIO_CONFIG_CNTL, pATIHW->config_cntl);
}
/*
@@ -726,12 +802,12 @@ ATIMach64SaveScreen
{
case SCREEN_SAVER_OFF:
case SCREEN_SAVER_FORCER:
- outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_EN);
+ outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl & ~CRTC_DISPLAY_DIS);
break;
case SCREEN_SAVER_ON:
case SCREEN_SAVER_CYCLE:
- outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl & ~CRTC_EN);
+ outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl | CRTC_DISPLAY_DIS);
break;
default:
@@ -740,6 +816,93 @@ ATIMach64SaveScreen
}
/*
+ * ATIMach64SetDPMSMode --
+ *
+ * This function sets a Mach64's VESA Display Power Management Signaling mode.
+ */
+void
+ATIMach64SetDPMSMode
+(
+ ATIPtr pATI,
+ int DPMSMode
+)
+{
+ CARD32 crtc_gen_cntl =
+ inl(pATI->CPIO_CRTC_GEN_CNTL) & ~(CRTC_HSYNC_DIS | CRTC_VSYNC_DIS);
+
+ switch (DPMSMode)
+ {
+ case DPMSModeOn: /* HSync on, VSync on */
+ break;
+
+ case DPMSModeStandby: /* HSync off, VSync on */
+ crtc_gen_cntl |= CRTC_HSYNC_DIS;
+ break;
+
+ case DPMSModeSuspend: /* HSync on, VSync off */
+ crtc_gen_cntl |= CRTC_VSYNC_DIS;
+ break;
+
+ case DPMSModeOff: /* HSync off, VSync off */
+ crtc_gen_cntl |= CRTC_HSYNC_DIS | CRTC_VSYNC_DIS;
+ break;
+
+ default: /* Muffle compiler */
+ return;
+ }
+
+ outl(pATI->CPIO_CRTC_GEN_CNTL, crtc_gen_cntl);
+
+ if ((pATI->LCDPanelID >= 0) && !pATI->OptionCRT)
+ {
+ CARD32 lcd_index = 0, power_management;
+
+ if (pATI->Chip == ATI_CHIP_264LT)
+ power_management = inl(pATI->CPIO_POWER_MANAGEMENT);
+ else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) ||
+ (pATI->Chip == ATI_CHIP_264XL) ||
+ (pATI->Chip == ATI_CHIP_MOBILITY)) */
+ {
+ lcd_index = inl(pATI->CPIO_LCD_INDEX);
+ power_management = ATIGetLTProLCDReg(LCD_POWER_MANAGEMENT);
+ }
+
+ power_management &= ~(STANDBY_NOW | SUSPEND_NOW);
+
+ switch (DPMSMode)
+ {
+ case DPMSModeOn:
+ break;
+
+ case DPMSModeStandby:
+ power_management |= STANDBY_NOW;
+ break;
+
+ case DPMSModeSuspend:
+ power_management |= SUSPEND_NOW;
+ break;
+
+ case DPMSModeOff:
+ power_management |= STANDBY_NOW | SUSPEND_NOW; /* ? */
+ break;
+
+ default: /* Muffle compiler */
+ return;
+ }
+
+ if (pATI->Chip == ATI_CHIP_264LT)
+ outl(POWER_MANAGEMENT, power_management);
+ else /* if ((pATI->Chip == ATI_CHIP_264LTPRO) ||
+ (pATI->Chip == ATI_CHIP_264XL) ||
+ (pATI->Chip == ATI_CHIP_MOBILITY)) */
+ {
+ ATIPutLTProLCDReg(LCD_POWER_MANAGEMENT, power_management);
+ outl(pATI->CPIO_LCD_INDEX, lcd_index);
+ }
+ }
+}
+
+/*
* ATIMach64Sync --
*
* This is called to wait for the draw engine to become idle.
@@ -754,6 +917,128 @@ ATIMach64Sync
ATIMach64WaitForIdle();
+ if (pATI->OptionMMIOCache)
+ {
+ /*
+ * For debugging purposes, attempt to verify that each cached register
+ * should actually be cached.
+ */
+ if (RegisterIsCached(SRC_CNTL) &&
+ (CacheSlot(SRC_CNTL) != inm(SRC_CNTL)))
+ {
+ UncacheRegister(SRC_CNTL);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "SRC_CNTL write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(HOST_CNTL) &&
+ (CacheSlot(HOST_CNTL) != inm(HOST_CNTL)))
+ {
+ UncacheRegister(HOST_CNTL);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "HOST_CNTL write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(PAT_REG0) &&
+ (CacheSlot(PAT_REG0) != inm(PAT_REG0)))
+ {
+ UncacheRegister(PAT_REG0);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "PAT_REG0 write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(PAT_REG1) &&
+ (CacheSlot(PAT_REG1) != inm(PAT_REG1)))
+ {
+ UncacheRegister(PAT_REG1);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "PAT_REG1 write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(PAT_CNTL) &&
+ (CacheSlot(PAT_CNTL) != inm(PAT_CNTL)))
+ {
+ UncacheRegister(PAT_CNTL);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "PAT_CNTL write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(SC_LEFT_RIGHT) &&
+ (CacheSlot(SC_LEFT_RIGHT) !=
+ (SetWord(inm(SC_RIGHT), 1) | SetWord(inm(SC_LEFT), 0))))
+ {
+ UncacheRegister(SC_LEFT_RIGHT);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "SC_LEFT_RIGHT write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(SC_TOP_BOTTOM) &&
+ (CacheSlot(SC_TOP_BOTTOM) !=
+ (SetWord(inm(SC_BOTTOM), 1) | SetWord(inm(SC_TOP), 0))))
+ {
+ UncacheRegister(SC_TOP_BOTTOM);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "SC_TOP_BOTTOM write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(DP_BKGD_CLR) &&
+ (CacheSlot(DP_BKGD_CLR) != inm(DP_BKGD_CLR)))
+ {
+ UncacheRegister(DP_BKGD_CLR);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "DP_BKGD_CLR write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(DP_FRGD_CLR) &&
+ (CacheSlot(DP_FRGD_CLR) != inm(DP_FRGD_CLR)))
+ {
+ UncacheRegister(DP_FRGD_CLR);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "DP_FRGD_CLR write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(DP_WRITE_MASK) &&
+ (CacheSlot(DP_WRITE_MASK) != inm(DP_WRITE_MASK)))
+ {
+ UncacheRegister(DP_WRITE_MASK);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "DP_WRITE_MASK write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(DP_MIX) &&
+ (CacheSlot(DP_MIX) != inm(DP_MIX)))
+ {
+ UncacheRegister(DP_MIX);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "DP_MIX write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(CLR_CMP_CLR) &&
+ (CacheSlot(CLR_CMP_CLR) != inm(CLR_CMP_CLR)))
+ {
+ UncacheRegister(CLR_CMP_CLR);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "CLR_CMP_CLR write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(CLR_CMP_MSK) &&
+ (CacheSlot(CLR_CMP_MSK) != inm(CLR_CMP_MSK)))
+ {
+ UncacheRegister(CLR_CMP_MSK);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "CLR_CMP_MSK write cache disabled!\n");
+ }
+
+ if (RegisterIsCached(CLR_CMP_CNTL) &&
+ (CacheSlot(CLR_CMP_CNTL) != inm(CLR_CMP_CNTL)))
+ {
+ UncacheRegister(CLR_CMP_CNTL);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "CLR_CMP_CNTL write cache disabled!\n");
+ }
+
+ }
+
/*
* For VTB's and later, the first CPU read of the framebuffer will return
* zeroes, so do it here. This appears to be due to some kind of engine
@@ -789,20 +1074,15 @@ ATIMach64SetupForScreenToScreenCopy
if (xdir > 0)
pATI->dst_cntl |= DST_X_DIR;
- if (pATI->PitchModifier == 1)
- {
- ATIMach64WaitForFIFO(4);
+ if (pATI->XModifier == 1)
outm(DST_CNTL, pATI->dst_cntl);
- }
else
- {
- ATIMach64WaitForFIFO(3);
pATI->dst_cntl |= DST_24_ROT_EN;
- }
+ ATIMach64WaitForFIFO(3);
outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX));
outm(DP_WRITE_MASK, planemask);
- outm(DP_SRC, SetBits(DP_MONO_SRC_ALLONES, DP_MONO_SRC) |
+ outm(DP_SRC, DP_MONO_SRC_ALLONES |
SetBits(SRC_BLIT, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
}
@@ -825,9 +1105,19 @@ ATIMach64SubsequentScreenToScreenCopy
{
ATIPtr pATI = ATIPTR(pScreenInfo);
- xSrc *= pATI->PitchModifier;
- xDst *= pATI->PitchModifier;
- w *= pATI->PitchModifier;
+ xSrc *= pATI->XModifier;
+ xDst *= pATI->XModifier;
+ w *= pATI->XModifier;
+
+ /* Disable clipping if it gets in the way */
+ if ((xDst < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) ||
+ ((xDst + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1)))
+ outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) |
+ SetWord(pATI->NewHW.sc_left, 0));
+ if ((yDst < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) ||
+ ((yDst + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1)))
+ outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) |
+ SetWord(pATI->NewHW.sc_top, 0));
if (!(pATI->dst_cntl & DST_X_DIR))
{
@@ -841,14 +1131,10 @@ ATIMach64SubsequentScreenToScreenCopy
yDst += h - 1;
}
- if (pATI->PitchModifier == 1)
- ATIMach64WaitForFIFO(4);
- else
- {
- ATIMach64WaitForFIFO(5);
+ if (pATI->XModifier != 1)
outm(DST_CNTL, pATI->dst_cntl | SetBits((xDst / 4) % 6, DST_24_ROT));
- }
+ ATIMach64WaitForFIFO(4);
outm(SRC_Y_X, SetWord(xSrc, 1) | SetWord(ySrc, 0));
outm(SRC_WIDTH1, w);
outm(DST_Y_X, SetWord(xDst, 1) | SetWord(yDst, 0));
@@ -871,17 +1157,13 @@ ATIMach64SetupForSolidFill
{
ATIPtr pATI = ATIPTR(pScreenInfo);
- if (pATI->PitchModifier != 1)
- ATIMach64WaitForFIFO(4);
- else
- {
- ATIMach64WaitForFIFO(5);
- outm(DST_CNTL, pATI->NewHW.dst_cntl);
- }
+ if (pATI->XModifier == 1)
+ outm(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+ ATIMach64WaitForFIFO(4);
outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX));
outm(DP_WRITE_MASK, planemask);
- outm(DP_SRC, SetBits(DP_MONO_SRC_ALLONES, DP_MONO_SRC) |
+ outm(DP_SRC, DP_MONO_SRC_ALLONES |
SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
outm(DP_FRGD_CLR, colour);
}
@@ -903,64 +1185,319 @@ ATIMach64SubsequentSolidFillRect
{
ATIPtr pATI = ATIPTR(pScreenInfo);
- if (pATI->PitchModifier == 1)
- ATIMach64WaitForFIFO(2);
- else
+ if (pATI->XModifier != 1)
{
- x *= pATI->PitchModifier;
- w *= pATI->PitchModifier;
+ x *= pATI->XModifier;
+ w *= pATI->XModifier;
- ATIMach64WaitForFIFO(3);
- outm(DST_CNTL, pATI->NewHW.dst_cntl | DST_24_ROT_EN |
- SetBits((x / 4) % 6, DST_24_ROT));
+ outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |
+ (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));
}
+ /* Disable clipping if it gets in the way */
+ if ((x < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) ||
+ ((x + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1)))
+ outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) |
+ SetWord(pATI->NewHW.sc_left, 0));
+ if ((y < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) ||
+ ((y + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1)))
+ outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) |
+ SetWord(pATI->NewHW.sc_top, 0));
+
+ ATIMach64WaitForFIFO(2);
outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0));
}
/*
- * ATIMach64SetClippingRectangle --
+ * ATIMach64SetupForSolidLine --
*
- * This function sets the draw engine's clipping rectangle.
+ * This function sets up the draw engine for a series of solid lines. It is
+ * not used for 24bpp because the engine doesn't support it.
*/
static void
-ATIMach64SetClippingRectangle
+ATIMach64SetupForSolidLine
+(
+ ScrnInfoPtr pScreenInfo,
+ int colour,
+ int rop,
+ unsigned int planemask
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+
+ ATIMach64WaitForFIFO(6);
+ outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX));
+ outm(DP_WRITE_MASK, planemask);
+ outm(DP_SRC, DP_MONO_SRC_ALLONES |
+ SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+ outm(DP_FRGD_CLR, colour);
+
+ outm(SC_LEFT_RIGHT,
+ SetWord(pATI->NewHW.sc_right, 1) | SetWord(pATI->NewHW.sc_left, 0));
+ outm(SC_TOP_BOTTOM,
+ SetWord(pATI->NewHW.sc_bottom, 1) | SetWord(pATI->NewHW.sc_top, 0));
+}
+
+/*
+ * ATIMach64SubsequentSolidHorVertLine --
+ *
+ * This is called to draw a solid horizontal or vertical line. This does a
+ * one-pixel wide solid fill.
+ */
+static void
+ATIMach64SubsequentSolidHorVertLine
(
ScrnInfoPtr pScreenInfo,
- int left,
- int top,
- int right,
- int bottom
+ int x,
+ int y,
+ int len,
+ int dir
)
{
ATIPtr pATI = ATIPTR(pScreenInfo);
- ATIMach64WaitForFIFO(2);
- outm(SC_LEFT_RIGHT, SetWord(((right + 1) * pATI->PitchModifier) - 1, 1) |
- SetWord(left * pATI->PitchModifier, 0));
- outm(SC_TOP_BOTTOM, SetWord(bottom, 1) | SetWord(top, 0));
+ ATIMach64WaitForFIFO(3);
+ outm(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+ outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+
+ if (dir == DEGREES_0)
+ outm(DST_HEIGHT_WIDTH, SetWord(len, 1) | SetWord(1, 0));
+ else /* if (dir == DEGREES_270) */
+ outm(DST_HEIGHT_WIDTH, SetWord(1, 1) | SetWord(len, 0));
}
/*
- * ATIMach64DisableClipping --
+ * ATIMach64SubsequentSolidBresenhamLine --
*
- * This function resets the draw engine's clipping rectangle to include the
- * entire virtual resolution.
+ * This function draws a line using the Bresenham line engine.
*/
static void
-ATIMach64DisableClipping
+ATIMach64SubsequentSolidBresenhamLine
(
- ScrnInfoPtr pScreenInfo
+ ScrnInfoPtr pScreenInfo,
+ int x,
+ int y,
+ int major,
+ int minor,
+ int err,
+ int len,
+ int octant
)
{
ATIPtr pATI = ATIPTR(pScreenInfo);
+ CARD32 dst_cntl = DST_LAST_PEL;
+
+ if (octant & YMAJOR)
+ dst_cntl |= DST_Y_MAJOR;
+
+ if (!(octant & XDECREASING))
+ dst_cntl |= DST_X_DIR;
+
+ if (!(octant & YDECREASING))
+ dst_cntl |= DST_Y_DIR;
+
+ ATIMach64WaitForFIFO(6);
+ outm(DST_CNTL, dst_cntl);
+ outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+ outm(DST_BRES_ERR, minor + err);
+ outm(DST_BRES_INC, minor);
+ outm(DST_BRES_DEC, minor - major);
+ outm(DST_BRES_LNTH, len);
+}
+
+/*
+ * ATIMach64SetupForMono8x8PatternFill --
+ *
+ * This function sets up the draw engine for a series of 8x8 1bpp pattern
+ * fills.
+ */
+static void
+ATIMach64SetupForMono8x8PatternFill
+(
+ ScrnInfoPtr pScreenInfo,
+ int patx,
+ int paty,
+ int fg,
+ int bg,
+ int rop,
+ unsigned int planemask
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+
+ if (pATI->XModifier == 1)
+ outm(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+
+ if (bg == -1)
+ outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+ SetBits(MIX_DST, DP_BKGD_MIX));
+ else
+ {
+ ATIMach64WaitForFIFO(2);
+ outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+ SetBits(ATIMach64ALU[rop], DP_BKGD_MIX));
+ outm(DP_BKGD_CLR, bg);
+ }
+
+ ATIMach64WaitForFIFO(6);
+ outm(DP_WRITE_MASK, planemask);
+ outm(DP_SRC, DP_MONO_SRC_PATTERN |
+ SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+ outm(DP_FRGD_CLR, fg);
+
+ outm(PAT_REG0, patx);
+ outm(PAT_REG1, paty);
+ outm(PAT_CNTL, PAT_MONO_EN);
+}
+
+/*
+ * ATIMach64SubsequentMono8x8PatternFillRect --
+ *
+ * This function performs an 8x8 1bpp pattern fill.
+ */
+static void
+ATIMach64SubsequentMono8x8PatternFillRect
+(
+ ScrnInfoPtr pScreenInfo,
+ int patx,
+ int paty,
+ int x,
+ int y,
+ int w,
+ int h
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+
+ if (pATI->XModifier != 1)
+ {
+ x *= pATI->XModifier;
+ w *= pATI->XModifier;
+
+ outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |
+ (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));
+ }
+
+ /* Disable clipping if it gets in the way */
+ if ((x < (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 0)) ||
+ ((x + w - 1) > (int)GetWord(CacheSlot(SC_LEFT_RIGHT), 1)))
+ outm(SC_LEFT_RIGHT, SetWord(pATI->NewHW.sc_right, 1) |
+ SetWord(pATI->NewHW.sc_left, 0));
+ if ((y < (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 0)) ||
+ ((y + h - 1) > (int)GetWord(CacheSlot(SC_TOP_BOTTOM), 1)))
+ outm(SC_TOP_BOTTOM, SetWord(pATI->NewHW.sc_bottom, 1) |
+ SetWord(pATI->NewHW.sc_top, 0));
ATIMach64WaitForFIFO(2);
- outm(SC_LEFT_RIGHT,
- SetWord(pATI->NewHW.sc_right, 1) | SetWord(pATI->NewHW.sc_left, 0));
- outm(SC_TOP_BOTTOM,
- SetWord(pATI->NewHW.sc_bottom, 1) | SetWord(pATI->NewHW.sc_top, 0));
+ outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+ outm(DST_HEIGHT_WIDTH, SetWord(w, 1) | SetWord(h, 0));
+}
+
+/*
+ * ATIMach64SetupForScanlineCPUToScreenColorExpandFill --
+ *
+ * This function sets up the engine for a series of colour expansion fills.
+ */
+static void
+ATIMach64SetupForScanlineCPUToScreenColorExpandFill
+(
+ ScrnInfoPtr pScreenInfo,
+ int fg,
+ int bg,
+ int rop,
+ unsigned int planemask
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+
+ if (pATI->XModifier == 1)
+ outm(DST_CNTL, DST_X_DIR | DST_Y_DIR);
+
+ if (bg == -1)
+ outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+ SetBits(MIX_DST, DP_BKGD_MIX));
+ else
+ {
+ ATIMach64WaitForFIFO(2);
+ outm(DP_MIX, SetBits(ATIMach64ALU[rop], DP_FRGD_MIX) |
+ SetBits(ATIMach64ALU[rop], DP_BKGD_MIX));
+ outm(DP_BKGD_CLR, bg);
+ }
+
+ ATIMach64WaitForFIFO(3);
+ outm(DP_WRITE_MASK, planemask);
+ outm(DP_SRC, DP_MONO_SRC_HOST |
+ SetBits(SRC_FRGD, DP_FRGD_SRC) | SetBits(SRC_BKGD, DP_BKGD_SRC));
+ outm(DP_FRGD_CLR, fg);
+}
+
+/*
+ * ATIMach64SubsequentScanlineCPUToScreenColorExpandFill --
+ *
+ * This function sets up the engine for a single colour expansion fill.
+ */
+static void
+ATIMach64SubsequentScanlineCPUToScreenColorExpandFill
+(
+ ScrnInfoPtr pScreenInfo,
+ int x,
+ int y,
+ int w,
+ int h,
+ int skipleft
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+
+ if (pATI->XModifier != 1)
+ {
+ x *= pATI->XModifier;
+ w *= pATI->XModifier;
+ skipleft *= pATI->XModifier;
+
+ outm(DST_CNTL, SetBits((x / 4) % 6, DST_24_ROT) |
+ (DST_X_DIR | DST_Y_DIR | DST_24_ROT_EN));
+ }
+
+ pATI->ExpansionBitmapWidth = (w + 31) / 32;
+
+ ATIMach64WaitForFIFO(3);
+ outm(SC_LEFT_RIGHT, SetWord(x + w - 1, 1) | SetWord(x + skipleft, 0));
+ outm(DST_Y_X, SetWord(x, 1) | SetWord(y, 0));
+ outm(DST_HEIGHT_WIDTH,
+ SetWord(pATI->ExpansionBitmapWidth * 32, 1) | SetWord(h, 0));
+}
+
+/*
+ * ATIMach64SubsequentColorExpandScanline --
+ *
+ * This function feeds a bitmap scanline to the engine for a colour expansion
+ * fill.
+ */
+static void
+ATIMach64SubsequentColorExpandScanline
+(
+ ScrnInfoPtr pScreenInfo,
+ int iBuffer
+)
+{
+ ATIPtr pATI = ATIPTR(pScreenInfo);
+ CARD32 *pBitmapData = pATI->ExpansionBitmapScanline;
+ int w = pATI->ExpansionBitmapWidth;
+ int nFIFOEntries = pATI->nFIFOEntries;
+
+ pATI->nFIFOEntries >>= 1;
+
+ for (; w > 0; w--, pBitmapData++)
+ {
+ if (!pATI->nAvailableFIFOEntries && (w > 1))
+ ATIMach64WaitForFIFO(w);
+
+ outm(HOST_DATA_0, *pBitmapData);
+ }
+
+ pATI->nFIFOEntries = nFIFOEntries;
}
/*
@@ -972,14 +1509,12 @@ ATIMach64DisableClipping
Bool
ATIMach64AccelInit
(
- ScrnInfoPtr pScreenInfo,
- ScreenPtr pScreen,
ATIPtr pATI,
XAAInfoRecPtr pXAAInfo
)
{
/* This doesn't seem quite right... */
- if (pATI->PitchModifier == 1)
+ if (pATI->XModifier == 1)
{
pXAAInfo->Flags = PIXMAP_CACHE | OFFSCREEN_PIXMAPS;
if (!pATI->BankInfo.BankSize)
@@ -999,13 +1534,43 @@ ATIMach64AccelInit
pXAAInfo->SetupForSolidFill = ATIMach64SetupForSolidFill;
pXAAInfo->SubsequentSolidFillRect = ATIMach64SubsequentSolidFillRect;
- /* Clips */
- pXAAInfo->ClippingFlags = 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;
- pXAAInfo->SetClippingRectangle = ATIMach64SetClippingRectangle;
- pXAAInfo->DisableClipping = ATIMach64DisableClipping;
+ /* 8x8 mono pattern fills */
+ pXAAInfo->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_BITS |
+ HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST;
+ pXAAInfo->SetupForMono8x8PatternFill = ATIMach64SetupForMono8x8PatternFill;
+ pXAAInfo->SubsequentMono8x8PatternFillRect =
+ ATIMach64SubsequentMono8x8PatternFillRect;
+
+ /*
+ * Use scanline version of colour expansion, not only for the non-ix86
+ * case, but also to avoid PCI retries.
+ */
+ pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags =
+ LEFT_EDGE_CLIPPING | LEFT_EDGE_CLIPPING_NEGATIVE_X |
+ BIT_ORDER_IN_BYTE_MSBFIRST | CPU_TRANSFER_PAD_DWORD |
+ SCANLINE_PAD_DWORD;
+ if (pATI->XModifier != 1)
+ pXAAInfo->ScanlineCPUToScreenColorExpandFillFlags |= TRIPLE_BITS_24BPP;
+ pXAAInfo->NumScanlineColorExpandBuffers = 1;
+ pATI->ExpansionBitmapScanlinePtr = pATI->ExpansionBitmapScanline;
+ pXAAInfo->ScanlineColorExpandBuffers =
+ (CARD8 **)&pATI->ExpansionBitmapScanlinePtr;
+ pXAAInfo->SetupForScanlineCPUToScreenColorExpandFill =
+ ATIMach64SetupForScanlineCPUToScreenColorExpandFill;
+ pXAAInfo->SubsequentScanlineCPUToScreenColorExpandFill =
+ ATIMach64SubsequentScanlineCPUToScreenColorExpandFill;
+ pXAAInfo->SubsequentColorExpandScanline =
+ ATIMach64SubsequentColorExpandScanline;
+
+ /* The engine does not support the following primitives for 24bpp */
+ if (pATI->XModifier != 1)
+ return TRUE;
+
+ /* Solid lines */
+ pXAAInfo->SetupForSolidLine = ATIMach64SetupForSolidLine;
+ pXAAInfo->SubsequentSolidHorVertLine = ATIMach64SubsequentSolidHorVertLine;
+ pXAAInfo->SubsequentSolidBresenhamLine =
+ ATIMach64SubsequentSolidBresenhamLine;
return TRUE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h
index c8fa68653..0cfa6e92b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h,v 1.4 2000/02/18 12:19:26 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimach64.h,v 1.8 2000/06/19 15:00:57 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -28,16 +28,19 @@
#include "atiproto.h"
#include "xaa.h"
-extern void ATIMach64PreInit FunctionPrototype((ScrnInfoPtr, ATIPtr,
- ATIHWPtr));
-extern void ATIMach64Save FunctionPrototype((ATIPtr, ATIHWPtr));
-extern void ATIMach64Calculate FunctionPrototype((ScrnInfoPtr, ATIPtr,
- ATIHWPtr, DisplayModePtr));
-extern void ATIMach64Set FunctionPrototype((ATIPtr, ATIHWPtr));
+#define ATIMach64MaxX 8191
+#define ATIMach64MaxY 32767
-extern void ATIMach64SaveScreen FunctionPrototype((ATIPtr, int));
+extern void ATIMach64PreInit FunctionPrototype((ScrnInfoPtr, ATIPtr,
+ ATIHWPtr));
+extern void ATIMach64Save FunctionPrototype((ATIPtr, ATIHWPtr));
+extern void ATIMach64Calculate FunctionPrototype((ATIPtr, ATIHWPtr,
+ DisplayModePtr));
+extern void ATIMach64Set FunctionPrototype((ATIPtr, ATIHWPtr));
-extern Bool ATIMach64AccelInit FunctionPrototype((ScrnInfoPtr, ScreenPtr,
- ATIPtr, XAAInfoRecPtr));
+extern void ATIMach64SaveScreen FunctionPrototype((ATIPtr, int));
+extern void ATIMach64SetDPMSMode FunctionPrototype((ATIPtr, int));
+
+extern Bool ATIMach64AccelInit FunctionPrototype((ATIPtr, XAAInfoRecPtr));
#endif /* ___ATIMACH64_H___ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c
index 51b414a77..a334861f6 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.5 2000/02/18 12:19:26 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atimodule.c,v 1.6 2000/06/19 15:00:57 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -147,7 +147,7 @@ ATILoadModules
}
/* Load depth-specific entry points */
- switch (pScreenInfo->bitsPerPixel)
+ switch (pATI->bitsPerPixel)
{
case 1:
return ATILoadModule(pScreenInfo, "xf1bpp", "xf1bppScreenInit");
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c
index 47d0f2b2b..8b30b41a0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.6 2000/02/18 12:19:27 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atioption.c,v 1.8 2000/05/03 00:44:06 tsi Exp $ */
/*
* Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -26,7 +26,6 @@
#include "atibus.h"
#include "atioption.h"
#include "atistruct.h"
-#include "atiutil.h"
/*
* Recognised XF86Config options.
@@ -37,6 +36,7 @@ typedef enum
ATI_OPTION_CRT,
ATI_OPTION_CSYNC,
ATI_OPTION_LINEAR,
+ ATI_OPTION_MMIO_CACHE,
ATI_OPTION_PROBE_CLOCKS,
ATI_OPTION_SHADOW_FB
} ATIPublicOptionType;
@@ -53,6 +53,7 @@ static OptionInfoRec ATIPublicOptions[] =
{ATI_OPTION_CRT, "crt_screen", OPTV_BOOLEAN, {0, }, FALSE},
{ATI_OPTION_CSYNC, "composite_sync", OPTV_BOOLEAN, {0, }, FALSE},
{ATI_OPTION_LINEAR, "linear", OPTV_BOOLEAN, {0, }, FALSE},
+ {ATI_OPTION_MMIO_CACHE, "mmio_cache", OPTV_BOOLEAN, {0, }, FALSE},
{ATI_OPTION_PROBE_CLOCKS, "probe_clocks", OPTV_BOOLEAN, {0, }, FALSE},
{ATI_OPTION_SHADOW_FB, "shadow_fb", OPTV_BOOLEAN, {0, }, FALSE},
{-1, NULL, OPTV_NONE , {0, }, FALSE}
@@ -94,13 +95,14 @@ ATIProcessOptions
{-1, NULL, OPTV_NONE , {0, }, FALSE}
};
- memcpy(PublicOption, ATIPublicOptions, SizeOf(ATIPublicOptions));
+ (void)memcpy(PublicOption, ATIPublicOptions, SizeOf(ATIPublicOptions));
# define Accel PublicOption[ATI_OPTION_ACCEL].value.bool
# define CRTScreen PublicOption[ATI_OPTION_CRT].value.bool
# define CSync PublicOption[ATI_OPTION_CSYNC].value.bool
# define Devel PrivateOption[ATI_OPTION_DEVEL].value.bool
# define Linear PublicOption[ATI_OPTION_LINEAR].value.bool
+# define CacheMMIO PublicOption[ATI_OPTION_MMIO_CACHE].value.bool
# define ProbeClocks PublicOption[ATI_OPTION_PROBE_CLOCKS].value.bool
# define ShadowFB PublicOption[ATI_OPTION_SHADOW_FB].value.bool
# define Sync PrivateOption[ATI_OPTION_SYNC].value.bool
@@ -110,7 +112,7 @@ ATIProcessOptions
/* Set non-zero defaults */
if (pATI->Adapter >= ATI_ADAPTER_MACH64)
- Accel = Linear = TRUE;
+ Accel = Linear = CacheMMIO = TRUE;
if (pATI->BusType >= ATI_BUS_PCI)
ShadowFB = TRUE;
Sync = TRUE;
@@ -135,6 +137,7 @@ ATIProcessOptions
pATI->OptionCSync = CSync;
pATI->OptionDevel = Devel;
pATI->OptionLinear = Linear;
+ pATI->OptionMMIOCache = CacheMMIO;
pATI->OptionProbeClocks = ProbeClocks;
pATI->OptionShadowFB = ShadowFB;
pATI->OptionSync = Sync;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c
index 0ed5146a1..73d5dc9dc 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c,v 1.16 2000/03/07 16:31:53 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atipreinit.c,v 1.26 2000/06/19 15:00:57 tsi Exp $ */
/*
* Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -24,20 +24,20 @@
#include "ati.h"
#include "atiadapter.h"
#include "atiadjust.h"
-#include "atibios.h"
#include "atibus.h"
#include "atichip.h"
#include "atidac.h"
#include "atidsp.h"
#include "atiident.h"
#include "atilock.h"
+#include "atimach64.h"
#include "atimodule.h"
#include "atioption.h"
#include "atipreinit.h"
#include "atiprint.h"
#include "atividmem.h"
+#include "vbe.h"
#include "xf86RAC.h"
-#include "xf86Resources.h"
typedef CARD16 Colour; /* The correct spelling should be OK :-) */
@@ -295,7 +295,7 @@ ATIReportMemory
Message = Buffer +
snprintf(Buffer, SizeOf(Buffer), "%d kB of %s detected",
pATI->VideoRAM, MemoryTypeName);
- if (pScreenInfo->depth == 1)
+ if (pATI->depth == 1)
{
/* 1bpp only uses one plane of four */
pScreenInfo->videoRam /= 4;
@@ -326,31 +326,34 @@ ATIPreInit
int flags
)
{
-# define BIOS_SIZE 0x00010000U /* 64kB */
- CARD8 BIOS[BIOS_SIZE];
-# define BIOSByte(_n) (*((CARD8 *)(BIOS + (_n))))
-# define BIOSWord(_n) (*((CARD16 *)(BIOS + (_n))))
-# define BIOSLong(_n) (*((CARD32 *)(BIOS + (_n))))
- unsigned int BIOSSize = BIOS_SIZE;
- unsigned int ROMTable = 0, ClockTable = 0, FrequencyTable = 0;
- unsigned int LCDTable = 0, LCDPanelInfo = 0;
-
- char Buffer[128], *Message;
- ATIPtr pATI;
- GDevPtr pGDev;
- EntityInfoPtr pEntity;
- resPtr pResources;
- Bool AllowCRT = TRUE;
- CARD32 IOValue1, IOValue2;
- int i, j, AcceleratorVideoRAM = 0, VGAVideoRAM = 0;
- int Numerator, Denominator;
- resRange Resources[2] = {{0, 0, 0}, _END};
- ClockRange ATIClockRange = {NULL, 0, 80000, 0, TRUE, TRUE, 1, 1, 0};
- int minPitch, maxPitch = 0xFFU, pitchInc;
- LookupModeFlags Strategy = LOOKUP_CLOSEST_CLOCK;
-
- if (flags & PROBE_DETECT)
- return FALSE;
+# define BIOS_SIZE 0x00010000U /* 64kB */
+ CARD8 BIOS[BIOS_SIZE], *pBIOS;
+# define BIOSByte(_n) (*((CARD8 *)(BIOS + (_n))))
+# define BIOSWord(_n) (*((CARD16 *)(BIOS + (_n))))
+# define BIOSLong(_n) (*((CARD32 *)(BIOS + (_n))))
+ unsigned int BIOSSize;
+ unsigned int ROMTable = 0, ClockTable = 0, FrequencyTable = 0;
+ unsigned int LCDTable = 0, LCDPanelInfo = 0;
+
+ char Buffer[128], *Message;
+ ATIPtr pATI;
+ GDevPtr pGDev;
+ EntityInfoPtr pEntity;
+ resPtr pResources;
+ DisplayModePtr pMode;
+ xf86Int10InfoPtr pInt10Info;
+ vbeInfoPtr pVBE;
+ xf86MonPtr pMonitor = NULL;
+ pointer pInt10Module, pDDCModule, pVBEModule = NULL;
+ Bool AllowCRT = TRUE;
+ CARD32 IOValue1, IOValue2 = 0;
+ int i, j, AcceleratorVideoRAM = 0, VGAVideoRAM = 0;
+ int Numerator, Denominator;
+ int MinX, MinY;
+ resRange Resources[2] = {{0, 0, 0}, _END};
+ ClockRange ATIClockRange = {NULL, 0, 80000, 0, TRUE, TRUE, 1, 1, 0};
+ int minPitch, maxPitch = 0xFFU, maxHeight = 0;
+ LookupModeFlags Strategy = LOOKUP_CLOSEST_CLOCK;
if (pScreenInfo->numEntities != 1)
{
@@ -368,6 +371,69 @@ ATIPreInit
return FALSE;
}
+ /*
+ * Get adapter BIOS, after ensuring its initialisation entry point has been
+ * executed.
+ */
+ if (!(pInt10Module = xf86LoadSubModule(pScreenInfo, "int10")))
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ "Unable to load int10 module.\n");
+ return FALSE;
+ }
+
+ if (!(pInt10Info = xf86InitInt10(pATI->iEntity)))
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ "Unable to initialise int10 interface.\n");
+ xf86UnloadSubModule(pInt10Module);
+ return FALSE;
+ }
+
+ if (!(pDDCModule = xf86LoadSubModule(pScreenInfo, "ddc")))
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Unable to load ddc module.\n");
+ else if (!(pVBEModule = xf86LoadSubModule(pScreenInfo, "vbe")))
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Unable to load vbe module.\n");
+ else
+ {
+ if ((pVBE = VBEInit(pInt10Info, pATI->iEntity)))
+ pMonitor = vbeDoEDID(pVBE, pDDCModule);
+ vbeFree(pVBE);
+ xf86UnloadSubModule(pVBEModule);
+ }
+
+ /*
+ * Validate, then make a private copy of, the initialised BIOS. This
+ * allows de-activating int10 early.
+ */
+ pBIOS = xf86int10Addr(pInt10Info, pInt10Info->BIOSseg << 4);
+ if ((pBIOS[0] != 0x55U) || (pBIOS[1] != 0xAAU) || !pBIOS[2])
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ "Unable to correctly retrieve adapter BIOS.\n");
+ xf86FreeInt10(pInt10Info);
+ xf86UnloadSubModule(pInt10Module);
+ return FALSE;
+ }
+
+ BIOSSize = pBIOS[2] << 9;
+ (void)memcpy(BIOS, pBIOS, BIOSSize);
+ if (BIOSSize < SizeOf(BIOS))
+ (void)memset(BIOS + BIOSSize, 0, SizeOf(BIOS) - BIOSSize);
+
+ /* De-activate int10 */
+ xf86FreeInt10(pInt10Info);
+ xf86UnloadSubModule(pInt10Module);
+
+ if (flags & PROBE_DETECT)
+ {
+ ConfiguredMonitor = pMonitor;
+ xf86UnloadSubModule(pDDCModule);
+ return TRUE;
+ }
+
/* Register resources */
pEntity = xf86GetEntityInfo(pScreenInfo->entityList[0]);
pGDev = pEntity->device;
@@ -381,6 +447,7 @@ ATIPreInit
xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
"Unable to register the following bus resources:\n");
xf86PrintResList(0, pResources);
+ xf86FreeResList(pResources);
return FALSE;
}
@@ -390,6 +457,15 @@ ATIPreInit
/* Set monitor */
pScreenInfo->monitor = pScreenInfo->confScreen->monitor;
+ if (pMonitor)
+ {
+ xf86PrintEDID(pMonitor);
+ xf86SetDDCproperties(pScreenInfo, pMonitor);
+ }
+
+ /* DDC module is no longer needed at this point */
+ xf86UnloadSubModule(pDDCModule);
+
/* Deal with ChipID & ChipRev overrides */
if (pGDev->chipID >= 0)
{
@@ -533,11 +609,9 @@ ATIPreInit
pATI->VideoRAM = (IOValue1 - 7) * 2048;
}
- IOValue1 = inl(pATI->CPIO_DAC_CNTL);
- pATI->DAC = GetBits(IOValue1, DAC_TYPE);
+ pATI->DAC = GetBits(inl(pATI->CPIO_DAC_CNTL), DAC_TYPE);
IOValue1 = inl(ATIIOPort(CONFIG_STATUS64_0));
- IOValue2 = inl(ATIIOPort(SCRATCH_REG1));
if (pATI->Chip >= ATI_CHIP_264CT)
{
pATI->MemoryType = GetBits(IOValue1, CFG_MEM_TYPE_T);
@@ -550,6 +624,7 @@ ATIPreInit
pATI->CPIO_HORZ_STRETCHING = ATIIOPort(HORZ_STRETCHING);
pATI->CPIO_VERT_STRETCHING = ATIIOPort(VERT_STRETCHING);
pATI->CPIO_LCD_GEN_CTRL = ATIIOPort(LCD_GEN_CTRL);
+ pATI->CPIO_POWER_MANAGEMENT = ATIIOPort(POWER_MANAGEMENT);
IOValue2 = inl(pATI->CPIO_LCD_GEN_CTRL);
}
@@ -600,7 +675,8 @@ ATIPreInit
/* Factor in what the BIOS says the DAC is */
pATI->DAC = ATI_DAC(pATI->DAC,
- GetBits(IOValue2, BIOS_INIT_DAC_SUBTYPE));
+ GetBits(inl(ATIIOPort(SCRATCH_REG1)),
+ BIOS_INIT_DAC_SUBTYPE));
}
/*
@@ -616,25 +692,6 @@ ATIPreInit
break;
}
- /* Get PCI or legacy video BIOS, >all< of it */
- i = ATIReadBIOS(pATI, BIOS, 0, SizeOf(BIOS));
-
- /* Clear off what could not be read */
- if (i < 0)
- i = 0;
- if (i < SizeOf(BIOS))
- memset(BIOS + i, 0, SizeOf(BIOS) - i);
- if ((BIOSByte(0) == 0x55U) && (BIOSByte(1) == 0xAAU) && BIOSByte(2))
- BIOSSize = BIOSByte(2) << 9;
- else
- i = 0;
- if ((unsigned int)i < BIOSSize)
- {
- xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
- "Unable to correctly read adapter BIOS.\n");
- return FALSE;
- }
-
/*
* For Mach64 adapters, pick up, from the BIOS, the type of programmable
* clock generator (if any), and various information about it.
@@ -810,6 +867,7 @@ ATIPreInit
i += j;
goto NextBIOSByte;
}
+
/* ... verify panel width ... */
if ((pATI->LCDHorizontal > 8) &&
(pATI->LCDHorizontal <=
@@ -845,7 +903,7 @@ ATIPreInit
if (LCDPanelInfo > 0)
{
- CARD8 ClockMask, PostMask, xpDiv, maxpDiv, pDiv;
+ CARD8 ClockMask, PostMask;
pATI->LCDPanelID = BIOSByte(LCDPanelInfo);
pATI->LCDHorizontal = BIOSWord(LCDPanelInfo + 0x19U);
@@ -864,10 +922,9 @@ ATIPreInit
*/
ClockMask = PLL_VCLK0_XDIV << i;
PostMask = PLL_VCLK0_POST_DIV << (i * 2);
- xpDiv = GetBits(ATIGetMach64PLLReg(PLL_XCLK_CNTL), ClockMask);
- maxpDiv = MaxBits(PLL_VCLK0_POST_DIV) + 1;
- pDiv = GetBits(ATIGetMach64PLLReg(PLL_VCLK_POST_DIV), PostMask);
- j = (xpDiv * maxpDiv) | pDiv;
+ j = GetBits(ATIGetMach64PLLReg(PLL_XCLK_CNTL), ClockMask);
+ j *= MaxBits(PLL_VCLK0_POST_DIV) + 1;
+ j |= GetBits(ATIGetMach64PLLReg(PLL_VCLK_POST_DIV), PostMask);
/* Calculate clock of mode on entry */
Numerator = ATIGetMach64PLLReg(PLL_VCLK0_FB_DIV + i) *
@@ -999,14 +1056,6 @@ ATIPreInit
"Panel clock is %.3f MHz.\n", (double)(pATI->LCDClock) / 1000.0);
}
- /* Report BIOS address */
- if (pATI->BIOSBase)
- xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
- "BIOS bus address: 0x%08X.\n", pATI->BIOSBase);
- else
- xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
- "BIOS not mapped by BIOS initialisation.\n");
-
/* Promote chipset specification */
switch (pATI->Chipset)
{
@@ -1084,6 +1133,7 @@ ATIPreInit
pScreenInfo->rgbBits = 6;
else
pScreenInfo->rgbBits = 8;
+ pATI->rgbBits = pScreenInfo->rgbBits;
if (!xf86SetWeight(pScreenInfo, defaultWeight, defaultWeight))
{
ATILock(pATI);
@@ -1138,17 +1188,61 @@ ATIPreInit
return FALSE;
}
+ pATI->depth = pScreenInfo->depth;
+ pATI->bitsPerPixel = pScreenInfo->bitsPerPixel;
+ pATI->weight = pScreenInfo->weight;
+ pATI->XModifier = pATI->bitsPerPixel / UnitOf(pATI->bitsPerPixel);
+
/*
* Determine which CRT controller to use for video modes.
*/
if ((pATI->Chip >= ATI_CHIP_88800GXC) &&
- (pScreenInfo->depth >= 8) &&
+ (pATI->depth >= 8) &&
(pATI->Chipset == ATI_CHIPSET_ATI))
+ {
pATI->NewHW.crtc = ATI_CRTC_MACH64;
+
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
+ "Using Mach64 accelerator CRTC.\n");
+
+ if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
+ {
+ /*
+ * No need for VGA I/O resources during operating state (but they
+ * are still decoded).
+ */
+ pResources =
+ xf86SetOperatingState(resVgaIo, pATI->iEntity, ResUnusedOpr);
+ if (pResources)
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Logic error setting operating state for VGA I/O.\n");
+ xf86FreeResList(pResources);
+ }
+
+ if (pATI->CPIO_VGAWonder)
+ {
+ pResources = xf86SetOperatingState(pATI->VGAWonderResources,
+ pATI->iEntity, ResUnusedOpr);
+ if (pResources)
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Logic error setting operating state for"
+ " VGAWonder I/O.\n");
+ xf86FreeResList(pResources);
+ }
+ }
+ }
+ }
else
+ {
pATI->NewHW.crtc = ATI_CRTC_VGA;
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
+ "Using VGA CRTC.\n");
+ }
+
/* Complain if VGA is needed but not there */
if ((pATI->NewHW.crtc == ATI_CRTC_VGA) || !pATI->OptionLinear)
{
@@ -1183,7 +1277,7 @@ ATIPreInit
{
pATI->OptionCRT = FALSE;
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
- "Using digital flat panel and disabling CRT interface.\n");
+ "Using digital flat panel interface.\n");
}
}
@@ -1194,7 +1288,7 @@ ATIPreInit
AcceleratorVideoRAM = pScreenInfo->videoRam = pATI->VideoRAM;
if (pATI->Chip == ATI_CHIP_VGA)
{
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
VGAVideoRAM = 256;
else
VGAVideoRAM = 64;
@@ -1239,7 +1333,7 @@ ATIPreInit
* VGA Wonder V3's, V4's and V5's don't appear to support banking in
* planar modes.
*/
- if ((pScreenInfo->depth <= 4) &&
+ if ((pATI->depth <= 4) &&
(pATI->Chip <= ATI_CHIP_18800_1) &&
(VGAVideoRAM > 256))
{
@@ -1248,7 +1342,7 @@ ATIPreInit
xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE,
"Virtual resolutions requiring more than %s kB\n of video"
" memory might not function properly." ATI_README,
- (pScreenInfo->depth == 1) ? "64" : "256");
+ (pATI->depth == 1) ? "64" : "256");
}
else
{
@@ -1262,7 +1356,7 @@ ATIPreInit
else if ((pATI->NewHW.crtc == ATI_CRTC_MACH64) ||
(pATI->Chip >= ATI_CHIP_264CT))
{
- if (pScreenInfo->depth >= 8)
+ if (pATI->depth >= 8)
{
/* Set MMIO address from PCI configuration space, if available */
if (pATI->PCIInfo &&
@@ -1276,9 +1370,23 @@ ATIPreInit
IOValue1 = inl(pATI->CPIO_CONFIG_CNTL);
pATI->LinearBase = GetBits(IOValue1, CFG_MEM_AP_LOC) << 22;
if ((IOValue1 & CFG_MEM_AP_SIZE) != CFG_MEM_AP_SIZE)
+ {
pATI->LinearSize =
GetBits(IOValue1, CFG_MEM_AP_SIZE) << 22;
+ /*
+ * Linear aperture could have been disabled (but still
+ * assigned) by BIOS initialisation.
+ */
+ if (pATI->LinearBase && !pATI->LinearSize)
+ {
+ if (pATI->VideoRAM < 4096)
+ pATI->LinearSize = 4 * 1024 * 1024;
+ else
+ pATI->LinearSize = 8 * 1024 * 1024;
+ }
+ }
+
/* Except for PCI & AGP, allow for user override */
if ((pATI->BusType != ATI_BUS_PCI) &&
(pATI->BusType != ATI_BUS_AGP))
@@ -1403,7 +1511,7 @@ ATIPreInit
pATI->CPIO_MEM_VGA_WP_SEL = ATIIOPort(MEM_VGA_WP_SEL);
/* Set banking functions */
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
{
pATI->NewHW.SetBank = ATIMach64SetBankPlanar;
pATI->BankInfo.SetSourceBank = ATIMach64SetReadPlanar;
@@ -1465,7 +1573,7 @@ ATIPreInit
{
if (pATI->OptionDevel)
{
- if (pScreenInfo->depth == 1)
+ if (pATI->depth == 1)
AcceleratorVideoRAM /= 4;
xf86DrvMsg(pScreenInfo->scrnIndex, X_NOTICE,
@@ -1483,18 +1591,47 @@ ATIPreInit
}
}
- if (pATI->OptionLinear && !pATI->LinearBase)
+ if (pATI->OptionLinear)
{
- xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
- "Linear aperture not supported in this configuration.\n");
- pATI->OptionLinear = FALSE;
+ if (!pATI->LinearBase)
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Linear aperture not supported in this configuration.\n");
+ pATI->OptionLinear = FALSE;
+ }
+ else
+ {
+ if (pATI->VGAAdapter != ATI_ADAPTER_NONE)
+ {
+ /*
+ * Free VGA memory aperture during operating state (but it is
+ * still decoded).
+ */
+ pResources = xf86SetOperatingState(resVgaMem,
+ pATI->iEntity, ResUnusedOpr);
+ if (pResources)
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Logic error setting operating state for VGA memory"
+ " aperture.\n");
+ xf86FreeResList(pResources);
+ }
+ }
+ }
}
- if (pATI->OptionAccel && !pATI->Block0Base)
+ if (pATI->OptionAccel)
{
- xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
- "Acceleration not supported in this configuration.\n");
- pATI->OptionAccel = FALSE;
+ if (!pATI->Block0Base || (pATI->NewHW.crtc == ATI_CRTC_VGA))
+ {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Acceleration not supported in this configuration.\n");
+ pATI->OptionAccel = FALSE;
+ }
+ else
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
+ "MMIO write caching %sabled.\n",
+ pATI->OptionMMIOCache ? "en" : "dis");
}
if (pATI->Adapter >= ATI_ADAPTER_MACH32)
@@ -1538,14 +1675,14 @@ ATIPreInit
(inl(pATI->CPIO_CRTC_GEN_CNTL) & CRTC_EXT_DISP_EN))
pATI->OldHW.crtc = ATI_CRTC_MACH64;
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
{
pATI->BankInfo.nBankDepth = 1;
pATI->NewHW.nPlane = 4;
}
else
{
- pATI->BankInfo.nBankDepth = pScreenInfo->depth;
+ pATI->BankInfo.nBankDepth = pATI->depth;
pATI->NewHW.nPlane = 1;
}
@@ -1568,7 +1705,8 @@ ATIPreInit
}
else if (!pATI->UseSmallApertures)
pATI->OldHW.SetBank = pATI->NewHW.SetBank;
- else if (!(inl(pATI->CPIO_CONFIG_CNTL) & CFG_MEM_VGA_AP_EN))
+ else if ((pATI->OldHW.crtc == ATI_CRTC_VGA) &&
+ !(inl(pATI->CPIO_CONFIG_CNTL) & CFG_MEM_VGA_AP_EN))
{
pATI->OldHW.SetBank = (ATIBankProcPtr)NoopDDA;
pATI->OldHW.nBank = 1;
@@ -1578,7 +1716,7 @@ ATIPreInit
else
pATI->OldHW.SetBank = ATIMach64SetBankPlanar;
- if (((pATI->ApertureSize * pScreenInfo->depth) /
+ if (((pATI->ApertureSize * pATI->depth) /
pATI->BankInfo.nBankDepth) >=
(unsigned)(pScreenInfo->videoRam * 1024))
pATI->BankInfo.BankSize = 0; /* No banking */
@@ -1593,7 +1731,7 @@ ATIPreInit
"Cannot shadow a banked frame buffer.\n");
pATI->OptionShadowFB = FALSE;
}
- else if (pScreenInfo->depth < 8)
+ else if (pATI->depth < 8)
{
xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
"Cannot shadow a planar frame buffer.\n");
@@ -1619,8 +1757,8 @@ ATIPreInit
}
/*
- * Determine maxClock. For adapters with supported programmable clock
- * generators, start with an absolute maximum.
+ * Determine minClock and maxClock. For adapters with supported
+ * programmable clock generators, start with an absolute maximum.
*/
if (pATI->ClockDescriptor.MaxN > 0)
{
@@ -1634,10 +1772,39 @@ ATIPreInit
*/
if (pATI->ProgrammableClock == ATI_CLOCK_INTERNAL)
Numerator <<= 1;
- else if (pScreenInfo->depth > 8)
- Denominator *= (pScreenInfo->bitsPerPixel / 8);
+ else if (pATI->depth > 8)
+ Denominator *= (pATI->bitsPerPixel / 8);
ATIClockRange.maxClock = (Numerator / (Denominator * 1000)) * 1000;
+
+ Numerator = pATI->ClockDescriptor.MinN * pATI->ReferenceNumerator;
+ Denominator = pATI->ClockDescriptor.MaxM * pATI->ReferenceDenominator *
+ pATI->ClockDescriptor.PostDividers[pATI->ClockDescriptor.NumD - 1];
+
+ if (pATI->ProgrammableClock == ATI_CLOCK_INTERNAL)
+ Numerator <<= 1;
+
+ ATIClockRange.minClock = (Numerator / (Denominator * 1000)) * 1000;
+
+ if (pATI->XCLKFeedbackDivider)
+ {
+ /* Possibly reduce maxClock due to memory bandwidth */
+ Numerator = pATI->XCLKFeedbackDivider * 2 *
+ pATI->ReferenceNumerator;
+ Denominator = pATI->ClockDescriptor.MinM *
+ pATI->XCLKReferenceDivider * pATI->ReferenceDenominator;
+
+ if (pATI->depth >= 8)
+ Denominator *= pATI->bitsPerPixel / 4;
+
+ i = (5 - 2) - pATI->XCLKPostDivider;
+ if (pATI->NewHW.crtc != ATI_CRTC_VGA)
+ i++;
+
+ i = (ATIDivide(Numerator, Denominator, i, -1) / 1000) * 1000;
+ if (i < ATIClockRange.maxClock)
+ ATIClockRange.maxClock = i;
+ }
}
/*
@@ -1648,7 +1815,7 @@ ATIPreInit
if ((pATI->DAC & ~0x0FU) == ATI_DAC_INTERNAL)
{
int DacSpeed;
- switch (pScreenInfo->bitsPerPixel)
+ switch (pATI->bitsPerPixel)
{
case 15:
case 16:
@@ -1673,13 +1840,14 @@ ATIPreInit
{
int DefaultmaxClock = 135000;
- if (pScreenInfo->depth > 8)
+ if (pATI->depth > 8)
DefaultmaxClock = 80000;
if ((pATI->Chip >= ATI_CHIP_264VTB) &&
(pATI->Chip != ATI_CHIP_Mach64))
{
- if (pATI->Chip >= ATI_CHIP_264VT4)
+ if ((pATI->Chip >= ATI_CHIP_264VT4) &&
+ (pATI->Chip != ATI_CHIP_264LTPRO))
DefaultmaxClock = 230000;
else if (pATI->Chip >= ATI_CHIP_264VT3)
DefaultmaxClock = 200000;
@@ -1711,16 +1879,21 @@ ATIPreInit
ATIClockRange.maxClock = 40000;
else if (pATI->CPIO_VGAWonder &&
(pATI->VideoRAM < 1024) &&
- (pScreenInfo->depth >= 8))
+ (pATI->depth >= 8))
ATIClockRange.maxClock =
(GetBits(BIOSByte(0x44U), 0x04U) * 5000) + 40000;
else
ATIClockRange.maxClock = 80000;
break;
}
- xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
- "Maximum pixel clock: %.3f MHz.\n",
- (double)ATIClockRange.maxClock / 1000.0);
+ if (pATI->ClockDescriptor.MaxN <= 0)
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
+ "Maximum pixel clock: %.3f MHz.\n",
+ (double)ATIClockRange.maxClock / 1000.0);
+
+ /* Map MMIO areas */
+ if (!ATIMapApertures(pScreenInfo, pATI))
+ return FALSE;
/*
* Determine available pixel clock frequencies.
@@ -1734,12 +1907,12 @@ ATIPreInit
* Mode validation.
*/
- if ((pScreenInfo->depth >= 8) && (pATI->Chip >= ATI_CHIP_264CT))
+ if ((pATI->depth >= 8) && (pATI->Chip >= ATI_CHIP_264CT))
minPitch = 8;
else if (pATI->CPIO_VGAWonder &&
(pATI->Chip <= ATI_CHIP_18800_1) &&
(pATI->VideoRAM == 256) &&
- (pScreenInfo->depth >= 8))
+ (pATI->depth >= 8))
{
minPitch = 32; /* Very strange, but true */
maxPitch = 0x3FU;
@@ -1747,23 +1920,9 @@ ATIPreInit
else
minPitch = 16;
- pitchInc = minPitch;
- if (pScreenInfo->depth >= 8)
- pitchInc *= pScreenInfo->bitsPerPixel;
-
- /*
- * For SGRAM & WRAM adapters, the display engine limits the pitch to
- * multiples of 64 bytes.
- */
- if (pATI->OptionAccel && (pATI->Chip >= ATI_CHIP_264CT) &&
- ((pATI->Chip >= ATI_CHIP_264VTB) ||
- (pATI->MemoryType >= MEM_264_SGRAM)))
- {
- if (pScreenInfo->bitsPerPixel == 24)
- pitchInc = 64 * 24;
- else
- pitchInc = 64 * 8;
- }
+ pATI->pitchInc = minPitch;
+ if (pATI->depth >= 8)
+ pATI->pitchInc *= pATI->bitsPerPixel;
switch (pATI->NewHW.crtc)
{
@@ -1837,6 +1996,26 @@ ATIPreInit
maxPitch *= minPitch;
+ if (pATI->OptionAccel)
+ {
+ /*
+ * Set engine restrictions on coordinate space. Use maxPitch for the
+ * horizontal and maxHeight for the vertical.
+ */
+ if (maxPitch > (ATIMach64MaxX / pATI->XModifier))
+ maxPitch = ATIMach64MaxX / pATI->XModifier;
+ maxHeight = ATIMach64MaxY;
+
+ /*
+ * For SGRAM & WRAM adapters, the display engine limits the pitch to
+ * multiples of 64 bytes.
+ */
+ if ((pATI->Chip >= ATI_CHIP_264CT) &&
+ ((pATI->Chip >= ATI_CHIP_264VTB) ||
+ (pATI->MemoryType >= MEM_264_SGRAM)))
+ pATI->pitchInc = pATI->XModifier * (64 * 8);
+ }
+
if (!pATI->OptionCRT && pATI->LCDPanelID >= 0)
{
/*
@@ -1845,23 +2024,67 @@ ATIPreInit
* and/or vertical refresh tolerances.
*/
Strategy |= LOOKUP_OPTIONAL_TOLERANCES;
+
+ /*
+ * Add a mode to the end of the monitor's list for the panel's native
+ * resolution.
+ */
+ pMode = (DisplayModePtr)xnfcalloc(1, SizeOf(DisplayModeRec));
+ pMode->name = "Native panel mode";
+ pMode->type = M_T_BUILTIN;
+ pMode->Clock = pATI->LCDClock;
+ pMode->HDisplay = pATI->LCDHorizontal;
+ pMode->VDisplay = pATI->LCDVertical;
+
+ /*
+ * These timings are bogus, but enough to survive sync tolerance
+ * checks.
+ */
+ pMode->HSyncStart = pMode->HDisplay;
+ pMode->HSyncEnd = pMode->HSyncStart + minPitch;
+ pMode->HTotal = pMode->HSyncEnd + minPitch;
+ pMode->VSyncStart = pMode->VDisplay;
+ pMode->VSyncEnd = pMode->VSyncStart + 1;
+ pMode->VTotal = pMode->VSyncEnd + 1;
+
+ pMode->CrtcHDisplay = pMode->HDisplay;
+ pMode->CrtcHBlankStart = pMode->HDisplay;
+ pMode->CrtcHSyncStart = pMode->HSyncStart;
+ pMode->CrtcHSyncEnd = pMode->HSyncEnd;
+ pMode->CrtcHBlankEnd = pMode->HTotal;
+ pMode->CrtcHTotal = pMode->HTotal;
+
+ pMode->CrtcVDisplay = pMode->VDisplay;
+ pMode->CrtcVBlankStart = pMode->VDisplay;
+ pMode->CrtcVSyncStart = pMode->VSyncStart;
+ pMode->CrtcVSyncEnd = pMode->VSyncEnd;
+ pMode->CrtcVBlankEnd = pMode->VTotal;
+ pMode->CrtcVTotal = pMode->VTotal;
+
+ if (!pScreenInfo->monitor->Modes)
+ pScreenInfo->monitor->Modes = pMode;
+ else
+ {
+ pScreenInfo->monitor->Last->next = pMode;
+ pMode->prev = pScreenInfo->monitor->Last;
+ }
+
+ pScreenInfo->monitor->Last = pMode;
}
i = xf86ValidateModes(pScreenInfo,
pScreenInfo->monitor->Modes, pScreenInfo->display->modes,
- &ATIClockRange, NULL, minPitch, maxPitch, pitchInc, 0, 0,
+ &ATIClockRange, NULL, minPitch, maxPitch,
+ pATI->pitchInc, 0, maxHeight,
pScreenInfo->display->virtualX, pScreenInfo->display->virtualY,
pATI->ApertureSize, Strategy);
if (i <= 0)
{
+ ATIUnmapApertures(pScreenInfo, pATI);
ATILock(pATI);
return FALSE;
}
- /* Map MMIO areas */
- if (!ATIMapApertures(pScreenInfo, pATI))
- return FALSE;
-
/* Remove invalid modes */
xf86PruneDriverModes(pScreenInfo);
@@ -1884,8 +2107,32 @@ ATIPreInit
}
#endif
+ pATI->displayWidth = pScreenInfo->displayWidth;
+
/* Initialise for panning */
- ATIAdjustPreInit(pScreenInfo, pATI);
+ ATIAdjustPreInit(pATI);
+
+ /*
+ * Warn about modes that are too small, or not aligned, to scroll to the
+ * bottom right corner of the virtual screen.
+ */
+ MinX = pScreenInfo->virtualX - pATI->AdjustMaxX;
+ MinY = pScreenInfo->virtualY - pATI->AdjustMaxY;
+
+ pMode = pScreenInfo->modes;
+ do
+ {
+ if ((pMode->VDisplay <= MinY) &&
+ ((pMode->VDisplay < MinY) || (pMode->HDisplay < MinX)))
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Mode \"%s\" too small to scroll to bottom right corner of"
+ " virtual resolution.\n", pMode->name);
+ else if ((pMode->HDisplay & ~pATI->AdjustMask) / pScreenInfo->xInc)
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ "Mode \"%s\" cannot scroll to bottom right corner of virtual"
+ " resolution.\n Horizontal dimension not a multiple of %d.\n",
+ pMode->name, ~pATI->AdjustMask + 1);
+ } while ((pMode = pMode->next) != pScreenInfo->modes);
/* Initialise CRTC code */
ATIAdapterPreInit(pScreenInfo, pATI, &pATI->NewHW);
@@ -1900,7 +2147,7 @@ ATIPreInit
/* Generate noise if requested */
if (xf86GetVerbosity() > 3)
{
- ATIPrintBIOS(pATI, BIOS, 0, BIOSSize);
+ ATIPrintBIOS(BIOS, 0, BIOSSize);
xf86ErrorFVerb(4, "\n On server entry:\n");
ATIPrintRegisters(pATI);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c
index 67e6174a7..d00909198 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c,v 1.11 2000/03/07 16:13:35 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.c,v 1.13 2000/06/19 15:00:58 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -35,7 +35,6 @@
void
ATIPrintBIOS
(
- ATIPtr pATI,
const CARD8 *BIOS,
const unsigned int Start,
const unsigned int End
@@ -48,9 +47,9 @@ ATIPrintBIOS
if (xf86GetVerbosity() <= 4)
return;
- memset(Printable, 0, SizeOf(Printable));
+ (void)memset(Printable, 0, SizeOf(Printable));
- xf86ErrorFVerb(5, "\n BIOS data at 0x%08X:", Start + pATI->BIOSBase);
+ xf86ErrorFVerb(5, "\n BIOS data at offset 0x%08X:", Start);
for (; Index < ((End + (16U - 1U)) & ~(16U - 1U)); Index++)
{
@@ -61,7 +60,7 @@ ATIPrintBIOS
if (Printable[0])
xf86ErrorFVerb(5, " |%s|", Printable);
Char = Printable;
- xf86ErrorFVerb(5, "\n 0x%08X: ", Index + pATI->BIOSBase);
+ xf86ErrorFVerb(5, "\n 0x%08X: ", Index);
}
xf86ErrorFVerb(5, " ");
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h
index 072997baf..ce6c40273 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h,v 1.4 2000/02/18 12:19:31 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprint.h,v 1.5 2000/04/20 21:28:31 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -28,7 +28,7 @@
#include "atiproto.h"
#include "xf86str.h"
-extern void ATIPrintBIOS FunctionPrototype((ATIPtr, const CARD8 *,
+extern void ATIPrintBIOS FunctionPrototype((const CARD8 *,
const unsigned int,
const unsigned int));
extern void ATIPrintRegisters FunctionPrototype((ATIPtr));
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c
index 36c5735a7..b8228f2f5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.19 2000/03/07 16:13:36 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiprobe.c,v 1.22 2000/06/19 15:00:58 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -216,15 +216,15 @@ ATIVGAProbe
* need to unlock them.
*/
ATISetVGAIOBase(pVGA, inb(R_GENMO));
- (void) inb(GENS1(pVGA->CPIO_VGABase));
+ (void)inb(GENS1(pVGA->CPIO_VGABase));
IOValue1 = inb(ATTRX);
- (void) inb(GENS1(pVGA->CPIO_VGABase));
+ (void)inb(GENS1(pVGA->CPIO_VGABase));
IOValue2 = GetReg(ATTRX, 0x14U | 0x20U);
outb(ATTRX, IOValue2 ^ 0x0FU);
IOValue3 = GetReg(ATTRX, 0x14U | 0x20U);
outb(ATTRX, IOValue2);
outb(ATTRX, IOValue1);
- (void) inb(GENS1(pVGA->CPIO_VGABase));
+ (void)inb(GENS1(pVGA->CPIO_VGABase));
if (IOValue3 == (IOValue2 ^ 0x0FU))
{
/* VGA device detected */
@@ -848,7 +848,7 @@ ATIProbe
return FALSE;
ATIGDevs = (ATIGDevPtr)xnfcalloc(nGDev, SizeOf(ATIGDev));
- memset(fChipsets, FALSE, SizeOf(fChipsets));
+ (void)memset(fChipsets, FALSE, SizeOf(fChipsets));
for (i = 0, pATIGDev = ATIGDevs; i < nGDev; i++)
{
@@ -965,7 +965,7 @@ ATIProbe
PCI_CMD_IO_ENABLE) ? 0 : Allowed);
/* Generate ProbeFlags array from list of registered PCI I/O bases */
- memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags));
+ (void)memset(ProbeFlags, Allowed | DoProbe, SizeOf(ProbeFlags));
for (i = 0; i < nPCIPort; i++)
{
CARD32 Base = PCIPorts[i].Base;
@@ -1089,21 +1089,20 @@ ATIProbe
* this is verbiage to deal with potential situations that are very
* unlikely to occur in practice.
*
- * First, look for non-ATI shareable VGA's. For now, these must have
- * been previously initialised by their BIOS.
+ * First, look for non-ATI shareable VGA's. For now, these must the
+ * primary device.
*/
if (ATICheckSparseIOBases(ProbeFlags, ATTRX, 16, TRUE) == DoProbe)
{
for (i = 0; (pVideo = xf86PciVideoInfo[i++]); )
{
if ((pVideo->vendor == PCI_VENDOR_ATI) ||
- !(((pciConfigPtr)(pVideo->thisCard))->pci_command &
- PCI_CMD_IO_ENABLE) ||
- (pVideo->interface != 0) ||
- (((pVideo->class != PCI_CLASS_PREHISTORIC) ||
- (pVideo->subclass != PCI_SUBCLASS_PREHISTORIC_VGA)) &&
- ((pVideo->class != PCI_CLASS_DISPLAY) ||
- (pVideo->subclass != PCI_SUBCLASS_DISPLAY_VGA))))
+ !xf86IsPrimaryPci(pVideo))
+ continue;
+
+ if (!xf86CheckPciSlot(pVideo->bus,
+ pVideo->device,
+ pVideo->func))
continue;
xf86SetPciVideo(pVideo, IO);
@@ -1169,6 +1168,11 @@ ATIProbe
break;
default: /* Must be DoProbe */
+ if (!xf86CheckPciSlot(pVideo->bus,
+ pVideo->device,
+ pVideo->func))
+ continue;
+
xf86SetPciVideo(pVideo, IO);
if (!(pATI = ATI8514Probe(pVideo)))
@@ -1252,6 +1256,11 @@ ATIProbe
break;
default: /* Must be DoProbe */
+ if (!xf86CheckPciSlot(pVideo->bus,
+ pVideo->device,
+ pVideo->func))
+ continue;
+
xf86SetPciVideo(pVideo, IO);
pATI = ATIMach64Probe(Mach64SparseIOBases[j], SPARSE_IO,
@@ -1298,6 +1307,9 @@ ATIProbe
goto SetPCIInfo;
}
+ if (!xf86CheckPciSlot(pVideo->bus, pVideo->device, pVideo->func))
+ continue;
+
/* Probe for it */
xf86SetPciVideo(pVideo, IO);
@@ -1533,6 +1545,30 @@ NoVGAWonder:;
}
/*
+ * Re-order list of detected devices so that the primary device is before
+ * any other PCI device.
+ */
+ for (i = 0; i < nATIPtr; i++)
+ {
+ if (!ATIPtrs[i]->PCIInfo)
+ continue;
+
+ for (j = i; j < nATIPtr; j++)
+ {
+ pATI = ATIPtrs[j];
+ if (!xf86IsPrimaryPci(pATI->PCIInfo))
+ continue;
+
+ for (; j > i; j--)
+ ATIPtrs[j] = ATIPtrs[j - 1];
+ ATIPtrs[j] = pATI;
+ break;
+ }
+
+ break;
+ }
+
+ /*
* Assign detected devices to XF86Config Device sections. This is done by
* comparing certain Device section specifications against the
* corresponding adapter information. Begin with those specifications that
@@ -1624,9 +1660,35 @@ NoVGAWonder:;
{
if (pATI->Adapter != ATI_ADAPTER_MACH64)
continue;
- if ((pGDev->chipRev >= 0) &&
- (pATI->Chip != ATI_CHIP_Mach64))
- continue;
+
+ if (pATI->Chip != ATI_CHIP_Mach64)
+ {
+ if (pATI->ChipRev == pATI->ChipRevision)
+ continue;
+
+ /*
+ * There are two foundry codes for UMC. Some adapters
+ * will advertise one in CONFIG_CHIP_ID and the other
+ * in PCI configuration space. For matching purposes,
+ * make both codes compare equal.
+ */
+# define UMC_IGNORE (ATI_FOUNDRY_UMC ^ ATI_FOUNDRY_UMCA)
+# define UMC_NOCARE \
+ GetBits(SetBits(UMC_IGNORE, CFG_CHIP_FOUNDRY), \
+ CFG_CHIP_REV)
+
+ if ((pATI->ChipRev ^ pGDev->chipRev) & ~UMC_NOCARE)
+ continue;
+
+ if ((pATI->ChipFoundry != ATI_FOUNDRY_UMC) &&
+ (pATI->ChipFoundry != ATI_FOUNDRY_UMCA))
+ continue;
+
+ k = GetBits(pGDev->chipRev,
+ GetBits(CFG_CHIP_FOUNDRY, CFG_CHIP_REV));
+ if ((k != ATI_FOUNDRY_UMC) && (k != ATI_FOUNDRY_UMCA))
+ continue;
+ }
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h
index c4c0f616b..6b8d93209 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h,v 1.8 2000/02/18 12:19:35 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiregs.h,v 1.10 2000/03/30 15:41:20 tsi Exp $ */
/*
* Copyright 1994 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -46,6 +46,7 @@
#define MM_IO_SELECT 0x03fcu
#define BLOCK_SELECT 0x0400u
+#define DWORD_SELECT (BLOCK_SELECT | MM_IO_SELECT)
#define IO_BYTE_SELECT 0x0003u
@@ -1246,15 +1247,9 @@
#define DST_X BlockIOTag(0x41u)
#define DST_Y BlockIOTag(0x42u)
#define DST_Y_X BlockIOTag(0x43u)
-#define DST_y 0x00007ffful
-#define DST_Y_LSB 0x00008000ul /* GTPro */
-#define DST_x 0x7fff0000ul
-#define DST_Y_SECONDARY_LSB 0x80000000ul /* GTPro */
#define DST_WIDTH BlockIOTag(0x44u)
#define DST_HEIGHT BlockIOTag(0x45u)
#define DST_HEIGHT_WIDTH BlockIOTag(0x46u)
-#define DST_height 0x0000fffful
-#define DST_width 0xffff0000ul
#define DST_X_WIDTH BlockIOTag(0x47u)
#define DST_BRES_LNTH BlockIOTag(0x48u)
#define DST_BRES_ERR BlockIOTag(0x49u)
@@ -1308,31 +1303,15 @@
#define SRC_X BlockIOTag(0x61u)
#define SRC_Y BlockIOTag(0x62u)
#define SRC_Y_X BlockIOTag(0x63u)
-#define SRC_y 0x00007ffful
-/* ? 0x00008000ul */
-#define SRC_x 0x3fff0000ul
-/* ? 0xc0000000ul */
#define SRC_WIDTH1 BlockIOTag(0x64u)
#define SRC_HEIGHT1 BlockIOTag(0x65u)
#define SRC_HEIGHT1_WIDTH1 BlockIOTag(0x66u)
-#define SRC_height1 0x00007ffful
-/* ? 0x00008000ul */
-#define SRC_width1 0x3fff0000ul
-/* ? 0xc0000000ul */
#define SRC_X_START BlockIOTag(0x67u)
#define SRC_Y_START BlockIOTag(0x68u)
#define SRC_Y_X_START BlockIOTag(0x69u)
-#define SRC_y_start 0x00007ffful
-/* ? 0x00008000ul */
-#define SRC_x_start 0x3fff0000ul
-/* ? 0xc0000000ul */
#define SRC_WIDTH2 BlockIOTag(0x6au)
#define SRC_HEIGHT2 BlockIOTag(0x6bu)
#define SRC_HEIGHT2_WIDTH2 BlockIOTag(0x6cu)
-#define SRC_height2 0x00007ffful
-/* ? 0x00008000ul */
-#define SRC_width2 0x3fff0000ul
-/* ? 0xc0000000ul */
#define SRC_CNTL BlockIOTag(0x6du)
#define SRC_PATT_EN 0x00000001ul
#define SRC_PATT_ROT_EN 0x00000002ul
@@ -1426,17 +1405,9 @@
#define SC_LEFT BlockIOTag(0xa8u)
#define SC_RIGHT BlockIOTag(0xa9u)
#define SC_LEFT_RIGHT BlockIOTag(0xaau)
-#define SC_left 0x00003ffful
-/* ? 0x0000c000ul */
-#define SC_right 0x3fff0000ul
-/* ? 0xc0000000ul */
#define SC_TOP BlockIOTag(0xabu)
#define SC_BOTTOM BlockIOTag(0xacu)
#define SC_TOP_BOTTOM BlockIOTag(0xadu)
-#define SC_top 0x00007ffful
-/* ? 0x00008000ul */
-#define SC_bottom 0x7fff0000ul
-/* ? 0x80000000ul */
#define USR1_DST_OFF_PITCH BlockIOTag(0xaeu) /* LTPro */
#define USR2_DST_OFF_PITCH BlockIOTag(0xafu) /* LTPro */
#define DP_BKGD_CLR BlockIOTag(0xb0u)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c
index d6c45130b..85d650d89 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c,v 1.6 2000/02/18 12:19:37 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiscreen.c,v 1.9 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -25,6 +25,7 @@
#include "atiadapter.h"
#include "aticonsole.h"
#include "atidac.h"
+#include "atidga.h"
#include "atiscreen.h"
#include "shadowfb.h"
@@ -73,7 +74,7 @@ ATIRefreshArea
while (h-- > 0)
{
- memcpy(pDst, pSrc, w);
+ (void)memcpy(pDst, pSrc, w);
pSrc = (char *)pSrc + pATI->FBPitch;
pDst = (char *)pDst + pATI->FBPitch;
}
@@ -108,21 +109,20 @@ ATIScreenInit
/* Re-initialise mi's visual list */
miClearVisualTypes();
- if ((pScreenInfo->depth > 8) && (pATI->DAC == ATI_DAC_INTERNAL))
+ if ((pATI->depth > 8) && (pATI->DAC == ATI_DAC_INTERNAL))
VisualMask = TrueColorMask;
else
- VisualMask = miGetDefaultVisualMask(pScreenInfo->depth);
+ VisualMask = miGetDefaultVisualMask(pATI->depth);
- if (!miSetVisualTypes(pScreenInfo->depth, VisualMask,
- pScreenInfo->rgbBits, pScreenInfo->defaultVisual))
+ if (!miSetVisualTypes(pATI->depth, VisualMask, pScreenInfo->rgbBits,
+ pScreenInfo->defaultVisual))
return FALSE;
pFB = pATI->pMemory;
if (pATI->OptionShadowFB)
{
- pATI->FBBytesPerPixel = pScreenInfo->bitsPerPixel >> 3;
- pATI->FBPitch =
- PixmapBytePad(pScreenInfo->displayWidth, pScreenInfo->depth);
+ pATI->FBBytesPerPixel = pATI->bitsPerPixel >> 3;
+ pATI->FBPitch = PixmapBytePad(pATI->displayWidth, pATI->depth);
if ((pATI->pShadow = xalloc(pATI->FBPitch * pScreenInfo->virtualY)))
pFB = pATI->pShadow;
else
@@ -134,48 +134,42 @@ ATIScreenInit
}
/* Initialise framebuffer layer */
- switch (pScreenInfo->bitsPerPixel)
+ switch (pATI->bitsPerPixel)
{
case 1:
pATI->Closeable = xf1bppScreenInit(pScreen, pFB,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->xDpi, pScreenInfo->yDpi,
- pScreenInfo->displayWidth);
+ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth);
break;
case 4:
pATI->Closeable = xf4bppScreenInit(pScreen, pFB,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->xDpi, pScreenInfo->yDpi,
- pScreenInfo->displayWidth);
+ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth);
break;
case 8:
pATI->Closeable = cfbScreenInit(pScreen, pFB,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->xDpi, pScreenInfo->yDpi,
- pScreenInfo->displayWidth);
+ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth);
break;
case 16:
pATI->Closeable = cfb16ScreenInit(pScreen, pFB,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->xDpi, pScreenInfo->yDpi,
- pScreenInfo->displayWidth);
+ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth);
break;
case 24:
pATI->Closeable = cfb24ScreenInit(pScreen, pFB,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->xDpi, pScreenInfo->yDpi,
- pScreenInfo->displayWidth);
+ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth);
break;
case 32:
pATI->Closeable = cfb32ScreenInit(pScreen, pFB,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->xDpi, pScreenInfo->yDpi,
- pScreenInfo->displayWidth);
+ pScreenInfo->xDpi, pScreenInfo->yDpi, pATI->displayWidth);
break;
default:
@@ -186,7 +180,7 @@ ATIScreenInit
return FALSE;
/* Fixup RGB ordering */
- if (pScreenInfo->depth > 8)
+ if (pATI->depth > 8)
{
VisualPtr pVisual = pScreen->visuals + pScreen->numVisuals;
@@ -210,9 +204,12 @@ ATIScreenInit
/* Initialise banking if needed */
if (!miInitializeBanking(pScreen,
pScreenInfo->virtualX, pScreenInfo->virtualY,
- pScreenInfo->displayWidth, &pATI->BankInfo))
+ pATI->displayWidth, &pATI->BankInfo))
return FALSE;
+ /* Initialise DGA support */
+ (void)ATIDGAInit(pScreenInfo, pScreen, pATI);
+
/* Setup acceleration */
if (!ATIAdapterAccelInit(pScreenInfo, pScreen, pATI))
return FALSE;
@@ -228,8 +225,8 @@ ATIScreenInit
if (!miCreateDefColormap(pScreen))
return FALSE;
- if (pScreenInfo->depth > 1)
- if (!xf86HandleColormaps(pScreen, (pScreenInfo->depth == 4) ? 16 : 256,
+ if (pATI->depth > 1)
+ if (!xf86HandleColormaps(pScreen, (pATI->depth == 4) ? 16 : 256,
pScreenInfo->rgbBits, ATILoadPalette, NULL,
CMAP_PALETTED_TRUECOLOR |
CMAP_LOAD_EVEN_IF_OFFSCREEN))
@@ -240,6 +237,9 @@ ATIScreenInit
!ShadowFBInit(pScreen, ATIRefreshArea))
return FALSE;
+ /* Initialise DPMS support */
+ (void)xf86DPMSInit(pScreen, ATISetDPMSMode, 0);
+
/* Set pScreen->SaveScreen and wrap CloseScreen vector */
pScreen->SaveScreen = ATISaveScreen;
pATI->CloseScreen = pScreen->CloseScreen;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h
index 7b6f65860..c75b44baf 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.12 2000/03/03 04:47:13 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atistruct.h,v 1.18 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1999 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -26,8 +26,12 @@
#include "atibank.h"
#include "aticlock.h"
+#include "atiregs.h"
+#include "xf86Resources.h"
#include "xaa.h"
+#define CacheSlotOf(____Register) ((____Register) / UnitOf(DWORD_SELECT))
+
/*
* This is probably as good a place as any to put this note, as it applies to
* the entire driver, but especially here. CARD8's are used rather than the
@@ -58,7 +62,10 @@ typedef struct _ATIHWRec
b0, b1, b2, b3, b5, b6, b8, b9, ba, bd, be, bf;
/* Mach64 PLL registers */
- CARD8 pll_vclk_cntl, pll_ext_vpll_cntl;
+ CARD8 pll_vclk_cntl, pll_vclk_post_div,
+ pll_vclk0_fb_div, pll_vclk1_fb_div,
+ pll_vclk2_fb_div, pll_vclk3_fb_div,
+ pll_xclk_cntl, pll_ext_vpll_cntl;
/* Mach64 CPIO registers */
CARD32 crtc_h_total_disp, crtc_h_sync_strt_wid,
@@ -129,8 +136,8 @@ typedef struct _ATIRec
* Chip-related definitions.
*/
CARD8 Chip, Coprocessor;
- CARD16 ChipType, ChipClass, ChipRevision, ChipRev;
- CARD16 ChipVersion, ChipFoundry;
+ CARD16 ChipType;
+ CARD8 ChipClass, ChipRevision, ChipRev, ChipVersion, ChipFoundry;
CARD8 ChipHasSUBSYS_CNTL;
/*
@@ -164,18 +171,21 @@ typedef struct _ATIRec
CPIO_MEM_VGA_WP_SEL, CPIO_MEM_VGA_RP_SEL,
CPIO_DAC_REGS, CPIO_DAC_CNTL,
CPIO_HORZ_STRETCHING, CPIO_VERT_STRETCHING,
- CPIO_GEN_TEST_CNTL, CPIO_LCD_GEN_CTRL, CPIO_CONFIG_CNTL;
+ CPIO_GEN_TEST_CNTL, CPIO_LCD_GEN_CTRL,
+ CPIO_POWER_MANAGEMENT, CPIO_CONFIG_CNTL;
/*
* DAC-related definitions.
*/
CARD16 DAC;
CARD16 CPIO_DAC_MASK, CPIO_DAC_DATA, CPIO_DAC_READ, CPIO_DAC_WRITE;
+ CARD8 rgbBits;
/*
* Definitions related to system bus interface.
*/
pciVideoPtr PCIInfo;
+ resRange VGAWonderResources[2];
CARD8 BusType;
CARD8 SharedVGA, SharedAccelerator;
@@ -215,8 +225,17 @@ typedef struct _ATIRec
*/
XAAInfoRecPtr pXAAInfo;
int nAvailableFIFOEntries, nFIFOEntries;
- CARD8 EngineIsBusy, EngineIsLocked, PitchModifier;
+ CARD8 EngineIsBusy, EngineIsLocked, XModifier;
CARD32 dst_cntl; /* For SetupFor/Subsequent communication */
+ CARD32 ExpansionBitmapScanline[256];
+ CARD32 *ExpansionBitmapScanlinePtr;
+ int ExpansionBitmapWidth;
+
+ /*
+ * MMIO cache.
+ */
+ CARD32 MMIOCache[CacheSlotOf(DWORD_SELECT) + 1];
+ CARD8 MMIOCached[(CacheSlotOf(DWORD_SELECT) + 8) >> 3];
/*
* Clock-related definitions.
@@ -245,7 +264,22 @@ typedef struct _ATIRec
* Data used by ATIAdjustFrame().
*/
int AdjustDepth, AdjustMaxX, AdjustMaxY;
- unsigned long AdjustMask;
+ unsigned long AdjustMask, AdjustMaxBase;
+
+ /*
+ * DGA and non-DGA common data.
+ */
+ DisplayModePtr currentMode;
+ CARD8 depth, bitsPerPixel;
+ short int displayWidth;
+ int pitchInc;
+ rgb weight;
+
+ /*
+ * Video mode data for DGA.
+ */
+ DGAModePtr pDGAMode;
+ int nDGAMode;
/*
* Data saved by ATIUnlock() and restored by ATILock().
@@ -287,6 +321,7 @@ typedef struct _ATIRec
CARD8 OptionCSync; /* Use composite sync */
CARD8 OptionDevel; /* Intentionally undocumented */
CARD8 OptionLinear; /* Use linear fb aperture when available */
+ CARD8 OptionMMIOCache; /* Cache MMIO writes */
CARD8 OptionProbeClocks; /* Force probe for fixed clocks */
CARD8 OptionShadowFB; /* Use shadow frame buffer */
CARD8 OptionSync; /* Temporary */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c
index b897e90f8..44109758c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c,v 1.9 2000/02/18 12:19:42 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativalid.c,v 1.10 2000/04/12 14:44:40 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -96,8 +96,14 @@ ATIValidMode
(pMode->CrtcVDisplay > pATI->LCDVertical))
return MODE_PANEL;
- if (!pATI->OptionSync)
+ if (!pATI->OptionSync || (pMode->type & M_T_BUILTIN))
+ {
+ if ((pMode->HDisplay > pATI->LCDHorizontal) ||
+ (pMode->VDisplay > pATI->LCDVertical))
+ return MODE_PANEL;
+
return MODE_OK;
+ }
/*
* Adjust effective timings for monitor checks. Here the modeline
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h
index 160924266..d96b5fbd2 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.13 2000/03/07 16:13:37 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativersion.h,v 1.16 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -27,11 +27,11 @@
#define ATI_NAME "ATI"
#define ATI_DRIVER_NAME "ati"
-#define ATI_VERSION_NAME "5.3.2"
+#define ATI_VERSION_NAME "5.3.5"
#define ATI_VERSION_MAJOR 5
#define ATI_VERSION_MINOR 3
-#define ATI_VERSION_PATCH 2
+#define ATI_VERSION_PATCH 5
#define ATI_VERSION_CURRENT \
((ATI_VERSION_MAJOR << 20) | (ATI_VERSION_MINOR << 10) | ATI_VERSION_PATCH)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c
index c1cd6ab8a..ab5c10032 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c,v 1.9 2000/02/18 12:19:43 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.c,v 1.11 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -21,6 +21,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
+#include "ati.h"
#include "atiadapter.h"
#include "atichip.h"
#include "atiio.h"
@@ -28,6 +29,9 @@
#include "ativga.h"
#include "xf86.h"
+#define DPMS_SERVER
+#include "extensions/dpms.h"
+
/*
* ATIVGAPreInit --
*
@@ -37,7 +41,6 @@
void
ATIVGAPreInit
(
- ScrnInfoPtr pScreenInfo,
ATIPtr pATI,
ATIHWPtr pATIHW
)
@@ -46,11 +49,11 @@ ATIVGAPreInit
/* Initialise sequencer register values */
pATIHW->seq[0] = 0x03U;
- if (pScreenInfo->depth == 1)
+ if (pATI->depth == 1)
pATIHW->seq[2] = 0x01U << BIT_PLANE;
else
pATIHW->seq[2] = 0x0FU;
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
pATIHW->seq[4] = 0x06U;
else if (pATI->Adapter == ATI_ADAPTER_VGA)
pATIHW->seq[4] = 0x0EU;
@@ -58,22 +61,22 @@ ATIVGAPreInit
pATIHW->seq[4] = 0x0AU;
/* Initialise CRTC register values */
- if ((pScreenInfo->depth >= 8) &&
+ if ((pATI->depth >= 8) &&
((pATI->Chip >= ATI_CHIP_264CT) ||
(pATI->CPIO_VGAWonder &&
(pATI->Chip <= ATI_CHIP_18800_1) &&
(pATI->VideoRAM == 256))))
- pATIHW->crt[19] = pScreenInfo->displayWidth >> 3;
+ pATIHW->crt[19] = pATI->displayWidth >> 3;
else
- pATIHW->crt[19] = pScreenInfo->displayWidth >> 4;
- if ((pScreenInfo->depth >= 8) && (pATI->Adapter == ATI_ADAPTER_VGA))
+ pATIHW->crt[19] = pATI->displayWidth >> 4;
+ if ((pATI->depth >= 8) && (pATI->Adapter == ATI_ADAPTER_VGA))
pATIHW->crt[23] = 0xC3U;
else
pATIHW->crt[23] = 0xE3U;
pATIHW->crt[24] = 0xFFU;
/* Initialise attribute controller register values */
- if (pScreenInfo->depth == 1)
+ if (pATI->depth == 1)
{
Bool FlipPixels = xf86GetFlipPixels();
@@ -89,7 +92,7 @@ ATIVGAPreInit
{
for (Index = 0; Index < 16; Index++)
pATIHW->attr[Index] = Index;
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
pATIHW->attr[16] = 0x81U;
else if (pATI->Adapter == ATI_ADAPTER_VGA)
pATIHW->attr[16] = 0x41U;
@@ -100,9 +103,9 @@ ATIVGAPreInit
pATIHW->attr[18] = 0x0FU;
/* Initialise graphics controller register values */
- if (pScreenInfo->depth == 1)
+ if (pATI->depth == 1)
pATIHW->gra[4] = BIT_PLANE;
- else if (pScreenInfo->depth <= 4)
+ else if (pATI->depth <= 4)
pATIHW->gra[5] = 0x02U;
else if (pATI->Chip >= ATI_CHIP_264CT)
pATIHW->gra[5] = 0x40U;
@@ -444,3 +447,52 @@ ATIVGASaveScreen
break;
}
}
+
+/*
+ * ATIVGASetDPMSMode --
+ *
+ * This function sets a VGA's VESA Display Power Management Signaling mode.
+ */
+void
+ATIVGASetDPMSMode
+(
+ ATIPtr pATI,
+ int DPMSMode
+)
+{
+ CARD8 seq1, crt17;
+
+ switch (DPMSMode)
+ {
+ case DPMSModeOn: /* HSync on, VSync on */
+ seq1 = 0x00U;
+ crt17 = 0x80U;
+ break;
+
+ case DPMSModeStandby: /* HSync off, VSync on -- unsupported */
+ seq1 = 0x20U;
+ crt17 = 0x80U;
+ break;
+
+ case DPMSModeSuspend: /* HSync on, VSync off -- unsupported */
+ seq1 = 0x20U;
+ crt17 = 0x80U;
+ break;
+
+ case DPMSModeOff: /* HSync off, VSync off */
+ seq1 = 0x20U;
+ crt17 = 0x00U;
+ break;
+
+ default: /* Muffle compiler */
+ return;
+ }
+
+ PutReg(SEQX, 0x00U, 0x01U); /* Start synchonous reset */
+ seq1 |= GetReg(SEQX, 0x01U) & ~0x20U;
+ PutReg(SEQX, 0x01U, seq1);
+ crt17 |= GetReg(CRTX(pATI->CPIO_VGABase), 0x17U) & ~0x80U;
+ usleep(10000);
+ PutReg(CRTX(pATI->CPIO_VGABase), 0x17U, crt17);
+ PutReg(SEQX, 0x01U, 0x03U); /* End synchonous reset */
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h
index 24edc4ec3..bda485384 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h,v 1.4 2000/02/18 12:19:44 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/ativga.h,v 1.6 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -28,13 +28,13 @@
#include "atiproto.h"
#include "xf86str.h"
-extern void ATIVGAPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr,
- ATIHWPtr));
-extern void ATIVGASave FunctionPrototype((ATIPtr, ATIHWPtr));
-extern void ATIVGACalculate FunctionPrototype((ATIPtr, ATIHWPtr,
- DisplayModePtr));
-extern void ATIVGASet FunctionPrototype((ATIPtr, ATIHWPtr));
+extern void ATIVGAPreInit FunctionPrototype((ATIPtr, ATIHWPtr));
+extern void ATIVGASave FunctionPrototype((ATIPtr, ATIHWPtr));
+extern void ATIVGACalculate FunctionPrototype((ATIPtr, ATIHWPtr,
+ DisplayModePtr));
+extern void ATIVGASet FunctionPrototype((ATIPtr, ATIHWPtr));
-extern void ATIVGASaveScreen FunctionPrototype((ATIPtr, int));
+extern void ATIVGASaveScreen FunctionPrototype((ATIPtr, int));
+extern void ATIVGASetDPMSMode FunctionPrototype((ATIPtr, int));
#endif /* ___ATIVGA_H___ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c
index 899916988..ad55dc846 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c,v 1.7 2000/02/18 12:19:45 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.c,v 1.8 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -63,13 +63,12 @@
void
ATIVGAWonderPreInit
(
- ScrnInfoPtr pScreenInfo,
ATIPtr pATI,
ATIHWPtr pATIHW
)
{
pATIHW->b3 = ATIGetExtReg(0xB3U) & 0x20U;
- if (pScreenInfo->depth <= 4)
+ if (pATI->depth <= 4)
pATIHW->b6 = 0x40U;
else
pATIHW->b6 = 0x04U;
@@ -135,7 +134,6 @@ ATIVGAWonderSave
void
ATIVGAWonderCalculate
(
- ScrnInfoPtr pScreenInfo,
ATIPtr pATI,
ATIHWPtr pATIHW,
DisplayModePtr pMode
@@ -162,7 +160,7 @@ ATIVGAWonderCalculate
* Fill in mode-specific VGA Wonder data.
*/
pATIHW->b0 = 0x00U;
- if (pScreenInfo->depth >= 8)
+ if (pATI->depth >= 8)
pATIHW->b0 = 0x20U;
if (pATI->Chip >= ATI_CHIP_28800_2)
{
@@ -171,7 +169,7 @@ ATIVGAWonderCalculate
else if (pATI->VideoRAM > 256)
pATIHW->b0 |= 0x10U;
}
- else if (pScreenInfo->depth <= 4)
+ else if (pATI->depth <= 4)
{
if (pATI->VideoRAM > 256)
pATIHW->b0 |= 0x08U;
@@ -191,7 +189,7 @@ ATIVGAWonderCalculate
* adapter can then only be re-enabled with a powerdown. The bit, when on,
* blanks out the overscan.
*/
- if ((pATI->Chip == ATI_CHIP_18800_1) && (pScreenInfo->depth >= 8))
+ if ((pATI->Chip == ATI_CHIP_18800_1) && (pATI->depth >= 8))
pATIHW->b5 = 0x00U;
else
pATIHW->b5 = 0x01U;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h
index ede3cdc43..dcf390c04 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h,v 1.4 2000/02/18 12:19:46 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/atiwonder.h,v 1.5 2000/06/19 15:00:59 tsi Exp $ */
/*
* Copyright 1997 through 2000 by Marc Aurele La France (TSI @ UQV), tsi@ualberta.ca
*
@@ -28,11 +28,9 @@
#include "atiproto.h"
#include "xf86str.h"
-extern void ATIVGAWonderPreInit FunctionPrototype((ScrnInfoPtr, ATIPtr,
- ATIHWPtr));
+extern void ATIVGAWonderPreInit FunctionPrototype((ATIPtr, ATIHWPtr));
extern void ATIVGAWonderSave FunctionPrototype((ATIPtr, ATIHWPtr));
-extern void ATIVGAWonderCalculate FunctionPrototype((ScrnInfoPtr, ATIPtr,
- ATIHWPtr,
+extern void ATIVGAWonderCalculate FunctionPrototype((ATIPtr, ATIHWPtr,
DisplayModePtr));
extern void ATIVGAWonderSet FunctionPrototype((ATIPtr, ATIHWPtr));
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile
index 40626361d..ee375e0ae 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile
@@ -4,23 +4,23 @@ XCOMM $XConsortium: Imakefile /main/13 1996/10/27 11:49:09 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile,v 1.22 2000/02/08 13:13:10 eich Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/Imakefile,v 1.24 2000/04/04 19:25:05 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
SRCS = ct_driver.c ct_bank.c ct_accel.c ct_accelmm.c ct_accelhi.c ct_cursor.c\
- ct_ddc.c ct_regs.c ct_dga.c ct_shadow.c
+ ct_ddc.c ct_regs.c ct_dga.c ct_shadow.c ct_video.c
OBJS = ct_driver.o ct_bank.o ct_accel.o ct_accelmm.o ct_accelhi.o ct_cursor.o\
- ct_ddc.o ct_regs.o ct_dga.o ct_shadow.o
+ ct_ddc.o ct_regs.o ct_dga.o ct_shadow.o ct_video.o
DEFINES = -DPSZ=8
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
#else
-INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86SRC)/fbdevhw\
-I$(XF86SRC)/vgafb -I$(XF86SRC)/vgahw -I$(SERVERSRC)/include \
-I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \
-I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/Xext \
@@ -28,7 +28,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(XF86SRC)/ramdac -I$(XF86SRC)/rac -I$(XF86SRC)/ddc \
-I$(XF86SRC)/i2c -I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/shadowfb \
-I$(XF86SRC)/xf8_16bpp -I$(XF86SRC)/int10 \
- -I$(XF86OSSRC)/vbe
+ -I$(XF86OSSRC)/vbe -I$(EXTINCSRC)
#endif
#if MakeHasPosixVariableSubstitutions
@@ -65,5 +65,8 @@ InstallDriverSDKNonExecFile(ct_dga.c,$(DRIVERSDKDIR)/drivers/chips)
InstallDriverSDKNonExecFile(ct_driver.c,$(DRIVERSDKDIR)/drivers/chips)
InstallDriverSDKNonExecFile(ct_driver.h,$(DRIVERSDKDIR)/drivers/chips)
InstallDriverSDKNonExecFile(ct_regs.c,$(DRIVERSDKDIR)/drivers/chips)
+InstallDriverSDKNonExecFile(ct_shadow.c,$(DRIVERSDKDIR)/drivers/chips)
+InstallDriverSDKNonExecFile(ct_video.c,$(DRIVERSDKDIR)/drivers/chips)
InstallDriverSDKObjectModule(chips,$(DRIVERSDKMODULEDIR),drivers)
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp b/xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp
index 3c9842327..142a546e8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp,v 1.3 2000/03/03 01:05:34 dawes Exp $
-.TH CHIPS __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/chips.cpp,v 1.7 2000/06/14 02:13:08 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH CHIPS __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
chips \- Chips and Technologies video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""chips"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qchips\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B chips
is an XFree86 driver for Chips and Technologies video processors. The majority
@@ -84,7 +84,7 @@ driver.
The driver auto-detects the chipset type, but the following
.B ChipSet
names may optionally be specified in the config file
-.B """Device"""
+.B \*qDevice\*q
section, and will override the auto-detection:
.PP
.RS 4
@@ -97,97 +97,101 @@ The driver will auto-detect the amount of video memory present for all
chipsets. But maybe overridden with the
.B VideoRam
entry in the config file
-.B """Device"""
+.B \*qDevice\*q
section.
.PP
The following driver
.B Options
are supported, on one or more of the supported chipsets:
.TP
-.BI "Option ""NoAccel"" """ boolean """
+.BI "Option \*qNoAccel\*q \*q" boolean \*q
Disable or enable acceleration. Default: acceleration is enabled.
.TP
-.BI "Option ""NoLinear"" """ boolean """
+.BI "Option \*qNoLinear\*q \*q" boolean \*q
Disables linear addressing in cases where it is enabled by default.
Default: off
.TP
-.BI "Option ""Linear"" """ boolean """
+.BI "Option \*qLinear\*q \*q" boolean \*q
Enables linear addressing in cases where it isdisabled by default.
Default: off
.TP
-.BI "Option ""HWCursor"" """ boolean """
+.BI "Option \*qHWCursor\*q \*q" boolean \*q
Enable or disable the HW cursor. Default: on.
.TP
-.BI "Option ""SWCursor"" """ boolean """
+.BI "Option \*qSWCursor\*q \*q" boolean \*q
Enable or disable the HW cursor. Default: off.
.TP
-.BI "Option ""STN"" """ boolean """
+.BI "Option \*qSTN\*q \*q" boolean \*q
Force detection of STN screen type. Default: off.
.TP
-.BI "Option ""UseModeline"" """ boolean """
+.BI "Option \*qUseModeline\*q \*q" boolean \*q
Reprogram flat panel timings with values from the modeline. Default: off
.TP
-.BI "Option ""FixPanelSize"" """ boolean """
+.BI "Option \*qFixPanelSize\*q \*q" boolean \*q
Reprogram flat panel size with values from the modeline. Default: off
.TP
-.BI "Option ""NoStretch"" """ boolean """
+.BI "Option \*qNoStretch\*q \*q" boolean \*q
This option disables the stretching on a mode on a flat panel to fill the
screen. Default: off
.TP
-.BI "Option ""LcdCenter"" """ boolean """
+.BI "Option \*qLcdCenter\*q \*q" boolean \*q
Center the mode displayed on the flat panel on the screen. Default: off
.TP
-.BI "Option ""HWclocks"" """ boolean """
+.BI "Option \*qHWclocks\*q \*q" boolean \*q
Force the use of fixed hardware clocks on chips that support both fixed
and programmable clocks. Default: off
.TP
-.BI "Option ""UseVclk1"" """ boolean """
+.BI "Option \*qUseVclk1\*q \*q" boolean \*q
Use the Vclk1 programable clock on
.B HiQV
chipsets instead of Vclk2. Default: off
.TP
-.BI "Option ""FPClock8"" """ float """
+.BI "Option \*qFPClock8\*q \*q" float \*q
.TP
-.BI "Option ""FPClock16"" """ float """
+.BI "Option \*qFPClock16\*q \*q" float \*q
.TP
-.BI "Option ""FPClock24"" """ float """
+.BI "Option \*qFPClock24\*q \*q" float \*q
.TP
-.BI "Option ""FPClock32"" """ float """
+.BI "Option \*qFPClock32\*q \*q" float \*q
Force the use of a particular video clock speed for use with the
flat panel at a specified depth
.TP
-.BI "Option ""MMIO"" """ boolean """
+.BI "Option \*qMMIO\*q \*q" boolean \*q
Force the use of memory mapped IO where it can be used. Default: off
.TP
-.BI "Option ""SuspendHack"" """ boolean """
+.BI "Option \*qSuspendHack\*q \*q" boolean \*q
Force driver to leave centering and stretching resgisters alone. This
can fix some laptop suspend/resume problems. Default: off
.TP
-.BI "Option ""Overlay""
+.BI "Option \*qOverlay\*q"
Enable 8+24 overlay mode. Only appropriate for depth 24. Default: off.
.TP
-.BI "Option ""ColorKey"" """ integer """
+.BI "Option \*qColorKey\*q \*q" integer \*q
Set the colormap index used for the transparency key for the depth 8 plane
when operating in 8+16 overlay mode. The value must be in the range
2\-255. Default: 255.
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qVideoKey\*q \*q" integer \*q
+This sets the default pixel value for the YUV video overlay key.
+Default: undefined.
+.TP
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
Enable or disable use of the shadow framebuffer layer. See
shadowfb(__drivermansuffix__) for further information. Default: off.
.TP
-.BI "Option ""SyncOnGreen"" """ boolean """
+.BI "Option \*qSyncOnGreen\*q \*q" boolean \*q
Enable or disable combining the sync signals with the green signal.
Default: off.
.TP
-.BI "Option ""ShowCache"" """ boolean """
+.BI "Option \*qShowCache\*q \*q" boolean \*q
Enable or disable viewing offscreen memory. Used for debugging only
Default: off.
.TP
-.BI "Option ""18bitBus"" """ boolean """
+.BI "Option \*q18bitBus\*q \*q" boolean \*q
Force the driver to assume that the flat panel has an 18bit data bus.
Default: off.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.PP
You are also recommended to read the README.chips file that comes with all
XFree86 distributions, which discusses the
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c
index 5b31a258a..9185faf76 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c,v 1.4 1998/12/20 11:57:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_bank.c,v 1.5 2000/04/04 19:25:05 dawes Exp $ */
/*
* Copyright 1997
@@ -36,14 +36,14 @@
*/
/* #define DIRECT_REGISTER_ACCESS */
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c
index d9a8337a2..048563e68 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c,v 1.19 2000/02/08 13:13:10 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_cursor.c,v 1.20 2000/04/04 19:25:06 dawes Exp $ */
/*
* Copyright 1994 The XFree86 Project
@@ -26,14 +26,14 @@
* Modified for Chips and Technologies by David Bateman <dbateman@eng.uts.edu.au>
*/
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c
index cecc5c13e..c32a3695e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c
@@ -1,13 +1,13 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c,v 1.6 1999/12/03 19:17:27 eich Exp $ */
-
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_ddc.c,v 1.7 2000/04/04 19:25:06 dawes Exp $ */
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c
index bf123fa87..03af630e3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.84 2000/03/06 23:54:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.c,v 1.91 2000/06/21 17:28:04 dawes Exp $ */
/*
* Copyright 1993 by Jon Block <block@frc.com>
@@ -70,14 +70,14 @@
* advised of the possibility of such damage.
*/
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
@@ -553,6 +553,7 @@ typedef enum {
OPTION_SHADOW_FB,
OPTION_OVERLAY,
OPTION_COLOR_KEY,
+ OPTION_VIDEO_KEY,
OPTION_FP_CLOCK_8,
OPTION_FP_CLOCK_16,
OPTION_FP_CLOCK_24,
@@ -622,6 +623,7 @@ static OptionInfoRec ChipsHiQVOptions[] = {
{ OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE },
{ OPTION_OVERLAY, "Overlay", OPTV_ANYSTR, {0}, FALSE },
{ OPTION_COLOR_KEY, "ColorKey", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE },
{ OPTION_FP_CLOCK_8, "FPClock8", OPTV_FREQ, {0}, FALSE },
{ OPTION_FP_CLOCK_16, "FPClock16", OPTV_FREQ, {0}, FALSE },
{ OPTION_FP_CLOCK_24, "FPClock24", OPTV_FREQ, {0}, FALSE },
@@ -846,7 +848,42 @@ CHIPSProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
/* Allocate a ScrnInfoRec */
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
+ CHIPSPCIchipsets,NULL,
+ NULL,NULL,NULL,NULL))){
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = CHIPS_DRIVER_NAME;
+ pScrn->name = CHIPS_NAME;
+ pScrn->Probe = CHIPSProbe;
+ pScrn->PreInit = CHIPSPreInit;
+ pScrn->ScreenInit = CHIPSScreenInit;
+ pScrn->SwitchMode = CHIPSSwitchMode;
+ pScrn->AdjustFrame = CHIPSAdjustFrame;
+ pScrn->EnterVT = CHIPSEnterVT;
+ pScrn->LeaveVT = CHIPSLeaveVT;
+ pScrn->FreeScreen = CHIPSFreeScreen;
+ pScrn->ValidMode = CHIPSValidMode;
+ foundScreen = TRUE;
+ }
+ }
+ xfree(usedChips);
+ }
+ }
+
+ /* Isa Bus */
+ numUsed = xf86MatchIsaInstances(CHIPS_NAME,CHIPSChipsets,CHIPSISAchipsets,
+ drv,chipsFindIsaDevice,devSections,
+ numDevSections,&usedChips);
+ if (numUsed > 0) {
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn,0,
+ usedChips[i],
+ CHIPSISAchipsets,NULL,
+ NULL,NULL,NULL,NULL))) {
pScrn->driverVersion = VERSION;
pScrn->driverName = CHIPS_DRIVER_NAME;
pScrn->name = CHIPS_NAME;
@@ -860,41 +897,11 @@ CHIPSProbe(DriverPtr drv, int flags)
pScrn->FreeScreen = CHIPSFreeScreen;
pScrn->ValidMode = CHIPSValidMode;
foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn,usedChips[i],CHIPSPCIchipsets,
- NULL,NULL,NULL,NULL,NULL);
}
xfree(usedChips);
}
}
- /* Isa Bus */
- numUsed = xf86MatchIsaInstances(CHIPS_NAME,CHIPSChipsets,CHIPSISAchipsets,
- drv,chipsFindIsaDevice,devSections,
- numDevSections,&usedChips);
- if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = CHIPS_DRIVER_NAME;
- pScrn->name = CHIPS_NAME;
- pScrn->Probe = CHIPSProbe;
- pScrn->PreInit = CHIPSPreInit;
- pScrn->ScreenInit = CHIPSScreenInit;
- pScrn->SwitchMode = CHIPSSwitchMode;
- pScrn->AdjustFrame = CHIPSAdjustFrame;
- pScrn->EnterVT = CHIPSEnterVT;
- pScrn->LeaveVT = CHIPSLeaveVT;
- pScrn->FreeScreen = CHIPSFreeScreen;
- pScrn->ValidMode = CHIPSValidMode;
- foundScreen = TRUE;
- xf86ConfigActiveIsaEntity(pScrn,usedChips[i],CHIPSISAchipsets,
- NULL,NULL,NULL,NULL,NULL);
- }
- xfree(usedChips);
- }
xfree(devSections);
return foundScreen;
}
@@ -1046,8 +1053,8 @@ CHIPSPreInit(ScrnInfoPtr pScrn, int flags)
#endif
}
#endif
+
if (xf86LoadSubModule(pScrn, "vbe")) {
-
cPtr->pVbe = VBEInit(NULL,cPtr->pEnt->index);
}
@@ -1066,6 +1073,7 @@ CHIPSPreInit(ScrnInfoPtr pScrn, int flags)
case CHIPS_CT65554:
case CHIPS_CT65550:
cPtr->Flags |= ChipsGammaSupport;
+ cPtr->Flags |= ChipsVideoSupport;
/* Fall through */
case CHIPS_CT65548:
case CHIPS_CT65546:
@@ -1109,7 +1117,7 @@ CHIPSPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->ClockMulFactor = cPtr->ClockMulFactor;
clockRanges->minClock = cPtr->MinClock;
@@ -1562,6 +1570,19 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
}
}
+ if (!(cPtr->Flags & ChipsOverlay8plus16)) {
+ if(xf86GetOptValInteger(cPtr->Options, OPTION_VIDEO_KEY,
+ &(cPtr->videoKey))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "video key set to 0x%x\n",
+ cPtr->videoKey);
+ } else {
+ cPtr->videoKey = (1 << pScrn->offset.red) |
+ (1 << pScrn->offset.green) |
+ (((pScrn->mask.blue >> pScrn->offset.blue) - 1)
+ << pScrn->offset.blue);
+ }
+ }
+
if (cPtr->Flags & ChipsShadowFB) {
if (cPtr->Flags & ChipsAccelSupport) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
@@ -1676,9 +1697,6 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
cPtr->IOBase = (unsigned int)(cPtr->SuspendHack.vgaIOBaseFlag ?
0x3D0 : 0x3B0);
- /* monitor info */
- cPtr->Monitor = chipsSetMonitor(pScrn);
-
/*test STN / TFT */
tmp = cPtr->readFR(cPtr, 0x10);
@@ -1712,9 +1730,11 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "LCD/CRT\n");
else if (cPtr->PanelType & ChipsLCD)
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "LCD\n");
- else if (cPtr->PanelType & ChipsCRT)
+ else if (cPtr->PanelType & ChipsCRT) {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRT\n");
-
+ /* monitor info */
+ cPtr->Monitor = chipsSetMonitor(pScrn);
+ }
/* screen size */
/*
@@ -1938,7 +1958,7 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
}
} else
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "Memory clock of %7.3f MHz exceeds limit of %7.3 MHz\n",
+ "Memory clock of %7.3f MHz exceeds limit of %7.3f MHz\n",
(float)(mclk/1000.),
(float)(MemClk->Max/1000.));
} else
@@ -2017,11 +2037,11 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
}
if (speed == 0)
- cPtr->MaxClock = cPtr->pEnt->device->dacSpeeds[0];
+ speed = cPtr->pEnt->device->dacSpeeds[0];
from = X_CONFIG;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
"User max pixel clock of %7.3f MHz overrides %7.3f MHz limit\n",
- (float)(cPtr->MaxClock / 1000.), (float)(speed / 1000.));
+ (float)(speed / 1000.), (float)(cPtr->MaxClock / 1000.));
cPtr->MaxClock = speed;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
@@ -2082,9 +2102,10 @@ chipsPreInitHiQV(ScrnInfoPtr pScrn, int flags)
#ifdef XFree86LOADER
if (cPtr->pVbe) {
- if ((pMon = xf86PrintEDID(vbeDoEDID(cPtr->pVbe))) != NULL)
+ if ((pMon = xf86PrintEDID(vbeDoEDID(cPtr->pVbe, NULL))) != NULL) {
ddc_done = TRUE;
- xf86SetDDCproperties(pScrn,pMon);
+ xf86SetDDCproperties(pScrn,pMon);
+ }
}
#endif
@@ -2396,12 +2417,12 @@ chipsPreInitWingine(ScrnInfoPtr pScrn, int flags)
}
}
- /* monitor info */
- cPtr->Monitor = chipsSetMonitor(pScrn);
-
cPtr->PanelType |= ChipsCRT;
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRT\n");
+ /* monitor info */
+ cPtr->Monitor = chipsSetMonitor(pScrn);
+
/* bus type */
tmp = cPtr->readXR(cPtr, 0x01) & 3;
switch (tmp) {
@@ -2576,7 +2597,7 @@ chipsPreInitWingine(ScrnInfoPtr pScrn, int flags)
if (xf86LoadSubModule(pScrn, "ddc")) {
xf86LoaderReqSymLists(ddcSymbols, NULL);
if (cPtr->pVbe)
- xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(cPtr->pVbe)));
+ xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(cPtr->pVbe, NULL)));
}
#endif
return TRUE;
@@ -2898,9 +2919,6 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags)
}
}
- /* monitor info */
- cPtr->Monitor = chipsSetMonitor(pScrn);
-
/*test STN / TFT */
tmp = cPtr->readXR(cPtr, 0x51);
@@ -2934,9 +2952,11 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "LCD/CRT\n");
else if (cPtr->PanelType & ChipsLCD)
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "LCD\n");
- else if (cPtr->PanelType & ChipsCRT)
+ else if (cPtr->PanelType & ChipsCRT) {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "CRT\n");
-
+ /* monitor info */
+ cPtr->Monitor = chipsSetMonitor(pScrn);
+ }
/* screen size */
/*
@@ -3334,7 +3354,7 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags)
} else {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"Memory clock of %7.3f MHz exceeds limit of "
- "%7.3 MHz\n",(float)(mclk/1000.),
+ "%7.3f MHz\n",(float)(mclk/1000.),
(float)(cPtr->MemClock.Max/1000.));
cPtr->MemClock.Clk = cPtr->MemClock.Max * 0.9;
}
@@ -3349,7 +3369,7 @@ chipsPreInit655xx(ScrnInfoPtr pScrn, int flags)
if (xf86LoadSubModule(pScrn, "ddc")) {
xf86LoaderReqSymLists(ddcSymbols, NULL);
if (cPtr->pVbe)
- xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(cPtr->pVbe)));
+ xf86SetDDCproperties(pScrn,xf86PrintEDID(vbeDoEDID(cPtr->pVbe, NULL)));
}
#endif
return TRUE;
@@ -3742,9 +3762,6 @@ CHIPSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
miInitializeBackingStore(pScreen);
xf86SetBackingStore(pScreen);
-#ifdef ENABLE_SILKEN_MOUSE
- xf86SetSilkenMouse(pScreen);
-#endif
/* Initialise cursor functions */
miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
@@ -3933,6 +3950,14 @@ CHIPSScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
racflag |= (RAC_FB | RAC_VIEWPORT);
/* XXX Check if I/O and Mem flags need to be the same. */
pScrn->racIoFlags = pScrn->racMemFlags = racflag;
+#ifdef ENABLE_SILKEN_MOUSE
+ xf86SetSilkenMouse(pScreen);
+#endif
+
+ if ((!(cPtr->Flags & ChipsOverlay8plus16)) &&
+ (cPtr->Flags & ChipsVideoSupport)) {
+ CHIPSInitVideo(pScreen);
+ }
pScreen->SaveScreen = CHIPSSaveScreen;
@@ -4795,7 +4820,6 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
CHIPSRegPtr ChipsNew;
vgaRegPtr ChipsStd;
unsigned int tmp;
- int OverlaySkewX, OverlaySkewY;
ChipsNew = &cPtr->ModeReg;
ChipsStd = &hwp->ModeReg;
@@ -4824,18 +4848,18 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
/* get C&T Specific Registers */
for (i = 0; i < 0xFF; i++) {
- ChipsNew->XR[i] = cPtr->readXR(cPtr, i);
+ /* Save SAR04 multimedia register correctly */
+ if (i == 0x4F) {
+ cPtr->writeXR(cPtr, 0x4E, 0x04);
+ ChipsNew->XR[i] = cPtr->readXR(cPtr, i);
+ } else
+ ChipsNew->XR[i] = cPtr->readXR(cPtr, i);
}
for (i = 0; i < 0x80; i++) {
ChipsNew->FR[i] = cPtr->readFR(cPtr, i);
}
for (i = 0; i < 0x80; i++) {
- /* Save SAR04 multimedia register correctly */
- if (i == 0x4F) {
- cPtr->writeXR(cPtr, 0x4E, 0x04);
- ChipsNew->MR[i] = cPtr->readMR(cPtr, i);
- } else
- ChipsNew->MR[i] = cPtr->readMR(cPtr, i);
+ ChipsNew->MR[i] = cPtr->readMR(cPtr, i);
}
for (i = 0x30; i < 0x80; i++) { /* These are the CT extended CRT regs */
ChipsNew->CR[i] = hwp->readCrtc(hwp, i);
@@ -5117,7 +5141,46 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
ChipsNew->FR[0x12] |= 0x4; /* rid of line in DSTN screens */
}
- /* Setup the overlay */
+ /*
+ * The zero position of the overlay does not align with the zero
+ * position of the display. The skew is dependent on the depth,
+ * display type and refresh rate. Calculate the skew before setting
+ * the X and Y dimensions of the overlay. These values are needed
+ * both by the overlay and XvImages. So calculate and store them
+ */
+ if (cPtr->PanelType & ChipsLCD) {
+ cPtr->OverlaySkewX = (((ChipsNew->FR[0x23] & 0xFF)
+ - (ChipsNew->FR[0x20] & 0xFF) + 3) << 3)
+ - 1;
+ cPtr->OverlaySkewY = (ChipsNew->FR[0x33]
+ + ((ChipsNew->FR[0x36] & 0xF) << 8)
+ - (ChipsNew->FR[0x31] & 0xF0)
+ - (ChipsNew->FR[0x32] & 0x0F)
+ - ((ChipsNew->FR[0x35] & 0xF0) << 4));
+ if (cPtr->PanelSize.HDisplay > mode->CrtcHDisplay)
+ cPtr->OverlaySkewX += (cPtr->PanelSize.HDisplay -
+ mode->CrtcHDisplay) / 2;
+ if (cPtr->PanelSize.VDisplay > mode->CrtcVDisplay)
+ cPtr->OverlaySkewY += (cPtr->PanelSize.VDisplay -
+ mode->CrtcVDisplay) / 2;
+ } else {
+ cPtr->OverlaySkewX = mode->CrtcHTotal - mode->CrtcHBlankStart - 1;
+ cPtr->OverlaySkewY = mode->CrtcVTotal - mode->CrtcVSyncEnd;
+
+ if (mode->Flags & V_INTERLACE) {
+ /*
+ * This handles 1024 and 1280 interlaced modes only. Its
+ * pretty arbitrary, but its what C&T recommends
+ */
+ if (mode->CrtcHDisplay == 1024)
+ cPtr->OverlaySkewY += 5;
+ if (mode->CrtcHDisplay == 1280)
+ cPtr->OverlaySkewY *= 2;
+
+ }
+ }
+
+ /* Setup the video/overlay */
if (cPtr->Flags & ChipsOverlay8plus16) {
ChipsNew->XR[0xD0] |= 0x10; /* Force the Multimedia engine on */
ChipsNew->XR[0x4F] = 0x2A; /* SAR04 >352 pixel overlay width */
@@ -5140,58 +5203,23 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
ChipsNew->MR[0x28] = (pScrn->displayWidth >> 2) - 1; /* Width */
ChipsNew->MR[0x34] = (pScrn->displayWidth >> 2) - 1;
- /*
- * The zero position of the overlay does not align with the zero
- * position of the display. The skew is dependent on the depth,
- * display type and refresh rate. Calculate the skew before setting
- * the X and Y dimensions of the overlay
- */
- if (cPtr->PanelType & ChipsLCD) {
- OverlaySkewX = (((ChipsNew->FR[0x23] & 0xFF)
- - (ChipsNew->FR[0x20] & 0xFF) + 3) << 3)
- - 1;
- OverlaySkewY = (ChipsNew->FR[0x33]
- + ((ChipsNew->FR[0x36] & 0xF) << 8)
- - (ChipsNew->FR[0x31] & 0xF0)
- - (ChipsNew->FR[0x32] & 0x0F)
- - ((ChipsNew->FR[0x35] & 0xF0) << 4));
- if (cPtr->PanelSize.HDisplay > mode->CrtcHDisplay)
- OverlaySkewX += (cPtr->PanelSize.HDisplay - mode->CrtcHDisplay)
- / 2;
- if (cPtr->PanelSize.VDisplay > mode->CrtcVDisplay)
- OverlaySkewY += (cPtr->PanelSize.VDisplay - mode->CrtcVDisplay)
- / 2;
- } else {
- OverlaySkewX = mode->CrtcHTotal - mode->CrtcHBlankStart - 1;
- OverlaySkewY = mode->CrtcVTotal - mode->CrtcVSyncEnd;
-
- if (mode->Flags & V_INTERLACE) {
- /*
- * This handles 1024 and 1280 interlaced modes only. Its
- * pretty arbitrary, but its what C&T recommends
- */
- if (mode->CrtcHDisplay == 1024)
- OverlaySkewY += 5;
- if (mode->CrtcHDisplay == 1280)
- OverlaySkewY *= 2;
-
- }
- }
-
/* Left Edge of Overlay */
- ChipsNew->MR[0x2A] = OverlaySkewX;
+ ChipsNew->MR[0x2A] = cPtr->OverlaySkewX;
ChipsNew->MR[0x2B] &= 0xF8;
/* Right Edge of Overlay */
- ChipsNew->MR[0x2C] = (OverlaySkewX + pScrn->displayWidth - 1) & 0xFF;
+ ChipsNew->MR[0x2C] = (cPtr->OverlaySkewX + pScrn->displayWidth -
+ 1) & 0xFF;
ChipsNew->MR[0x2D] &= 0xF8; /* Mask reserved bits */
- ChipsNew->MR[0x2D] = ((OverlaySkewX + pScrn->displayWidth - 1) >> 8) & 0x07;
+ ChipsNew->MR[0x2D] = ((cPtr->OverlaySkewX + pScrn->displayWidth -
+ 1) >> 8) & 0x07;
/* Top Edge of Overlay */
- ChipsNew->MR[0x2E] = OverlaySkewY;
+ ChipsNew->MR[0x2E] = cPtr->OverlaySkewY;
ChipsNew->MR[0x2F] &= 0xF8;
/* Bottom Edge of Overlay*/
- ChipsNew->MR[0x30] = (OverlaySkewY + pScrn->virtualY - 1 )& 0xFF;
+ ChipsNew->MR[0x30] = (cPtr->OverlaySkewY + pScrn->virtualY - 1 )& 0xFF;
ChipsNew->MR[0x31] &= 0xF8; /* Mask reserved bits */
- ChipsNew->MR[0x31] = ((OverlaySkewY + pScrn->virtualY - 1 ) >> 8) & 0x07;
+ ChipsNew->MR[0x31] = ((cPtr->OverlaySkewY + pScrn->virtualY -
+ 1 ) >> 8) & 0x07;
ChipsNew->MR[0x3C] &= 0x18; /* Mask reserved bits */
ChipsNew->MR[0x3C] |= 0x07; /* Enable keyed overlay window */
@@ -5201,6 +5229,17 @@ chipsModeInitHiQV(ScrnInfoPtr pScrn, DisplayModePtr mode)
ChipsNew->MR[0x40] = 0xFF;
ChipsNew->MR[0x41] = 0xFF;
ChipsNew->MR[0x42] = 0x00;
+ } else if (cPtr->Flags & ChipsVideoSupport) {
+ ChipsNew->XR[0xD0] |= 0x10; /* Force the Multimedia engine on */
+ ChipsNew->XR[0x4F] = 0x2A; /* SAR04 >352 pixel overlay width */
+ ChipsNew->MR[0x3C] &= 0x18; /* Ensure that the overlay is off */
+ cPtr->VideoZoomMax = 0x100;
+
+ if (cPtr->Chipset == CHIPS_CT65550) {
+ tmp = cPtr->readXR(cPtr, 0x04);
+ if (tmp < 0x02) /* 65550 ES0 has */
+ cPtr->VideoZoomMax = 0x40; /* 0x40 max zoom */
+ }
}
/* Program the registers */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h
index c708efb8e..503124e84 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h
@@ -22,7 +22,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h,v 1.26 2000/03/05 16:59:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_driver.h,v 1.27 2000/04/04 19:25:08 dawes Exp $ */
#ifndef _CT_DRIVER_H_
@@ -34,6 +34,7 @@
#include "xf86Cursor.h"
#include "xf86i2c.h"
#include "xf86DDC.h"
+#include "xf86xv.h"
/* Supported chipsets */
typedef enum {
@@ -103,15 +104,16 @@ typedef struct {
#define ChipsDPMSSupport 0x00000020
#define ChipsTMEDSupport 0x00000040
#define ChipsGammaSupport 0x00000080
+#define ChipsVideoSupport 0x00000100
/* Options flags for the C&T chipsets */
-#define ChipsHWCursor 0x00000100
-#define ChipsShadowFB 0x00000200
-#define ChipsOverlay8plus16 0x00000400
+#define ChipsHWCursor 0x00001000
+#define ChipsShadowFB 0x00002000
+#define ChipsOverlay8plus16 0x00004000
/* Architecture type flags */
-#define ChipsHiQV 0x00001000
-#define ChipsWingine 0x00002000
+#define ChipsHiQV 0x00010000
+#define ChipsWingine 0x00020000
#define IS_Wingine(x) ((x->Flags) & ChipsWingine)
#define IS_HiQV(x) ((x->Flags) & ChipsHiQV)
@@ -283,6 +285,13 @@ typedef struct _CHIPSRec {
Bool DGAactive;
int DGAViewportStatus;
CloseScreenProcPtr CloseScreen;
+ ScreenBlockHandlerProcPtr BlockHandler;
+ int videoKey;
+ XF86VideoAdaptorPtr adaptor;
+ int OverlaySkewX;
+ int OverlaySkewY;
+ int VideoZoomMax;
+
#ifdef __arm32__
#ifdef __NetBSD__
int TVMode;
@@ -318,6 +327,10 @@ extern unsigned int ChipsReg32HiQV[];
void CHIPSAdjustFrame(int scrnIndex, int x, int y, int flags);
Bool CHIPSSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* video */
+void CHIPSInitVideo(ScreenPtr pScreen);
+void CHIPSResetVideo(ScrnInfoPtr pScrn);
+
/* banking */
int CHIPSSetRead(ScreenPtr pScreen, int bank);
int CHIPSSetWrite(ScreenPtr pScreen, int bank);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c
index 2def45166..ae73a571d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c
@@ -19,7 +19,7 @@
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c,v 1.2 1999/12/03 19:17:31 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_regs.c,v 1.3 2000/04/04 19:25:08 dawes Exp $ */
/*
* The functions in this file are used to read/write the C&T extension register
@@ -48,14 +48,14 @@
*/
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c
new file mode 100644
index 000000000..ed608e545
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c
@@ -0,0 +1,1121 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/ct_video.c,v 1.2 2000/04/07 03:57:50 tsi Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86_ansic.h"
+#include "compiler.h"
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#include "xf86fbman.h"
+#include "regionstr.h"
+
+#include "ct_driver.h"
+#include "Xv.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "dixstruct.h"
+
+#define OFF_DELAY 200 /* milliseconds */
+#define FREE_DELAY 60000
+
+#define OFF_TIMER 0x01
+#define FREE_TIMER 0x02
+#define CLIENT_VIDEO_ON 0x04
+
+#define TIMER_MASK (OFF_TIMER | FREE_TIMER)
+
+#ifndef XvExtension
+void CHIPSInitVideo(ScreenPtr pScreen) {}
+void CHIPSResetVideo(ScrnInfoPtr pScrn) {}
+#else
+
+static XF86VideoAdaptorPtr CHIPSSetupImageVideo(ScreenPtr);
+static void CHIPSInitOffscreenImages(ScreenPtr);
+static void CHIPSStopVideo(ScrnInfoPtr, pointer, Bool);
+static int CHIPSSetPortAttribute(ScrnInfoPtr, Atom, INT32, pointer);
+static int CHIPSGetPortAttribute(ScrnInfoPtr, Atom ,INT32 *, pointer);
+static void CHIPSQueryBestSize(ScrnInfoPtr, Bool,
+ short, short, short, short, unsigned int *, unsigned int *, pointer);
+static int CHIPSPutImage( ScrnInfoPtr,
+ short, short, short, short, short, short, short, short,
+ int, unsigned char*, short, short, Bool, RegionPtr, pointer);
+static int CHIPSQueryImageAttributes(ScrnInfoPtr,
+ int, unsigned short *, unsigned short *, int *, int *);
+
+static void CHIPSBlockHandler(int, pointer, pointer, pointer);
+
+#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
+
+static Atom xvColorKey;
+
+void CHIPSInitVideo(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XF86VideoAdaptorPtr *adaptors, *newAdaptors = NULL;
+ XF86VideoAdaptorPtr newAdaptor = NULL;
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ int num_adaptors;
+
+ if(!(cPtr->Flags & ChipsOverlay8plus16) &&
+ (cPtr->Flags & ChipsVideoSupport)) {
+ newAdaptor = CHIPSSetupImageVideo(pScreen);
+ CHIPSInitOffscreenImages(pScreen);
+ }
+
+ num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
+
+ if(newAdaptor) {
+ if(!num_adaptors) {
+ num_adaptors = 1;
+ adaptors = &newAdaptor;
+ } else {
+ newAdaptors = /* need to free this someplace */
+ xalloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr*));
+ if(newAdaptors) {
+ memcpy(newAdaptors, adaptors, num_adaptors *
+ sizeof(XF86VideoAdaptorPtr));
+ newAdaptors[num_adaptors] = newAdaptor;
+ adaptors = newAdaptors;
+ num_adaptors++;
+ }
+ }
+ }
+
+ if(num_adaptors)
+ xf86XVScreenInit(pScreen, adaptors, num_adaptors);
+
+ if(newAdaptors)
+ xfree(newAdaptors);
+}
+
+/* client libraries expect an encoding */
+static XF86VideoEncodingRec DummyEncoding[1] =
+{
+ {
+ 0,
+ "XV_IMAGE",
+ 1024, 1024,
+ {1, 1}
+ }
+};
+
+#define NUM_FORMATS 4
+
+static XF86VideoFormatRec Formats[NUM_FORMATS] =
+{
+ {8, PseudoColor}, {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+};
+
+#define NUM_ATTRIBUTES 1
+
+static XF86AttributeRec Attributes[NUM_ATTRIBUTES] =
+{
+ {XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"}
+};
+
+#define NUM_IMAGES 4
+
+static XF86ImageRec Images[NUM_IMAGES] =
+{
+ {
+ 0x35315652,
+ XvRGB,
+ LSBFirst,
+ {'R','V','1','5',
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+ 16,
+ XvPacked,
+ 1,
+ 15, 0x001F, 0x03E0, 0x7C00,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ {'R','V','B',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
+ },
+ {
+ 0x36315652,
+ XvRGB,
+ LSBFirst,
+ {'R','V','1','6',
+ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
+ 16,
+ XvPacked,
+ 1,
+ 16, 0x001F, 0x07E0, 0xF800,
+ 0, 0, 0,
+ 0, 0, 0,
+ 0, 0, 0,
+ {'R','V','B',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
+ },
+ {
+ 0x32315659,
+ 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
+ },
+ {
+ 0x32595559,
+ 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
+ }
+};
+
+typedef struct {
+ FBAreaPtr area;
+ RegionRec clip;
+ CARD32 colorKey;
+ CARD32 videoStatus;
+ Time offTime;
+ Time freeTime;
+} CHIPSPortPrivRec, *CHIPSPortPrivPtr;
+
+
+#define GET_PORT_PRIVATE(pScrn) \
+ (CHIPSPortPrivPtr)((CHIPSPTR(pScrn))->adaptor->pPortPrivates[0].ptr)
+
+void CHIPSResetVideo(ScrnInfoPtr pScrn)
+{
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ CHIPSPortPrivPtr pPriv = cPtr->adaptor->pPortPrivates[0].ptr;
+ unsigned char mr3c;
+ int red, green, blue;
+
+ CHIPSHiQVSync(pScrn);
+ mr3c = cPtr->readMR(cPtr, 0x3C);
+ cPtr->writeMR(cPtr, 0x3C, (mr3c | 0x6));
+
+ switch (pScrn->depth) {
+ case 8:
+ cPtr->writeMR(cPtr, 0x3D, 0x00);
+ cPtr->writeMR(cPtr, 0x3E, 0x00);
+ cPtr->writeMR(cPtr, 0x3F, (pPriv->colorKey & 0xFF));
+ cPtr->writeMR(cPtr, 0x40, 0xFF);
+ cPtr->writeMR(cPtr, 0x41, 0xFF);
+ cPtr->writeMR(cPtr, 0x42, 0x00);
+ break;
+ default:
+ red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red;
+ green = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green;
+ blue = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue;
+ switch (pScrn->depth) {
+ case 15:
+ cPtr->writeMR(cPtr, 0x3D, (red << 3));
+ cPtr->writeMR(cPtr, 0x3E, (green << 3));
+ cPtr->writeMR(cPtr, 0x3F, (blue << 3));
+ cPtr->writeMR(cPtr, 0x40, 0x07);
+ cPtr->writeMR(cPtr, 0x41, 0x07);
+ cPtr->writeMR(cPtr, 0x42, 0x07);
+ break;
+ case 16:
+ cPtr->writeMR(cPtr, 0x3D, (red << 3));
+ cPtr->writeMR(cPtr, 0x3E, (green << 2));
+ cPtr->writeMR(cPtr, 0x3F, (blue << 3));
+ cPtr->writeMR(cPtr, 0x40, 0x07);
+ cPtr->writeMR(cPtr, 0x41, 0x03);
+ cPtr->writeMR(cPtr, 0x42, 0x07);
+ break;
+ case 24:
+ cPtr->writeMR(cPtr, 0x3D, red);
+ cPtr->writeMR(cPtr, 0x3E, green);
+ cPtr->writeMR(cPtr, 0x3F, blue);
+ cPtr->writeMR(cPtr, 0x40, 0x00);
+ cPtr->writeMR(cPtr, 0x41, 0x00);
+ cPtr->writeMR(cPtr, 0x42, 0x00);
+ break;
+ }
+ }
+}
+
+
+static XF86VideoAdaptorPtr
+CHIPSSetupImageVideo(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ XF86VideoAdaptorPtr adapt;
+ CHIPSPortPrivPtr pPriv;
+
+ if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
+ sizeof(CHIPSPortPrivRec) +
+ sizeof(DevUnion))))
+ return NULL;
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
+ adapt->name = "Chips and Technologies Backend Scaler";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = DummyEncoding;
+ adapt->nFormats = NUM_FORMATS;
+ adapt->pFormats = Formats;
+ adapt->nPorts = 1;
+ adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
+ pPriv = (CHIPSPortPrivPtr)(&adapt->pPortPrivates[1]);
+ adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
+ adapt->pAttributes = Attributes;
+ adapt->nImages = NUM_IMAGES;
+ adapt->nAttributes = NUM_ATTRIBUTES;
+ adapt->pImages = Images;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = CHIPSStopVideo;
+ adapt->SetPortAttribute = CHIPSSetPortAttribute;
+ adapt->GetPortAttribute = CHIPSGetPortAttribute;
+ adapt->QueryBestSize = CHIPSQueryBestSize;
+ adapt->PutImage = CHIPSPutImage;
+ adapt->QueryImageAttributes = CHIPSQueryImageAttributes;
+
+ pPriv->colorKey = cPtr->videoKey;
+ pPriv->videoStatus = 0;
+
+ /* gotta uninit this someplace */
+ REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
+
+ cPtr->adaptor = adapt;
+
+ cPtr->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = CHIPSBlockHandler;
+
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+
+ CHIPSResetVideo(pScrn);
+
+ return adapt;
+}
+
+
+static Bool
+RegionsEqual(RegionPtr A, RegionPtr B)
+{
+ int *dataA, *dataB;
+ int num;
+
+ num = REGION_NUM_RECTS(A);
+ if(num != REGION_NUM_RECTS(B))
+ return FALSE;
+
+ if((A->extents.x1 != B->extents.x1) ||
+ (A->extents.x2 != B->extents.x2) ||
+ (A->extents.y1 != B->extents.y1) ||
+ (A->extents.y2 != B->extents.y2))
+ return FALSE;
+
+ dataA = (int*)REGION_RECTS(A);
+ dataB = (int*)REGION_RECTS(B);
+
+ while(num--) {
+ if((dataA[0] != dataB[0]) || (dataA[1] != dataB[1]))
+ return FALSE;
+ dataA += 2;
+ dataB += 2;
+ }
+
+ return TRUE;
+}
+
+
+/* CHIPSClipVideo -
+
+ Takes the dst box in standard X BoxRec form (top and left
+ edges inclusive, bottom and right exclusive). The new dst
+ box is returned. The source boundaries are given (x1, y1
+ inclusive, x2, y2 exclusive) and returned are the new source
+ boundaries in 16.16 fixed point.
+*/
+
+static void
+CHIPSClipVideo(
+ BoxPtr dst,
+ INT32 *x1,
+ INT32 *x2,
+ INT32 *y1,
+ INT32 *y2,
+ BoxPtr extents, /* extents of the clip region */
+ INT32 width,
+ INT32 height
+){
+ INT32 vscale, hscale, delta;
+ int diff;
+
+ hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
+ vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
+
+ *x1 <<= 16; *x2 <<= 16;
+ *y1 <<= 16; *y2 <<= 16;
+
+ diff = extents->x1 - dst->x1;
+ if(diff > 0) {
+ dst->x1 = extents->x1;
+ *x1 += diff * hscale;
+ }
+ diff = dst->x2 - extents->x2;
+ if(diff > 0) {
+ dst->x2 = extents->x2;
+ *x2 -= diff * hscale;
+ }
+ diff = extents->y1 - dst->y1;
+ if(diff > 0) {
+ dst->y1 = extents->y1;
+ *y1 += diff * vscale;
+ }
+ diff = dst->y2 - extents->y2;
+ if(diff > 0) {
+ dst->y2 = extents->y2;
+ *y2 -= diff * vscale;
+ }
+
+ if(*x1 < 0) {
+ diff = (- *x1 + hscale - 1)/ hscale;
+ dst->x1 += diff;
+ *x1 += diff * hscale;
+ }
+ delta = *x2 - (width << 16);
+ if(delta > 0) {
+ diff = (delta + hscale - 1)/ hscale;
+ dst->x2 -= diff;
+ *x2 -= diff * hscale;
+ }
+ if(*y1 < 0) {
+ diff = (- *y1 + vscale - 1)/ vscale;
+ dst->y1 += diff;
+ *y1 += diff * vscale;
+ }
+ delta = *y2 - (height << 16);
+ if(delta > 0) {
+ diff = (delta + vscale - 1)/ vscale;
+ dst->y2 -= diff;
+ *y2 -= diff * vscale;
+ }
+}
+
+static void
+CHIPSStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)
+{
+ CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data;
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ unsigned char mr3c;
+
+ REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
+
+ CHIPSHiQVSync(pScrn);
+ if(exit) {
+ if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ mr3c = cPtr->readMR(cPtr, 0x3C);
+ cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE));
+ }
+ if(pPriv->area) {
+ xf86FreeOffscreenArea(pPriv->area);
+ pPriv->area = NULL;
+ }
+ pPriv->videoStatus = 0;
+ } else {
+ if(pPriv->videoStatus & CLIENT_VIDEO_ON) {
+ pPriv->videoStatus |= OFF_TIMER;
+ pPriv->offTime = currentTime.milliseconds + OFF_DELAY;
+ }
+ }
+}
+
+static int
+CHIPSSetPortAttribute(
+ ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 value,
+ pointer data
+){
+ CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data;
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+
+ CHIPSHiQVSync(pScrn);
+ if(attribute == xvColorKey) {
+ int red, green, blue;
+ pPriv->colorKey = value;
+ switch (pScrn->depth) {
+ case 8:
+ cPtr->writeMR(cPtr, 0x3D, 0x00);
+ cPtr->writeMR(cPtr, 0x3E, 0x00);
+ cPtr->writeMR(cPtr, 0x3F, (pPriv->colorKey & 0xFF));
+ break;
+ default:
+ red = (pPriv->colorKey & pScrn->mask.red) >> pScrn->offset.red;
+ green = (pPriv->colorKey & pScrn->mask.green) >> pScrn->offset.green;
+ blue = (pPriv->colorKey & pScrn->mask.blue) >> pScrn->offset.blue;
+ switch (pScrn->depth) {
+ case 15:
+ cPtr->writeMR(cPtr, 0x3D, (red << 3));
+ cPtr->writeMR(cPtr, 0x3E, (green << 3));
+ cPtr->writeMR(cPtr, 0x3F, (blue << 3));
+ break;
+ case 16:
+ cPtr->writeMR(cPtr, 0x3D, (red << 3));
+ cPtr->writeMR(cPtr, 0x3E, (green << 2));
+ cPtr->writeMR(cPtr, 0x3F, (blue << 3));
+ break;
+ case 24:
+ cPtr->writeMR(cPtr, 0x3D, red);
+ cPtr->writeMR(cPtr, 0x3E, green);
+ cPtr->writeMR(cPtr, 0x3F, blue);
+ break;
+ }
+ }
+ REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
+ } else return BadMatch;
+
+ return Success;
+}
+
+static int
+CHIPSGetPortAttribute(
+ ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 *value,
+ pointer data
+){
+ CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data;
+
+ if(attribute == xvColorKey) {
+ *value = pPriv->colorKey;
+ } else return BadMatch;
+
+ return Success;
+}
+
+static void
+CHIPSQueryBestSize(
+ 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
+){
+ *p_w = drw_w;
+ *p_h = drw_h;
+
+ if(*p_w > 16384) *p_w = 16384;
+}
+
+
+static void
+CHIPSCopyData(
+ unsigned char *src,
+ unsigned char *dst,
+ int srcPitch,
+ int dstPitch,
+ int h,
+ int w
+){
+ w <<= 1;
+ while(h--) {
+ memcpy(dst, src, w);
+ src += srcPitch;
+ dst += dstPitch;
+ }
+}
+
+static void
+CHIPSCopyMungedData(
+ unsigned char *src1,
+ unsigned char *src2,
+ unsigned char *src3,
+ unsigned char *dst1,
+ int srcPitch,
+ int srcPitch2,
+ int dstPitch,
+ int h,
+ int w
+){
+ CARD32 *dst = (CARD32*)dst1;
+ int i, j;
+
+ dstPitch >>= 2;
+ w >>= 1;
+
+ for(j = 0; j < h; j++) {
+ for(i = 0; i < w; i++) {
+#if 1
+ dst[i] = src1[i << 1] | (src1[(i << 1) + 1] << 16) |
+ (src3[i] << 8) | (src2[i] << 24);
+#else
+ dst[i] = (src1[i << 1] << 24) | (src1[(i << 1) + 1] << 8) |
+ (src3[i] << 0) | (src2[i] << 16);
+#endif
+ }
+ dst += dstPitch;
+ src1 += srcPitch;
+ if(j & 1) {
+ src2 += srcPitch2;
+ src3 += srcPitch2;
+ }
+ }
+}
+
+static FBAreaPtr
+CHIPSAllocateMemory(
+ ScrnInfoPtr pScrn,
+ FBAreaPtr area,
+ int numlines
+){
+ ScreenPtr pScreen;
+ FBAreaPtr new_area;
+
+ if(area) {
+ if((area->box.y2 - area->box.y1) >= numlines)
+ return area;
+
+ if(xf86ResizeOffscreenArea(area, pScrn->displayWidth, numlines))
+ return area;
+
+ xf86FreeOffscreenArea(area);
+ }
+
+ pScreen = screenInfo.screens[pScrn->scrnIndex];
+
+ new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
+ numlines, 0, NULL, NULL, NULL);
+
+ if(!new_area) {
+ int max_w, max_h;
+
+ xf86QueryLargestOffscreenArea(pScreen, &max_w, &max_h, 0,
+ FAVOR_WIDTH_THEN_AREA, PRIORITY_EXTREME);
+
+ if((max_w < pScrn->displayWidth) || (max_h < numlines))
+ return NULL;
+
+ xf86PurgeUnlockedOffscreenAreas(pScreen);
+ new_area = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
+ numlines, 0, NULL, NULL, NULL);
+ }
+
+ return new_area;
+}
+
+static void
+CHIPSDisplayVideo(
+ ScrnInfoPtr pScrn,
+ int id,
+ int offset,
+ short width, short height,
+ int pitch,
+ int x1, int y1, int x2, int y2,
+ BoxPtr dstBox,
+ short src_w, short src_h,
+ short drw_w, short drw_h
+){
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ DisplayModePtr mode = pScrn->currentMode;
+ unsigned char tmp;
+
+ CHIPSHiQVSync(pScrn);
+
+ tmp = cPtr->readMR(cPtr, 0x1E);
+ tmp &= 0xE0; /* Set Zoom and Direction */
+ if ((!(cPtr->PanelType & ChipsLCD)) && (mode->Flags & V_INTERLACE))
+ tmp |= 0x10;
+ cPtr->writeMR(cPtr, 0x1E, tmp);
+ tmp = cPtr->readMR(cPtr, 0x1F);
+ tmp = (tmp & 0x14); /* Mask reserved bits, unset interpolation */
+ switch(id) {
+ case 0x35315652: /* RGB15 */
+ tmp |= 0x09;
+ break;
+ case 0x36315652: /* RGB16 */
+ tmp |= 0x08;
+ break;
+ case 0x32315659: /* YV12 */
+ tmp |= 0x00;
+ break;
+ case 0x32595559: /* YUY2 */
+ default:
+ tmp |= 0x00; /* Do nothing here */
+ break;
+ }
+
+ cPtr->writeMR(cPtr, 0x1F, tmp);
+ tmp = cPtr->readMR(cPtr, 0x20);
+ tmp &= 0xC3;
+ cPtr->writeMR(cPtr, 0x20, tmp);
+
+ /* Setup Pointer 1 */
+ cPtr->writeMR(cPtr, 0x22, (offset & 0xF8));
+ cPtr->writeMR(cPtr, 0x23, ((offset >> 8) & 0xFF));
+ cPtr->writeMR(cPtr, 0x24, ((offset >> 16) & 0xFF));
+ /* Setup Pointer 2 */
+ cPtr->writeMR(cPtr, 0x25, (offset & 0xF8));
+ cPtr->writeMR(cPtr, 0x26, ((offset >> 8) & 0xFF));
+ cPtr->writeMR(cPtr, 0x27, ((offset >> 16) & 0xFF));
+ cPtr->writeMR(cPtr, 0x28, ((width >> 2) - 1)); /* Width */
+ cPtr->writeMR(cPtr, 0x34, ((width >> 2) - 1));
+
+ /* Left Edge of Overlay */
+ cPtr->writeMR(cPtr, 0x2A, ((cPtr->OverlaySkewX + dstBox->x1) & 0xFF));
+ tmp = cPtr->readMR(cPtr, 0x2B);
+ tmp = (tmp & 0xF8) + (((cPtr->OverlaySkewX + dstBox->x1) >> 8) & 0x07);
+ cPtr->writeMR(cPtr, 0x2B, tmp);
+ /* Right Edge of Overlay */
+ cPtr->writeMR(cPtr, 0x2C, ((cPtr->OverlaySkewX + dstBox->x2 -1)
+ & 0xFF));
+ tmp = cPtr->readMR(cPtr, 0x2D);
+ tmp = (tmp & 0xF8) + (((cPtr->OverlaySkewX + dstBox->x2 - 1) >> 8) & 0x07);
+ cPtr->writeMR(cPtr, 0x2D, tmp);
+ /* Top Edge of Overlay */
+ cPtr->writeMR(cPtr, 0x2E, ((cPtr->OverlaySkewY + dstBox->y1) & 0xFF));
+ tmp = cPtr->readMR(cPtr, 0x2F);
+ tmp = (tmp & 0xF8) + (((cPtr->OverlaySkewY + dstBox->y1) >> 8) & 0x07);
+ cPtr->writeMR(cPtr, 0x2F, tmp);
+ /* Bottom Edge of Overlay*/
+ cPtr->writeMR(cPtr, 0x30, ((cPtr->OverlaySkewY + dstBox->y2 - 1) & 0xFF));
+ tmp = cPtr->readMR(cPtr, 0x31);
+ tmp = (tmp & 0xF8) + (((cPtr->OverlaySkewY + dstBox->y2 - 1) >> 8) & 0x07);
+ cPtr->writeMR(cPtr, 0x31, tmp);
+
+ /* Horizontal Zoom */
+ if (drw_w > src_w) {
+ tmp = cPtr->readMR(cPtr, 0x1F);
+ cPtr->writeMR(cPtr, 0x1F, (tmp | 0x20)); /* set H-interpolation */
+ tmp = cPtr->readMR(cPtr, 0x1E);
+ cPtr->writeMR(cPtr, 0x1E, (tmp | 0x04));
+ tmp = cPtr->VideoZoomMax * src_w / drw_w;
+ cPtr->writeMR(cPtr, 0x32, tmp);
+ }
+
+ /* Vertical Zoom */
+ if (drw_h > src_h) {
+ tmp = cPtr->readMR(cPtr, 0x1F);
+ cPtr->writeMR(cPtr, 0x1F, (tmp | 0x80)); /* set V-interpolation */
+ tmp = cPtr->readMR(cPtr, 0x1E);
+ cPtr->writeMR(cPtr, 0x1E, (tmp | 0x08));
+ tmp = cPtr->VideoZoomMax * src_h / drw_h;
+ cPtr->writeMR(cPtr, 0x33, tmp);
+ }
+
+ tmp = cPtr->readMR(cPtr, 0x3C);
+ cPtr->writeMR(cPtr, 0x3C, (tmp | 0x7));
+}
+
+static int
+CHIPSPutImage(
+ 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 id, unsigned char* buf,
+ short width, short height,
+ Bool sync,
+ RegionPtr clipBoxes, pointer data
+){
+ CHIPSPortPrivPtr pPriv = (CHIPSPortPrivPtr)data;
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ INT32 x1, x2, y1, y2;
+ unsigned char *dst_start;
+ int pitch, new_h, offset, offset2, offset3;
+ int srcPitch, srcPitch2, dstPitch;
+ int top, left, npixels, nlines;
+ BoxRec dstBox;
+ CARD32 tmp;
+
+ if(drw_w > 16384) drw_w = 16384;
+
+ /* Clip */
+ x1 = src_x;
+ x2 = src_x + src_w;
+ y1 = src_y;
+ y2 = src_y + src_h;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+
+ CHIPSClipVideo(&dstBox, &x1, &x2, &y1, &y2,
+ REGION_EXTENTS(pScreen, clipBoxes), width, height);
+
+ if((x1 >= x2) || (y1 >= y2))
+ return Success;
+
+ dstBox.x1 -= pScrn->frameX0;
+ dstBox.x2 -= pScrn->frameX0;
+ dstBox.y1 -= pScrn->frameY0;
+ dstBox.y2 -= pScrn->frameY0;
+
+ pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3;
+
+ dstPitch = ((width << 1) + 15) & ~15;
+ new_h = ((dstPitch * height) + pitch - 1) / pitch;
+
+ switch(id) {
+ case 0x32315659: /* YV12 */
+ srcPitch = (width + 3) & ~3;
+ offset2 = srcPitch * height;
+ srcPitch2 = ((width >> 1) + 3) & ~3;
+ offset3 = (srcPitch2 * (height >> 1)) + offset2;
+ break;
+ case 0x35315652: /* RGB15 */
+ case 0x36315652: /* RGB16 */
+ case 0x32595559: /* YUY2 */
+ default:
+ srcPitch = (width << 1);
+ break;
+ }
+
+ if(!(pPriv->area = CHIPSAllocateMemory(pScrn, pPriv->area, new_h)))
+ return BadAlloc;
+
+ /* copy data */
+ top = y1 >> 16;
+ left = (x1 >> 16) & ~1;
+ npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
+ left <<= 1;
+
+ offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch);
+ dst_start = cPtr->FbBase + offset + left;
+
+ switch(id) {
+ case 0x32315659: /* YV12 */
+ top &= ~1;
+ tmp = ((top >> 1) * srcPitch2) + (left >> 2);
+ offset2 += tmp;
+ offset3 += tmp;
+ nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
+ CHIPSCopyMungedData(buf + (top * srcPitch) + (left >> 1),
+ buf + offset2, buf + offset3, dst_start,
+ srcPitch, srcPitch2, dstPitch, nlines, npixels);
+ break;
+ case 0x35315652: /* RGB15 */
+ case 0x36315652: /* RGB16 */
+ case 0x32595559: /* YUY2 */
+ default:
+ buf += (top * srcPitch) + left;
+ nlines = ((y2 + 0xffff) >> 16) - top;
+ CHIPSCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
+ break;
+ }
+
+ /* update cliplist */
+ if(!RegionsEqual(&pPriv->clip, clipBoxes)) {
+ REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
+ /* draw these */
+ XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0,
+ REGION_NUM_RECTS(clipBoxes),
+ REGION_RECTS(clipBoxes));
+ }
+
+ CHIPSDisplayVideo(pScrn, id, offset, width, height, dstPitch,
+ x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
+
+ pPriv->videoStatus = CLIENT_VIDEO_ON;
+
+ return Success;
+}
+
+static int
+CHIPSQueryImageAttributes(
+ ScrnInfoPtr pScrn,
+ int id,
+ unsigned short *w, unsigned short *h,
+ int *pitches, int *offsets
+){
+ int size, tmp;
+
+ if(*w > 1024) *w = 1024;
+ if(*h > 1024) *h = 1024;
+
+ *w = (*w + 1) & ~1;
+ if(offsets) offsets[0] = 0;
+
+ switch(id) {
+ case 0x32315659: /* YV12 */
+ *h = (*h + 1) & ~1;
+ size = (*w + 3) & ~3;
+ if(pitches) pitches[0] = size;
+ size *= *h;
+ if(offsets) offsets[1] = size;
+ tmp = ((*w >> 1) + 3) & ~3;
+ if(pitches) pitches[1] = pitches[2] = tmp;
+ tmp *= (*h >> 1);
+ size += tmp;
+ if(offsets) offsets[2] = size;
+ size += tmp;
+ break;
+ case 0x35315652: /* RGB15 */
+ case 0x36315652: /* RGB16 */
+ case 0x32595559: /* YUY2 */
+ default:
+ size = *w << 1;
+ if(pitches) pitches[0] = size;
+ size *= *h;
+ break;
+ }
+
+ return size;
+}
+
+static void
+CHIPSBlockHandler (
+ int i,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask
+){
+ ScreenPtr pScreen = screenInfo.screens[i];
+ ScrnInfoPtr pScrn = xf86Screens[i];
+ CHIPSPtr cPtr = CHIPSPTR(pScrn);
+ CHIPSPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn);
+ unsigned char mr3c;
+
+ pScreen->BlockHandler = cPtr->BlockHandler;
+
+ (*pScreen->BlockHandler) (i, blockData, pTimeout, pReadmask);
+
+ pScreen->BlockHandler = CHIPSBlockHandler;
+
+ CHIPSHiQVSync(pScrn);
+ if(pPriv->videoStatus & TIMER_MASK) {
+ UpdateCurrentTime();
+ if(pPriv->videoStatus & OFF_TIMER) {
+ if(pPriv->offTime < currentTime.milliseconds) {
+ mr3c = cPtr->readMR(cPtr, 0x3C);
+ cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE));
+ pPriv->videoStatus = FREE_TIMER;
+ pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ }
+ } else { /* FREE_TIMER */
+ if(pPriv->freeTime < currentTime.milliseconds) {
+ if(pPriv->area) {
+ xf86FreeOffscreenArea(pPriv->area);
+ pPriv->area = NULL;
+ }
+ pPriv->videoStatus = 0;
+ }
+ }
+ }
+}
+
+
+/****************** Offscreen stuff ***************/
+
+typedef struct {
+ FBAreaPtr area;
+ Bool isOn;
+} OffscreenPrivRec, * OffscreenPrivPtr;
+
+static int
+CHIPSAllocateSurface(
+ ScrnInfoPtr pScrn,
+ int id,
+ unsigned short w,
+ unsigned short h,
+ XF86SurfacePtr surface
+){
+ FBAreaPtr area;
+ int pitch, fbpitch, numlines;
+ OffscreenPrivPtr pPriv;
+
+ if((w > 1024) || (h > 1024))
+ return BadAlloc;
+
+ w = (w + 1) & ~1;
+ pitch = ((w << 1) + 15) & ~15;
+ fbpitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3;
+ numlines = ((pitch * h) + fbpitch - 1) / fbpitch;
+
+ if(!(area = CHIPSAllocateMemory(pScrn, NULL, numlines)))
+ return BadAlloc;
+
+ surface->width = w;
+ surface->height = h;
+
+ if(!(surface->pitches = xalloc(sizeof(int))))
+ return BadAlloc;
+ if(!(surface->offsets = xalloc(sizeof(int)))) {
+ xfree(surface->pitches);
+ return BadAlloc;
+ }
+ if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
+ xfree(surface->pitches);
+ xfree(surface->offsets);
+ return BadAlloc;
+ }
+
+ pPriv->area = area;
+ pPriv->isOn = FALSE;
+
+ surface->pScrn = pScrn;
+ surface->id = id;
+ surface->pitches[0] = pitch;
+ surface->offsets[0] = area->box.y1 * fbpitch;
+ surface->devPrivate.ptr = (pointer)pPriv;
+
+ return Success;
+}
+
+static int
+CHIPSStopSurface(
+ XF86SurfacePtr surface
+){
+ OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;
+
+ if(pPriv->isOn) {
+ CHIPSPtr cPtr = CHIPSPTR(surface->pScrn);
+ unsigned char mr3c;
+ mr3c = cPtr->readMR(cPtr, 0x3C);
+ cPtr->writeMR(cPtr, 0x3C, (mr3c & 0xFE));
+ pPriv->isOn = FALSE;
+ }
+
+ return Success;
+}
+
+
+static int
+CHIPSFreeSurface(
+ XF86SurfacePtr surface
+){
+ OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;
+
+ if(pPriv->isOn)
+ CHIPSStopSurface(surface);
+ xf86FreeOffscreenArea(pPriv->area);
+ xfree(surface->pitches);
+ xfree(surface->offsets);
+ xfree(surface->devPrivate.ptr);
+
+ return Success;
+}
+
+static int
+CHIPSGetSurfaceAttribute(
+ ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 *value
+){
+ return CHIPSGetPortAttribute(pScrn, attribute, value,
+ (pointer)(GET_PORT_PRIVATE(pScrn)));
+}
+
+static int
+CHIPSSetSurfaceAttribute(
+ ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 value
+){
+ return CHIPSSetPortAttribute(pScrn, attribute, value,
+ (pointer)(GET_PORT_PRIVATE(pScrn)));
+}
+
+
+static int
+CHIPSDisplaySurface(
+ XF86SurfacePtr surface,
+ short src_x, short src_y,
+ short drw_x, short drw_y,
+ short src_w, short src_h,
+ short drw_w, short drw_h,
+ RegionPtr clipBoxes
+){
+ OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;
+ ScrnInfoPtr pScrn = surface->pScrn;
+ CHIPSPortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn);
+ INT32 x1, y1, x2, y2;
+ BoxRec dstBox;
+
+ x1 = src_x;
+ x2 = src_x + src_w;
+ y1 = src_y;
+ y2 = src_y + src_h;
+
+ dstBox.x1 = drw_x;
+ dstBox.x2 = drw_x + drw_w;
+ dstBox.y1 = drw_y;
+ dstBox.y2 = drw_y + drw_h;
+
+ CHIPSClipVideo(&dstBox, &x1, &x2, &y1, &y2,
+ REGION_EXTENTS(pScreen, clipBoxes),
+ surface->width, surface->height);
+
+ if((x1 >= x2) || (y1 >= y2))
+ return Success;
+
+ dstBox.x1 -= pScrn->frameX0;
+ dstBox.x2 -= pScrn->frameX0;
+ dstBox.y1 -= pScrn->frameY0;
+ dstBox.y2 -= pScrn->frameY0;
+
+ XAAFillSolidRects(pScrn, portPriv->colorKey, GXcopy, ~0,
+ REGION_NUM_RECTS(clipBoxes),
+ REGION_RECTS(clipBoxes));
+
+ CHIPSDisplayVideo(pScrn, surface->id, surface->offsets[0],
+ surface->width, surface->height, surface->pitches[0],
+ x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
+
+ pPriv->isOn = TRUE;
+ if(portPriv->videoStatus & CLIENT_VIDEO_ON) {
+ REGION_EMPTY(pScrn->pScreen, &portPriv->clip);
+ UpdateCurrentTime();
+ portPriv->videoStatus = FREE_TIMER;
+ portPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ }
+
+ return Success;
+}
+
+
+static void
+CHIPSInitOffscreenImages(ScreenPtr pScreen)
+{
+ XF86OffscreenImagePtr offscreenImages;
+
+ /* need to free this someplace */
+ if(!(offscreenImages = xalloc(sizeof(XF86OffscreenImageRec))))
+ return;
+
+ offscreenImages[0].image = &Images[0];
+ offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES |
+ VIDEO_CLIP_TO_VIEWPORT;
+ offscreenImages[0].alloc_surface = CHIPSAllocateSurface;
+ offscreenImages[0].free_surface = CHIPSFreeSurface;
+ offscreenImages[0].display = CHIPSDisplaySurface;
+ offscreenImages[0].stop = CHIPSStopSurface;
+ offscreenImages[0].setAttribute = CHIPSSetSurfaceAttribute;
+ offscreenImages[0].getAttribute = CHIPSGetSurfaceAttribute;
+ offscreenImages[0].max_width = 1024;
+ offscreenImages[0].max_height = 1024;
+ offscreenImages[0].num_attributes = NUM_ATTRIBUTES;
+ offscreenImages[0].attributes = Attributes;
+
+ xf86XVRegisterOffscreenImages(pScreen, offscreenImages, 1);
+}
+
+#endif /* !XvExtension */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c b/xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c
index ebc13775d..ec3d994fa 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c
@@ -4,7 +4,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c,v 1.3 1999/04/04 08:46:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/chips/util/mRegs.c,v 1.4 2000/04/28 18:19:23 eich Exp $ */
#ifdef __NetBSD__
# include <sys/types.h>
@@ -69,6 +69,7 @@ int main(int argc, char** argv)
char c, cport;
char* str;
unsigned int port;
+ int query = 0;
if(argc < 2) {
printf("usage: %s Cvvxx [Cvvxx]\n",argv[0]);
@@ -79,7 +80,8 @@ int main(int argc, char** argv)
printf(" = M|m write vv to MRxx (6555x only)\n");
printf(" = S|s write vv to SRxx\n");
printf(" = X|x write vv to XRxx\n");
- printf(" Both vv and xx are in hexadecimal\n");
+ printf(" xx is in hexadecimal\n");
+ printf(" vv is in hexadecimal or '?' for query\n");
}
if(SET_IOPL())
@@ -131,6 +133,9 @@ int main(int argc, char** argv)
}
index = inb(port);
while (c = *str++){
+ if (c == '?') {
+ query = 1;
+ }
if(c >= '0' && c <= '9')
value = (value << 4) | (c - '0'); /*ASCII assumed*/
else if(c >= 'A' && c < 'G')
@@ -139,10 +144,15 @@ int main(int argc, char** argv)
value = (value << 4) | (c - 'a'+10); /*ASCII assumed*/
}
outb(port,value&0xFF);
- printf("%cR%X: 0x%X -> 0x%X\n", cport, value & 0xFF,
- inb(port+1)&0xFF, (value&0xFF00)>>8);
- outw(port, value);
- outb(port, index &0xFF);
+ if (query) {
+ printf("%cR%X: 0x%X\n", cport, value & 0xFF,
+ inb(port+1)&0xFF);
+ } else {
+ printf("%cR%X: 0x%X -> 0x%X\n", cport, value & 0xFF,
+ inb(port+1)&0xFF, (value&0xFF00)>>8);
+ outw(port, value);
+ outb(port, index &0xFF);
+ }
}
RESET_IOPL();
return 0;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile
index b7fa4ce61..23975fbc2 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile,v 1.27 2000/03/03 01:05:35 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/Imakefile,v 1.28 2000/03/31 22:55:39 dawes Exp $
XCOMM
XCOMM This is an Imakefile for the Cirrus Logic driver.
XCOMM
@@ -93,11 +93,10 @@ InstallModuleManPage(cirrus)
DependTarget()
+InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(CirrusClk.c,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(cir_driver.c,$(DRIVERSDKDIR)/drivers/cirrus)
-InstallDriverSDKNonExecFile(cir_dga.c,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(cir_shadow.c,$(DRIVERSDKDIR)/drivers/cirrus)
-InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(cir.h,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(alp.h,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(alp_driver.c,$(DRIVERSDKDIR)/drivers/cirrus)
@@ -113,5 +112,5 @@ InstallDriverSDKNonExecFile(lg_xaa.c,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKNonExecFile(lg_xaa.h,$(DRIVERSDKDIR)/drivers/cirrus)
InstallDriverSDKObjectModule(cirrus,$(DRIVERSDKMODULEDIR),drivers)
-InstallDriverSDKObjectModule(cirrus_alpine,$(DRIVERSDKMODULEDIR),drivers)
-InstallDriverSDKObjectModule(cirrus_laguna,$(DRIVERSDKMODULEDIR),drivers)
+InstallDriverSDKObjectSubModule(cirrus_alpine,$(DRIVERSDKMODULEDIR),drivers)
+InstallDriverSDKObjectSubModule(cirrus_laguna,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c
index 4513adfa8..2a53879e4 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c
@@ -9,10 +9,7 @@
* Guy DESBIEF
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c,v 1.8 2000/02/27 02:45:26 alanh Exp $ */
-
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/alp_driver.c,v 1.11 2000/06/21 17:28:05 dawes Exp $ */
/* All drivers should typically include these */
#include "xf86.h"
@@ -21,6 +18,9 @@
/* All drivers need this */
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
@@ -87,7 +87,7 @@ static void AlpProbeI2C(int scrnIndex);
* Forward definitions for the functions that make up the driver.
*/
-Bool AlpProbe(int entity, ScrnInfoPtr pScrn);
+ScrnInfoPtr AlpProbe(int entity);
/* Mandatory functions */
@@ -288,9 +288,13 @@ AlpAvailableOptions(int chipid)
return CirOptions;
}
-Bool
-AlpProbe(int entity, ScrnInfoPtr pScrn)
+ScrnInfoPtr
+AlpProbe(int entity)
{
+ ScrnInfoPtr pScrn = NULL;
+
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, entity, CIRPciChipsets,
+ NULL,NULL, NULL, NULL, NULL))) {
pScrn->PreInit = AlpPreInit;
pScrn->ScreenInit = AlpScreenInit;
pScrn->SwitchMode = AlpSwitchMode;
@@ -299,11 +303,9 @@ AlpProbe(int entity, ScrnInfoPtr pScrn)
pScrn->LeaveVT = AlpLeaveVT;
pScrn->FreeScreen = AlpFreeScreen;
pScrn->ValidMode = AlpValidMode;
+ }
- xf86ConfigActivePciEntity(pScrn, entity, CIRPciChipsets, NULL,
- NULL, NULL, NULL, NULL);
-
- return TRUE;
+ return pScrn;
}
@@ -939,7 +941,7 @@ AlpPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pCir->MinClock;
clockRanges->maxClock = pCir->MaxClock;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c
index d7eb3a0c7..3caf7f2f5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c
@@ -9,7 +9,7 @@
* Guy DESBIEF
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c,v 1.54 2000/03/08 21:21:29 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cir_driver.c,v 1.58 2000/04/27 16:26:47 eich Exp $ */
/* All drivers should typically include these */
#include "xf86.h"
@@ -40,8 +40,11 @@ static Bool CIRProbe(DriverPtr drv, int flags);
extern OptionInfoPtr AlpAvailableOptions(int chipid);
extern OptionInfoPtr LgAvailableOptions(int chipid);
-extern Bool AlpProbe(int entity, ScrnInfoPtr pScrn);
-extern Bool LgProbe(int entity, ScrnInfoPtr pScrn);
+extern ScrnInfoPtr AlpProbe(int entity);
+extern ScrnInfoPtr LgProbe(int entity);
+
+static Bool lg_loaded = FALSE;
+static Bool alp_loaded = FALSE;
#define VERSION 4000
#define CIR_NAME "CIRRUS"
@@ -177,142 +180,128 @@ static
OptionInfoPtr
CIRAvailableOptions(int chipid, int busid)
{
- int vendor = (chipid & 0xffff0000) >> 16;
int chip = chipid & 0xffff;
-#if 0
if (chip == PCI_CHIP_GD5462 ||
chip == PCI_CHIP_GD5464 ||
chip == PCI_CHIP_GD5464BD ||
- chip == PCI_CHIP_GD5465)
- if (!lg_loaded) {
- if(!xf86LoadSubModule(pScrn, "cirrus_laguna")) {
- return NULL;
- }
- xf86LoaderReqSymLists(lgSymbols, NULL);
- lg_loaded = TRUE;
- }
- return LgAvailableOptions(chipid);
+ chip == PCI_CHIP_GD5465) {
+ if (lg_loaded)
+ return LgAvailableOptions(chipid);
+ else
+ return NULL;
} else {
- if (!alp_loaded) {
- if (!xf86LoadSubModule(pScrn, "cirrus_alpine")) {
- return NULL;
- }
- xf86LoaderReqSymLists(alpSymbols, NULL);
- alp_loaded = TRUE;
- }
- return AlpAvailableOptions(chipid);
+ if (alp_loaded)
+ return AlpAvailableOptions(chipid);
+ else
+ return NULL;
}
-#else
- return NULL;
-#endif
}
-/* Mandatory */
static Bool
CIRProbe(DriverPtr drv, int flags)
{
- int i;
- GDevPtr *devSections = NULL;
- pciVideoPtr pPci;
- int *usedChips;
- int numDevSections;
- int numUsed;
- Bool foundScreen = FALSE;
- Bool (*subProbe)(int entity, ScrnInfoPtr pScrn);
- Bool lg_loaded = FALSE;
- Bool alp_loaded = FALSE;
+ int i;
+ GDevPtr *devSections = NULL;
+ pciVideoPtr pPci;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ ScrnInfoPtr (*subProbe)(int entity);
+ ScrnInfoPtr pScrn;
+
#ifdef CIR_DEBUG
- ErrorF("CirProbe\n");
+ ErrorF("CirProbe\n");
#endif
-
- if ((numDevSections = xf86MatchDevice(CIR_DRIVER_NAME,
- &devSections)) <= 0) {
- return FALSE;
+
+ /*
+ * For PROBE_DETECT, make sure both sub-modules are loaded before
+ * calling xf86MatchPciInstances(), because the AvailableOptions()
+ * functions may be called before xf86MatchPciInstances() returns.
+ */
+
+ if (flags & PROBE_DETECT) {
+ if (!lg_loaded) {
+ if (xf86LoadDrvSubModule(drv, "cirrus_laguna")) {
+ xf86LoaderReqSymLists(lgSymbols, NULL);
+ lg_loaded = TRUE;
+ }
}
+ if (!alp_loaded) {
+ if (xf86LoadDrvSubModule(drv, "cirrus_alpine")) {
+ xf86LoaderReqSymLists(alpSymbols, NULL);
+ alp_loaded = TRUE;
+ }
+ }
+ }
+ if ((numDevSections = xf86MatchDevice(CIR_DRIVER_NAME,
+ &devSections)) <= 0) {
+ return FALSE;
+ }
+
+ if (xf86GetPciVideoInfo() == NULL) {
/*
- * While we're VGA-dependent, can really only have one such instance, but
- * we'll ignore that.
- */
-
- /*
- * We need to probe the hardware first. We then need to see how this
- * fits in with what is given in the config file, and allow the config
- * file info to override any contradictions.
- */
-
- /*
- * All of the cards this driver supports are PCI, so the "probing" just
- * amounts to checking the PCI data that the server has already collected.
+ * We won't let anything in the config file override finding no
+ * PCI video cards at all. This seems reasonable now, but we'll see.
*/
- if (xf86GetPciVideoInfo() == NULL) {
- /*
- * We won't let anything in the config file override finding no
- * PCI video cards at all. This seems reasonable now, but we'll see.
- */
- return FALSE;
- }
-
- numUsed = xf86MatchPciInstances(CIR_NAME, PCI_VENDOR_CIRRUS,
- CIRChipsets, CIRPciChipsets, devSections,
- numDevSections, drv, &usedChips);
- /* Free it since we don't need that list after this */
- if (devSections)
- xfree(devSections);
- devSections = NULL;
- if (numUsed <= 0)
- return FALSE;
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
-
- /* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = CIR_DRIVER_NAME;
- pScrn->name = CIR_NAME;
- pScrn->Probe = NULL;
- /* The Laguna family of chips is so different from the Alpine
- family that we won't share even the highest-level of
- functions. But, the Laguna chips /are/ Cirrus chips, so
- they should be handled in this driver (as opposed to their
- own driver). */
- pPci = xf86GetPciInfoForEntity(usedChips[i]);
- if (pPci->chipType == PCI_CHIP_GD5462 ||
- pPci->chipType == PCI_CHIP_GD5464 ||
- pPci->chipType == PCI_CHIP_GD5464BD ||
- pPci->chipType == PCI_CHIP_GD5465) {
-
- if (!lg_loaded) {
- if(!xf86LoadSubModule(pScrn, "cirrus_laguna")) {
- xf86DeleteScreen(pScrn->scrnIndex, 0);
- continue;
- }
- xf86LoaderReqSymLists(lgSymbols, NULL);
- lg_loaded = TRUE;
- }
- subProbe = LgProbe;
- } else {
- if (!alp_loaded) {
- if (!xf86LoadSubModule(pScrn, "cirrus_alpine")) {
- xf86DeleteScreen(pScrn->scrnIndex, 0);
- continue;
- }
- xf86LoaderReqSymLists(alpSymbols, NULL);
- alp_loaded = TRUE;
- }
- subProbe = AlpProbe;
- }
- if (subProbe(usedChips[i], pScrn))
- foundScreen = TRUE;
- }
- xfree(usedChips);
-
- return foundScreen;
+ return FALSE;
+ }
+
+ numUsed = xf86MatchPciInstances(CIR_NAME, PCI_VENDOR_CIRRUS,
+ CIRChipsets, CIRPciChipsets, devSections,
+ numDevSections, drv, &usedChips);
+ /* Free it since we don't need that list after this */
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ /* The Laguna family of chips is so different from the Alpine
+ family that we won't share even the highest-level of
+ functions. But, the Laguna chips /are/ Cirrus chips, so
+ they should be handled in this driver (as opposed to their
+ own driver). */
+ pPci = xf86GetPciInfoForEntity(usedChips[i]);
+ if (pPci->chipType == PCI_CHIP_GD5462 ||
+ pPci->chipType == PCI_CHIP_GD5464 ||
+ pPci->chipType == PCI_CHIP_GD5464BD ||
+ pPci->chipType == PCI_CHIP_GD5465) {
+
+ if (!lg_loaded) {
+ if (!xf86LoadDrvSubModule(drv, "cirrus_laguna"))
+ continue;
+ xf86LoaderReqSymLists(lgSymbols, NULL);
+ lg_loaded = TRUE;
+ }
+ subProbe = LgProbe;
+ } else {
+ if (!alp_loaded) {
+ if (!xf86LoadDrvSubModule(drv, "cirrus_alpine"))
+ continue;
+ xf86LoaderReqSymLists(alpSymbols, NULL);
+ alp_loaded = TRUE;
+ }
+ subProbe = AlpProbe;
+ }
+ pScrn = NULL;
+
+ if ((pScrn = subProbe(usedChips[i]))) {
+ foundScreen = TRUE;
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = CIR_DRIVER_NAME;
+ pScrn->name = CIR_NAME;
+ pScrn->Probe = NULL;
+ }
+ }
+ xfree(usedChips);
+
+ return foundScreen;
}
/*
@@ -331,12 +320,15 @@ CirMapMem(CirPtr pCir, int scrnIndex)
/*
* Map the frame buffer.
*/
-
- pCir->FbBase = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER, pCir->PciTag,
- pCir->FbAddress, pCir->FbMapSize);
- if (pCir->FbBase == NULL)
+ if (pCir->FbMapSize) {
+
+ pCir->FbBase = xf86MapPciMem(scrnIndex, VIDMEM_FRAMEBUFFER,
+ pCir->PciTag, pCir->FbAddress,
+ pCir->FbMapSize);
+ if (pCir->FbBase == NULL)
return FALSE;
-
+ }
+
#ifdef CIR_DEBUG
ErrorF("CirMapMem pCir->FbBase=0x%08x\n", pCir->FbBase);
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp
index a5c29e047..d6cf0dea1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp,v 1.1 2000/03/03 01:05:35 dawes Exp $
-.TH CIRRUS __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/cirrus.cpp,v 1.4 2000/06/14 02:13:08 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH CIRRUS __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
cirrus \- Cirrus Logic video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""cirrus"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qcirrus\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B cirrus
is an XFree86 driver for Cirrus Logic video chips.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c
index 2c253390e..78e3ddada 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c
@@ -13,12 +13,10 @@
* David Dawes, Andrew E. Mileski, Leonard N. Zubkoff,
* Guy DESBIEF, Itai Nahshon.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c,v 1.24 2000/02/27 02:45:26 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cirrus/lg_driver.c,v 1.30 2000/06/21 17:28:05 dawes Exp $ */
#define EXPERIMENTAL
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -26,6 +24,8 @@
/* All drivers need this */
#include "xf86_ansic.h"
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
@@ -80,7 +80,7 @@
* Forward definitions for the functions that make up the driver.
*/
-Bool LgProbe(int entity, ScrnInfoPtr pScrn);
+ScrnInfoPtr LgProbe(int entity);
/* Mandatory functions */
Bool LgPreInit(ScrnInfoPtr pScrn, int flags);
@@ -285,8 +285,6 @@ lgSetup(pointer module, pointer opts, int *errmaj, int *errmin)
{
static Bool setupDone = FALSE;
- ErrorF("lgSetup\n");
-
if (!setupDone) {
setupDone = TRUE;
LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols,
@@ -304,22 +302,22 @@ LgAvailableOptions(int chipid)
return LgOptions;
}
-Bool
-LgProbe(int entity, ScrnInfoPtr pScrn)
+ScrnInfoPtr
+LgProbe(int entity)
{
- pScrn->PreInit = LgPreInit;
- pScrn->ScreenInit = LgScreenInit;
- pScrn->SwitchMode = LgSwitchMode;
- pScrn->AdjustFrame = LgAdjustFrame;
- pScrn->EnterVT = LgEnterVT;
- pScrn->LeaveVT = LgLeaveVT;
- pScrn->FreeScreen = LgFreeScreen;
- pScrn->ValidMode = LgValidMode;
-
- xf86ConfigActivePciEntity(pScrn, entity, CIRPciChipsets, NULL,
- NULL, NULL, NULL, NULL);
-
- return TRUE;
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, entity, CIRPciChipsets,
+ NULL, NULL, NULL, NULL, NULL))) {
+ pScrn->PreInit = LgPreInit;
+ pScrn->ScreenInit = LgScreenInit;
+ pScrn->SwitchMode = LgSwitchMode;
+ pScrn->AdjustFrame = LgAdjustFrame;
+ pScrn->EnterVT = LgEnterVT;
+ pScrn->LeaveVT = LgLeaveVT;
+ pScrn->FreeScreen = LgFreeScreen;
+ pScrn->ValidMode = LgValidMode;
+ }
+ return pScrn;
}
@@ -640,6 +638,34 @@ LgPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n",
(unsigned long)pCir->IOAddress);
+ /*
+ * If the user has specified the amount of memory in the XF86Config
+ * file, we respect that setting.
+ */
+ if (pCir->pEnt->device->videoRam != 0) {
+ pScrn->videoRam = pCir->pEnt->device->videoRam;
+ from = X_CONFIG;
+ } else {
+ pScrn->videoRam = LgCountRam(pScrn);
+ from = X_PROBED;
+ }
+ if (2048 == pScrn->videoRam) {
+ /* Two-way interleaving */
+ pCir->chip.lg->memInterleave = 0x40;
+ } else if (4096 == pScrn->videoRam || 8192 == pScrn->videoRam) {
+ /* Four-way interleaving */
+ pCir->chip.lg->memInterleave = 0x80;
+ } else {
+ /* One-way interleaving */
+ pCir->chip.lg->memInterleave = 0x00;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
+ pScrn->videoRam);
+
+ pCir->FbMapSize = pScrn->videoRam * 1024;
+ pCir->IoMapSize = 0x4000; /* 16K for moment, will increase */
+
pScrn->racIoFlags = RAC_COLORMAP
#ifndef EXPERIMENTAL
| RAC_VIEWPORT
@@ -715,34 +741,6 @@ LgPreInit(ScrnInfoPtr pScrn, int flags)
pCir->HWCursor = FALSE;
}
- /*
- * If the user has specified the amount of memory in the XF86Config
- * file, we respect that setting.
- */
- if (pCir->pEnt->device->videoRam != 0) {
- pScrn->videoRam = pCir->pEnt->device->videoRam;
- from = X_CONFIG;
- } else {
- pScrn->videoRam = LgCountRam(pScrn);
- from = X_PROBED;
- }
- if (2048 == pScrn->videoRam) {
- /* Two-way interleaving */
- pCir->chip.lg->memInterleave = 0x40;
- } else if (4096 == pScrn->videoRam || 8192 == pScrn->videoRam) {
- /* Four-way interleaving */
- pCir->chip.lg->memInterleave = 0x80;
- } else {
- /* One-way interleaving */
- pCir->chip.lg->memInterleave = 0x00;
- }
-
- xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
- pScrn->videoRam);
-
- pCir->FbMapSize = pScrn->videoRam * 1024;
- pCir->IoMapSize = 0x4000; /* 16K for moment, will increase */
-
/* We use a programamble clock */
pScrn->progClock = TRUE;
@@ -806,7 +804,7 @@ LgPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pCir->MinClock;
clockRanges->maxClock = pCir->MaxClock;
@@ -1369,10 +1367,6 @@ LgScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#endif
vgaHWGetIOBase(hwp);
- /* Map the CIR memory and MMIO areas */
- if (!CirMapMem(pCir, pScrn->scrnIndex))
- return FALSE;
-
/* Save the current state */
LgSave(pScrn);
@@ -1903,13 +1897,13 @@ LgDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
static void
mmioWriteCrtc(vgaHWPtr hwp, CARD8 index, CARD8 value)
{
- moutb(index << 4, value);
+ moutb(index << 2, value);
}
static CARD8
mmioReadCrtc(vgaHWPtr hwp, CARD8 index)
{
- return minb(index << 4);
+ return minb(index << 2);
}
static void
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile
index 2bc25102b..6f3dfc6f7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile,v 1.2 2000/03/03 01:05:35 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/Imakefile,v 1.3 2000/03/31 22:55:41 dawes Exp $
XCOMM
XCOMM This is an Imakefile for the CYRIX driver.
XCOMM
@@ -9,12 +9,16 @@ XCOMM
SRCS = cyrix_driver.c cyrix_accel.c cyrix_bank.c cyrix_helper.c
OBJS = cyrix_driver.o cyrix_accel.o cyrix_bank.o cyrix_helper.o
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \
-I$(SERVERSRC)/fb -I$(SERVERSRC)/mi -I$(XF86SRC)/i2c \
-I$(XF86SRC)/xaa -I$(XF86SRC)/rac \
-I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/ramdac \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-I$(XTOP)/include/extensions
+#endif
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
@@ -32,3 +36,13 @@ InstallModuleManPage(cyrix)
#endif
DependTarget()
+
+InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/cyrix)
+InstallDriverSDKNonExecFile(cyrix.h,$(DRIVERSDKDIR)/drivers/cyrix)
+InstallDriverSDKNonExecFile(cyrix_accel.c,$(DRIVERSDKDIR)/drivers/cyrix)
+InstallDriverSDKNonExecFile(cyrix_bank.c,$(DRIVERSDKDIR)/drivers/cyrix)
+InstallDriverSDKNonExecFile(cyrix_driver.c,$(DRIVERSDKDIR)/drivers/cyrix)
+InstallDriverSDKNonExecFile(cyrix_helper.c,$(DRIVERSDKDIR)/drivers/cyrix)
+
+InstallDriverSDKObjectModule(cyrix,$(DRIVERSDKMODULEDIR),drivers)
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp
index b88b832ac..e9c6ecb70 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp,v 1.1 2000/03/03 01:05:36 dawes Exp $
-.TH CYRIX __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.cpp,v 1.4 2000/06/14 02:13:08 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH CYRIX __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
cyrix \- Cyrix video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""cyrix"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qcyrix\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B cyrix
is an XFree86 driver for Cyrix video chips.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h
index 332f26337..ff0ba00d8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h
@@ -26,7 +26,7 @@
* Dirk H. Hohndel (hohndel@suse.de),
* Portions: the GGI project & confidential CYRIX databooks.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h,v 1.1 2000/02/13 00:56:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix.h,v 1.2 2000/04/19 16:57:43 eich Exp $ */
#ifndef _CYRIX_H_
#define _CYRIX_H_
@@ -89,7 +89,12 @@ typedef struct {
/* struct for the server */
CARD32 IOAccelAddress;
CARD32 FbAddress;
- EntityInfoPtr pEnt;
+ char* GXregisters;
+ int CYRIXcursorAddress; /* relative to fb base */
+ int CYRIXbltBuf0Address;/*relative to GXregisters*/
+ int CYRIXbltBuf1Address;
+ int CYRIXbltBufSize;
+ EntityInfoPtr pEnt;
unsigned char * FbBase;
pciVideoPtr PciInfo;
XAAInfoRecPtr AccelInfoRec;
@@ -111,6 +116,14 @@ typedef struct {
Bool IsCyber;
Bool NewClockCode;
Bool NoAccel;
+ /* accel stuff */
+ int bltBufWidth;
+ int blitMode;
+ int vectorMode;
+ int transMode;
+ int copyXdir;
+ int setBlitModeOnSync;
+
} CYRIXPrivate, *CYRIXPrvPtr;
typedef struct {
@@ -125,24 +138,13 @@ extern int CyrixInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
extern void CyrixRestore(ScrnInfoPtr pScrn, CYRIXRegPtr cyrixReg);
extern void * CyrixSave(ScrnInfoPtr pScrn, CYRIXRegPtr cyrixReg);
-/* externs in cyrix_driver.c */
-extern char* GXregisters;
-extern int CYRIXisOldChipRevision;
-
-extern int CYRIXcursorAddress; /* relative to frame buffer base */
-extern int CYRIXoffscreenAddress;
-extern int CYRIXoffscreenSize;
-
-extern int CYRIXbltBuf0Address; /* relative to GXregisters */
-extern int CYRIXbltBuf1Address;
-extern int CYRIXbltBufSize;
/* externs in cyrix_asm.s */
extern void CYRIXsetBlitBuffers(void);
extern void CYRIXsetBlitBuffersOnOldChip(void);
/* 32 bit access to GX registers */
-#define GX_REG(a) (*(volatile CARD32*)(GXregisters + (a)))
+#define GX_REG(a) (*(volatile CARD32*)(pCyrix->GXregisters + (a)))
/* externs in cyrix_accel.c */
@@ -187,10 +189,10 @@ extern void CYRIXAccelInit(ScreenPtr);
GX_REG(GP_RASTER_MODE) = ((pm) | RM_CLIP_ENABLE | 0xC6);
#define CYRIXsetBlitMode() \
- GX_REG(GP_BLIT_MODE) = (blitMode)
+ GX_REG(GP_BLIT_MODE) = (pCyrix->blitMode)
#define CYRIXsetVectorMode() \
- GX_REG(GP_VECTOR_MODE) = (vectorMode)
+ GX_REG(GP_VECTOR_MODE) = (pCyrix->vectorMode)
#define IfDest(rop, planemask, val) \
(( (((rop) & 0x5) ^ (((rop) & 0xA) >> 1)) \
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c
index b818821a8..77fa3f35d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c
@@ -26,7 +26,7 @@
* Dirk H. Hohndel (hohndel@suse.de),
* Portions: the GGI project & confidential CYRIX databooks.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c,v 1.2 2000/02/14 19:20:48 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_accel.c,v 1.3 2000/04/19 16:57:43 eich Exp $ */
#include "vgaHW.h"
#include "xf86.h"
@@ -58,14 +58,8 @@ static const int windowsROPsrcMask[16] = { 0x22, 0xA2, 0x62, 0xE2,
0x26, 0xA6, 0x66, 0xE6,
0x2E, 0xAE, 0x6E, 0xEE };
-static int bltBufWidth;
-
-static int blitMode;
-static int vectorMode;
-static int transMode;
-static int copyXdir;
-static int setBlitModeOnSync = 0;
-
+#if 0
+#endif
/* Forward declaration of functions used in the driver */
void CYRIXAccelSync(ScrnInfoPtr pScrn);
@@ -77,8 +71,9 @@ void CYRIXSetupForScreenToScreenCopy(ScrnInfoPtr, int xdir, int ydir,
int rop, unsigned int planemask, int transparency_color);
void CYRIXSubsequentScreenToScreenCopy(ScrnInfoPtr, int x1, int y1, int x2,
int y2, int w, int h);
-void CYRIXSubsequentBresenhamLine(int x1, int y1, int octant, int err,
- int e1, int e2, int length);
+void CYRIXSubsequentBresenhamLine(ScrnInfoPtr pScrn,int x1, int y1,
+ int e1, int e2, int err, int length,
+ int octant);
void CYRIXSetupForColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx,
int patterny, int rop, unsigned int planemask, int transparency_color);
void CYRIXSubsequentColor8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx,
@@ -89,7 +84,6 @@ void CYRIXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x,
int y, int w, int h, int skipleft);
void InitPixmapCache(ScreenPtr pScreen, RegionPtr areas, pointer data);
/* Info Rec for all these routines to use */
-static XAAInfoRecPtr localRecPtr;
/* Acceleration init function, sets up pointers to our accelerated functions */
void
@@ -98,6 +92,7 @@ CYRIXAccelInit(ScreenPtr pScreen)
CYRIXPrvPtr pCyrix;
ScrnInfoPtr pScrn;
+ XAAInfoRecPtr localRecPtr;
pScrn = xf86Screens[pScreen->myNum];
pCyrix = CYRIXPTR(pScrn);
@@ -152,9 +147,9 @@ CYRIXAccelInit(ScreenPtr pScreen)
bug if we don't give XAA enough room, but the only thing that
seems to make it work properly) */
localRecPtr->ColorExpandBase =
- (unsigned char*)(GXregisters + CYRIXbltBuf0Address);
+ (unsigned char*)(pCyrix->GXregisters + pCyrix->CYRIXbltBuf0Address);
localRecPtr->ColorExpandRange =
- CYRIXbltBufSize * 2;
+ pCyrix->CYRIXbltBufSize * 2;
localRecPtr->SetupForCPUToScreenColorExpandFill =
CYRIXSetupForCPUToScreenColorExpandFill;
@@ -162,14 +157,16 @@ CYRIXAccelInit(ScreenPtr pScreen)
CYRIXSubsequentCPUToScreenColorExpandFill;
/* calculate the pixel width of a blit buffer for convenience */
- bltBufWidth = CYRIXbltBufSize / (pScrn->bitsPerPixel / 8);
+ pCyrix->bltBufWidth = pCyrix->CYRIXbltBufSize / (pScrn->bitsPerPixel / 8);
}
/* set colors - called through access macros in cyrix.h */
static __inline__ void CYRIXsetColors01(ScrnInfoPtr pScrn, int reg,
- int col0, int col1)
-{ if (pScrn->bitsPerPixel == 16)
+ int col0, int col1) {
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+
+ if (pScrn->bitsPerPixel == 16)
GX_REG(reg) = ((col1 & 0xFFFF) << 16) | (col0 & 0xFFFF);
else
{ col0 &= 0xFF;
@@ -183,8 +180,11 @@ static __inline__ void CYRIXsetColors01(ScrnInfoPtr pScrn, int reg,
directly). */
void
CYRIXAccelSync(ScrnInfoPtr pScrn)
-{ if (setBlitModeOnSync)
- { setBlitModeOnSync = 0;
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+
+ if (pCyrix->setBlitModeOnSync)
+ { pCyrix->setBlitModeOnSync = 0;
CYRIXsetupSync();
CYRIXsetBlitMode();
}
@@ -211,9 +211,9 @@ unsigned int planemask;
CYRIXsetSourceColors01(pScrn, color, color);
CYRIXsetPatColors01(pScrn, planemask, 0);
CYRIXsetPatMode(rop, RM_PAT_DISABLE);
- blitMode = BM_READ_SRC_NONE | BM_WRITE_FB | BM_SOURCE_EXPAND
- | IfDest(rop, planemask, BM_READ_DST_FB0);
- vectorMode = IfDest(rop, planemask, VM_READ_DST_FB);
+ pCyrix->blitMode = BM_READ_SRC_NONE | BM_WRITE_FB | BM_SOURCE_EXPAND
+ | IfDest(rop, planemask, BM_READ_DST_FB0);
+ pCyrix->vectorMode = IfDest(rop, planemask, VM_READ_DST_FB);
}
@@ -221,12 +221,16 @@ void
CYRIXSubsequentSolidFillRect(pScrn, x, y, w, h)
ScrnInfoPtr pScrn;
int x, y, w, h;
-{ /* divide the operation into columns if required; use twice the
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+
+ /* divide the operation into columns if required; use twice the
blit buffer width because buffer 0 will overflow into buffer 1 */
- while (w > 2 * bltBufWidth)
- { CYRIXSubsequentSolidFillRect(pScrn, x, y, 2 * bltBufWidth, h);
- x += 2 * bltBufWidth;
- w -= 2 * bltBufWidth;
+ while (w > 2 * pCyrix->bltBufWidth)
+ { CYRIXSubsequentSolidFillRect(pScrn, x, y,
+ 2 * pCyrix->bltBufWidth, h);
+ x += 2 * pCyrix->bltBufWidth;
+ w -= 2 * pCyrix->bltBufWidth;
}
CYRIXsetupSync();
CYRIXsetDstXY(x, y);
@@ -260,11 +264,11 @@ int transparency_color;
if (transparency_color == -1)
{ CYRIXsetPatMode(rop, RM_PAT_DISABLE);
- transMode = 0;
+ pCyrix->transMode = 0;
}
else
{ CYRIXsetPatModeTrans(RM_PAT_DISABLE);
- transMode = 1;
+ pCyrix->transMode = 1;
if (pCyrix->AccelInfoRec->CopyAreaFlags &
TRANSPARENCY_GXCOPY_ONLY)
@@ -272,48 +276,50 @@ int transparency_color;
/* fill blit buffer 1 with the transparency color */
if (pScrn->bitsPerPixel == 16)
- { int k = CYRIXbltBufSize / 4;
+ { int k = pCyrix->CYRIXbltBufSize / 4;
CARD32 val = (transparency_color << 16) |
transparency_color;
- volatile CARD32* buf = &(GX_REG(CYRIXbltBuf1Address));
+ volatile CARD32* buf = &(GX_REG(pCyrix->CYRIXbltBuf1Address));
while (--k >= 0) buf[k] = val;
}
else
- memset(GXregisters + CYRIXbltBuf1Address,
- transparency_color, CYRIXbltBufSize);
+ memset(pCyrix->GXregisters + pCyrix->CYRIXbltBuf1Address,
+ transparency_color, pCyrix->CYRIXbltBufSize);
}
- blitMode = BM_READ_SRC_FB | BM_WRITE_FB | BM_SOURCE_COLOR
- | (transMode ? BM_READ_DST_NONE : IfDest(rop, planemask, BM_READ_DST_FB1))
- | (ydir < 0 ? BM_REVERSE_Y : 0);
+ pCyrix->blitMode = BM_READ_SRC_FB | BM_WRITE_FB | BM_SOURCE_COLOR
+ | (pCyrix->transMode ? BM_READ_DST_NONE : IfDest(rop, planemask, BM_READ_DST_FB1))
+ | (ydir < 0 ? BM_REVERSE_Y : 0);
- copyXdir = xdir;
+ pCyrix->copyXdir = xdir;
}
void
CYRIXSubsequentScreenToScreenCopy(pScrn, x1, y1, x2, y2, w, h)
ScrnInfoPtr pScrn;
int x1, y1, x2, y2, w, h;
-{ int up = (blitMode & BM_REVERSE_Y);
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+ int up = (pCyrix->blitMode & BM_REVERSE_Y);
/* divide the operation into columns when necessary */
- if (copyXdir < 0)
- { int x_offset = w - bltBufWidth;
+ if (pCyrix->copyXdir < 0)
+ { int x_offset = w - pCyrix->bltBufWidth;
while (x_offset > 0)
{ CYRIXSubsequentScreenToScreenCopy(pScrn, x1 + x_offset, y1,
x2 + x_offset, y2,
- bltBufWidth, h);
- x_offset -= bltBufWidth;
- w -= bltBufWidth;
+ pCyrix->bltBufWidth, h);
+ x_offset -= pCyrix->bltBufWidth;
+ w -= pCyrix->bltBufWidth;
} }
- else while (w > bltBufWidth)
+ else while (w > pCyrix->bltBufWidth)
{ CYRIXSubsequentScreenToScreenCopy(pScrn, x1, y1, x2, y2,
- bltBufWidth, h);
- x1 += bltBufWidth;
- x2 += bltBufWidth;
- w -= bltBufWidth;
+ pCyrix->bltBufWidth, h);
+ x1 += pCyrix->bltBufWidth;
+ x2 += pCyrix->bltBufWidth;
+ w -= pCyrix->bltBufWidth;
}
CYRIXsetupSync();
@@ -323,8 +329,8 @@ int x1, y1, x2, y2, w, h;
/* in transparent mode, one line reads the transparency color
into a processor-internal register, and the remaining lines
can be done in a single second pass */
- if (transMode)
- { blitMode |= BM_READ_DST_BB1;
+ if (pCyrix->transMode)
+ { pCyrix->blitMode |= BM_READ_DST_BB1;
CYRIXsetWH(w, 1);
CYRIXsetBlitMode();
h--;
@@ -332,7 +338,7 @@ int x1, y1, x2, y2, w, h;
if (up) { y1--; y2--; }
else { y1++; y2++; }
CYRIXsetupSync();
- blitMode &= ~(BM_READ_DST_BB1);
+ pCyrix->blitMode &= ~(BM_READ_DST_BB1);
}
CYRIXsetWH(w, h);
CYRIXsetBlitMode();
@@ -341,24 +347,26 @@ int x1, y1, x2, y2, w, h;
/* Bresenham lines */
void
-CYRIXSubsequentBresenhamLine(x1, y1, octant, err, e1, e2, length)
-int x1, y1, octant, err, e1, e2, length;
-{ if (octant & YMAJOR)
- { vectorMode = (vectorMode & VM_READ_DST_FB) | VM_Y_MAJOR;
- if (!(octant & XDECREASING)) vectorMode |= VM_MINOR_INC;
- if (!(octant & YDECREASING)) vectorMode |= VM_MAJOR_INC;
- }
- else
- { vectorMode = (vectorMode & VM_READ_DST_FB) | VM_X_MAJOR;
- if (!(octant & XDECREASING)) vectorMode |= VM_MAJOR_INC;
- if (!(octant & YDECREASING)) vectorMode |= VM_MINOR_INC;
- }
-
- CYRIXsetupSync();
- CYRIXsetDstXY(x1, y1);
- CYRIXsetWH(length, (err & 0xFFFF));
- CYRIXsetSrcXY((e1 & 0xFFFF), (e2 & 0xFFFF));
- CYRIXsetVectorMode();
+CYRIXSubsequentBresenhamLine(pScrn, x1, y1, e1, e2, err, length, octant)
+ScrnInfoPtr pScrn; int x1, y1, octant, err, e1, e2, length;
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+
+ if (octant & YMAJOR) {
+ pCyrix->vectorMode = (pCyrix->vectorMode & VM_READ_DST_FB) | VM_Y_MAJOR;
+ if (!(octant & XDECREASING)) pCyrix->vectorMode |= VM_MINOR_INC;
+ if (!(octant & YDECREASING)) pCyrix->vectorMode |= VM_MAJOR_INC;
+ } else {
+ pCyrix->vectorMode = (pCyrix->vectorMode & VM_READ_DST_FB) | VM_X_MAJOR;
+ if (!(octant & XDECREASING)) pCyrix->vectorMode |= VM_MAJOR_INC;
+ if (!(octant & YDECREASING)) pCyrix->vectorMode |= VM_MINOR_INC;
+ }
+
+ CYRIXsetupSync();
+ CYRIXsetDstXY(x1, y1);
+ CYRIXsetWH(length, (err & 0xFFFF));
+ CYRIXsetSrcXY((e1 & 0xFFFF), (e2 & 0xFFFF));
+ CYRIXsetVectorMode();
}
@@ -370,7 +378,9 @@ int patternx, patterny;
int rop, transparency_color;
unsigned int planemask;
{
-
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+ XAAInfoRecPtr localRecPtr = pCyrix->AccelInfoRec;
+
if (localRecPtr->Color8x8PatternFillFlags & NO_PLANEMASK)
planemask = 0xFFFF;
if ((transparency_color == -1) && (localRecPtr->Color8x8PatternFillFlags &
@@ -384,7 +394,7 @@ unsigned int planemask;
CYRIXsetPatModeX(rop, RM_PAT_MONO | ((transparency_color == -1) ?
RM_PAT_TRANSPARENT : 0));
- blitMode = BM_READ_SRC_NONE | BM_WRITE_FB | BM_SOURCE_EXPAND |
+ pCyrix->blitMode = BM_READ_SRC_NONE | BM_WRITE_FB | BM_SOURCE_EXPAND |
((transparency_color == -1) ?
IfDest(rop, planemask, BM_READ_DST_FB0) : BM_READ_DST_NONE);
}
@@ -402,7 +412,11 @@ void CYRIXSetupForCPUToScreenColorExpandFill(pScrn, fg, bg, rop, planemask)
ScrnInfoPtr pScrn;
int bg, fg, rop;
unsigned int planemask;
-{ int trans = (bg == -1);
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+ XAAInfoRecPtr localRecPtr = pCyrix->AccelInfoRec;
+
+ int trans = (bg == -1);
if (trans && (localRecPtr->CPUToScreenColorExpandFillFlags &
TRANSPARENCY_GXCOPY_ONLY))
@@ -418,20 +432,22 @@ unsigned int planemask;
for the text source bitmap, so READ_DST_FB1 should not be
used. So far, this problem has not manifested itself in
practice. */
- blitMode = BM_READ_SRC_BB0 | BM_WRITE_FB | BM_SOURCE_EXPAND
- | (trans ? IfDest(rop, planemask, BM_READ_DST_FB1) : BM_READ_DST_NONE);
+ pCyrix->blitMode = BM_READ_SRC_BB0 | BM_WRITE_FB | BM_SOURCE_EXPAND
+ | (trans ? IfDest(rop, planemask, BM_READ_DST_FB1) : BM_READ_DST_NONE);
}
void CYRIXSubsequentCPUToScreenColorExpandFill(pScrn, x, y, w, h, skipleft)
ScrnInfoPtr pScrn;
int x, y, w, h;
int skipleft;
-{ CYRIXsetupSync();
- CYRIXsetSrcXY(0, 0);
- CYRIXsetDstXY(x, y);
- CYRIXsetWH(w, h);
-
- CYRIXAccelSync(pScrn);
- setBlitModeOnSync = 1;
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+ CYRIXsetupSync();
+ CYRIXsetSrcXY(0, 0);
+ CYRIXsetDstXY(x, y);
+ CYRIXsetWH(w, h);
+
+ CYRIXAccelSync(pScrn);
+ pCyrix->setBlitModeOnSync = 1;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c
index 40a61e271..95659094f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c
@@ -26,7 +26,7 @@
* Dirk H. Hohndel (hohndel@suse.de),
* Portions: the GGI project & confidential CYRIX databooks.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c,v 1.6 2000/03/01 16:01:07 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_driver.c,v 1.9 2000/06/21 17:28:06 dawes Exp $ */
#include "compiler.h"
#include "fb.h"
@@ -78,7 +78,9 @@ static int CYRIXValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
int flags);
/* Internally used functions */
+#if 0
static void CYRIXEnterLeave(Bool enter);
+#endif
static void CYRIXSave(ScrnInfoPtr pScrn);
static void CYRIXRestore(ScrnInfoPtr pScrn);
static Bool CYRIXModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
@@ -164,24 +166,8 @@ static const char *racSymbols[] = {
NULL
};
-unsigned long vgaIOBase;
-CARD32 physbase, padsize;
-
/* access to the MediaGX video hardware registers */
-char* GXregisters;
-
-int CYRIXcbufferAddress; /* relative to video base */
-int CYRIXoffscreenAddress;
-int CYRIXcursorAddress;
-int CYRIXcbLineDelta; /* DWORDS */
-int CYRIXoffscreenSize; /* bytes */
-
-int CYRIXbltBuf0Address; /* relative to GXregisters */
-int CYRIXbltBuf1Address;
-int CYRIXbltBufSize;
-
-int CYRIXisOldChipRevision;
/* DEBUG variables & flags */
#define ENTER TRUE
@@ -313,9 +299,7 @@ static Bool
CYRIXProbe(DriverPtr drv, int flags)
{
int i, numDevSections, numUsed, *usedChips;
- unsigned char gcr;
GDevPtr *devSections;
- int device_step, device_revision;
ScrnInfoPtr pScrn;
/*
@@ -348,101 +332,33 @@ CYRIXProbe(DriverPtr drv, int flags)
if (numUsed <= 0)
return FALSE;
- /* use register probing to decide whether the chip is
- * `suitable' for us.
- */
- vgaIOBase = VGAHW_GET_IOBASE();
-
- /* the lock register should read 0xFF after we have
- written 0x00 to lock */
- outb(vgaIOBase + 4, CrtcExtendedRegisterLock);
- outb(vgaIOBase + 5, 0x00);
-
- if (inb(vgaIOBase + 5) != 0xFF) goto probeFailed;
-
- /* the lock register should read 0x00 after we have
- writen the magic word 'WL' to unlock */
- outb(vgaIOBase + 5, 0x57);
- outb(vgaIOBase + 5, 0x4C);
-
- /* GGI's idea to do two comparisons */
- if (inb(vgaIOBase + 5) != 0x00) goto probeFailed;
- if (inb(vgaIOBase + 5) != 0x00)
- { probeFailed:
- CYRIXEnterLeave(LEAVE);
- return (FALSE);
- }
- /* OK, it's most likely a MediaGX. Now check the scratchpad
- * size. If it is zero, we're not using the MediaGX graphics
- * facilities.
- */
- outb(GX_IOPORT_INDEX, GX_IOIDX_DIR0); /* doesn't work w/o that */
- outb(GX_IOPORT_INDEX, GX_IOIDX_GCR);
- gcr = inb(GX_IOPORT_DATA);
-
- physbase = (gcr & 3) << 30;
- padsize = (gcr & 12) ? (((gcr & 12) >> 2) + 1) : 0;
-
-
- /* end GGI MediaGX driver based code */
- if (padsize == 0) return (FALSE);
-
- if (flags & PROBE_DETECT)
- return TRUE;
-
- xf86ErrorF("%s: GX_BASE: 0x%x\n",CYRIX_NAME, physbase);
- xf86ErrorF("%s: Scratchpad size: %d kbytes\n",CYRIX_NAME, padsize);
-
- /* Probe for the MediaGX processor version details. Older versions
- * use different op-codes for setting the organization of the
- * blit buffers within the scratch padarea. We currently
- * also use this version ID to guess whether the chipset has
- * an external DAC (in which case we treat the colour maps
- * in a slightly different fashion)
- */
- outb(0x22, 0xFF);
- device_step = device_revision = inb(0x23);
- device_step >>= 8;
- device_revision &= 0xFF;
- xf86ErrorF("%s: MediaGX processor ID %d revision %d\n",
- CYRIX_NAME, device_step, device_revision);
-
- CYRIXisOldChipRevision = (device_step == 0 && device_revision < 40);
-
- /* Some MediaGX systems have different blit buffer offsets than
- * is indicated by the scratchpad size. Make sure that we have
- * the right offsets by writing them into the corresponding CPU
- * registers. The op-codes to use depend on the processor
- * revision. The value `40' is a guess (awaiting details from Cyrix).
- */
- CYRIXbltBufSize = (padsize == 4) ? 1840 : (padsize == 3) ? 1328 : 816;
- CYRIXbltBuf1Address = 0x0E60 - CYRIXbltBufSize;
- CYRIXbltBuf0Address = CYRIXbltBuf1Address - CYRIXbltBufSize;
-
/* Free it since we don't need that list after this */
xfree(devSections);
- for (i=0; i < numUsed; i++) {
+ for (i=0; i < numUsed; i++) {
/* Fill in what we can of the ScrnInfoRec */
- pScrn = xf86AllocateScreen(drv,0);
- pScrn->driverVersion = VERSION;
- pScrn->ioBase = vgaIOBase;
- pScrn->driverName = CYRIX_DRIVER_NAME;
- pScrn->name = CYRIX_NAME;
- pScrn->Probe = CYRIXProbe;
- pScrn->PreInit = CYRIXPreInit;
- pScrn->ScreenInit = CYRIXScreenInit;
- pScrn->SwitchMode = CYRIXSwitchMode;
- pScrn->AdjustFrame = CYRIXAdjustFrame;
- pScrn->LeaveVT = CYRIXLeaveVT;
- pScrn->EnterVT = CYRIXEnterVT;
- pScrn->FreeScreen = CYRIXFreeScreen;
- pScrn->ValidMode = CYRIXValidMode;
- xf86ConfigActiveIsaEntity(pScrn, usedChips[i], CYRIXISAChipsets,
- NULL, NULL, NULL, NULL, NULL);
- }
+ pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn, 0, usedChips[i],
+ CYRIXISAChipsets, NULL,
+ NULL, NULL, NULL, NULL))){
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = CYRIX_DRIVER_NAME;
+ pScrn->name = CYRIX_NAME;
+ pScrn->Probe = CYRIXProbe;
+ pScrn->PreInit = CYRIXPreInit;
+ pScrn->ScreenInit = CYRIXScreenInit;
+ pScrn->SwitchMode = CYRIXSwitchMode;
+ pScrn->AdjustFrame = CYRIXAdjustFrame;
+ pScrn->LeaveVT = CYRIXLeaveVT;
+ pScrn->EnterVT = CYRIXEnterVT;
+ pScrn->FreeScreen = CYRIXFreeScreen;
+ pScrn->ValidMode = CYRIXValidMode;
+ return (TRUE);
+ }
+ xfree(usedChips);
+ }
return (TRUE);
}
@@ -450,10 +366,16 @@ static int
CYRIXFindIsaDevice(GDevPtr dev)
{
CARD32 CurrentValue, TestValue;
+ unsigned char gcr;
/* No need to unlock VGA CRTC registers here */
/* VGA has one more read/write attribute register than EGA */
+ /* use register probing to decide whether the chip is
+ * `suitable' for us.
+ */
+ int vgaIOBase = VGAHW_GET_IOBASE();
+
(void) inb(vgaIOBase + 0x0AU); /* Reset flip-flop */
outb(0x3C0, 0x14 | 0x20);
CurrentValue = inb(0x3C1);
@@ -465,7 +387,44 @@ CYRIXFindIsaDevice(GDevPtr dev)
/* Quit now if no VGA is present */
if ((CurrentValue ^ 0x0F) != TestValue)
return -1;
+
+ /* the lock register should read 0xFF after we have
+ written 0x00 to lock */
+ outb(vgaIOBase + 4, CrtcExtendedRegisterLock);
+ outb(vgaIOBase + 5, 0x00);
+
+ if (inb(vgaIOBase + 5) != 0xFF) return -1;
+
+ /* the lock register should read 0x00 after we have
+ written the magic word 'WL' to unlock */
+ outb(vgaIOBase + 5, 0x57);
+ outb(vgaIOBase + 5, 0x4C);
+
+ /* GGI's idea to do two comparisons */
+ if (inb(vgaIOBase + 5) != 0x00) goto fail;
+ if (inb(vgaIOBase + 5) != 0x00) goto fail;
+
+ /* OK, it's most likely a MediaGX. Now check the scratchpad
+ * size. If it is zero, we're not using the MediaGX graphics
+ * facilities.
+ */
+ outb(GX_IOPORT_INDEX, GX_IOIDX_DIR0); /* doesn't work w/o that */
+ outb(GX_IOPORT_INDEX, GX_IOIDX_GCR);
+ gcr = inb(GX_IOPORT_DATA);
+
+ /* end GGI MediaGX driver based code */
+ if (!(gcr & 12)) goto fail;
+
+ /* Unprotect MediaGX extended registers */
+ outb(vgaIOBase + 4, CrtcExtendedRegisterLock);
+ outb(vgaIOBase + 5, 0x00);
return (int)CHIP_CYRIXmediagx;
+
+ fail:
+ /* Protect MediaGX extended registers */
+ outb(vgaIOBase + 4, CrtcExtendedRegisterLock);
+ outb(vgaIOBase + 5, 0x00);
+ return -1;
}
/* Mandatory */
@@ -478,7 +437,12 @@ CYRIXPreInit(ScrnInfoPtr pScrn, int flags)
int i;
ClockRangePtr clockRanges;
char *mod = NULL;
- const char *Sym;
+ const char *Sym = NULL;
+ CARD32 physbase, padsize;
+ int CYRIXisOldChipRevision;
+ int device_step, device_revision;
+ int vgaIOBase;
+ unsigned char gcr;
if (flags & PROBE_DETECT) return FALSE;
@@ -511,17 +475,66 @@ CYRIXPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
VGAHWPTR(pScrn)->MapSize = 0x10000; /* Standard 64k VGA window */
-
if (!vgaHWMapMem(pScrn))
return FALSE;
+
vgaHWGetIOBase(VGAHWPTR(pScrn));
vgaIOBase = VGAHWPTR(pScrn)->IOBase;
+
+
+ /* Unprotect MediaGX extended registers */
+ outb(vgaIOBase + 4, CrtcExtendedRegisterLock);
+ outb(vgaIOBase + 5, 0x57);
+ outb(vgaIOBase + 5, 0x4C);
+
+ outb(GX_IOPORT_INDEX, GX_IOIDX_DIR0); /* doesn't work w/o that */
+ outb(GX_IOPORT_INDEX, GX_IOIDX_GCR);
+ gcr = inb(GX_IOPORT_DATA);
+
+ physbase = (gcr & 3) << 30;
+ padsize = (gcr & 12) ? (((gcr & 12) >> 2) + 1) : 0;
+
+
+ /* end GGI MediaGX driver based code */
+ if (padsize == 0) return (FALSE);
+
+ if (flags & PROBE_DETECT)
+ return TRUE;
+
+ xf86ErrorF("%s: GX_BASE: 0x%x\n",CYRIX_NAME, physbase);
+ xf86ErrorF("%s: Scratchpad size: %d kbytes\n",CYRIX_NAME, padsize);
+
+ /* Probe for the MediaGX processor version details. Older versions
+ * use different op-codes for setting the organization of the
+ * blit buffers within the scratch padarea. We currently
+ * also use this version ID to guess whether the chipset has
+ * an external DAC (in which case we treat the colour maps
+ * in a slightly different fashion)
+ */
+ outb(0x22, 0xFF);
+ device_step = device_revision = inb(0x23);
+ device_step >>= 8;
+ device_revision &= 0xFF;
+ xf86ErrorF("%s: MediaGX processor ID %d revision %d\n",
+ CYRIX_NAME, device_step, device_revision);
+
+ CYRIXisOldChipRevision = (device_step == 0 && device_revision < 40);
+
+ /* Some MediaGX systems have different blit buffer offsets than
+ * is indicated by the scratchpad size. Make sure that we have
+ * the right offsets by writing them into the corresponding CPU
+ * registers. The op-codes to use depend on the processor
+ * revision. The value `40' is a guess (awaiting details from Cyrix).
+ */
+ pCyrix->CYRIXbltBufSize = (padsize == 4) ? 1840 : (padsize == 3) ? 1328 : 816;
+ pCyrix->CYRIXbltBuf1Address = 0x0E60 - pCyrix->CYRIXbltBufSize;
+ pCyrix->CYRIXbltBuf0Address = pCyrix->CYRIXbltBuf1Address - pCyrix->CYRIXbltBufSize;
/* map the entire area from GX_BASE (scratchpad area)
up to the end of the control registers */
- GXregisters = (char*)xf86MapVidMem(pScrn->scrnIndex,
+ pCyrix->GXregisters = (char*)xf86MapVidMem(pScrn->scrnIndex,
VGA_REGION, (int )physbase, 0x9000);
- if (!GXregisters) {
+ if (!pCyrix->GXregisters) {
ErrorF("%s: Cannot map hardware registers\n", CYRIX_NAME);
return FALSE;
}
@@ -690,8 +703,8 @@ CYRIXPreInit(ScrnInfoPtr pScrn, int flags)
from = X_CONFIG;
} else {
from = X_PROBED;
- outb(pScrn->ioBase + 4, CrtcGraphicsMemorySize);
- videoram = (inb(pScrn->ioBase + 5) * 64);
+ outb(vgaIOBase + 4, CrtcGraphicsMemorySize);
+ videoram = (inb(vgaIOBase + 5) * 64);
pScrn->videoRam = videoram & 0xFFFFFC00; /* mask out the part we want */
}
@@ -713,7 +726,7 @@ CYRIXPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = (ClockRangePtr)xnfalloc(sizeof(ClockRange));
+ clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pCyrix->MinClock;
clockRanges->maxClock = pCyrix->MaxClock;
@@ -1104,11 +1117,13 @@ CYRIXAdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp;
- CYRIXPtr pCyrix;
+ CYRIXPrvPtr pCyrix;
int base = y * pScrn->displayWidth + x;
unsigned char temp;
-
+ int vgaIOBase;
+
hwp = VGAHWPTR(pScrn);
+ vgaIOBase = hwp->IOBase;
pCyrix = CYRIXPTR(pScrn);
switch (pScrn->bitsPerPixel) {
@@ -1124,6 +1139,7 @@ CYRIXAdjustFrame(int scrnIndex, int x, int y, int flags)
}
GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
+
/*GX_REG(DC_FB_ST_OFFSET) = base; */
/* CRT bits 0-15 */
outw(vgaIOBase + 4, (base & 0x00FF00) | 0x0C);
@@ -1232,6 +1248,7 @@ CYRIXSaveScreen(ScreenPtr pScreen, int mode)
return vgaHWSaveScreen(pScreen, mode);
}
+#if 0
static void
CYRIXEnterLeave(enter)
Bool enter;
@@ -1263,3 +1280,4 @@ Bool enter;
GX_REG(DC_UNLOCK) = 0;
}
}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c
index e6e9f0248..de655dbdc 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c
@@ -26,17 +26,22 @@
* Dirk H. Hohndel (hohndel@suse.de),
* Portions: the GGI project & confidential CYRIX databooks.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c,v 1.1 2000/02/13 00:56:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/cyrix/cyrix_helper.c,v 1.2 2000/04/19 16:57:43 eich Exp $ */
#include "cyrix.h"
#include "compiler.h"
#include "vgaHW.h"
#include "xf86_ansic.h"
-static void CYRIXresetVGA(unsigned long vgaIOBase);
-static void CYRIXmarkLinesDirty(void);
-/* DEBUG STUFF */
-int CYRIXcbLineDelta = 800;
+#define CYRIXmarkLinesDirty { \
+ int k = 0; \
+ while (k < 1024) { \
+ GX_REG(MC_DR_ADD) = k++; \
+ GX_REG(MC_DR_ACC) = 0; \
+ } \
+ }
+
+static void CYRIXresetVGA(ScrnInfoPtr pScrn, unsigned long vgaIOBase);
void
Cyrix1bppColorMap(ScrnInfoPtr pScrn)
@@ -63,7 +68,6 @@ CyrixRestore(ScrnInfoPtr pScrn, CYRIXRegPtr cyrixReg)
{ unsigned char temp;
CYRIXPrvPtr pCyrix;
vgaRegPtr vgaReg;
- int flags;
unsigned long vgaIOBase;
vgaHWProtect(pScrn, TRUE); /* Blank the screen */
@@ -78,9 +82,9 @@ CyrixRestore(ScrnInfoPtr pScrn, CYRIXRegPtr cyrixReg)
the font). Luckily things seem to work without it. */
/* restore standard VGA portion */
- CYRIXresetVGA(vgaIOBase);
- vgaHWRestore(pScrn, vgaReg, flags);
- CYRIXmarkLinesDirty();
+ CYRIXresetVGA(pScrn,vgaIOBase);
+ vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL);
+ CYRIXmarkLinesDirty;
/* restore miscellaneous output registers */
outb(0x3C2, vgaReg->MiscOutReg);
@@ -124,7 +128,7 @@ CyrixRestore(ScrnInfoPtr pScrn, CYRIXRegPtr cyrixReg)
/* let SoftVGA programming settle before we access DC registers,
but don't wait too long */
usleep(1000);
- CYRIXmarkLinesDirty();
+ CYRIXmarkLinesDirty;
/* restore display controller hardware registers */
#ifndef MONOVGA
@@ -222,7 +226,7 @@ CyrixSave(ScrnInfoPtr pScrn, CYRIXRegPtr cyrixReg)
pCyrix->PrevExt.RefreshRate = inb(vgaIOBase + 5);
/* save standard VGA portion */
- CYRIXresetVGA(vgaIOBase);
+ CYRIXresetVGA(pScrn,vgaIOBase);
return((void *)vgaIOBase);
}
@@ -283,10 +287,7 @@ CyrixInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
#ifndef MONOVGA
/* initialize masked contents of display controller
hardware registers. */
- pCyrix->PrevExt.DcCursStOffset = CYRIXcursorAddress;
-/* DEBUG
- pCyrix->PrevExt.DcCbStOffset = CYRIXcbufferAddress;
-*/
+ pCyrix->PrevExt.DcCursStOffset = pCyrix->CYRIXcursorAddress;
pCyrix->PrevExt.DcLineDelta = 0 << 12;
pCyrix->PrevExt.DcBufSize = 0x41 << 9;
pCyrix->PrevExt.DcCursorX = 0;
@@ -298,8 +299,7 @@ CyrixInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
screen. If the line delta is not 1024 or 2048, entire frames
will be flagged dirty as opposed to lines. Problems with 16bpp
and line-dirty flagging seem to have been solved now. */
- if (CYRIXcbLineDelta != 0 &&
- mode->CrtcVDisplay == pScrn->virtualY &&
+ if (mode->CrtcVDisplay == pScrn->virtualY &&
mode->CrtcHDisplay == pScrn->virtualX)
{ pCyrix->PrevExt.DcGeneralCfg = DC_GCFG_DECE
| DC_GCFG_CMPE;
@@ -323,21 +323,15 @@ CyrixInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
static void
-CYRIXmarkLinesDirty()
-{ int k = 0;
- while (k < 1024)
- { GX_REG(MC_DR_ADD) = k++;
- GX_REG(MC_DR_ACC) = 0;
-} }
-
-static void
-CYRIXresetVGA(unsigned long vgaIOBase)
-{ unsigned char temp;
- /* switch off compression and cursor the hard way */
- GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
+CYRIXresetVGA(ScrnInfoPtr pScrn, unsigned long vgaIOBase)
+{
+ CYRIXPrvPtr pCyrix = CYRIXPTR(pScrn);
+ unsigned char temp;
+ /* switch off compression and cursor the hard way */
+ GX_REG(DC_UNLOCK) = DC_UNLOCK_VALUE;
GX_REG(DC_GENERAL_CFG) &= ~(DC_GCFG_CMPE | DC_GCFG_DECE | DC_GCFG_FDTY | DC_GCFG_CURE);
GX_REG(DC_UNLOCK) = 0;
- CYRIXmarkLinesDirty();
+ CYRIXmarkLinesDirty;
/* reset SoftVGA extensions to standard VGA behaviour */
outb(vgaIOBase + 4, CrtcExtendedAddressControl);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c b/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c
index 119bdbe92..ce84e6475 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c,v 1.20 2000/03/01 16:01:07 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.c,v 1.22 2000/06/13 02:28:33 dawes Exp $ */
/*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
@@ -243,7 +243,7 @@ static Bool
FBDevProbe(DriverPtr drv, int flags)
{
int i;
- ScrnInfoPtr pScrn, pScrn0;
+ ScrnInfoPtr pScrn;
GDevPtr *devSections = NULL;
int numDevSections;
int bus,device,func;
@@ -256,71 +256,67 @@ FBDevProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
return FALSE;
- pScrn0 = xf86AllocateScreen(drv, 0);
- if (!xf86LoadSubModule(pScrn0, "fbdevhw")) {
- xf86DeleteScreen(pScrn0->scrnIndex,0);
- return FALSE;
- }
+ if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0)
+ return FALSE;
+
+ if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
+ return FALSE;
+
xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
-
- if ((numDevSections = xf86MatchDevice(FBDEV_DRIVER_NAME, &devSections)) <= 0) {
- xf86DeleteScreen(pScrn0->scrnIndex,0);
- return FALSE;
- }
-
+
for (i = 0; i < numDevSections; i++) {
- dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
+ dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
+ if (devSections[i]->busID) {
+ xf86ParsePciBusString(devSections[i]->busID,&bus,&device,&func);
+ if (!xf86CheckPciSlot(bus,device,func))
+ continue;
+ }
+ if (fbdevHWProbe(NULL,dev,NULL)) {
+ pScrn = NULL;
if (devSections[i]->busID) {
- xf86ParsePciBusString(devSections[i]->busID,&bus,&device,&func);
- if (!xf86CheckPciSlot(bus,device,func))
- continue;
+ /* XXX what about when there's no busID set? */
+ int entity;
+
+ entity = xf86ClaimPciSlot(bus,device,func,drv,
+ 0,devSections[i],
+ TRUE);
+ pScrn = xf86ConfigPciEntity(pScrn,0,entity,
+ NULL,RES_SHARED_VGA,
+ NULL,NULL,NULL,NULL);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "claimed PCI slot %d:%d:%d\n",bus,device,func);
+
+ } else {
+ /* XXX This is a quick hack */
+ int entity;
+
+ entity = xf86ClaimIsaSlot(drv, 0,
+ devSections[i], TRUE);
+ pScrn = xf86ConfigIsaEntity(pScrn,0,entity,
+ NULL,RES_SHARED_VGA,
+ NULL,NULL,NULL,NULL);
}
- if (fbdevHWProbe(NULL,dev)) {
- foundScreen = TRUE;
- pScrn = xf86AllocateScreen(drv, 0);
- xf86LoadSubModule(pScrn, "fbdevhw");
- xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = FBDEV_DRIVER_NAME;
- pScrn->name = FBDEV_NAME;
- pScrn->Probe = FBDevProbe;
- pScrn->PreInit = FBDevPreInit;
- pScrn->ScreenInit = FBDevScreenInit;
- pScrn->SwitchMode = fbdevHWSwitchMode;
- pScrn->AdjustFrame = fbdevHWAdjustFrame;
- pScrn->EnterVT = fbdevHWEnterVT;
- pScrn->LeaveVT = fbdevHWLeaveVT;
- pScrn->ValidMode = fbdevHWValidMode;
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "using %s\n", dev ? dev : "default device");
- if (devSections[i]->busID) {
- /* XXX what about when there's no busID set? */
- int entity;
-
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "claimed PCI slot %d:%d:%d\n",bus,device,func);
- entity = xf86ClaimPciSlot(bus,device,func,drv,
- 0,devSections[i],
- TRUE);
- xf86ConfigActivePciEntity(pScrn,entity,
- NULL,RES_SHARED_VGA,
- NULL,NULL,NULL,NULL);
- } else {
- /* XXX This is a quick hack */
- int entity;
-
- entity = xf86ClaimIsaSlot(drv, 0,
- devSections[i], TRUE);
- xf86ConfigActiveIsaEntity(pScrn,entity,
- NULL,RES_SHARED_VGA,
- NULL,NULL,NULL,NULL);
- }
+ if (pScrn) {
+ foundScreen = TRUE;
+
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = FBDEV_DRIVER_NAME;
+ pScrn->name = FBDEV_NAME;
+ pScrn->Probe = FBDevProbe;
+ pScrn->PreInit = FBDevPreInit;
+ pScrn->ScreenInit = FBDevScreenInit;
+ pScrn->SwitchMode = fbdevHWSwitchMode;
+ pScrn->AdjustFrame = fbdevHWAdjustFrame;
+ pScrn->EnterVT = fbdevHWEnterVT;
+ pScrn->LeaveVT = fbdevHWLeaveVT;
+ pScrn->ValidMode = fbdevHWValidMode;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "using %s\n", dev ? dev : "default device");
}
+ }
}
xfree(devSections);
- xf86DeleteScreen(pScrn0->scrnIndex,0);
TRACE("probe done");
return foundScreen;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp b/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp
index 2a75c3e60..9609d89fe 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp
@@ -1,19 +1,18 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp,v 1.5 2000/03/03 01:05:36 dawes Exp $
-.TH FBDEV __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/fbdev/fbdev.cpp,v 1.8 2000/06/14 02:13:09 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH FBDEV __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
fbdev \- video driver for framebuffer device
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""fbdev"""
-.br
-.BI " BusID ""pci:" bus : dev : func """
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qfbdev\*q"
+.BI " BusID \*qpci:" bus : dev : func \*q
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B fbdev
is an XFree86 driver for framebuffer devices. This is a non-accelerated
@@ -46,11 +45,11 @@ The following driver
.B Options
are supported:
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
Enable or disable use of the shadow framebuffer layer. See
shadowfb(__drivermansuffix__) for further information. Default: on.
.SH "SEE ALSO"
XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1),
-X(1), fbdevhw(__drivermansuffix__)
+X(__miscmansuffix__), fbdevhw(__drivermansuffix__)
.SH AUTHORS
Authors include: Gerd Knorr
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp b/xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp
index 5ae2e5560..e5665beec 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp,v 1.7 2000/03/03 01:05:37 dawes Exp $
-.TH GLIDE __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide.cpp,v 1.10 2000/06/14 02:13:09 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH GLIDE __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
glide \- Glide video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""glide"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qglide\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH READ THIS IF NOTHING ELSE
This driver has a special requirement that needs to be fulfilled
before it will work: You need Glide installed and you need to make a link for the libglide2x.so
@@ -101,7 +101,7 @@ Section "Device"
.br
Option "dpms" "on"
.br
- Option "GlideDevice" "0"
+ Option "GlideDevice" "0"
.br
EndSection
.PP
@@ -129,13 +129,13 @@ The following driver
.B Options
are supported:
.TP
-.BI "Option ""OnAtExit"" """ boolean """
+.BI "Option \*qOnAtExit\*q \*q" boolean \*q
If true, will leave the Voodoo board on when the server exits. Useful in a multihead setup when
only the Voodoo board is connected to a second monitor and you don't want that monitor to lose
signal when you quit the server. Put this option in the Device section.
Default: off.
.TP
-.BI "Option ""GlideDevice"" """ integer """
+.BI "Option \*qGlideDevice\*q \*q" integer \*q
Selects which Voodoo board to use. (Or boards, in an SLI configuration).
The value should be 0 for the first board, 1 for the second and so on.
If it is not present, the first Voodoo board found will be selected.
@@ -293,6 +293,6 @@ Xinerama extension can be done for example like this:
.PP
$ xinit -- +xinerama
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Author: Henrik Harmsen.
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c
index 7e9f82c0d..ded27d15a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c
@@ -45,7 +45,7 @@
* Support static loading.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c,v 1.12 2000/03/01 16:01:08 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glide/glide_driver.c,v 1.15 2000/06/21 17:28:06 dawes Exp $ */
#include "xaa.h"
#include "xf86Cursor.h"
@@ -408,38 +408,40 @@ GLIDEProbe(DriverPtr drv, int flags)
{
int entity;
/* Match */
- /* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- /* I'm not going to "claim" the glide device since no other driver than this can drive it */
- /* (A glide device is not a PCI device) */
- /* XXX Need to see how this fits in with the new RAC */
-
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = GLIDE_DRIVER_NAME;
- pScrn->name = GLIDE_NAME;
- pScrn->Probe = GLIDEProbe;
- pScrn->PreInit = GLIDEPreInit;
- pScrn->ScreenInit = GLIDEScreenInit;
- pScrn->EnterVT = GLIDEEnterVT;
- pScrn->LeaveVT = GLIDELeaveVT;
- pScrn->FreeScreen = GLIDEFreeScreen;
- pScrn->driverPrivate = (void*)sst;
- /*
- * XXX This is a hack because don't have the PCI info. Set it as
- * an ISA entity with no resources.
- */
entity = xf86ClaimIsaSlot(drv, 0, dev, TRUE);
- xf86ConfigActiveIsaEntity(pScrn, entity, NULL, NULL, NULL, NULL, NULL,
- NULL);
- foundScreen = TRUE;
+ pScrn = NULL;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86ConfigIsaEntity(pScrn, 0, entity, NULL, NULL,
+ NULL, NULL, NULL, NULL))) {
+
+ /* I'm not going to "claim" the glide device since no other driver than this can drive it */
+ /* (A glide device is not a PCI device) */
+ /* XXX Need to see how this fits in with the new RAC */
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = GLIDE_DRIVER_NAME;
+ pScrn->name = GLIDE_NAME;
+ pScrn->Probe = GLIDEProbe;
+ pScrn->PreInit = GLIDEPreInit;
+ pScrn->ScreenInit = GLIDEScreenInit;
+ pScrn->EnterVT = GLIDEEnterVT;
+ pScrn->LeaveVT = GLIDELeaveVT;
+ pScrn->FreeScreen = GLIDEFreeScreen;
+ pScrn->driverPrivate = (void*)sst;
+ /*
+ * XXX This is a hack because don't have the PCI info. Set it as
+ * an ISA entity with no resources.
+ */
+ foundScreen = TRUE;
+ }
break;
}
}
}
-cleanup:
+ cleanup:
if (devList) xfree(devList);
return foundScreen;
}
@@ -574,7 +576,7 @@ GLIDEPreInit(ScrnInfoPtr pScrn, int flags)
/* Set up clock ranges so that the xf86ValidateModes() function will not fail a mode because of the clock
requirement (because we don't use the clock value anyway) */
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = 10000;
clockRanges->maxClock = 300000;
@@ -1012,7 +1014,7 @@ GLIDERestore(ScrnInfoPtr pScrn, Bool Closing)
#define GLIDE_FIND_FUNC(x) \
- p##x = (p##x##_t)LoaderSymbol(#x); \
+ p##x = (p##x##_t)xf86LoaderCheckSymbol(#x); \
if (!p##x) \
{ \
xf86Msg(X_ERROR, "Could not find " #x "() in libglide2x.so.\n"); \
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile
index c8624e19f..a2079af0b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.22 2000/03/03 01:05:37 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/Imakefile,v 1.28 2000/06/12 10:11:37 alanh Exp $
XCOMM
XCOMM This is an Imakefile for the GLINT driver.
XCOMM
@@ -14,10 +14,12 @@ DRIINCLUDES=-I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri
SRCS = glint_driver.c pm2_dac.c pm2ramdac.c pm2_accel.c pm_dac.c IBMramdac.c \
pm_accel.c tx_dac.c tx_accel.c pm2v_dac.c pm2vramdac.c pm2_video.c \
- TIramdac.c dualmx_dac.c dualmx_accel.c glint_shadow.c $(DRISRC)
+ pm3_dac.c pm3_accel.c TIramdac.c dualmx_dac.c dualmx_accel.c \
+ glint_shadow.c $(DRISRC) sx_accel.c TIdualramdac.c glint_dga.c
OBJS = glint_driver.o pm2_dac.o pm2ramdac.o pm2_accel.o pm_dac.o IBMramdac.o \
pm_accel.o tx_dac.o tx_accel.o pm2v_dac.o pm2vramdac.o pm2_video.o \
- TIramdac.o dualmx_dac.o dualmx_accel.o glint_shadow.o $(DRIOBJ)
+ pm3_dac.o pm3_accel.o TIramdac.o dualmx_dac.o dualmx_accel.o \
+ glint_shadow.o $(DRIOBJ) sx_accel.o TIdualramdac.o glint_dga.o
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
@@ -33,10 +35,10 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \
-I$(XF86SRC)/xf4bpp -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(EXTINCSRC) $(DRIINCLUDES) \
-I$(XF86SRC)/shadowfb -I$(XF86SRC)/fbdevhw \
- -I$(XTOP)/include
+ -I$(XTOP)/include -I$(XF86OSSRC)/vbe
#endif
-DEFINES = $(GLX_DEFINES)
+DEFINES = $(GLX_DEFINES) -DPPC_MMIO_IS_BE
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
@@ -58,6 +60,7 @@ DependTarget()
InstallDriverSDKNonExecFile(IBMramdac.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(TIramdac.c,$(DRIVERSDKDIR)/drivers/glint)
+InstallDriverSDKNonExecFile(TIdualramdac.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(dualmx_accel.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(dualmx_dac.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(glint.h,$(DRIVERSDKDIR)/drivers/glint)
@@ -65,6 +68,7 @@ InstallDriverSDKNonExecFile(glint_dri.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(glint_dri.h,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(glint_dripriv.h,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(glint_driver.c,$(DRIVERSDKDIR)/drivers/glint)
+InstallDriverSDKNonExecFile(glint_dga.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(glint_regs.h,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(glint_shadow.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(pm2_accel.c,$(DRIVERSDKDIR)/drivers/glint)
@@ -73,9 +77,12 @@ InstallDriverSDKNonExecFile(pm2_video.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(pm2ramdac.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(pm2v_dac.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(pm2vramdac.c,$(DRIVERSDKDIR)/drivers/glint)
+InstallDriverSDKNonExecFile(pm3_dac.c,$(DRIVERSDKDIR)/drivers/glint)
+InstallDriverSDKNonExecFile(pm3_accel.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(pm_accel.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(pm_dac.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(tx_accel.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKNonExecFile(tx_dac.c,$(DRIVERSDKDIR)/drivers/glint)
+InstallDriverSDKNonExecFile(sx_accel.c,$(DRIVERSDKDIR)/drivers/glint)
InstallDriverSDKObjectModule(glint,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3 b/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3
new file mode 100644
index 000000000..2815efcd1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3
@@ -0,0 +1,55 @@
+STATUS as of Sat, 10 Jun 2000 13:43:50 +0200.
+
+Known problems :
+
+ * Dual head : worked with 4.0a, but got broken in 4.0b
+ * Depth 8 with 8bpp : Tested only upto 1280x1024 as my monitor don't support
+ higher modes.
+ * Depth 15, 16 with 16 bpp : Modes above 1024x768 show a partial overlap
+ of the screen on the right.
+ * Depth 24 with 32 bpp : left half of the screen is repeated on the
+ right half.
+ * 2D Accel : only clipping pseudo accel is working.
+ * Video overlay : not supported by pm3 yet.
+
+Unaccelerated video modes :
+
+ * [OK] Depths 8 is working upto 1280x1024 (didn't test higher modes).
+ * [PROBLEM] Depth 15 and 16 are working up to 1024x768 modes. Higher modes
+ show a partial overlap of the screen on the right.
+ * [PROBLEM] Depth 24, 32 bpp : the screen is repeated in the second half
+ * [NEED HELP] Dot clock is 300MHz. I see pm2 is lowering dotclock for
+ 24 & 32 bpp. I did the same for now, but don't know if it is the right.
+
+Hardware features :
+
+ * [OK] HW cursor & ShadowFb works.
+
+Video Overlay :
+
+ * [NOTHING DONE] Video Overlay is untested. nothing has been done here.
+
+2D Accels :
+
+ * [NEED MORE WORK] only clipping pseudo accel is enabled, it makes a
+ difference in some case, as for example the Gnome logout anim.
+ True accels need more work, especially accel engine setup need to be
+ done with pm3 values.
+
+Dual head :
+
+ * [NEW PROBLEM] Dual head got broken in 4.0b. Culprit is the pci slot
+ claiming code in GLINTProbe, around line 700 of glint_driver.c
+ * [OK] Dual head did working fine, just, i didn't know how to make
+ enlightenment use both heads (:0.0 and :0.1). 3.3.6 twm has also
+ problems with this, should use 4.0 twm instead maybe.
+ * [SOLUTION] I need to make a XF86Config with orientation of various screens.
+
+ * [NEED TESTING ON NON J2000 BOARD] Second head of Jeronimo 2000 is not
+ initialized by the bios, So memory timings need to be set. I set them only
+ if subsysVendor & subsysCard are matching J2000. Need feedback of other
+ dual pm3 boards.
+
+
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/README.pm3,v 1.1 2000/06/13 23:34:38 dawes Exp $ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c
new file mode 100644
index 000000000..92efb5f13
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c
@@ -0,0 +1,133 @@
+/*
+ * 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 IBMramdac.c to support TI RAMDAC routines
+ * by Jens Owen, <jens@precisioninsight.com>.
+ *
+ * glintOutTIIndReg() and glintInTIIndReg() are used to access
+ * the indirect TI RAMDAC registers only.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/TIdualramdac.c,v 1.1 2000/03/21 21:46:27 alanh Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+#include "TI.h"
+#include "glint_regs.h"
+#include "glint.h"
+
+#define TI_WRITE_ADDR 0x4000
+#define TI_RAMDAC_DATA 0x4008
+#define TI_PIXEL_MASK 0x4010
+#define TI_READ_ADDR 0x4018
+#define TI_CURS_COLOR_WRITE_ADDR 0x4020
+#define TI_CURS_COLOR_DATA 0x4028
+#define TI_CURS_COLOR_READ_ADDR 0x4038
+#define TI_DIRECT_CURS_CTRL 0x4048
+#define TI_INDEX_DATA 0x4050
+#define TI_CURS_RAM_DATA 0x4058
+#define TI_CURS_X_LOW 0x4060
+#define TI_CURS_X_HIGH 0x4068
+#define TI_CURS_Y_LOW 0x4070
+#define TI_CURS_Y_HIGH 0x4078
+
+void
+DUALglintOutTIIndReg(ScrnInfoPtr pScrn,
+ CARD32 reg, unsigned char mask, unsigned char data)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ unsigned char tmp = 0x00;
+ int offset;
+
+ if ((reg & 0xf0) == 0xa0) { /* this is really a direct register write */
+ offset = TI_WRITE_ADDR + ((reg & 0xf) << 3);
+ if (mask != 0x00)
+ tmp = GLINT_SECONDARY_READ_REG(offset) & mask;
+
+ GLINT_SECONDARY_SLOW_WRITE_REG(tmp | data, offset);
+ }
+ else { /* normal indirect access */
+ GLINT_SECONDARY_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR);
+
+ if (mask != 0x00)
+ tmp = GLINT_SECONDARY_READ_REG(TI_INDEX_DATA) & mask;
+
+ GLINT_SECONDARY_SLOW_WRITE_REG(tmp | data, TI_INDEX_DATA);
+ }
+}
+
+unsigned char
+DUALglintInTIIndReg (ScrnInfoPtr pScrn, CARD32 reg)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ unsigned char ret;
+ int offset;
+
+ if ((reg & 0xf0) == 0xa0) { /* this is really a direct register write */
+ offset = TI_WRITE_ADDR + ((reg & 0xf) << 3);
+ ret = GLINT_SECONDARY_READ_REG(offset);
+ }
+ else { /* normal indirect access */
+ GLINT_SECONDARY_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR);
+ ret = GLINT_SECONDARY_READ_REG(TI_INDEX_DATA);
+ }
+
+ return (ret);
+}
+
+void
+DUALglintTIWriteAddress (ScrnInfoPtr pScrn, CARD32 index)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_SECONDARY_SLOW_WRITE_REG(index, TI_WRITE_ADDR);
+}
+
+void
+DUALglintTIWriteData (ScrnInfoPtr pScrn, unsigned char data)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_SECONDARY_SLOW_WRITE_REG(data, TI_RAMDAC_DATA);
+}
+
+void
+DUALglintTIReadAddress (ScrnInfoPtr pScrn, CARD32 index)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_SECONDARY_SLOW_WRITE_REG(0xFF, TI_PIXEL_MASK);
+ GLINT_SECONDARY_SLOW_WRITE_REG(index, TI_READ_ADDR);
+}
+
+unsigned char
+DUALglintTIReadData (ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ return(GLINT_SECONDARY_READ_REG(TI_RAMDAC_DATA));
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c
index 3d3e88d66..7b14d5d26 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c
@@ -27,7 +27,7 @@
* glintOutTIIndReg() and glintInTIIndReg() are used to access
* the indirect TI RAMDAC registers only.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c,v 1.2 2000/02/23 04:47:06 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/TIramdac.c,v 1.3 2000/03/21 21:46:27 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -66,17 +66,17 @@ glintOutTIIndReg(ScrnInfoPtr pScrn,
if ((reg & 0xf0) == 0xa0) { /* this is really a direct register write */
offset = TI_WRITE_ADDR + ((reg & 0xf) << 3);
if (mask != 0x00)
- tmp = GLINT_SECONDARY_READ_REG(offset) & mask;
+ tmp = GLINT_READ_REG(offset) & mask;
- GLINT_SECONDARY_SLOW_WRITE_REG(tmp | data, offset);
+ GLINT_SLOW_WRITE_REG(tmp | data, offset);
}
else { /* normal indirect access */
- GLINT_SECONDARY_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR);
+ GLINT_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR);
if (mask != 0x00)
- tmp = GLINT_SECONDARY_READ_REG(TI_INDEX_DATA) & mask;
+ tmp = GLINT_READ_REG(TI_INDEX_DATA) & mask;
- GLINT_SECONDARY_SLOW_WRITE_REG(tmp | data, TI_INDEX_DATA);
+ GLINT_SLOW_WRITE_REG(tmp | data, TI_INDEX_DATA);
}
}
@@ -89,11 +89,11 @@ glintInTIIndReg (ScrnInfoPtr pScrn, CARD32 reg)
if ((reg & 0xf0) == 0xa0) { /* this is really a direct register write */
offset = TI_WRITE_ADDR + ((reg & 0xf) << 3);
- ret = GLINT_SECONDARY_READ_REG(offset);
+ ret = GLINT_READ_REG(offset);
}
else { /* normal indirect access */
- GLINT_SECONDARY_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR);
- ret = GLINT_SECONDARY_READ_REG(TI_INDEX_DATA);
+ GLINT_SLOW_WRITE_REG(reg & 0xFF, TI_WRITE_ADDR);
+ ret = GLINT_READ_REG(TI_INDEX_DATA);
}
return (ret);
@@ -104,7 +104,7 @@ glintTIWriteAddress (ScrnInfoPtr pScrn, CARD32 index)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
- GLINT_SECONDARY_SLOW_WRITE_REG(index, TI_WRITE_ADDR);
+ GLINT_SLOW_WRITE_REG(index, TI_WRITE_ADDR);
}
void
@@ -112,7 +112,7 @@ glintTIWriteData (ScrnInfoPtr pScrn, unsigned char data)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
- GLINT_SECONDARY_SLOW_WRITE_REG(data, TI_RAMDAC_DATA);
+ GLINT_SLOW_WRITE_REG(data, TI_RAMDAC_DATA);
}
void
@@ -120,8 +120,8 @@ glintTIReadAddress (ScrnInfoPtr pScrn, CARD32 index)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
- GLINT_SECONDARY_SLOW_WRITE_REG(0xFF, TI_PIXEL_MASK);
- GLINT_SECONDARY_SLOW_WRITE_REG(index, TI_READ_ADDR);
+ GLINT_SLOW_WRITE_REG(0xFF, TI_PIXEL_MASK);
+ GLINT_SLOW_WRITE_REG(index, TI_READ_ADDR);
}
unsigned char
@@ -129,7 +129,7 @@ glintTIReadData (ScrnInfoPtr pScrn)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
- return(GLINT_SECONDARY_READ_REG(TI_RAMDAC_DATA));
+ return(GLINT_READ_REG(TI_RAMDAC_DATA));
}
Bool
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c
index a6d34a4bf..fa93a2905 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c
@@ -28,7 +28,7 @@
* Modified version of tx_accel.c to support dual MX chips by
* Jens Owen, <jens@precisioninsight.com>
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c,v 1.6 2000/02/23 04:47:06 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_accel.c,v 1.9 2000/06/21 13:35:51 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -105,7 +105,6 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn)
GLINTPtr pGlint = GLINTPTR(pScrn);
pGlint->rasterizerMode = RMMultiGLINT;
- pGlint->pprod |= FBRM_ScanlineInt2;
/* Initialize the Accelerator Engine to defaults */
@@ -120,8 +119,10 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn)
/* Make sure the rest of the register writes go to both MX's */
GLINT_SLOW_WRITE_REG(3, BroadcastMask);
+ GLINT_SLOW_WRITE_REG(pGlint->rasterizerMode, RasterizerMode);
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode);
- GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode);
+ GLINT_SLOW_WRITE_REG(pGlint->pprod | LBRM_ScanlineInt2, LBReadMode);
+ pGlint->pprod |= FBRM_ScanlineInt2;
GLINT_SLOW_WRITE_REG(pGlint->pprod, FBReadMode);
GLINT_SLOW_WRITE_REG(0, dXSub);
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWriteMode);
@@ -149,7 +150,6 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn)
GLINT_SLOW_WRITE_REG(0x400, FilterMode);
GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask);
GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask);
- GLINT_SLOW_WRITE_REG(pGlint->rasterizerMode, RasterizerMode);
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth);
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset);
GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset);
@@ -172,6 +172,7 @@ DualMXInitializeEngine(ScrnInfoPtr pScrn)
GLINT_SLOW_WRITE_REG(0x0, PixelSize);
break;
}
+
pGlint->ROP = 0xFF;
pGlint->ClippingOn = FALSE;
pGlint->startxsub = 0;
@@ -212,32 +213,34 @@ DualMXAccelInit(ScreenPtr pScreen)
infoPtr->SetClippingRectangle = DualMXSetClippingRectangle;
infoPtr->DisableClipping = DualMXDisableClipping;
infoPtr->ClippingFlags = HARDWARE_CLIP_MONO_8x8_FILL |
+#if 0
HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
+#endif
HARDWARE_CLIP_SOLID_FILL;
infoPtr->SolidFillFlags = 0;
infoPtr->SetupForSolidFill = DualMXSetupForFillRectSolid;
infoPtr->SubsequentSolidFillRect = DualMXSubsequentFillRectSolid;
- /*
- * The following optimized routines are copied from tx_accel.c,
- * but haven't been ported to a dual MX board.
- */
-#ifdef NOT_DONE
infoPtr->SolidLineFlags = 0;
infoPtr->PolySegmentThinSolidFlags = 0;
infoPtr->PolylinesThinSolidFlags = 0;
infoPtr->SetupForSolidLine = DualMXSetupForSolidLine;
infoPtr->SubsequentSolidHorVertLine = DualMXSubsequentHorVertLine;
- infoPtr->SubsequentSolidBresenhamLine =
+ if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR))
+ {
+ infoPtr->SubsequentSolidBresenhamLine =
DualMXSubsequentSolidBresenhamLine;
+ }
infoPtr->PolySegmentThinSolid = DualMXPolySegmentThinSolidWrapper;
infoPtr->PolylinesThinSolid = DualMXPolylinesThinSolidWrapper;
+#if 0
infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY |
ONLY_LEFT_TO_RIGHT_BITBLT;
infoPtr->SetupForScreenToScreenCopy = DualMXSetupForScreenToScreenCopy;
infoPtr->SubsequentScreenToScreenCopy = DualMXSubsequentScreenToScreenCopy;
+#endif
infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
HARDWARE_PATTERN_SCREEN_ORIGIN |
@@ -246,6 +249,7 @@ DualMXAccelInit(ScreenPtr pScreen)
infoPtr->SubsequentMono8x8PatternFillRect =
DualMXSubsequentMono8x8PatternFillRect;
+#if 0
if (!pGlint->UsePCIRetry) {
infoPtr->ScanlineCPUToScreenColorExpandFillFlags =
TRANSPARENCY_ONLY |
@@ -285,6 +289,7 @@ DualMXAccelInit(ScreenPtr pScreen)
infoPtr->SubsequentCPUToScreenColorExpandFill =
DualMXSubsequentCPUToScreenColorExpandFill;
}
+#endif
infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES;
@@ -299,7 +304,6 @@ DualMXAccelInit(ScreenPtr pScreen)
pScrn->bitsPerPixel / 8);
xf86InitFBManager(pScreen, &AvailFBArea);
-#endif /* NOT_DONE */
return (XAAInit(pScreen, infoPtr));
}
@@ -312,11 +316,6 @@ static void DualMXLoadCoord(
){
GLINTPtr pGlint = GLINTPTR(pScrn);
- /*
- * Optimization from tx_accel.c where these values are cached on the
- * host doesn't appear to work. We definitely need to reload at least
- * the StartXDom value. I'll play it safe and reload them all.
- */
GLINT_WRITE_REG(w<<16, StartXSub);
GLINT_WRITE_REG(x<<16,StartXDom);
GLINT_WRITE_REG(y<<16,StartY);
@@ -686,14 +685,15 @@ DualMXSubsequentMono8x8PatternFillRect(
if (pGlint->FrameBufferReadMode != -1) {
if (pGlint->ROP == GXcopy) {
GLINT_WRITE_REG(pGlint->BackGroundColor, FBBlockColor);
- GLINT_WRITE_REG(PrimitiveTrapezoid | FastFillEnable,Render);
+ span = 0;
} else {
GLINT_WRITE_REG(pGlint->BackGroundColor, PatternRamData0);
- GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|ASM_InvertPattern |
+ span = SpanOperation;
+ }
+ GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|ASM_InvertPattern |
UNIT_ENABLE, AreaStippleMode);
- GLINT_WRITE_REG(AreaStippleEnable | SpanOperation | FastFillEnable |
+ GLINT_WRITE_REG(AreaStippleEnable | span | FastFillEnable |
PrimitiveTrapezoid, Render);
- }
}
if (pGlint->ROP == GXcopy) {
@@ -932,6 +932,7 @@ DualMXPolySegmentThinSolidWrapper(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
XAAPolySegment(pDraw, pGC, nseg, pSeg);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c
index a17ab1c8b..d042bfa47 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c
@@ -27,7 +27,7 @@
* Modified version of tx_dac.c to support Dual MX rasterizers by
* Jens Owen <jens@precisioninsight.com>
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c,v 1.3 2000/02/23 04:47:07 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/dualmx_dac.c,v 1.4 2000/05/10 18:55:28 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -36,10 +36,12 @@
#include "xf86PciInfo.h"
#include "xf86Pci.h"
+#include "IBM.h"
#include "TI.h"
#include "glint_regs.h"
#include "glint.h"
+#define DEBUG
#ifdef DEBUG
#define DUMP(name,field) do { \
value = GLINT_READ_REG(field); \
@@ -389,7 +391,11 @@ Shiftbpp(ScrnInfoPtr pScrn, int value)
GLINTPtr pGlint = GLINTPTR(pScrn);
int logbytesperaccess;
- logbytesperaccess = 4;
+ if ( (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) ||
+ (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) )
+ logbytesperaccess = 4;
+ else
+ logbytesperaccess = 3;
switch (pScrn->bitsPerPixel) {
case 8:
@@ -431,11 +437,14 @@ DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->glintRegs[Aperture1 >> 3] = 0;
if (pGlint->UsePCIRetry) {
- pReg->glintRegs[DFIFODis >> 3] = 1;
- pReg->glintRegs[FIFODis >> 3] = 3;
+ pReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis) | 0x01;
+ if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)
+ pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x01;
+ else
+ pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x03;
} else {
- pReg->glintRegs[DFIFODis >> 3] = 0;
- pReg->glintRegs[FIFODis >> 3] = 1;
+ pReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis) & 0xFFFFFFFE;
+ pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x01;
}
temp1 = mode->CrtcHSyncStart - mode->CrtcHDisplay;
@@ -454,21 +463,25 @@ DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->glintRegs[VTGVSyncStart >> 3] = temp2;
pReg->glintRegs[VTGVBlankEnd >> 3] = mode->CrtcVTotal - mode->CrtcVDisplay;
+#if 1 /* We force them high */
+ pReg->glintRegs[VTGPolarity >> 3] = 0xBA;
+#else
pReg->glintRegs[VTGPolarity >> 3] = (((mode->Flags & V_PHSYNC) ? 0:2)<<2) |
((mode->Flags & V_PVSYNC) ? 0 : 2) | (0xb0);
+#endif
- pReg->glintRegs[VClkCtl >> 3] = 0;
+ pReg->glintRegs[VClkCtl >> 3] = 0;
pReg->glintRegs[VTGVGateStart >> 3] = pReg->glintRegs[VTGVBlankEnd>>3] - 1;
pReg->glintRegs[VTGVGateEnd >> 3] = pReg->glintRegs[VTGVBlankEnd>>3];
/*
* tell DAC to use the ICD chip clock 0 as ref clock
- * and set up some more video timining generator registers
+ * and set up some more video timing generator registers
*/
pReg->glintRegs[VTGHGateStart >> 3] = pReg->glintRegs[VTGHBlankEnd>>3] - 1;
pReg->glintRegs[VTGHGateEnd >> 3] = pReg->glintRegs[VTGHLimit>>3] - 1;
- pReg->glintRegs[VTGSerialClk >> 3] = 0x0002;
- pReg->glintRegs[FBModeSel >> 3] = 0x0907;
- pReg->glintRegs[VTGModeCtl >> 3] = 0x00;
+ pReg->glintRegs[VTGSerialClk >> 3] = 0x0002;
+ pReg->glintRegs[FBModeSel >> 3] = 0x907;
+ pReg->glintRegs[VTGModeCtl >> 3] = 0x04;
/*
* Setup memory control registers for FB and LB
@@ -498,9 +511,27 @@ DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
(0x20 << LBRefreshCountShift));
pReg->glintRegs[GCSRAperture >> 3] = GCSRSecondaryGLINTMapEn;
+ /*
+ * Setup HW
+ *
+ * Note: The order of discovery for the MX devices is dependent
+ * on which way the resource allocation code decides to scan the
+ * bus. This setup assumes the first MX found owns the even
+ * scanlines. Should the implementation change an scan the bus
+ * in the opposite direction, then simple invert the indices for
+ * MXPciInfo below. If this is setup wrong, the bug will appear
+ * as incorrect scanline interleaving when software rendering.
+ */
+ pReg->glintRegs[GMultGLINTAperture >> 3] = pGlint->realMXWidth;
+ pReg->glintRegs[GMultGLINT1 >> 3] =
+ pGlint->MXPciInfo[0]->memBase[2] & 0xFF800000;
+ pReg->glintRegs[GMultGLINT2 >> 3] =
+ pGlint->MXPciInfo[1]->memBase[2] & 0xFF800000;
+
/* Copy info to secondary regs */
pReg->glintSecondRegs[Aperture0>>3] = pReg->glintRegs[Aperture0>>3];
pReg->glintSecondRegs[Aperture1>>3] = pReg->glintRegs[Aperture1>>3];
+
pReg->glintSecondRegs[DFIFODis>>3] = pReg->glintRegs[DFIFODis>>3];
pReg->glintSecondRegs[FIFODis>>3] = pReg->glintRegs[FIFODis>>3];
pReg->glintSecondRegs[VTGHLimit>>3] = pReg->glintRegs[VTGHLimit>>3];
@@ -524,9 +555,14 @@ DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->glintSecondRegs[LBMemoryEDO>>3] = pReg->glintRegs[LBMemoryEDO>>3];
pReg->glintSecondRegs[LBMemoryCtl>>3] = pReg->glintRegs[LBMemoryCtl>>3];
pReg->glintSecondRegs[GCSRAperture>>3] = pReg->glintRegs[GCSRAperture>>3];
+ pReg->glintSecondRegs[GMultGLINTAperture>>3] =
+ pReg->glintRegs[GMultGLINTAperture>>3];
+ pReg->glintSecondRegs[GMultGLINT1>>3] = pReg->glintRegs[GMultGLINT1>>3];
+ pReg->glintSecondRegs[GMultGLINT2>>3] = pReg->glintRegs[GMultGLINT2>>3];
switch (pGlint->RamDac->RamDacType) {
case TI3030_RAMDAC:
+ case TI3026_RAMDAC:
{
/* Get the programmable clock values */
unsigned long m=0,n=0,p=0;
@@ -542,7 +578,10 @@ DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
ramdacReg->DacRegs[TIDAC_PIXEL_P] = ((p & 0x03) | 0xb0);
ramdacReg->DacRegs[TIDAC_PIXEL_VALID] = TRUE;
- n = 65 - ((128 << 2) / pScrn->bitsPerPixel);
+ if (pGlint->RamDac->RamDacType == (TI3026_RAMDAC))
+ n = 65 - ((64 << 2) / pScrn->bitsPerPixel);
+ else
+ n = 65 - ((128 << 2) / pScrn->bitsPerPixel);
m = 61;
p = 0;
for (q = 0; q < 8; q++) {
@@ -601,6 +640,10 @@ DualMXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
glintReg->glintRegs[LBMemoryEDO >> 3] = GLINT_READ_REG(LBMemoryEDO);
glintReg->glintRegs[LBMemoryCtl >> 3] = GLINT_READ_REG(LBMemoryCtl);
glintReg->glintRegs[GCSRAperture >> 3] = GLINT_READ_REG(GCSRAperture);
+ glintReg->glintRegs[GMultGLINTAperture>>3] =
+ GLINT_READ_REG(GMultGLINTAperture);
+ glintReg->glintRegs[GMultGLINT1>>3] = GLINT_READ_REG(GMultGLINT1);
+ glintReg->glintRegs[GMultGLINT2>>3] = GLINT_READ_REG(GMultGLINT2);
glintReg->glintSecondRegs[Aperture0 >> 3] =
GLINT_SECONDARY_READ_REG(Aperture0);
@@ -654,6 +697,12 @@ DualMXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
GLINT_SECONDARY_READ_REG(LBMemoryCtl);
glintReg->glintSecondRegs[GCSRAperture >> 3] =
GLINT_SECONDARY_READ_REG(GCSRAperture);
+ glintReg->glintSecondRegs[GMultGLINTAperture>>3] =
+ GLINT_SECONDARY_READ_REG(GMultGLINTAperture);
+ glintReg->glintSecondRegs[GMultGLINT1>>3] =
+ GLINT_SECONDARY_READ_REG(GMultGLINT1);
+ glintReg->glintSecondRegs[GMultGLINT2>>3] =
+ GLINT_SECONDARY_READ_REG(GMultGLINT2);
}
void
@@ -694,6 +743,10 @@ DualMXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[LBMemoryEDO >> 3], LBMemoryEDO);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[LBMemoryCtl >> 3], LBMemoryCtl);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GCSRAperture >> 3], GCSRAperture);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GMultGLINTAperture >> 3],
+ GMultGLINTAperture);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GMultGLINT1 >> 3], GMultGLINT1);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[GMultGLINT2 >> 3], GMultGLINT2);
GLINT_SECONDARY_SLOW_WRITE_REG(
glintReg->glintSecondRegs[Aperture0 >> 3], Aperture0);
@@ -744,5 +797,11 @@ DualMXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
GLINT_SECONDARY_SLOW_WRITE_REG(
glintReg->glintSecondRegs[LBMemoryCtl >> 3], LBMemoryCtl);
GLINT_SECONDARY_SLOW_WRITE_REG(
- glintReg->glintRegs[GCSRAperture >> 3], GCSRAperture);
+ glintReg->glintSecondRegs[GCSRAperture >> 3], GCSRAperture);
+ GLINT_SECONDARY_SLOW_WRITE_REG(
+ glintReg->glintSecondRegs[GMultGLINTAperture >>3], GMultGLINTAperture);
+ GLINT_SECONDARY_SLOW_WRITE_REG(
+ glintReg->glintSecondRegs[GMultGLINT1 >> 3], GMultGLINT1);
+ GLINT_SECONDARY_SLOW_WRITE_REG(
+ glintReg->glintSecondRegs[GMultGLINT2 >> 3], GMultGLINT2);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp
index 63baa3b28..ed908577c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp
@@ -1,28 +1,32 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp,v 1.2 2000/03/07 01:37:46 dawes Exp $
-.TH GLINT __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.cpp,v 1.7 2000/06/14 02:13:09 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH GLINT __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
glint \- GLINT/Permedia video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""glint"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qglint\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B glint
is an XFree86 driver for 3Dlabs & Texas Instruments GLINT/Permedia based video
cards. The driver is rather fully accelerated, and provides support for the
following framebuffer depths: 8, 15 (may give bad results with FBDev support),
16, 24 (32 bpp recommended, 24 bpp has problems), 30, and an 8+24 overlay mode.
+.B Glint permedia 3
+only support depth 8 (tested upto 1280x1024) and 15/16
+(ok upto 1024x768, partial screen overlap on the right at 1280x1024) and acceleration is not yet fully supported.
.SH SUPPORTED HARDWARE
The
.B glint
driver supports 3Dlabs (GLINT MX, GLINT 500TX, GLINT GAMMA, Permedia,
-Permedia 2, Permedia 2v) and Texas Instruments (Permedia, Permedia 2) chips.
+Permedia 2, Permedia 2v, Permedia 3) and Texas Instruments (Permedia,
+Permedia 2) chips.
.SH CONFIGURATION DETAILS
Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
@@ -31,11 +35,11 @@ driver.
The driver auto-detects the chipset type, but the following
.B ChipSet
names may optionally be specified in the config file
-.B """Device"""
+.B \*qDevice\*q
section, and will override the auto-detection:
.PP
.RS 4
-"ti_pm2", "ti_pm", "pm2v", "pm2", "pm", "500tx", "mx", "gamma".
+"ti_pm2", "ti_pm", "pm3", "pm2v", "pm2", "pm", "500tx", "mx", "gamma".
.RE
.PP
The driver will try to auto-detect the amount of video memory present for all
@@ -43,70 +47,81 @@ chips. If it's not detected correctly, the actual amount of video memory should
be specified with a
.B VideoRam
entry in the config file
-.B """Device"""
+.B \*qDevice\*q
section.
.PP
Additionally, you may need to specify the bus ID of your card with a
.B BusID
entry in the config file
-.B """Device"""
+.B \*qDevice\*q
section, especially with FBDev support.
.PP
The following driver
.B Options
are supported:
.TP
-.BI "Option ""HWCursor"" """ boolean """
+.BI "Option \*qHWCursor\*q \*q" boolean \*q
Enable or disable the HW cursor. Default: on.
.TP
-.BI "Option ""SWCursor"" """ boolean """
+.BI "Option \*qSWCursor\*q \*q" boolean \*q
Enable or disable the SW cursor. Default: off.
This option disables the
.B HWCursor
option and vice versa.
.TP
-.BI "Option ""NoAccel"" """ boolean """
+.BI "Option \*qNoAccel\*q \*q" boolean \*q
Disable or enable acceleration. Default: acceleration is enabled.
.TP
-.BI "Option ""Overlay""
+.BI "Option \*qOverlay\*q"
Enable 8+24 overlay mode. Only appropriate for depth 24, 32 bpp.
.RB ( Note:
This hasn't been tested with FBDev support and probably won't work.)
Recognized values are: "8,24", "24,8". Default: off.
.TP
-.BI "Option ""PciRetry"" """ boolean """
+.BI "Option \*qPciRetry\*q \*q" boolean \*q
Enable or disable PCI retries.
.RB ( Note:
This doesn't work with Permedia2 based cards for Amigas.) Default: off.
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
Enable or disable use of the shadow framebuffer layer. See
shadowfb(__drivermansuffix__) for further information.
.RB ( Note:
This disables hardware acceleration.) Default: off.
.TP
-.BI "Option ""UseFBDev"" """ boolean """
+.BI "Option \*qUseFBDev\*q \*q" boolean \*q
Enable or disable use of an OS-specific fb interface (which is not supported
on all OSs). See fbdevhw(__drivermansuffix__) for further information.
Default: off.
.ig
.TP
-.BI "Option ""RGBbits"" """ integer """
+.BI "Option \*qRGBbits\*q \*q" integer \*q
Each gun of the RGB triple can have either 8 or 10 bits. Default: 8
..
.TP
-.BI "Option ""BlockWrite"" """ boolean """
+.BI "Option \*qBlockWrite\*q \*q" boolean \*q
Enable or disable block writes for the various Permedia 2 chips. This improves
acceleration in general, but disables it for some special cases. Default: off.
.TP
-.BI "Option ""FireGL3000"" """ boolean """
+.BI "Option \*qFireGL3000\*q \*q" boolean \*q
If you have a card of the same name, turn this on. Default: off.
.TP
-.BI "Option ""SetMClk"" """ freq """
+.BI "Option \*qSetMClk\*q \*q" freq \*q
The driver will try to auto-detect the memory clock for all chips. If it's not
detected correctly, the actual value (in MHz) should be specified with this
option.
+.SH Known problems with the Glint Permedia 3 chip
+The
+.B Glint Permedia 3
+chip is newly supported since the 4.0.1 release but is still work in progress.
+The driver supports already unaccelerated modes at depth 8 (tested upto
+1280x1024) and depth 15 and 16 (ok upto 1024x768)
+Depth 24 and Depth 15 and 16 with modes higher than 1024x768 are showing a
+partial overlap of the right part of the screen.
+Acceleration only support clipping pseudo acceleration.
+Dual head for the Appian J2000 board was working but got broken since 4.0b,
+since now the driver claims all chip of the board.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: Alan Hourihane, Dirk Hohndel, Stefan Dirsch, Michel Dänzer
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h
index 48c1d1a5e..7ead39d60 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.25 2000/02/26 03:33:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint.h,v 1.31 2000/06/17 16:32:50 alanh Exp $ */
/*
* Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk>
*
@@ -48,6 +48,13 @@
#define GLINT_MAX_MX_DEVICES 2
#define GLINT_VGA_MMIO_OFF 0x6000
+#define VERSION 4000
+#define GLINT_NAME "GLINT"
+#define GLINT_DRIVER_NAME "glint"
+#define GLINT_MAJOR_VERSION 1
+#define GLINT_MINOR_VERSION 0
+#define GLINT_PATCHLEVEL 0
+
typedef struct {
CARD32 glintRegs[0x2000];
CARD32 glintSecondRegs[0x2000];
@@ -59,14 +66,10 @@ typedef struct {
typedef struct {
pciVideoPtr PciInfo;
- pciVideoPtr PciInfoGeometry;
pciVideoPtr MXPciInfo[GLINT_MAX_MX_DEVICES];
int numMXDevices;
PCITAG PciTag;
- PCITAG PciTagGeometry;
EntityInfoPtr pEnt;
- EntityInfoPtr pEntGeometry;
- EntityInfoPtr pEntMX[GLINT_MAX_MX_DEVICES];
RamDacHelperRecPtr RamDac;
int MemClock;
int Chipset;
@@ -91,6 +94,7 @@ typedef struct {
int cpuheight;
int cpucount;
int planemask;
+ int realMXWidth;
CARD32 IOAddress;
CARD32 FbAddress;
int irq;
@@ -98,6 +102,10 @@ typedef struct {
unsigned char * IOBaseVGA;
unsigned char * FbBase;
long FbMapSize;
+ DGAModePtr DGAModes;
+ int numDGAModes;
+ Bool DGAactive;
+ int DGAViewportStatus;
Bool DoubleBuffer;
Bool NoAccel;
Bool FBDev;
@@ -112,12 +120,8 @@ typedef struct {
Bool UseBlockWrite;
Bool UseFireGL3000;
Bool VGAcore;
- int MultiGLINTApSize;
int MXFbSize;
- int realMXWidth;
- CARD32 SecondaryAddress;
CARD32 rasterizerMode;
- unsigned char * SecondaryBase;
int MinClock;
int MaxClock;
int RefClock;
@@ -162,12 +166,18 @@ typedef struct {
((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_PERMEDIA2)
#define PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V \
((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_PERMEDIA2V)
+#define PCI_VENDOR_3DLABS_CHIP_PERMEDIA3 \
+ ((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_PERMEDIA3)
+#define PCI_VENDOR_3DLABS_CHIP_300SX \
+ ((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_300SX)
#define PCI_VENDOR_3DLABS_CHIP_500TX \
((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_500TX)
#define PCI_VENDOR_3DLABS_CHIP_MX \
((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_MX)
#define PCI_VENDOR_3DLABS_CHIP_GAMMA \
((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_GAMMA)
+#define PCI_VENDOR_3DLABS_CHIP_DELTA \
+ ((PCI_VENDOR_3DLABS << 16) | PCI_CHIP_DELTA)
/* Prototypes */
@@ -189,20 +199,38 @@ void PermediaRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
void PermediaSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
Bool PermediaInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
Bool PermediaAccelInit(ScreenPtr pScreen);
+void PermediaInitializeEngine(ScrnInfoPtr pScrn);
void Permedia2VRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
void Permedia2VSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
Bool Permedia2VInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
Bool Permedia2vHWCursorInit(ScreenPtr pScreen);
+/* pm3_dac.c */
+void Permedia3PreInit(ScrnInfoPtr pScrn, GLINTPtr pGlint);
+int Permedia3MemorySizeDetect(ScrnInfoPtr pScrn);
+void Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
+void Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
+Bool Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode);
+Bool Permedia3HWCursorInit(ScreenPtr pScreen);
+/* pm3_accel.c */
+Bool Permedia3AccelInit(ScreenPtr pScreen);
+void Permedia3Sync(ScrnInfoPtr pScrn);
+void Permedia3InitializeEngine(ScrnInfoPtr pScrn);
+/* End of pm3 stuff */
+
void TXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
void TXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
Bool TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
Bool TXAccelInit(ScreenPtr pScreen);
+void TXInitializeEngine(ScrnInfoPtr pScrn);
+
+Bool SXAccelInit(ScreenPtr pScreen);
void DualMXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
void DualMXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg);
Bool DualMXInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
Bool DualMXAccelInit(ScreenPtr pScreen);
+void DualMXInitializeEngine(ScrnInfoPtr pScrn);
void glintOutIBMRGBIndReg(ScrnInfoPtr pScrn,
CARD32 reg, unsigned char mask, unsigned char data);
@@ -218,10 +246,17 @@ Bool glintIBM640HWCursorInit(ScreenPtr pScreen);
void glintOutTIIndReg(ScrnInfoPtr pScrn,
CARD32 reg, unsigned char mask, unsigned char data);
unsigned char glintInTIIndReg(ScrnInfoPtr pScrn, CARD32 reg);
+void DUALglintOutTIIndReg(ScrnInfoPtr pScrn,
+ CARD32 reg, unsigned char mask, unsigned char data);
+unsigned char DUALglintInTIIndReg(ScrnInfoPtr pScrn, CARD32 reg);
void glintTIWriteAddress(ScrnInfoPtr pScrn, CARD32 index);
void glintTIReadAddress(ScrnInfoPtr pScrn, CARD32 index);
void glintTIWriteData(ScrnInfoPtr pScrn, unsigned char data);
unsigned char glintTIReadData(ScrnInfoPtr pScrn);
+void DUALglintTIWriteAddress(ScrnInfoPtr pScrn, CARD32 index);
+void DUALglintTIReadAddress(ScrnInfoPtr pScrn, CARD32 index);
+void DUALglintTIWriteData(ScrnInfoPtr pScrn, unsigned char data);
+unsigned char DUALglintTIReadData(ScrnInfoPtr pScrn);
Bool glintTIHWCursorInit(ScreenPtr pScreen);
void Permedia2OutIndReg(ScrnInfoPtr pScrn,
@@ -231,6 +266,8 @@ void Permedia2WriteAddress(ScrnInfoPtr pScrn, CARD32 index);
void Permedia2ReadAddress(ScrnInfoPtr pScrn, CARD32 index);
void Permedia2WriteData(ScrnInfoPtr pScrn, unsigned char data);
unsigned char Permedia2ReadData(ScrnInfoPtr pScrn);
+void TIramdacLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
+ LOCO *colors, VisualPtr pVisual);
void Permedia2LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indices,
LOCO *colors, VisualPtr pVisual);
void Permedia2LoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices,
@@ -239,14 +276,18 @@ void Permedia2I2CUDelay(I2CBusPtr b, int usec);
void Permedia2I2CPutBits(I2CBusPtr b, int scl, int sda);
void Permedia2I2CGetBits(I2CBusPtr b, int *scl, int *sda);
-void Permedia2VideoUninit(ScrnInfoPtr pScrn);
-void Permedia2VideoReset(ScrnInfoPtr pScrn);
void Permedia2VideoInit(ScreenPtr pScreen);
+void Permedia2VideoUninit(ScrnInfoPtr pScrn);
+void Permedia2VideoEnterVT(ScrnInfoPtr pScrn);
+void Permedia2VideoLeaveVT(ScrnInfoPtr pScrn);
void Permedia2vOutIndReg(ScrnInfoPtr pScrn,
CARD32, unsigned char mask, unsigned char data);
unsigned char Permedia2vInIndReg(ScrnInfoPtr pScrn, CARD32);
+Bool GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+void GLINTAdjustFrame(int scrnIndex, int x, int y, int flags);
+
extern int partprodPermedia[];
Bool GLINTDRIScreenInit(ScreenPtr pScreen);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c
new file mode 100644
index 000000000..2c6ed447f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
+ *
+ * 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>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dga.c,v 1.1 2000/05/10 18:55:29 alanh Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "glint.h"
+#include "glint_regs.h"
+#include "dgaproc.h"
+
+static Bool GLINT_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
+ int *, int *, int *);
+static Bool GLINT_SetMode(ScrnInfoPtr, DGAModePtr);
+static void GLINT_Sync(ScrnInfoPtr);
+static int GLINT_GetViewport(ScrnInfoPtr);
+static void GLINT_SetViewport(ScrnInfoPtr, int, int, int);
+static void GLINT_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
+static void GLINT_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
+static void GLINT_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int,
+ unsigned long);
+
+static
+DGAFunctionRec GLINTDGAFuncs = {
+ GLINT_OpenFramebuffer,
+ NULL,
+ GLINT_SetMode,
+ GLINT_SetViewport,
+ GLINT_GetViewport,
+ GLINT_Sync,
+ GLINT_FillRect,
+ NULL,
+#if 0
+ GLINT_BlitRect,
+ GLINT_BlitTransRect
+#else
+ NULL
+#endif
+};
+
+Bool
+GLINTDGAInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ DGAModePtr modes = NULL, newmodes = NULL, currentMode;
+ DisplayModePtr pMode, firstMode;
+ int Bpp = pScrn->bitsPerPixel >> 3;
+ int num = 0;
+ Bool oneMore;
+
+ pMode = firstMode = pScrn->modes;
+
+ while(pMode) {
+
+ if(0 /*pScrn->displayWidth != pMode->HDisplay*/) {
+ newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+ newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+ xfree(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+
+SECOND_PASS:
+
+ currentMode = modes + num;
+ num++;
+
+ currentMode->mode = pMode;
+ currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
+ if(!pGlint->NoAccel)
+ currentMode->flags |= DGA_FILL_RECT /*| DGA_BLIT_RECT*/;
+ if(pMode->Flags & V_DBLSCAN)
+ currentMode->flags |= DGA_DOUBLESCAN;
+ if(pMode->Flags & V_INTERLACE)
+ currentMode->flags |= DGA_INTERLACED;
+ currentMode->byteOrder = pScrn->imageByteOrder;
+ currentMode->depth = pScrn->depth;
+ currentMode->bitsPerPixel = pScrn->bitsPerPixel;
+ currentMode->red_mask = pScrn->mask.red;
+ currentMode->green_mask = pScrn->mask.green;
+ currentMode->blue_mask = pScrn->mask.blue;
+ currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
+ currentMode->viewportWidth = pMode->HDisplay;
+ currentMode->viewportHeight = pMode->VDisplay;
+ currentMode->xViewportStep = 1;
+ currentMode->yViewportStep = 1;
+ currentMode->viewportFlags = DGA_FLIP_RETRACE;
+ currentMode->offset = 0;
+ currentMode->address = pGlint->FbBase;
+
+ if(oneMore) { /* first one is narrow width */
+ currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pMode->HDisplay;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ oneMore = FALSE;
+ goto SECOND_PASS;
+ } else {
+ currentMode->bytesPerScanline =
+ ((pScrn->displayWidth * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pScrn->displayWidth;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ }
+
+ pMode = pMode->next;
+ if(pMode == firstMode)
+ break;
+ }
+
+ pGlint->numDGAModes = num;
+ pGlint->DGAModes = modes;
+
+ return DGAInit(pScreen, &GLINTDGAFuncs, modes, num);
+}
+
+
+static Bool
+GLINT_SetMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr pMode
+){
+ static int OldDisplayWidth[MAXSCREENS];
+ int index = pScrn->pScreen->myNum;
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if(!pMode) { /* restore the original mode */
+ /* put the ScreenParameters back */
+
+ pScrn->displayWidth = OldDisplayWidth[index];
+
+ GLINTSwitchMode(index, pScrn->currentMode, 0);
+ pGlint->DGAactive = FALSE;
+ } else {
+ if(!pGlint->DGAactive) { /* save the old parameters */
+ OldDisplayWidth[index] = pScrn->displayWidth;
+
+ pGlint->DGAactive = TRUE;
+ }
+
+ pScrn->displayWidth = pMode->bytesPerScanline /
+ (pMode->bitsPerPixel >> 3);
+
+ GLINTSwitchMode(index, pMode->mode, 0);
+ }
+
+ return TRUE;
+}
+
+static int
+GLINT_GetViewport(
+ ScrnInfoPtr pScrn
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ return pGlint->DGAViewportStatus;
+}
+
+static void
+GLINT_SetViewport(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int flags
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINTAdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+ pGlint->DGAViewportStatus = 0; /* GLINTAdjustFrame loops until finished */
+}
+
+static void
+GLINT_FillRect (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if(pGlint->AccelInfoRec) {
+ (*pGlint->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
+ (*pGlint->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
+ SET_SYNC_FLAG(pGlint->AccelInfoRec);
+ }
+}
+
+static void
+GLINT_Sync(
+ ScrnInfoPtr pScrn
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if(pGlint->AccelInfoRec) {
+ (*pGlint->AccelInfoRec->Sync)(pScrn);
+ }
+}
+
+static void
+GLINT_BlitRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if(pGlint->AccelInfoRec) {
+ int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
+ int ydir = (srcy < dsty) ? -1 : 1;
+
+ (*pGlint->AccelInfoRec->SetupForScreenToScreenCopy)(
+ pScrn, xdir, ydir, GXcopy, ~0, -1);
+ (*pGlint->AccelInfoRec->SubsequentScreenToScreenCopy)(
+ pScrn, srcx, srcy, dstx, dsty, w, h);
+ SET_SYNC_FLAG(pGlint->AccelInfoRec);
+ }
+}
+
+
+static void
+GLINT_BlitTransRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+){
+ /* this one should be separate since the XAA function would
+ prohibit usage of ~0 as the key */
+}
+
+
+static Bool
+GLINT_OpenFramebuffer(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ *name = NULL; /* no special device */
+ *mem = (unsigned char*)pGlint->FbAddress;
+ *size = pGlint->FbMapSize;
+ *offset = 0;
+ *flags = DGA_NEED_ROOT;
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
index 9acce4b54..babeeeb5c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.12 2000/03/02 16:07:47 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.c,v 1.18 2000/06/23 23:43:43 alanh Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -40,11 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xf86PciInfo.h"
#include "xf86Pci.h"
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb32.h"
+#include "fb.h"
#include "miline.h"
@@ -61,18 +57,7 @@ static void GLINTDestroyContext(ScreenPtr pScreen, drmContext hwContext,
DRIContextType contextStore);
static int
-GLINTDRIControlInitSingleMX(int drmSubFD, int irq)
-{
-
- int retcode;
-
- /* Perhaps add flag to for single mx here? */
- if ((retcode = drmCtlInstHandler(drmSubFD, irq))) return 1;
- return 0;
-}
-
-static int
-GLINTDRIControlInitDualMX(int drmSubFD, int irq)
+GLINTDRIControlInit(int drmSubFD, int irq)
{
int retcode;
@@ -351,13 +336,28 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
GLINTDRIPtr pGlintDRI;
int dmabufs = 0;
-#if XFree86LOADER
/* Check that the GLX, DRI, and DRM modules have been loaded by testing
for canonical symbols in each module. */
- if (!LoaderSymbol("GlxSetVisualConfigs")) return FALSE;
- if (!LoaderSymbol("DRIScreenInit")) return FALSE;
- if (!LoaderSymbol("drmAvailable")) return FALSE;
-#endif
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "GLINTDRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ DRIQueryVersion(&major, &minor, &patch);
+ if (major != 3 || minor != 0 || patch < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "GLINTDRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n",
+ major, minor, patch);
+ return FALSE;
+ }
+ }
if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_GAMMA) return FALSE;
@@ -377,9 +377,9 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
((pciConfigPtr)pGlint->PciInfo->thisCard)->busnum,
((pciConfigPtr)pGlint->PciInfo->thisCard)->devnum,
((pciConfigPtr)pGlint->PciInfo->thisCard)->funcnum);
- pDRIInfo->ddxDriverMajorVersion = 0;
- pDRIInfo->ddxDriverMinorVersion = 1;
- pDRIInfo->ddxDriverPatchVersion = 0;
+ pDRIInfo->ddxDriverMajorVersion = GLINT_MAJOR_VERSION;
+ pDRIInfo->ddxDriverMinorVersion = GLINT_MINOR_VERSION;
+ pDRIInfo->ddxDriverPatchVersion = GLINT_PATCHLEVEL;
pDRIInfo->frameBufferPhysicalAddress = pGlint->FbAddress;
pDRIInfo->frameBufferSize = pGlint->FbMapSize;
pDRIInfo->frameBufferStride =
@@ -412,6 +412,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
DRIDestroyInfoRec(pGlint->pDRIInfo);
return FALSE;
}
+
pDRIInfo->devPrivate = pGlintDRI;
pDRIInfo->devPrivateSize = sizeof(GLINTDRIRec);
pDRIInfo->contextSize = sizeof(GLINTDRIContextRec);
@@ -430,6 +431,32 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
+ /* Check the GLINT DRM version */
+ {
+ drmVersionPtr version = drmGetVersion(pGlint->drmSubFD);
+ if (version) {
+ if (version->version_major != 1 ||
+ version->version_minor != 0 ||
+ version->version_patchlevel < 0) {
+ /* incompatible drm version */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "GLINTDRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ GLINTDRICloseScreen(pScreen);
+ drmFreeVersion(version);
+ return FALSE;
+ }
+ drmFreeVersion(version);
+ }
+ }
+
+ /* Tell the client driver how many MX's we have */
+ pGlintDRI->numMXDevices = pGlint->numMXDevices;
+ /* Tell the client about our screen size setup */
+ pGlintDRI->pprod = pGlint->pprod;
+
/* setup device specific direct rendering memory maps */
/* pci region 0: control regs, first 4k page, priveledged writes */
@@ -510,6 +537,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
if ((bufs = drmAddBufs(pGlint->drmSubFD,
xf86ConfigDRI.bufs[i].count,
xf86ConfigDRI.bufs[i].size,
+ 0,
0 /* flags */)) <= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"[drm] failure adding %d %d byte DMA buffers\n",
@@ -530,6 +558,7 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
if ((bufs = drmAddBufs(pGlint->drmSubFD,
GLINT_DRI_BUF_COUNT,
GLINT_DRI_BUF_SIZE,
+ 0,
0 /* flags */)) <= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[drm] failure adding %d %d byte DMA buffers\n",
@@ -567,26 +596,13 @@ GLINTDRIScreenInit(ScreenPtr pScreen)
->thisCard)->funcnum);
}
- if (pGlint->numMXDevices == 2) {
- if ( (pGlint->irq <= 0) ||
- GLINTDRIControlInitDualMX(pGlint->drmSubFD, pGlint->irq) ) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] cannot initialize dma with IRQ %d\n",
- pGlint->irq);
- DRICloseScreen(pScreen);
- return FALSE;
- }
- }
-
- if (pGlint->numMXDevices == 1) {
- if ( (pGlint->irq <= 0) ||
- GLINTDRIControlInitSingleMX(pGlint->drmSubFD, pGlint->irq) ) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] cannot initialize dma with IRQ %d\n",
- pGlint->irq);
- DRICloseScreen(pScreen);
- return FALSE;
- }
+ if ( (pGlint->irq <= 0) ||
+ GLINTDRIControlInit(pGlint->drmSubFD, pGlint->irq) ) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[drm] cannot initialize dma with IRQ %d\n",
+ pGlint->irq);
+ DRICloseScreen(pScreen);
+ return FALSE;
}
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -634,7 +650,8 @@ Bool
GLINTCreateContext(ScreenPtr pScreen,
VisualPtr visual,
drmContext hwContext,
- void *pVisualConfigPriv)
+ void *pVisualConfigPriv,
+ DRIContextType contextStore)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
GLINTPtr pGlint = GLINTPTR(pScrn);
@@ -646,7 +663,7 @@ GLINTCreateContext(ScreenPtr pScreen,
if (!pGlintConfig)
return TRUE; /* no GLX driver private support, yet */
-#if 1
+#if 0
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"[GLINTCreateContext] context priv index = %d\n",
pGlintConfig->index);
@@ -730,9 +747,9 @@ GLINTDRISwapContext(
ScreenPtr pScreen,
DRISyncType syncType,
DRIContextType readContextType,
- void** readContextStore,
+ void *readContextStore,
DRIContextType writeContextType,
- void** writeContextStore)
+ void *writeContextStore)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
GLINTPtr pGlint = GLINTPTR(pScrn);
@@ -1125,7 +1142,7 @@ GLINTDRISwapContext(
/* send gamma the context dump command */
GLINT_WAIT(3);
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_WRITE_REG(1, BroadcastMask);
GLINT_WRITE_REG(3<<14, FilterMode); /* context bits on gamma */
GLINT_WRITE_REG(GLINT_GAMMA_CONTEXT_MASK, ContextDump);
@@ -1170,7 +1187,7 @@ dumpIndex,readValue);
/* send context restore command */
GLINT_WAIT(1);
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_WRITE_REG(1, BroadcastMask);
GLINT_WAIT(3);
@@ -1199,7 +1216,7 @@ dumpIndex,pWC->Gamma[dumpIndex]);
pGlint->AccelInfoRec->NeedToSync = TRUE;
/* finally the MX portions */
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_SLOW_WRITE_REG(1, BroadcastMask);
GLINT_SLOW_WRITE_REG(pWC->MX1.CSStart, SStart);
GLINT_SLOW_WRITE_REG(pWC->MX1.CdSdx, dSdx);
@@ -1452,7 +1469,7 @@ dumpIndex,pWC->Gamma[dumpIndex]);
/* restore the 2D portion of the new context */
/* Restore MX1's registers */
- if (pGlint->numMXDevices > 1)
+ if (pGlint->numMXDevices == 2)
GLINT_SLOW_WRITE_REG(1, BroadcastMask);
GLINT_SLOW_WRITE_REG(pWC->MX1.CStartXDom, StartXDom);
GLINT_SLOW_WRITE_REG(pWC->MX1.CdXDom, dXDom);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h
index 03f4d9fed..9fe9f02de 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h,v 1.3 2000/02/23 04:47:10 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dri.h,v 1.4 2000/05/10 18:55:29 alanh Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -50,6 +50,8 @@ typedef struct {
drmMapFlags flagsControlRegs1;
drmMapFlags flagsControlRegs2;
drmMapFlags flagsControlRegs3;
+ int numMXDevices;
+ int pprod;
} GLINTDRIRec, *GLINTDRIPtr;
#define GLINT_DRI_BUF_COUNT 20
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h
index fe29ffccf..83045b727 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h,v 1.2 2000/02/23 04:47:10 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_dripriv.h,v 1.5 2000/06/17 10:00:13 alanh Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -42,14 +42,15 @@ extern void GlxSetVisualConfigs(
extern Bool GLINTCreateContext(ScreenPtr pScreen,
VisualPtr visual,
drmContext hwContext,
- void* pVisualConfigPriv);
+ void* pVisualConfigPriv,
+ DRIContextType contextStore);
extern void GLINTDRISwapContext( ScreenPtr pScreen,
DRISyncType syncType,
DRIContextType readContextType,
- void** readContextStore,
+ void* readContextStore,
DRIContextType writeContextType,
- void** writeContextStore);
+ void* writeContextStore);
/* Macros to Setup Generic Kernel Device Driver to Handle DMA for gamma */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c
index 8c33db140..d961ef1ad 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c
@@ -23,22 +23,15 @@
* Dirk Hohndel, <hohndel@suse.de>
* Stefan Dirsch, <sndirsch@suse.de>
* Michel Dänzer, <michdaen@iiic.ethz.ch>
+ * Sven Luther, <luther@dpt-info.u-strasbg.fr>
*
- * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
- * Siemens Nixdorf Informationssysteme
+ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen,
+ * Siemens Nixdorf Informationssysteme and Appian Graphics.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.71 2000/03/07 01:37:47 dawes Exp $ */
-
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb24.h"
-#include "cfb32.h"
-#include "cfb24_32.h"
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_driver.c,v 1.89 2000/06/22 10:40:48 alanh Exp $ */
+
+#include "fb.h"
#include "cfb8_32.h"
-#include "xf1bpp.h"
-#include "xf4bpp.h"
#include "micmap.h"
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -53,6 +46,7 @@
#include "xf86RAC.h"
#include "xf86Resources.h"
#include "xf86int10.h"
+#include "vbe.h"
#include "compiler.h"
#include "mipointer.h"
@@ -94,16 +88,10 @@ static Bool GLINTPreInit(ScrnInfoPtr pScrn, int flags);
static Bool GLINTScreenInit(int Index, ScreenPtr pScreen, int argc,
char **argv);
static Bool GLINTEnterVT(int scrnIndex, int flags);
-static Bool GLINTEnterVTFBDev(int scrnIndex, int flags);
static void GLINTLeaveVT(int scrnIndex, int flags);
static Bool GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen);
static Bool GLINTSaveScreen(ScreenPtr pScreen, int mode);
-/* Required if the driver supports mode switching */
-static Bool GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
-/* Required if the driver supports moving the viewport */
-static void GLINTAdjustFrame(int scrnIndex, int x, int y, int flags);
-
/* Optional functions */
static void GLINTFreeScreen(int scrnIndex, int flags);
static int GLINTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
@@ -123,13 +111,6 @@ static Bool GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
static int pix24bpp = 0;
static Bool FBDevProbed = FALSE;
-#define VERSION 4000
-#define GLINT_NAME "GLINT"
-#define GLINT_DRIVER_NAME "glint"
-#define GLINT_MAJOR_VERSION 1
-#define GLINT_MINOR_VERSION 0
-#define GLINT_PATCHLEVEL 0
-
/*
* This contains the functions needed by the server after loading the driver
* module. It must be supplied, and gets passed back by the SetupProc
@@ -152,26 +133,36 @@ DriverRec GLINT = {
};
static SymTabRec GLINTChipsets[] = {
+ { PCI_VENDOR_3DLABS_CHIP_GAMMA, "gamma" },
{ PCI_VENDOR_TI_CHIP_PERMEDIA2, "ti_pm2" },
{ PCI_VENDOR_TI_CHIP_PERMEDIA, "ti_pm" },
+ { PCI_VENDOR_3DLABS_CHIP_PERMEDIA3, "pm3" },
{ PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V, "pm2v" },
{ PCI_VENDOR_3DLABS_CHIP_PERMEDIA2, "pm2" },
{ PCI_VENDOR_3DLABS_CHIP_PERMEDIA, "pm" },
+ { PCI_VENDOR_3DLABS_CHIP_300SX, "300sx" },
{ PCI_VENDOR_3DLABS_CHIP_500TX, "500tx" },
{ PCI_VENDOR_3DLABS_CHIP_MX, "mx" },
- { PCI_VENDOR_3DLABS_CHIP_GAMMA, "gamma" },
+/*
+ { PCI_VENDOR_3DLABS_CHIP_DELTA, "delta" },
+*/
{ -1, NULL }
};
static PciChipsets GLINTPciChipsets[] = {
+ { PCI_VENDOR_3DLABS_CHIP_GAMMA, PCI_VENDOR_3DLABS_CHIP_GAMMA, NULL },
{ PCI_VENDOR_TI_CHIP_PERMEDIA2, PCI_VENDOR_TI_CHIP_PERMEDIA2, RES_SHARED_VGA },
{ PCI_VENDOR_TI_CHIP_PERMEDIA, PCI_VENDOR_TI_CHIP_PERMEDIA, NULL },
+ { PCI_VENDOR_3DLABS_CHIP_PERMEDIA3, PCI_VENDOR_3DLABS_CHIP_PERMEDIA3, RES_SHARED_VGA },
{ PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V, PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V, RES_SHARED_VGA },
{ PCI_VENDOR_3DLABS_CHIP_PERMEDIA2, PCI_VENDOR_3DLABS_CHIP_PERMEDIA2, RES_SHARED_VGA },
{ PCI_VENDOR_3DLABS_CHIP_PERMEDIA, PCI_VENDOR_3DLABS_CHIP_PERMEDIA, NULL },
+ { PCI_VENDOR_3DLABS_CHIP_300SX, PCI_VENDOR_3DLABS_CHIP_300SX, NULL },
{ PCI_VENDOR_3DLABS_CHIP_500TX, PCI_VENDOR_3DLABS_CHIP_500TX, NULL },
{ PCI_VENDOR_3DLABS_CHIP_MX, PCI_VENDOR_3DLABS_CHIP_MX, NULL },
- { PCI_VENDOR_3DLABS_CHIP_GAMMA, PCI_VENDOR_3DLABS_CHIP_GAMMA, NULL },
+/*
+ { PCI_VENDOR_3DLABS_CHIP_DELTA, PCI_VENDOR_3DLABS_CHIP_DELTA, NULL },
+*/
{ -1, -1, RES_UNDEFINED }
};
@@ -206,21 +197,16 @@ static OptionInfoRec GLINTOptions[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
-static RamDacSupportedInfoRec PermediaRamdacs[] = {
- { IBM526DB_RAMDAC },
- { IBM526_RAMDAC },
- { -1 }
-};
-
-static RamDacSupportedInfoRec TXMXRamdacs[] = {
+static RamDacSupportedInfoRec IBMRamdacs[] = {
{ IBM526DB_RAMDAC },
{ IBM526_RAMDAC },
{ IBM640_RAMDAC },
{ -1 }
};
-static RamDacSupportedInfoRec GMX2000Ramdacs[] = {
+static RamDacSupportedInfoRec TIRamdacs[] = {
{ TI3030_RAMDAC },
+ { TI3026_RAMDAC },
{ -1 }
};
@@ -262,20 +248,9 @@ static const char *xaaSymbols[] = {
};
static const char *fbSymbols[] = {
- "xf1bppScreenInit",
- "xf4bppScreenInit",
- "cfbScreenInit",
- "cfb16ScreenInit",
- "cfb24ScreenInit",
- "cfb24_32ScreenInit",
- "cfb32ScreenInit",
"cfb8_32ScreenInit",
- "cfbGCPrivateIndex",
- "cfb16GCPrivateIndex",
- "cfb32GCPrivateIndex",
- "cfbBresS",
- "cfb16BresS",
- "cfb32BresS",
+ "fbScreenInit",
+ "fbBres",
NULL
};
@@ -302,9 +277,17 @@ static const char *shadowSymbols[] = {
NULL
};
+static const char *vbeSymbols[] = {
+ "VBEInit",
+ "vbeDoEDID",
+ NULL
+};
+
static const char *fbdevHWSymbols[] = {
"fbdevHWInit",
+ "fbdevHWFreeRec",
"fbdevHWProbe",
+ "fbdevHWFreeRec",
"fbdevHWGetName",
"fbdevHWUseBuildinMode",
@@ -347,6 +330,8 @@ static const char *drmSymbols[] = {
"drmMapBufs",
"drmMarkBufs",
"drmUnmapBufs",
+ "drmFreeVersion",
+ "drmGetVersion",
NULL
};
@@ -359,6 +344,7 @@ static const char *driSymbols[] = {
"DRIScreenInit",
"DRIDestroyInfoRec",
"DRICreateInfoRec",
+ "DRIQueryVersion",
"GlxSetVisualConfigs",
NULL
};
@@ -395,6 +381,7 @@ glintSetup(pointer module, pointer opts, int *errmaj, int *errmin)
LoaderRefSymLists(vgahwSymbols, fbSymbols, ddcSymbols, i2cSymbols,
xaaSymbols, xf8_32bppSymbols,
shadowSymbols, fbdevHWSymbols, int10Symbols,
+ vbeSymbols,
#ifdef XF86DRI
drmSymbols, driSymbols,
#endif
@@ -454,7 +441,7 @@ static int partprod500TX[] = {
int partprodPermedia[] = {
-1,
PARTPROD(0,0,1), PARTPROD(0,1,1), PARTPROD(1,1,1), PARTPROD(1,1,2),
- PARTPROD(1,2,2), PARTPROD(1,2,2), PARTPROD(1,2,3), PARTPROD(2,2,3),
+ PARTPROD(1,2,2), PARTPROD(2,2,2), PARTPROD(1,2,3), PARTPROD(2,2,3),
PARTPROD(1,3,3), PARTPROD(2,3,3), PARTPROD(1,2,4), PARTPROD(3,3,3),
PARTPROD(1,3,4), PARTPROD(2,3,4), -1, PARTPROD(3,3,4),
PARTPROD(1,4,4), PARTPROD(2,4,4), -1, PARTPROD(3,4,4),
@@ -496,6 +483,7 @@ GLINTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
int videocontrol = 0, vtgpolarity = 0;
if((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) {
vtgpolarity = GLINT_READ_REG(VTGPolarity) & 0xFFFFFFF0;
@@ -529,6 +517,7 @@ GLINTDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
}
if((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) {
GLINT_SLOW_WRITE_REG(vtgpolarity, VTGPolarity);
@@ -583,144 +572,115 @@ GLINTAvailableOptions(int chipid, int busid)
return GLINTOptions;
}
+void
+GLINTProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+ vbeInfoPtr pVbe;
+#ifdef XFree86LOADER
+ if (xf86LoadSubModule(pScrn, "vbe"))
+#endif
+ {
+ pVbe = VBEInit(NULL,index);
+ vbeDoEDID(pVbe, NULL);
+ }
+}
+
/* Mandatory */
static Bool
GLINTProbe(DriverPtr drv, int flags)
{
int i;
- ScrnInfoPtr pScrn0;
pciVideoPtr pPci, *checkusedPci;
- PCITAG deltatag = 0, chiptag = 0;
GDevPtr *devSections = NULL;
int numDevSections;
int numUsed,bus,device,func;
char *dev;
int *usedChips = NULL;
Bool foundScreen = FALSE;
- unsigned long glintbase = 0, glintbase3 = 0, deltabase = 0;
- unsigned long *delta_pci_base = 0 ;
+ char *name;
+ /*
TRACE_ENTER("GLINTProbe");
+ */
+ TRACE_EXIT("GLINTProbe (Enter)");
- /*
- * The aim here is to find all cards that this driver can handle,
- * and for the ones not already claimed by another driver, claim the
- * slot, and allocate a ScrnInfoRec.
- *
- * This should be a minimal probe, and it should under no circumstances
- * change the state of the hardware. Because a device is found, don't
- * assume that it will be used. Don't do any initialisations other than
- * the required ScrnInfoRec initialisations. Don't allocate any new
- * data structures.
- */
-
- /*
- * Next we check, if there has been a chipset override in the config file.
- * For this we must find out if there is an active device section which
- * is relevant, i.e., which has no driver specified or has THIS driver
- * specified.
- */
-
+
if ((numDevSections = xf86MatchDevice(GLINT_DRIVER_NAME,
- &devSections)) <= 0) {
- /*
- * There's no matching device section in the config file, so quit
- * now.
- */
- return FALSE;
+ &devSections)) <= 0) {
+ return FALSE;
}
-
- /*
- * We need to probe the hardware first. We then need to see how this
- * fits in with what is given in the config file, and allow the config
- * file info to override any contradictions.
- */
-
- /*
- * All of the cards this driver supports are PCI, so the "probing" just
- * amounts to checking the PCI data that the server has already collected.
- */
+
checkusedPci = xf86GetPciVideoInfo();
-
+
if (checkusedPci == NULL) {
- /*
- * Changed the behaviour to try probing using the FBDev support when no PCI cards have
- * been found. This is for systems without (proper) PCI support. (Michel)
- */
-
- pScrn0 = xf86AllocateScreen(drv, 0);
-
- pScrn0->name = GLINT_NAME;
-
- if (xf86LoadSubModule(pScrn0, "fbdevhw")) {
- xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
+ /*
+ * Changed the behaviour to try probing using the FBDev support
+ * when no PCI cards have been found. This is for systems without
+ * (proper) PCI support. (Michel)
+ */
+ if (!xf86LoadDrvSubModule(drv, "fbdevhw"))
+ return FALSE;
- for (i = 0; i < numDevSections; i++) {
- dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
- if (devSections[i]->busID) {
- xf86ParsePciBusString(devSections[i]->busID,&bus,&device,&func);
- if (!xf86CheckPciSlot(bus,device,func))
- continue;
- }
- if (fbdevHWProbe(NULL,dev)) {
- ScrnInfoPtr pScrn;
- fbdevHWInit(pScrn0, NULL, dev);
-
- /* Check for pm2fb */
- if (strcmp(fbdevHWGetName(pScrn0),"Permedia2")) continue;
-
- if (flags & PROBE_DETECT) {
- xf86AddDeviceToConfigure(GLINT_NAME, NULL, -1);
- return TRUE;
- }
-
- foundScreen = FBDevProbed = TRUE;
- pScrn = xf86AllocateScreen(drv, 0);
- xf86LoadSubModule(pScrn, "fbdevhw");
- xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
-
- xf86DrvMsg(pScrn0->scrnIndex, X_INFO,
- "%s successfully probed\n", dev ? dev : "default framebuffer device");
- if (devSections[i]->busID) {
- /* XXX what about when there's no busID set? */
- int entity;
-
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
- "claimed PCI slot %d:%d:%d\n",bus,device,func);
- entity = xf86ClaimPciSlot(bus,device,func,drv,
- 0,devSections[i],
- TRUE);
- xf86ConfigActivePciEntity(pScrn,entity,
- NULL,RES_SHARED_VGA,
- NULL,NULL,NULL,NULL);
- } else {
- /* XXX This is a quick hack */
- int entity;
-
- entity = xf86ClaimIsaSlot(drv, 0,
- devSections[i], TRUE);
- xf86ConfigActiveIsaEntity(pScrn,entity,
- NULL,RES_SHARED_VGA,
- NULL,NULL,NULL,NULL);
- }
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = GLINT_DRIVER_NAME;
+ xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
+
+ for (i = 0; i < numDevSections; i++) {
+ dev = xf86FindOptionValue(devSections[i]->options,"fbdev");
+ if (devSections[i]->busID) {
+ xf86ParsePciBusString(devSections[i]->busID,&bus,&device,&func);
+ if (!xf86CheckPciSlot(bus,device,func))
+ continue;
+ }
+ if (fbdevHWProbe(NULL,dev,&name)) {
+ ScrnInfoPtr pScrn;
+
+ /* Check for pm2fb */
+ if (strcmp(name,"Permedia2")) continue;
+ foundScreen = TRUE;
+ pScrn = NULL;
+
+ if (devSections[i]->busID) {
+ /* XXX what about when there's no busID set? */
+ int entity;
+ entity = xf86ClaimPciSlot(bus,device,func,drv,
+ 0,devSections[i],
+ TRUE);
+ pScrn = xf86ConfigPciEntity(pScrn,0,entity,
+ NULL,RES_SHARED_VGA,
+ NULL,NULL,NULL,NULL);
+ if (pScrn)
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "claimed PCI slot %d:%d:%d\n",bus,device,func);
+ } else {
+ /* XXX This is a quick hack */
+ int entity;
+
+ entity = xf86ClaimIsaSlot(drv, 0,
+ devSections[i], TRUE);
+ pScrn = xf86ConfigIsaEntity(pScrn,0,entity,
+ NULL,RES_SHARED_VGA,
+ NULL,NULL,NULL,NULL);
+ }
+ if (pScrn) {
+ /* Fill in what we can of the ScrnInfoRec */
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "%s successfully probed\n", dev ? dev : "default framebuffer device");
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = GLINT_DRIVER_NAME;
pScrn->name = GLINT_NAME;
pScrn->Probe = GLINTProbe;
pScrn->PreInit = GLINTPreInit;
pScrn->ScreenInit = GLINTScreenInit;
pScrn->SwitchMode = GLINTSwitchMode;
pScrn->FreeScreen = GLINTFreeScreen;
+ pScrn->EnterVT = GLINTEnterVT;
}
}
- }
+ }
- xf86DeleteScreen(pScrn0->scrnIndex,0);
xfree(devSections);
} else {
-
+
numUsed = xf86MatchPciInstances(GLINT_NAME, 0,
GLINTChipsets, GLINTPciChipsets, devSections,
numDevSections, drv, &usedChips);
@@ -732,168 +692,54 @@ GLINTProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
if (!(flags & PROBE_DETECT))
- for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
-
- /* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
- ErrorF("used chips: %i\n",usedChips[i]);
-
- xf86ConfigActivePciEntity(pScrn, usedChips[i], GLINTPciChipsets, NULL,
- NULL, NULL, NULL, NULL);
-
- pPci = xf86GetPciInfoForEntity(usedChips[i]);
- glintbase = pPci->memBase[0];
- chiptag = pciTag(pPci->bus, pPci->device, pPci->func);
+ for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
- /* Need to claim Glint Delta for PERMEDIA & 500TX */
- /* and for the moment we claim all other chips on the same */
- /* bus/device number */
- if ( (pPci->chipType == PCI_CHIP_500TX) ||
- (pPci->chipType == PCI_CHIP_MX) ||
- (pPci->chipType == PCI_CHIP_GAMMA) ||
- (pPci->chipType == PCI_CHIP_PERMEDIA) ) {
-
- while (*checkusedPci != NULL) {
- int gIndex;
- /* make sure we claim all but our source device */
- if ((pPci->bus == (*checkusedPci)->bus &&
- pPci->device == (*checkusedPci)->device) &&
- pPci->func != (*checkusedPci)->func) {
+ /* Allocate a ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ GLINTPciChipsets, NULL,
+ NULL, NULL, NULL, NULL))) {
+
+ pPci = xf86GetPciInfoForEntity(usedChips[i]);
+
+
+ /* Only claim other chips when GAMMA is used */
+ if (pPci->chipType == PCI_CHIP_GAMMA) {
+ while (*checkusedPci != NULL) {
+ int eIndex;
+ /* make sure we claim all but our source device */
+ if ((pPci->bus == (*checkusedPci)->bus &&
+ pPci->device == (*checkusedPci)->device) &&
+ pPci->func != (*checkusedPci)->func) {
- /* Find that Delta chip, and give us the tag value */
- if ( (((*checkusedPci)->vendor == PCI_VENDOR_TI) ||
- ((*checkusedPci)->vendor == PCI_VENDOR_3DLABS)) &&
- (((*checkusedPci)->chipType == PCI_CHIP_DELTA) ||
- ((*checkusedPci)->chipType == PCI_CHIP_MX)) ) {
- if ((*checkusedPci)->chipType == PCI_CHIP_DELTA) {
- deltabase = (*checkusedPci)->memBase[0];
- delta_pci_base = &((*checkusedPci)->memBase[0]);
- deltatag = pciTag((*checkusedPci)->bus,
- (*checkusedPci)->device,
- (*checkusedPci)->func);
- }
-
- gIndex = xf86ClaimPciSlot((*checkusedPci)->bus,
- (*checkusedPci)->device,
- (*checkusedPci)->func, drv,
- (*checkusedPci)->chipType,
- NULL, TRUE);
-
- if (gIndex == -1) {
- /* This can't happen */
- FatalError("someone claimed the free slot!\n");
- }
- xf86ConfigActivePciEntity(pScrn, gIndex,
- NULL, NULL, NULL, NULL,
- NULL, NULL);
- } else {
- int eIndex;
-
/* Claim other entities on the same card */
eIndex = xf86ClaimPciSlot((*checkusedPci)->bus,
- (*checkusedPci)->device,
- (*checkusedPci)->func,
- drv, -1 /* XXX */,
- NULL, FALSE);
-
+ (*checkusedPci)->device,
+ (*checkusedPci)->func,
+ drv, -1 /* XXX */,
+ NULL, FALSE);
if (eIndex == -1) {
- /* This can't happen */
- FatalError("someone claimed the free slot!\n");
+ /* This can't happen */
+ FatalError("someone claimed the free slot!\n");
}
- }
- }
- checkusedPci++;
- }
- }
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = GLINT_DRIVER_NAME;
- pScrn->name = GLINT_NAME;
- pScrn->Probe = GLINTProbe;
- pScrn->PreInit = GLINTPreInit;
- pScrn->ScreenInit = GLINTScreenInit;
- pScrn->SwitchMode = GLINTSwitchMode;
- pScrn->FreeScreen = GLINTFreeScreen;
-
-/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
-/* NEED TO MOVE THIS OUT OF THE PROBE CODE */
-/* XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX */
- {
- int temp;
- int bugbase = 0;
- /*
- * due to a few bugs in the GLINT Delta we might have to
- * relocate the base address of config region of the Delta, if
- * bit 17 of the base addresses of config region of the Delta
- * and the 500TX or 300SX are different
- * We only handle config type 1 at this point
- */
- if (deltatag && chiptag) {
- if ((deltabase & 0x20000) ^ (glintbase & 0x20000)) {
- /*
- * if the base addresses are different at bit 17,
- * we have to remap the base0 for the delta;
- * as wrong as this looks, we can use the base3 of the
- * 300SX/500TX for this. The delta is working as a bridge
- * here and gives its own addresses preference. And we
- * don't need to access base3, as this one is the bytw
- * swapped local buffer which we don't need.
- * Using base3 we know that the space is
- * a) large enough
- * b) free (well, almost)
- *
- * to be able to do that we need to enable IO
- */
- if (pPci->chipType == PCI_CHIP_PERMEDIA) {
- glintbase3 = pciReadLong(chiptag, 0x20); /* base4 */
- } else {
- glintbase3 = pciReadLong(chiptag, 0x1c); /* base3 */
- }
- if ((glintbase & 0x20000) ^ (glintbase3 & 0x20000)) {
- /*
- * oops, still different; we know that base3 is at least
- * 16 MB, so we just take 128k offset into it
- */
- glintbase3 += 0x20000;
+ xf86AddEntityToScreen(pScrn,eIndex);
+ }
+ checkusedPci++;
+ }
}
- /*
- * and now for the magic.
- * read old value
- * write fffffffff
- * read value
- * write new value
- */
- bugbase = pciReadLong(deltatag, 0x10);
- pciWriteLong(deltatag, 0x10, 0xffffffff);
- temp = pciReadLong(deltatag, 0x10);
- pciWriteLong(deltatag, 0x10, glintbase3);
-
- /* Update PCI tables */
- *delta_pci_base = glintbase3;
-
- /*
- * additionally, sometimes we see the baserom which might
- * confuse the chip, so let's make sure that is disabled
- */
- temp = pciReadLong(chiptag, 0x30);
- pciWriteLong(chiptag, 0x30, 0xffffffff);
- temp = pciReadLong(chiptag, 0x30);
- pciWriteLong(chiptag, 0x30, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = GLINT_DRIVER_NAME;
+ pScrn->name = GLINT_NAME;
+ pScrn->Probe = GLINTProbe;
+ pScrn->PreInit = GLINTPreInit;
+ pScrn->ScreenInit = GLINTScreenInit;
+ pScrn->SwitchMode = GLINTSwitchMode;
+ pScrn->FreeScreen = GLINTFreeScreen;
+ pScrn->EnterVT = GLINTEnterVT;
}
}
- if (bugbase)
- xf86DrvMsg(-1, X_INFO,
- "Glint Delta BUG, fixing.....old = 0x%x, new = 0x%x\n",
- bugbase, glintbase3);
- }
-
- /*
- * ok, now let's forget about the Delta, in case we found one
- */
- deltatag = deltabase = 0;
- }
-
}
if (usedChips) xfree(usedChips);
@@ -919,12 +765,14 @@ GetAccelPitchValues(ScrnInfoPtr pScrn)
switch (pGlint->Chipset) {
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
case PCI_VENDOR_TI_CHIP_PERMEDIA:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
linep = &partprodPermedia[0];
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
linep = &partprod500TX[0];
@@ -948,6 +796,69 @@ GetAccelPitchValues(ScrnInfoPtr pScrn)
return linePitches;
}
+static void
+GLINTProbeTIramdac(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint;
+ CARD32 temp = 0;
+ pGlint = GLINTPTR(pScrn);
+ if (pGlint->numMXDevices == 2) {
+ pGlint->RamDacRec = RamDacCreateInfoRec();
+ pGlint->RamDacRec->ReadDAC = DUALglintInTIIndReg;
+ pGlint->RamDacRec->WriteDAC = DUALglintOutTIIndReg;
+ pGlint->RamDacRec->ReadAddress = DUALglintTIReadAddress;
+ pGlint->RamDacRec->WriteAddress = DUALglintTIWriteAddress;
+ pGlint->RamDacRec->ReadData = DUALglintTIReadData;
+ pGlint->RamDacRec->WriteData = DUALglintTIWriteData;
+ pGlint->RamDacRec->LoadPalette = TIramdacLoadPalette;
+ } else {
+ pGlint->RamDacRec = RamDacCreateInfoRec();
+ pGlint->RamDacRec->ReadDAC = glintInTIIndReg;
+ pGlint->RamDacRec->WriteDAC = glintOutTIIndReg;
+ pGlint->RamDacRec->ReadAddress = glintTIReadAddress;
+ pGlint->RamDacRec->WriteAddress = glintTIWriteAddress;
+ pGlint->RamDacRec->ReadData = glintTIReadData;
+ pGlint->RamDacRec->WriteData = glintTIWriteData;
+ pGlint->RamDacRec->LoadPalette = TIramdacLoadPalette;
+ }
+ if(!RamDacInit(pScrn, pGlint->RamDacRec)) {
+ RamDacDestroyInfoRec(pGlint->RamDacRec);
+ return;
+ }
+ GLINTMapMem(pScrn);
+ if (pGlint->numMXDevices == 2) {
+ temp = GLINT_READ_REG(GCSRAperture);
+ GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture);
+ }
+ pGlint->RamDac = TIramdacProbe(pScrn, TIRamdacs);
+ if (pGlint->numMXDevices == 2) {
+ GLINT_SLOW_WRITE_REG(temp, GCSRAperture);
+ }
+ GLINTUnmapMem(pScrn);
+}
+
+static void
+GLINTProbeIBMramdac(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint;
+ pGlint = GLINTPTR(pScrn);
+ pGlint->RamDacRec = RamDacCreateInfoRec();
+ pGlint->RamDacRec->ReadDAC = glintInIBMRGBIndReg;
+ pGlint->RamDacRec->WriteDAC = glintOutIBMRGBIndReg;
+ pGlint->RamDacRec->ReadAddress = glintIBMReadAddress;
+ pGlint->RamDacRec->WriteAddress = glintIBMWriteAddress;
+ pGlint->RamDacRec->ReadData = glintIBMReadData;
+ pGlint->RamDacRec->WriteData = glintIBMWriteData;
+ pGlint->RamDacRec->LoadPalette = NULL;
+ if(!RamDacInit(pScrn, pGlint->RamDacRec)) {
+ RamDacDestroyInfoRec(pGlint->RamDacRec);
+ return;
+ }
+ GLINTMapMem(pScrn);
+ pGlint->RamDac = IBMramdacProbe(pScrn, IBMRamdacs);
+ GLINTUnmapMem(pScrn);
+}
+
/* Mandatory */
static Bool
GLINTPreInit(ScrnInfoPtr pScrn, int flags)
@@ -963,8 +874,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
char *mod = NULL;
const char *s;
- if (flags & PROBE_DETECT) return FALSE;
-
TRACE_ENTER("GLINTPreInit");
/*
@@ -984,13 +893,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
if (pScrn->numEntities < 1)
return FALSE;
- /* The ramdac module should be loaded here when needed */
- if (!xf86LoadSubModule(pScrn, "ramdac"))
- return FALSE;
-
- /* Set pScrn->monitor */
- pScrn->monitor = pScrn->confScreen->monitor;
-
/* Allocate the GLINTRec driverPrivate */
if (!GLINTGetRec(pScrn)) {
return FALSE;
@@ -999,21 +901,26 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
/* Get the entities, and make sure they are PCI. */
pGlint->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
- if (pGlint->pEnt->location.type == BUS_PCI)
- {
- /* Initialize the card through int10 interface if needed */
- if ( xf86LoadSubModule(pScrn, "int10")){
- xf86Int10InfoPtr pInt;
-
- xf86LoaderReqSymLists(int10Symbols, NULL);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n");
- pInt = xf86InitInt10(pGlint->pEnt->index);
- xf86FreeInt10(pInt);
+ if (flags & PROBE_DETECT) {
+ GLINTProbeDDC(pScrn, pGlint->pEnt->index);
+ return TRUE;
}
+
+ if (pGlint->pEnt->location.type == BUS_PCI)
+ {
+ /* Initialize the card through int10 interface if needed */
+ if ( xf86LoadSubModule(pScrn, "int10")){
+ xf86Int10InfoPtr pInt;
+
+ xf86LoaderReqSymLists(int10Symbols, NULL);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Initializing int10\n");
+ pInt = xf86InitInt10(pGlint->pEnt->index);
+ xf86FreeInt10(pInt);
+ }
- pGlint->PciInfo = xf86GetPciInfoForEntity(pGlint->pEnt->index);
- pGlint->PciTag = pciTag(pGlint->PciInfo->bus, pGlint->PciInfo->device,
+ pGlint->PciInfo = xf86GetPciInfoForEntity(pGlint->pEnt->index);
+ pGlint->PciTag = pciTag(pGlint->PciInfo->bus, pGlint->PciInfo->device,
pGlint->PciInfo->func);
}
@@ -1024,20 +931,14 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
for (i = 1; i < pScrn->numEntities; i++) {
pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
pPci = xf86GetPciInfoForEntity(pEnt->index);
- if (pPci->chipType == PCI_CHIP_DELTA
- ) {
- pGlint->pEntGeometry = pEnt;
- pGlint->PciInfoGeometry = pPci;
- pGlint->PciTagGeometry = pciTag(pPci->bus, pPci->device,
- pPci->func);
- } else if (pPci->chipType == PCI_CHIP_MX) {
+ if (pPci->chipType == PCI_CHIP_MX) {
if (pGlint->numMXDevices >= GLINT_MAX_MX_DEVICES) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "%d MX chips supported, additional MX device ignored\n",
- GLINT_MAX_MX_DEVICES);
+ "%d MX chips unsupported, aborting. (Max - 2)\n",
+ pGlint->numMXDevices);
+ return FALSE;
} else {
LinearFramebuffer = pPci->memBase[2];
- pGlint->pEntMX[pGlint->numMXDevices] = pEnt;
pGlint->MXPciInfo[pGlint->numMXDevices] = pPci;
pGlint->numMXDevices++;
}
@@ -1058,6 +959,8 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
/*
* The first thing we should figure out is the depth, bpp, etc.
* Our default depth is 8, so pass it to the helper function.
@@ -1081,8 +984,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
}
/* Check that the returned depth is one we support */
switch (pScrn->depth) {
- case 1:
- case 4:
case 8:
case 15:
case 16:
@@ -1208,7 +1109,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
from = X_CONFIG;
pScrn->AdjustFrame = fbdevHWAdjustFrame;
- pScrn->EnterVT = GLINTEnterVTFBDev;
pScrn->LeaveVT = fbdevHWLeaveVT;
pScrn->ValidMode = fbdevHWValidMode;
@@ -1218,7 +1118,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
from = X_PROBED;
pScrn->AdjustFrame = GLINTAdjustFrame;
- pScrn->EnterVT = GLINTEnterVT;
pScrn->LeaveVT = GLINTLeaveVT;
pScrn->ValidMode = GLINTValidMode;
@@ -1308,6 +1207,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
if ((pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2)) {
if (xf86ReturnOptValBool(GLINTOptions, OPTION_BLOCK_WRITE, FALSE)) {
@@ -1341,12 +1241,12 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
(unsigned long)pGlint->FbAddress);
/* Trap GAMMA & DELTA specification, with no linear address */
- /* Find the first TX/MX chip and use that address */
+ /* Find the first SX/TX/MX chip and use that address */
if (pGlint->FbAddress == 0) {
if (LinearFramebuffer) {
pGlint->FbAddress = LinearFramebuffer;
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
- "FrameBuffer used from first TX/MX chip at 0x%x\n",
+ "FrameBuffer used from first SX/TX/MX chip at 0x%x\n",
LinearFramebuffer);
} else {
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
@@ -1363,10 +1263,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
pGlint->IOAddress = pGlint->pEnt->device->IOBase;
from = X_CONFIG;
} else {
- if (pGlint->PciTagGeometry)
- pGlint->IOAddress = pGlint->PciInfoGeometry->memBase[0] &0xFFFFC000;
- else
- pGlint->IOAddress = pGlint->PciInfo->memBase[0] & 0xFFFFC000;
+ pGlint->IOAddress = pGlint->PciInfo->memBase[0] & 0xFFFFC000;
}
#if X_BYTE_ORDER == X_BIG_ENDIAN
pGlint->IOAddress += 0x10000;
@@ -1375,35 +1272,17 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at 0x%lX\n",
(unsigned long)pGlint->IOAddress);
- if (pGlint->SecondaryAddress)
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Secondary MMIO registers at 0x%lX\n", pGlint->SecondaryAddress);
-
pGlint->irq = pGlint->pEnt->device->irq;
- /* Register the PCI-assigned resources. */
- if (pGlint->numMXDevices == 0) {
- if (xf86RegisterResources(pGlint->pEnt->index, NULL, ResExclusive)) {
+ /* Register all entities */
+ for (i = 1; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt;
+ pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+ if (xf86RegisterResources(pEnt->index, NULL, ResExclusive)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"xf86RegisterResources() found resource conflicts\n");
return FALSE;
}
- } else {
- for (i = 0; i < pGlint->numMXDevices; i++) {
- if (xf86RegisterResources(pGlint->pEntMX[i]->index, NULL,
- ResExclusive)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "xf86RegisterResources() found resource conflicts\n");
- return FALSE;
- }
- }
- }
- if (pGlint->pEntGeometry) {
- if (xf86RegisterResources(pGlint->pEntGeometry->index, NULL, ResExclusive)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "xf86RegisterResources() found resource conflicts\n");
- return FALSE;
- }
}
}
@@ -1415,11 +1294,22 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
if (pGlint->pEnt->device->videoRam != 0) {
pScrn->videoRam = pGlint->pEnt->device->videoRam;
from = X_CONFIG;
+ } else if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) {
+ /* Need to initialize the memory timings of the second head
+ * of the Appian Jeronimo 2000 board here.
+ * Check this routine in pm3_dac.c if you have another board
+ * than a J2000, as memory timings will surely change.
+ */
+ GLINTMapMem(pScrn);
+ Permedia3PreInit(pScrn, pGlint);
+ GLINTUnmapMem(pScrn);
+ pScrn->videoRam = Permedia3MemorySizeDetect(pScrn);
} else {
pGlint->FbMapSize = 0; /* Need to set FbMapSize for MMIO access */
/* Need to access MMIO to determine videoRam */
GLINTMapMem(pScrn);
if( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) )
pScrn->videoRam = 1024 * (1 << ((GLINT_READ_REG(FBMemoryCtl) &
@@ -1433,11 +1323,21 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
pScrn->videoRam = fbdevHWGetVidmem(pScrn)/1024;
}
+ pGlint->FbMapSize = pScrn->videoRam * 1024;
+
+ /* We should move this out somewhere ! */
if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
(pGlint->numMXDevices == 2) ) {
- unsigned int chipconfig;
+ CARD32 chipconfig;
+ CARD32 temp;
+
GLINTMapMem(pScrn);
+#if 0
+ /* We shouldn't really do this yet, we haven't saved the
+ * state of the chip.
+ * Best of all put a timer in to reset the engine if it
+ * doesn't respond - but later */
/*
* This is needed before the first GLINT_SLOW_WRITE_REG --
* otherwise the server will hang if it was left in a bad state.
@@ -1446,9 +1346,12 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
while (GLINT_READ_REG(ResetStatus) & 0x80000000) {
xf86DrvMsg(pScrn->scrnIndex, from, "Resetting Core\n");
}
+#endif
+ temp = GLINT_READ_REG(GCSRAperture);
GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture);
+#if 0
xf86DrvMsg(pScrn->scrnIndex, from,
"InFIFOSpace = %d, %d (after reset)\n",
GLINT_READ_REG(InFIFOSpace),
@@ -1475,37 +1378,37 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
"OutFIFOSWords = %d, %d (after drain)\n",
GLINT_READ_REG(OutFIFOWords),
GLINT_SECONDARY_READ_REG(OutFIFOWords));
+#endif
chipconfig = GLINT_READ_REG(GChipConfig);
+
+ GLINT_SLOW_WRITE_REG(GCSRSecondaryGLINTMapEn, GCSRAperture);
+
GLINTUnmapMem(pScrn);
switch (chipconfig & GChipMultiGLINTApMask) {
case GChipMultiGLINTAp_0M:
- pGlint->MultiGLINTApSize = 0;
+ pGlint->FbMapSize = 0;
break;
case GChipMultiGLINTAp_16M:
- pGlint->MultiGLINTApSize = 16 * 1024 * 1024;
+ pGlint->FbMapSize = 16 * 1024 * 1024;
break;
case GChipMultiGLINTAp_32M:
- pGlint->MultiGLINTApSize = 32 * 1024 * 1024;
+ pGlint->FbMapSize = 32 * 1024 * 1024;
break;
case GChipMultiGLINTAp_64M:
- pGlint->MultiGLINTApSize = 64 * 1024 * 1024;
+ pGlint->FbMapSize = 64 * 1024 * 1024;
break;
}
-
- pGlint->FbMapSize = pGlint->MultiGLINTApSize;
- pGlint->MXFbSize = pScrn->videoRam * 1024;
- /* we have twice the memory w/ two MX chips */
- xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
- pScrn->videoRam * 2);
- }
- else {
- pGlint->FbMapSize = pScrn->videoRam * 1024;
- xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
- pScrn->videoRam);
}
+ xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
+ pGlint->FbMapSize / 1024);
+
+ /* The ramdac module should be loaded here when needed */
+ if (!xf86LoadSubModule(pScrn, "ramdac"))
+ return FALSE;
+
/* Let's check what type of DAC we have and reject if necessary */
switch (pGlint->Chipset) {
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
@@ -1526,6 +1429,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
maxheight = 2048;
maxwidth = 2048;
@@ -1547,115 +1451,58 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
maxheight = 1024;
maxwidth = 1536;
- pGlint->RefClock = 14318;
pGlint->VGAcore = TRUE; /* chip has a vga core */
- pGlint->RamDacRec = RamDacCreateInfoRec();
- pGlint->RamDacRec->ReadDAC = glintInIBMRGBIndReg;
- pGlint->RamDacRec->WriteDAC = glintOutIBMRGBIndReg;
- pGlint->RamDacRec->ReadAddress = glintIBMReadAddress;
- pGlint->RamDacRec->WriteAddress = glintIBMWriteAddress;
- pGlint->RamDacRec->ReadData = glintIBMReadData;
- pGlint->RamDacRec->WriteData = glintIBMWriteData;
- if(!RamDacInit(pScrn, pGlint->RamDacRec)) {
- RamDacDestroyInfoRec(pGlint->RamDacRec);
- return FALSE;
- }
- GLINTMapMem(pScrn);
- pGlint->RamDac = IBMramdacProbe(pScrn, PermediaRamdacs);
- GLINTUnmapMem(pScrn);
- if (pGlint->RamDac == NULL)
+ GLINTProbeIBMramdac(pScrn);
+ if (pGlint->RamDac == NULL) return FALSE;
+ if (pGlint->RamDac->RamDacType != (IBM526DB_RAMDAC) ||
+ pGlint->RamDac->RamDacType != (IBM526_RAMDAC))
return FALSE;
+ pGlint->RefClock = 14318;
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
- if (pScrn->bitsPerPixel == 24) {
+ case PCI_VENDOR_3DLABS_CHIP_GAMMA:
+ if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
+ pGlint->UsePCIRetry) {
xf86DrvMsg(pScrn->scrnIndex, from,
- "-depth 24 -pixmap24 not supported by this chip.\n");
- return FALSE;
- }
- maxheight = 4096;
- maxwidth = 4096;
- pGlint->RamDacRec = RamDacCreateInfoRec();
- pGlint->RamDacRec->ReadDAC = glintInIBMRGBIndReg;
- pGlint->RamDacRec->WriteDAC = glintOutIBMRGBIndReg;
- pGlint->RamDacRec->ReadAddress = glintIBMReadAddress;
- pGlint->RamDacRec->WriteAddress = glintIBMWriteAddress;
- pGlint->RamDacRec->ReadData = glintIBMReadData;
- pGlint->RamDacRec->WriteData = glintIBMWriteData;
- if(!RamDacInit(pScrn, pGlint->RamDacRec)) {
- RamDacDestroyInfoRec(pGlint->RamDacRec);
- return FALSE;
- }
- GLINTMapMem(pScrn);
- pGlint->RamDac = IBMramdacProbe(pScrn, TXMXRamdacs);
- GLINTUnmapMem(pScrn);
- if (pGlint->RamDac->RamDacType == (IBM640_RAMDAC))
- pGlint->RefClock = 28322;
- else
- if (pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC) ||
- pGlint->RamDac->RamDacType == (IBM526_RAMDAC))
- pGlint->RefClock = 40000;
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Undefined RefClock\n");
- return FALSE;
+ "GAMMA in use - PCI retries disabled\n");
+ pGlint->UsePCIRetry = FALSE;
}
- if (pGlint->RamDac == NULL)
- return FALSE;
- break;
- case PCI_VENDOR_3DLABS_CHIP_GAMMA:
if (pScrn->bitsPerPixel == 24) {
xf86DrvMsg(pScrn->scrnIndex, from,
"-depth 24 -pixmap24 not supported by this chip.\n");
return FALSE;
}
- if (pGlint->UsePCIRetry) {
- xf86DrvMsg(pScrn->scrnIndex, from,
- "GAMMA in use - PCI retries disabled\n");
- pGlint->UsePCIRetry = FALSE;
- }
maxheight = 4096;
maxwidth = 4096;
- pGlint->RefClock = 14318;
- pGlint->RamDacRec = RamDacCreateInfoRec();
- pGlint->RamDacRec->ReadDAC = glintInTIIndReg;
- pGlint->RamDacRec->WriteDAC = glintOutTIIndReg;
- pGlint->RamDacRec->ReadAddress = glintTIReadAddress;
- pGlint->RamDacRec->WriteAddress = glintTIWriteAddress;
- pGlint->RamDacRec->ReadData = glintTIReadData;
- pGlint->RamDacRec->WriteData = glintTIWriteData;
- if(!RamDacInit(pScrn, pGlint->RamDacRec)) {
- RamDacDestroyInfoRec(pGlint->RamDacRec);
- return FALSE;
+ /* Test for an TI ramdac */
+ if (!pGlint->RamDac) {
+ GLINTProbeTIramdac(pScrn);
+ if (pGlint->RamDac)
+ if ( (pGlint->RamDac->RamDacType == (TI3026_RAMDAC)) ||
+ (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) )
+ pGlint->RefClock = 14318;
}
- GLINTMapMem(pScrn);
- pGlint->RamDac = TIramdacProbe(pScrn, GMX2000Ramdacs);
- GLINTUnmapMem(pScrn);
+ /* Test for an IBM ramdac */
if (!pGlint->RamDac) {
- pGlint->RamDacRec = RamDacCreateInfoRec();
- pGlint->RamDacRec->ReadDAC = glintInIBMRGBIndReg;
- pGlint->RamDacRec->WriteDAC = glintOutIBMRGBIndReg;
- pGlint->RamDacRec->ReadAddress = glintIBMReadAddress;
- pGlint->RamDacRec->WriteAddress = glintIBMWriteAddress;
- pGlint->RamDacRec->ReadData = glintIBMReadData;
- pGlint->RamDacRec->WriteData = glintIBMWriteData;
- if(!RamDacInit(pScrn, pGlint->RamDacRec)) {
- RamDacDestroyInfoRec(pGlint->RamDacRec);
- return FALSE;
+ GLINTProbeIBMramdac(pScrn);
+ if (pGlint->RamDac) {
+ if (pGlint->RamDac->RamDacType == (IBM640_RAMDAC))
+ pGlint->RefClock = 28322;
+ else
+ if (pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC) ||
+ pGlint->RamDac->RamDacType == (IBM526_RAMDAC))
+ pGlint->RefClock = 40000;
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT,
+ "Undefined RefClock\n");
+ return FALSE;
+ }
+ }
}
- GLINTMapMem(pScrn);
- pGlint->RamDac = IBMramdacProbe(pScrn, TXMXRamdacs);
- GLINTUnmapMem(pScrn);
- if (pGlint->RamDac->RamDacType == (IBM640_RAMDAC))
- pGlint->RefClock = 28322;
- else
- if (pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC) ||
- pGlint->RamDac->RamDacType == (IBM526_RAMDAC))
- pGlint->RefClock = 40000;
- else {
- xf86DrvMsg(pScrn->scrnIndex, X_DEFAULT, "Undefined RefClock\n");
+ if (!pGlint->RamDac)
return FALSE;
- }
- }
break;
}
@@ -1708,14 +1555,13 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
from = X_CONFIG;
} else {
if((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX)||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) )
pGlint->MaxClock = 220000;
if ( (pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA) ) {
switch (pScrn->bitsPerPixel) {
- case 1:
- case 4:
case 8:
pGlint->MaxClock = 200000;
break;
@@ -1734,8 +1580,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) ) {
switch (pScrn->bitsPerPixel) {
- case 1:
- case 4:
case 8:
pGlint->MaxClock = 230000;
break;
@@ -1750,6 +1594,24 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
break;
}
}
+ if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) ) {
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ pGlint->MaxClock = 300000;
+ break;
+ case 16:
+ pGlint->MaxClock = 300000;
+ break;
+ case 24:
+ /* Not sure about the 24 & 32 bpp clocks, ... */
+ pGlint->MaxClock = 150000;
+ break;
+ case 32:
+ /* Not sure about the 24 & 32 bpp clocks, ... */
+ pGlint->MaxClock = 150000;
+ break;
+ }
+ }
}
xf86DrvMsg(pScrn->scrnIndex, from, "Max pixel clock is %d MHz\n",
pGlint->MaxClock / 1000);
@@ -1758,7 +1620,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pGlint->MinClock;
clockRanges->maxClock = pGlint->MaxClock;
@@ -1820,34 +1682,29 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
if (pGlint->FBDev) {
/* shift horizontal timings for 64bit VRAM's or 32bit SGRAMs */
- int logbytesperaccess = 2;
-
switch (pScrn->bitsPerPixel) {
case 8:
- pGlint->BppShift = logbytesperaccess;
+ pGlint->BppShift = 2;
break;
case 16:
if (pGlint->DoubleBuffer) {
- pGlint->BppShift = logbytesperaccess-2;
+ pGlint->BppShift = 0;
} else {
- pGlint->BppShift = logbytesperaccess-1;
+ pGlint->BppShift = 1;
}
break;
case 24:
- pGlint->BppShift = logbytesperaccess;
+ pGlint->BppShift = 2;
break;
case 32:
- pGlint->BppShift = logbytesperaccess-2;
+ pGlint->BppShift = 0;
break;
}
pScrn->displayWidth = pScrn->virtualX;
-
/* Ensure vsync and hsync are high when using HW cursor */
-
if (pGlint->HWCursor) {
-
DisplayModePtr mode, first = mode = pScrn->modes;
do { /* We know there is at least the built-in mode */
@@ -1863,10 +1720,11 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
/* Only allow a single mode for MX and TX chipsets */
if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_500TX) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_MX) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)) {
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "GLINT TX/MX chipsets only support one modeline, using first.\n");
+ "GLINT SX/TX/MX chipsets only support one modeline, using first\n");
pScrn->modes->next = NULL;
pScrn->virtualX = pScrn->modes->HDisplay;
pScrn->virtualY = pScrn->modes->VDisplay;
@@ -1878,7 +1736,6 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
i = partprod500TX[pScrn->displayWidth >> 5];
} while (i == -1);
}
- pGlint->realMXWidth = pScrn->displayWidth;
}
switch (pGlint->Chipset)
@@ -1886,6 +1743,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
pGlint->pprod = partprodPermedia[pScrn->displayWidth >> 5];
@@ -1893,12 +1751,98 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
case PCI_VENDOR_3DLABS_CHIP_MX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
pGlint->pprod = partprod500TX[pScrn->displayWidth >> 5];
pGlint->bppalign = 0;
break;
}
+ if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
+ (pGlint->numMXDevices == 2) ) {
+ int bytesPerPixel, realMXWidthBytes, inputXSpanBytes;
+ CARD32 postMultiply, productEnable, use16xProduct, inputXSpan;
+ CARD32 binaryEval, glintApSize;
+
+ /* setup multi glint framebuffer aperture */
+ bytesPerPixel = (pScrn->bitsPerPixel >> 3);
+ realMXWidthBytes = pScrn->displayWidth * bytesPerPixel;
+
+ /* compute Input X Span field */
+ binaryEval = ((realMXWidthBytes << 1) - 1);
+ if (binaryEval & (8 << 10)) { /* 8K */
+ inputXSpan = 3;
+ inputXSpanBytes = 8 * 1024;
+ }
+ else if (binaryEval & (4 << 10)) { /* 4K */
+ inputXSpan = 2;
+ inputXSpanBytes = 4 * 1024;
+ }
+ else if (binaryEval & (2 << 10)) { /* 2K */
+ inputXSpan = 1;
+ inputXSpanBytes = 2 * 1024;
+ }
+ else { /* 1K */
+ inputXSpan = 0;
+ inputXSpanBytes = 1024;
+ }
+
+ /* compute post multiply */
+ binaryEval = realMXWidthBytes >> 3;
+ postMultiply = 0;
+ while ((postMultiply < 5) && !(binaryEval & 1)) {
+ postMultiply++;
+ binaryEval >>= 1;
+ }
+ postMultiply <<= 7;
+
+ /* compute product enable fields */
+ if (binaryEval & ~0x1f) { /* too big */
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "GLINTModeInit: width (%d) too big\n",
+ pScrn->displayWidth);
+ return FALSE;
+ }
+ if ((binaryEval & 0x12) == 0x12) { /* clash between x2 and x16 */
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "GLINTModeInit: width (%d) is mult 18, not supported\n",
+ pScrn->displayWidth);
+ return FALSE;
+ }
+ if (binaryEval & 0x10) {
+ productEnable = (((binaryEval & 0xf) | 0x2) << 3);
+ use16xProduct = (1 << 2);
+ }
+ else {
+ productEnable = ((binaryEval & 0xf) << 3);
+ use16xProduct = 0;
+ }
+
+ /* compute GLINT Aperture Size field */
+ binaryEval = ((pScrn->videoRam << 11) - 1);
+ if (binaryEval & (32 << 20)) { /* 32M */
+ glintApSize = 3 << 10;
+ }
+ else if (binaryEval & (16 << 20)) { /* 16M */
+ glintApSize = 2 << 10;
+ }
+ else if (binaryEval & (8 << 20)) { /* 8M */
+ glintApSize = 1 << 10;
+ }
+ else { /* 4M */
+ glintApSize = 0 << 10;
+ }
+
+ pGlint->realMXWidth = ( glintApSize |
+ postMultiply |
+ productEnable |
+ use16xProduct |
+ inputXSpan );
+
+ /* set the MULTI width for software rendering */
+ pScrn->displayWidth = inputXSpanBytes / bytesPerPixel;
+ }
+
/* Set the current mode to the first in the list */
pScrn->currentMode = pScrn->modes;
@@ -1912,24 +1856,20 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
/* Load bpp-specific modules */
switch (pScrn->bitsPerPixel) {
- case 1:
- case 4:
case 8:
case 16:
- mod = "fb";
- break;
case 24:
- if (pix24bpp == 24)
- mod = "fb";
- else
- mod = "xf24_32bpp";
+ mod = "fb";
break;
case 32:
if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
- mod = "xf8_32bpp";
- } else {
+ if (xf86LoadSubModule(pScrn, "xf8_32bpp") == NULL) {
+ GLINTFreeRec(pScrn);
+ return FALSE;
+ } else
+ xf86LoaderReqSymLists(xf8_32bppSymbols,NULL);
+ } else
mod = "fb";
- }
break;
}
if (mod && xf86LoadSubModule(pScrn, mod) == NULL) {
@@ -1963,6 +1903,7 @@ GLINTPreInit(ScrnInfoPtr pScrn, int flags)
/* Load I2C if needed */
if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) ||
(pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2)) {
if (xf86LoadSubModule(pScrn, "i2c")) {
I2CBusPtr pBus;
@@ -2035,27 +1976,10 @@ GLINTMapMem(ScrnInfoPtr pScrn)
* Map IO registers to virtual address space
* We always map VGA IO registers - even if we don't need them
*/
- if (pGlint->PciTagGeometry) {
- pGlint->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT,
- pGlint->PciTagGeometry, pGlint->IOAddress, 0x20000);
- pGlint->IOBaseVGA = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
- pGlint->PciTagGeometry, pGlint->IOAddress + GLINT_VGA_MMIO_OFF,
- 0x2000);
- } else {
- pGlint->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT,
+ pGlint->IOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO_32BIT,
pGlint->PciTag, pGlint->IOAddress, 0x20000);
- pGlint->IOBaseVGA = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
+ pGlint->IOBaseVGA = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO,
pGlint->PciTag, pGlint->IOAddress + GLINT_VGA_MMIO_OFF, 0x2000);
- }
- if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
- (pGlint->numMXDevices == 2) ) {
- pGlint->SecondaryAddress = pGlint->IOAddress;
- pGlint->SecondaryBase = pGlint->IOBase+0x10000;
- }
- else {
- pGlint->SecondaryAddress = pGlint->IOAddress;
- pGlint->SecondaryBase = pGlint->IOBase;
- }
if (pGlint->IOBase == NULL)
return FALSE;
@@ -2069,55 +1993,8 @@ GLINTMapMem(ScrnInfoPtr pScrn)
return FALSE;
}
- /* Due to bugs in the Glint Delta/Permedia/500TX chips we need to do this */
- /* Bizarre, but it works. */
- if ((pGlint->Chipset != PCI_VENDOR_TI_CHIP_PERMEDIA2) &&
- (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) &&
- (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V)) {
- if (pGlint->PciTag) {
- unsigned long temp, temp2;
-
- /*
- * and now for the magic.
- * read old value
- * write fffffffff
- * read value
- * write old value
- */
- if (pGlint->PciTagGeometry) {
- temp = pciReadLong(pGlint->PciTagGeometry, 0x10);
- pciWriteLong(pGlint->PciTagGeometry, 0x10, 0xffffffff);
- temp2 = pciReadLong(pGlint->PciTagGeometry, 0x10);
- pciWriteLong(pGlint->PciTagGeometry, 0x10, temp & 0xfffffff0);
- }
-
- temp = pciReadLong(pGlint->PciTag, 0x10);
- pciWriteLong(pGlint->PciTag, 0x10, 0xffffffff);
- temp2 = pciReadLong(pGlint->PciTag, 0x10);
- pciWriteLong(pGlint->PciTag, 0x10, temp);
-
- temp = pciReadLong(pGlint->PciTag, 0x14);
- pciWriteLong(pGlint->PciTag, 0x14, 0xffffffff);
- temp2 = pciReadLong(pGlint->PciTag, 0x14);
- pciWriteLong(pGlint->PciTag, 0x14, temp);
-
- temp = pciReadLong(pGlint->PciTag, 0x18);
- pciWriteLong(pGlint->PciTag, 0x18, 0xffffffff);
- temp2 = pciReadLong(pGlint->PciTag, 0x18);
- pciWriteLong(pGlint->PciTag, 0x18, temp);
-
- temp = pciReadLong(pGlint->PciTag, 0x1c);
- pciWriteLong(pGlint->PciTag, 0x1c, 0xffffffff);
- temp2 = pciReadLong(pGlint->PciTag, 0x1c);
- pciWriteLong(pGlint->PciTag, 0x1c, temp);
-
- temp = pciReadLong(pGlint->PciTag, 0x20);
- pciWriteLong(pGlint->PciTag, 0x20, 0xffffffff);
- temp2 = pciReadLong(pGlint->PciTag, 0x20);
- pciWriteLong(pGlint->PciTag, 0x20, temp);
- }
- }
- return TRUE;
+ TRACE_EXIT("GLINTMapMem");
+ return TRUE;
}
@@ -2196,12 +2073,16 @@ GLINTSave(ScrnInfoPtr pScrn)
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
Permedia2VSave(pScrn, glintReg);
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ Permedia3Save(pScrn, glintReg);
+ break;
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
PermediaSave(pScrn, glintReg);
(*pGlint->RamDac->Save)(pScrn, pGlint->RamDacRec, RAMDACreg);
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
@@ -2232,9 +2113,6 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
GLINTRegPtr glintReg;
RamDacHWRecPtr pRAMDAC = RAMDACHWPTR(pScrn);
RamDacRegRecPtr RAMDACreg;
- int bytesPerPixel, realMXWidthBytes, inputXSpanBytes;
- CARD32 glintApSize, postMultiply, productEnable, use16xProduct, inputXSpan;
- CARD32 binaryEval, value;
if (pGlint->VGAcore) {
vgaHWPtr hwp = VGAHWPTR(pScrn);
@@ -2255,11 +2133,15 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
ret = Permedia2VInit(pScrn, mode);
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ ret = Permedia3Init(pScrn, mode);
+ break;
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
ret = PermediaInit(pScrn, mode);
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
@@ -2294,12 +2176,16 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
Permedia2VRestore(pScrn, glintReg);
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ Permedia3Restore(pScrn, glintReg);
+ break;
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
PermediaRestore(pScrn, glintReg);
(*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg);
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
@@ -2313,105 +2199,6 @@ GLINTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
break;
}
- if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
- (pGlint->numMXDevices == 2) ) {
-
- /* setup multi glint framebuffer aperture */
-
- bytesPerPixel = (pScrn->bitsPerPixel >> 3);
- realMXWidthBytes = pGlint->realMXWidth * bytesPerPixel;
-
- /* compute Input X Span field */
- binaryEval = ((realMXWidthBytes << 1) - 1);
- if (binaryEval & (8 << 10)) { /* 8K */
- inputXSpan = 3;
- inputXSpanBytes = 8 * 1024;
- }
- else if (binaryEval & (4 << 10)) { /* 4K */
- inputXSpan = 2;
- inputXSpanBytes = 4 * 1024;
- }
- else if (binaryEval & (2 << 10)) { /* 2K */
- inputXSpan = 1;
- inputXSpanBytes = 2 * 1024;
- }
- else { /* 1K */
- inputXSpan = 0;
- inputXSpanBytes = 1024;
- }
-
- /* set the MULTI width for software rendering */
- pScrn->displayWidth = inputXSpanBytes / bytesPerPixel;
-
- /* compute post multiply */
- binaryEval = (realMXWidthBytes >> 3);
- postMultiply = 0;
- while ((postMultiply < 5) && !(binaryEval & 1)) {
- postMultiply++;
- binaryEval >>= 1;
- }
- postMultiply <<= 7;
-
- /* compute product enable fields */
- if (binaryEval & ~0x1f) { /* too big */
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "GLINTModeInit: width (%d) too big\n",
- pScrn->displayWidth);
- return FALSE;
- }
- if ((binaryEval & 0x12) == 0x12) { /* clash between x2 and x16 */
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "GLINTModeInit: width (%d) is mult 18, not supported\n",
- pScrn->displayWidth);
- return FALSE;
- }
- if (binaryEval & 0x10) {
- productEnable = (((binaryEval & 0xf) | 0x2) << 3);
- use16xProduct = (1 << 2);
- }
- else {
- productEnable = ((binaryEval & 0xf) << 3);
- use16xProduct = 0;
- }
-
- /* compute GLINT Aperture Size field */
- binaryEval = ((pGlint->MXFbSize << 1) - 1);
- if (binaryEval & (32 << 20)) { /* 32M */
- glintApSize = 3 << 10;
- }
- else if (binaryEval & (16 << 20)) { /* 16M */
- glintApSize = 2 << 10;
- }
- else if (binaryEval & (8 << 20)) { /* 8M */
- glintApSize = 1 << 10;
- }
- else { /* 4M */
- glintApSize = 0 << 10;
- }
-
- /*
- * Setup HW
- *
- * Note: The order of discovery for the MX devices is dependent
- * on which way the resource allocation code decides to scan the
- * bus. This setup assumes the first MX found owns the even
- * scanlines. Should the implementation change an scan the bus
- * in the opposite direction, then simple invert the indices for
- * MXPciInfo below. If this is setup wrong, the bug will appear
- * as incorrect scanline interleaving when software rendering.
- */
- value = ( glintApSize |
- postMultiply |
- productEnable |
- use16xProduct |
- inputXSpan );
- GLINT_SLOW_WRITE_REG(value, GMultGLINTAperture);
- value = pGlint->MXPciInfo[0]->memBase[2] & 0xFF800000;
- GLINT_SLOW_WRITE_REG(value, GMultGLINT1);
- value = pGlint->MXPciInfo[1]->memBase[2] & 0xFF800000;
- GLINT_SLOW_WRITE_REG(value, GMultGLINT2);
- }
-
if (pGlint->VGAcore) {
vgaHWProtect(pScrn, FALSE);
}
@@ -2446,19 +2233,23 @@ GLINTRestore(ScrnInfoPtr pScrn)
switch (pGlint->Chipset) {
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
- Permedia2VideoReset(pScrn);
+ Permedia2VideoLeaveVT(pScrn);
Permedia2Restore(pScrn, glintReg);
break;
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
- Permedia2VideoReset(pScrn);
+ Permedia2VideoLeaveVT(pScrn);
Permedia2VRestore(pScrn, glintReg);
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ Permedia3Restore(pScrn, glintReg);
+ break;
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
PermediaRestore(pScrn, glintReg);
(*pGlint->RamDac->Restore)(pScrn, pGlint->RamDacRec, RAMDACreg);
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
@@ -2513,7 +2304,10 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!vgaHWMapMem(pScrn))
return FALSE;
}
- vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0);
+ /* Timing problem with PM3 & PM2V chips dont like being blasted */
+ if ((pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) &&
+ (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V))
+ vgaHWSetMmioFuncs(hwp, pGlint->IOBaseVGA, 0);
vgaHWGetIOBase(hwp);
}
@@ -2592,8 +2386,8 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#ifdef XF86DRI
/*
- * Setup DRI after visuals have been established, but before cfbScreenInit
- * is called. cfbScreenInit will eventually call into the drivers
+ * Setup DRI after visuals have been established, but before fbScreenInit
+ * is called. fbScreenInit will eventually call into the drivers
* InitGLXVisuals call back.
*/
if (!pGlint->NoAccel && pGlint->HWCursor) {
@@ -2620,27 +2414,14 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
switch (pScrn->bitsPerPixel) {
- case 1:
- case 4:
case 8:
case 16:
+ case 24:
ret = fbScreenInit(pScreen, FBStart,
pScrn->virtualX, pScrn->virtualY,
pScrn->xDpi, pScrn->yDpi,
displayWidth, pScrn->bitsPerPixel);
break;
- case 24:
- if (pix24bpp == 24)
- ret = fbScreenInit(pScreen, FBStart,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- displayWidth, pScrn->bitsPerPixel);
- else
- ret = cfb24_32ScreenInit(pScreen, FBStart,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- displayWidth);
- break;
case 32:
if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR)
ret = cfb8_32ScreenInit(pScreen, FBStart,
@@ -2665,6 +2446,9 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
xf86SetBlackWhitePixels(pScreen);
+ if (!pGlint->ShadowFB)
+ GLINTDGAInit(pScreen);
+
if (pScrn->bitsPerPixel > 8) {
/* Fixup RGB ordering */
visual = pScreen->visuals + pScreen->numVisuals;
@@ -2688,6 +2472,9 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
Permedia2AccelInit(pScreen);
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ Permedia3AccelInit(pScreen);
+ break;
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
PermediaAccelInit(pScreen);
@@ -2703,6 +2490,9 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
TXAccelInit(pScreen);
}
break;
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
+ SXAccelInit(pScreen);
+ break;
}
}
@@ -2714,6 +2504,7 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Initialise cursor functions */
if (pGlint->HWCursor) {
+ /* Handle VGA chipsets first */
if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) ||
(pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2))
Permedia2HWCursorInit(pScreen);
@@ -2721,15 +2512,17 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V)
Permedia2vHWCursorInit(pScreen);
else
- if ( ((pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) &&
- (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) &&
- (pGlint->Chipset != PCI_VENDOR_TI_CHIP_PERMEDIA2)) &&
- ((pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC)) ||
+ if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3)
+ Permedia3HWCursorInit(pScreen);
+ else
+ /* If we get here pGlint->Ramdac should have been set */
+ if ( ((pGlint->RamDac->RamDacType == (IBM526DB_RAMDAC)) ||
(pGlint->RamDac->RamDacType == (IBM526_RAMDAC)) ||
(pGlint->RamDac->RamDacType == (IBM640_RAMDAC))) )
glintIBMHWCursorInit(pScreen);
else
- if (pGlint->RamDac->RamDacType == (TI3030_RAMDAC))
+ if ( (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) ||
+ (pGlint->RamDac->RamDacType == (TI3026_RAMDAC)) )
glintTIHWCursorInit(pScreen);
}
@@ -2738,6 +2531,7 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
return FALSE;
if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA3) ||
(pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_PERMEDIA2) ||
(pGlint->Chipset == PCI_VENDOR_TI_CHIP_PERMEDIA2)) {
if (!xf86HandleColormaps(pScreen, 256, pScrn->rgbBits,
@@ -2818,7 +2612,7 @@ GLINTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
/* Usually mandatory */
-static Bool
+Bool
GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
ScrnInfoPtr pScrn;
@@ -2831,27 +2625,31 @@ GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
Bool ret = fbdevHWSwitchMode(scrnIndex, mode, flags);
if (!pGlint->NoAccel) {
- switch (pGlint->Chipset) {
- case PCI_VENDOR_TI_CHIP_PERMEDIA2:
- case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
- case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
- Permedia2InitializeEngine(pScrn);
- break;
- case PCI_VENDOR_TI_CHIP_PERMEDIA:
- case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
- PermediaInitializeEngine(pScrn);
- break;
- case PCI_VENDOR_3DLABS_CHIP_500TX:
- case PCI_VENDOR_3DLABS_CHIP_MX:
- case PCI_VENDOR_3DLABS_CHIP_GAMMA:
- if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
- (pGlint->numMXDevices == 2) ) {
- DualMXInitializeEngine(pScrn);
- } else {
- TXInitializeEngine(pScrn);
- }
- break;
- }
+ switch (pGlint->Chipset) {
+ case PCI_VENDOR_TI_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
+ Permedia2InitializeEngine(pScrn);
+ break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ Permedia3InitializeEngine(pScrn);
+ break;
+ case PCI_VENDOR_TI_CHIP_PERMEDIA:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
+ PermediaInitializeEngine(pScrn);
+ break;
+ case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
+ case PCI_VENDOR_3DLABS_CHIP_MX:
+ case PCI_VENDOR_3DLABS_CHIP_GAMMA:
+ if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
+ (pGlint->numMXDevices == 2)) {
+ DualMXInitializeEngine(pScrn);
+ } else {
+ TXInitializeEngine(pScrn);
+ }
+ break;
+ }
}
return ret;
@@ -2866,7 +2664,7 @@ GLINTSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
* displayed location in the video memory.
*/
/* Usually mandatory */
-static void
+void
GLINTAdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScrn;
@@ -2896,6 +2694,7 @@ GLINTAdjustFrame(int scrnIndex, int x, int y, int flags)
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
GLINT_SLOW_WRITE_REG(base, PMScreenBase);
break;
}
@@ -2914,22 +2713,23 @@ static Bool
GLINTEnterVT(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ GLINTPtr pGlint = GLINTPTR(pScrn);
- /* Should we re-save the text mode on each VT enter? */
- if (!GLINTModeInit(pScrn, pScrn->currentMode))
- return FALSE;
-
- return TRUE;
-}
+ TRACE_ENTER("GLINTEnterVT");
-static Bool
-GLINTEnterVTFBDev(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
- GLINTPtr pGlint = GLINTPTR(pScrn);
+ if (pGlint->FBDev)
+ fbdevHWEnterVT(scrnIndex, flags);
+ else
+ /* Should we re-save the text mode on each VT enter? */
+ if (!GLINTModeInit(pScrn, pScrn->currentMode))
+ return FALSE;
- TRACE_ENTER("GLINTEnterVTFBDev");
- fbdevHWEnterVT(scrnIndex, flags);
+ switch (pGlint->Chipset) {
+ case PCI_VENDOR_TI_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
+ Permedia2VideoEnterVT(pScrn);
+ }
if (!pGlint->NoAccel) {
switch (pGlint->Chipset) {
@@ -2938,11 +2738,15 @@ GLINTEnterVTFBDev(int scrnIndex, int flags)
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
Permedia2InitializeEngine(pScrn);
break;
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
+ Permedia3InitializeEngine(pScrn);
+ break;
case PCI_VENDOR_TI_CHIP_PERMEDIA:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
PermediaInitializeEngine(pScrn);
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
case PCI_VENDOR_3DLABS_CHIP_GAMMA:
if ( (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA) &&
@@ -3009,7 +2813,7 @@ GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen)
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
- Permedia2VideoUninit(xf86Screens[scrnIndex]);
+ Permedia2VideoUninit(pScrn);
}
if (pScrn->vtSema) {
@@ -3030,6 +2834,8 @@ GLINTCloseScreen(int scrnIndex, ScreenPtr pScreen)
xf86DestroyCursorInfoRec(pGlint->CursorInfoRec);
if (pGlint->ShadowPtr)
xfree(pGlint->ShadowPtr);
+ if (pGlint->DGAModes)
+ xfree(pGlint->DGAModes);
pScrn->vtSema = FALSE;
if (xf86IsPc98())
@@ -3051,7 +2857,7 @@ GLINTFreeScreen(int scrnIndex, int flags)
GLINTPtr pGlint = GLINTPTR(pScrn);
TRACE_ENTER("GLINTFreeScreen");
- if (pGlint->FBDev && xf86LoaderCheckSymbol("fbdevHWFreeRec"))
+ if ((pGlint->FBDev || FBDevProbed) && xf86LoaderCheckSymbol("fbdevHWFreeRec"))
fbdevHWFreeRec(xf86Screens[scrnIndex]);
if (pGlint->VGAcore && xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
vgaHWFreeHWRec(xf86Screens[scrnIndex]);
@@ -3079,6 +2885,7 @@ GLINTValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
* side appears if not aligned properly */
switch (pGlint->Chipset) {
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
if (mode->HDisplay % 8) {
@@ -3133,15 +2940,17 @@ GLINTSaveScreen(ScreenPtr pScreen, int mode)
switch (pGlint->Chipset) {
case PCI_VENDOR_TI_CHIP_PERMEDIA2:
case PCI_VENDOR_TI_CHIP_PERMEDIA:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA3:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
case PCI_VENDOR_3DLABS_CHIP_PERMEDIA:
temp = GLINT_READ_REG(PMVideoControl);
if (unblank) temp |= 1;
else temp &= 0xFFFFFFFE;
- GLINT_WRITE_REG(temp, PMVideoControl);
+ GLINT_SLOW_WRITE_REG(temp, PMVideoControl);
break;
case PCI_VENDOR_3DLABS_CHIP_500TX:
+ case PCI_VENDOR_3DLABS_CHIP_300SX:
case PCI_VENDOR_3DLABS_CHIP_MX:
break;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h
index f33e42c80..a1c5e5914 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.15 2000/03/07 01:37:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/glint_regs.h,v 1.19 2000/05/10 20:01:31 alanh Exp $ */
/*
* glint register file
@@ -35,6 +35,9 @@
#define PCI_CHIP_3DLABS_PERMEDIA 0x04
#define PCI_CHIP_3DLABS_MX 0x06
#define PCI_CHIP_3DLABS_PERMEDIA2 0x07
+#define PCI_CHIP_3DLABS_GAMMA 0x08
+#define PCI_CHIP_3DLABS_PERMEDIA2V 0x09
+#define PCI_CHIP_3DLABS_PERMEDIA3 0x0A
#define PCI_CHIP_TI_PERMEDIA 0x3d04
#define CFGRevisionId 0x08
@@ -90,6 +93,10 @@
#define SCLK_SEL_MCLK_HALF (3 << 10)
#define ByDMAControl 0x00D8
+/* GLINT R3 & Permedia3 Region 0 Bypass Controls */
+#define PM3ByAperture1Mode 0x0300
+#define PM3ByAperture2Mode 0x0328
+
/* GLINT 500TX LocalBuffer Registers */
#define LBMemoryCtl 0x1000
#define LBNumBanksMask 0x00000001
@@ -192,6 +199,17 @@
#define PMFramebufferWriteMask 0x1140
#define PMCount 0x1180
+/* Permedia 3 & GLINT R3 Memory Control */
+#define PM3MemCounter 0x1000
+#define PM3MemBypassWriteMask 0x1008
+#define PM3MemScratch 0x1010
+#define PM3LocalMemCaps 0x1018
+#define PM3LocalMemTimings 0x1020
+#define PM3LocalMemControl 0x1028
+#define PM3LocalMemRefresh 0x1030
+#define PM3LocalMemPowerDown 0x1038
+#define PM3RemoteMemControl 0x1100
+
/* Framebuffer Registers */
#define FBMemoryCtl 0x1800
#define FBModeSel 0x1808
@@ -1146,14 +1164,15 @@
#define GLINT_READ_REG(r) \
GLINT_VERB_READ_REG(pGlint,r,__FILE__,__LINE__)
#else
-#define GLINT_WRITE_REG(v,r) \
-do{ \
- *(volatile CARD32 *)((char *)pGlint->IOBase+(r))=v; \
- mem_barrier(); \
-}while(0)
-#define GLINT_READ_REG(r) \
- (*(volatile CARD32 *)((char *)pGlint->IOBase+(r)))
-#endif
+
+#define GLINT_WRITE_REG(v,r) MMIO_OUT32(pGlint->IOBase,(unsigned long)r, v)
+#define GLINT_READ_REG(r) MMIO_IN32(pGlint->IOBase,(unsigned long)r)
+#define GLINT_SECONDARY_WRITE_REG(v,r) \
+ MMIO_OUT32(pGlint->IOBase,(unsigned long)r+0x10000, v)
+#define GLINT_SECONDARY_READ_REG(r) \
+ MMIO_IN32(pGlint->IOBase,(unsigned long)r+0x10000)
+
+#endif /* DEBUG */
#define GLINT_WAIT(n) \
do{ \
@@ -1179,23 +1198,12 @@ do{ \
GLINTDACDelay(5); \
}while(0)
-#define GLINT_SECONDARY_WRITE_REG(v,r) \
-do{ \
- *(volatile CARD32 *)((char *)pGlint->SecondaryBase+(r))=v; \
-}while(0)
-
-#define GLINT_SECONDARY_READ_REG(r) \
- (*(volatile CARD32 *)((char *)pGlint->SecondaryBase+(r)))
-
#define GLINT_SECONDARY_SLOW_WRITE_REG(v,r) \
do{ \
while(GLINT_READ_REG(InFIFOSpace)<1); \
GLINT_SECONDARY_WRITE_REG(v,r); \
}while(0)
-#define GLINT_LOAD_PAR(v,r) \
- *(unsigned long *)((char*)pGlint->IOBase+r) = *((unsigned long *) &v)
-
#define REPLICATE(r) \
{ \
if (pScrn->bitsPerPixel == 16) { \
@@ -1208,14 +1216,21 @@ do{ \
} \
}
+#ifndef XF86DRI
#define LOADROP(rop) \
{ \
- if (pGlint->ROP != rop) { \
+ if (pGlint->ROP != rop) { \
GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \
pGlint->ROP = rop; \
} \
}
-
+#else
+#define LOADROP(rop) \
+ { \
+ GLINT_WRITE_REG(rop<<1|UNIT_ENABLE, LogicalOpMode); \
+ pGlint->ROP = rop; \
+ }
+#endif
#define CHECKCLIPPING \
{ \
@@ -1226,6 +1241,7 @@ do{ \
} \
}
+#ifndef XF86DRI
#define DO_PLANEMASK(planemask) \
{ \
if (planemask != pGlint->planemask) { \
@@ -1234,4 +1250,12 @@ do{ \
GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
} \
}
+#else
+#define DO_PLANEMASK(planemask) \
+ { \
+ pGlint->planemask = planemask; \
+ REPLICATE(planemask); \
+ GLINT_WRITE_REG(planemask, FBHardwareWriteMask);\
+ }
+#endif
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c
index 6d1863f0a..65b7d0b36 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c
@@ -30,7 +30,7 @@
*
* Permedia 2 accelerated options.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.23 2000/02/25 21:02:50 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_accel.c,v 1.24 2000/03/31 22:55:43 dawes Exp $ */
#include "Xarch.h"
#include "xf86.h"
@@ -288,8 +288,11 @@ Permedia2AccelInit(ScreenPtr pScreen)
infoPtr->PolylinesThinSolidFlags = 0;
infoPtr->SetupForSolidLine = Permedia2SetupForSolidLine;
infoPtr->SubsequentSolidHorVertLine = Permedia2SubsequentHorVertLine;
- infoPtr->SubsequentSolidBresenhamLine =
+ if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR))
+ {
+ infoPtr->SubsequentSolidBresenhamLine =
Permedia2SubsequentSolidBresenhamLine;
+ }
infoPtr->PolySegmentThinSolid = Permedia2PolySegmentThinSolidWrapper;
infoPtr->PolylinesThinSolid = Permedia2PolylinesThinSolidWrapper;
infoPtr->SetupForSolidFill = Permedia2SetupForFillRectSolid;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c
index 71b38c25c..8b8ad3263 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c
@@ -1,40 +1,27 @@
/*
- * Permedia 2 Xv Driver for Elsa Winner Office/2000 and GLoria Synergy cards
+ * Permedia 2 Xv Driver
*
- * Copyright (C) 1998, 1999 Michael Schimek <m.schimek@netway.at>
+ * Copyright (C) 1998-2000 Michael H. Schimek <m.schimek@netway.at>
*
- * 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 Michael Schimek not be used in
- * advertising or publicity pertaining to distribution of the software without
- * specific, written prior permission. Michael Schimek makes no representations
- * about the suitability of this software for any purpose. It is provided
- * "as is" without express or implied warranty.
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and 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:
*
- * MICHAEL SCHIMEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL MICHAEL SCHIMEK 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 above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
*
- * Kernel backbone, docs and test/demo applications at
- * <http://millennium.diads.com/mschimek/pm2>.
- *
- * Implementation note: The kernel backbone uses VSA, VSB and DMA (FIFO)
- * interrupts. It launches Input and Output FIFO DMAs when entered in
- * xvipcHandshake(). These resources are assumed to be available any time,
- * the server code must not touch them. All DMA will be completed before
- * returning from the kernel, no need to test.
- *
- * This driver is meant for the on-board video hardware only, no V4L
- * support in this file.
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY 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
*/
-
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c,v 1.14 1999/12/11 20:03:15 mvojkovi Exp $ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2_video.c,v 1.17 2000/06/19 15:01:01 tsi Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -50,124 +37,151 @@
#include "glint_regs.h"
#include "glint.h"
+#ifndef XvExtension
+
+void Permedia2VideoInit(ScreenPtr pScreen) {}
+void Permedia2VideoUninit(ScrnInfoPtr pScrn) {}
+void Permedia2VideoEnterVT(ScrnInfoPtr pScrn) {}
+void Permedia2VideoLeaveVT(ScrnInfoPtr pScrn) {}
+
+#else
+
+#undef MIN
+#undef ABS
+#undef CLAMP
+#undef ENTRIES
+
+#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define ABS(n) (((n) < 0) ? -(n) : (n))
+#define CLAMP(v, min, max) (((v) < (min)) ? (min) : MIN(v, max))
+#define ENTRIES(array) (sizeof(array) / sizeof((array)[0]))
+
+#define ADAPTORS 3
+#define PORTS 6
+
+#define PCI_SUBSYSTEM_ID_WINNER_2000_P2C 0x0a311048
+#define PCI_SUBSYSTEM_ID_GLORIA_SYNERGY_P2C 0x0a321048
+#define PCI_SUBSYSTEM_ID_GLORIA_SYNERGY_P2A 0x0a351048
+#define PCI_SUBSYSTEM_ID_WINNER_2000_P2A 0x0a441048
+
+/*
+ * Proprietary kernel backbone interface
+ */
+
#define XVIPC_MAGIC 0x6A5D70E6
#define XVIPC_VERSION 1
#define VIDIOC_PM2_XVIPC 0x00007F7F
typedef enum {
- OP_ATTR = 0,
- OP_RESET = 8, /* unused */
- OP_START,
- OP_STOP,
- OP_PLUG,
- OP_VIDEOSTD,
- OP_WINDOW, /* unused */
- OP_CONNECT,
- OP_EVENT,
- OP_ALLOC,
- OP_FREE,
- OP_UPDATE,
- OP_NOP /* ignored */
+ OP_ATTR = 0,
+ OP_RESET = 8, /* unused */
+ OP_START,
+ OP_STOP,
+ OP_PLUG,
+ OP_VIDEOSTD,
+ OP_WINDOW, /* unused */
+ OP_CONNECT,
+ OP_EVENT,
+ OP_ALLOC,
+ OP_FREE,
+ OP_UPDATE,
+ OP_NOP, /* ignored */
+ OP_ENTER,
+ OP_LEAVE,
+ OP_DISCONNECT
} xvipc_op;
typedef struct _pm2_xvipc {
- int magic;
- void *pm2p, *pAPriv;
- int port, op, time, block;
- int a,b,c,d,e,f;
+ int magic;
+ void *pm2p, *pAPriv;
+ int port, op, time, block;
+ int a, b, c, d, e, f;
} pm2_xvipc;
static pm2_xvipc xvipc;
static int xvipc_fd = -1;
-typedef enum {
- OPTION_DEVICE,
- OPTION_FPS,
- OPTION_BUFFERS,
- OPTION_EXPOSE
-} OptToken;
-
-static OptionInfoRec AdaptorOptions[] = {
- { OPTION_DEVICE, "Device", OPTV_STRING, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-static OptionInfoRec InputOptions[] = {
- { OPTION_BUFFERS, "Buffers", OPTV_INTEGER, {0}, FALSE },
- { OPTION_FPS, "FramesPerSec", OPTV_INTEGER, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-static OptionInfoRec OutputOptions[] = {
- { OPTION_BUFFERS, "Buffers", OPTV_INTEGER, {0}, FALSE },
- { OPTION_EXPOSE, "Expose", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_FPS, "FramesPerSec", OPTV_INTEGER, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
-};
-#define PCI_SUBSYSTEM_ID_WINNER_2000_P2C 0x0a311048
-#define PCI_SUBSYSTEM_ID_GLORIA_SYNERGY_P2C 0x0a321048
-#define PCI_SUBSYSTEM_ID_GLORIA_SYNERGY_P2A 0x0a351048
-#define PCI_SUBSYSTEM_ID_WINNER_2000_P2A 0x0a441048
-
-#define SAA7111_SLAVE_ADDRESS 0x48
-#define SAA7125_SLAVE_ADDRESS 0x88
+#define MAX_BUFFERS 2
typedef struct {
- CARD32 xy, wh; /* 16.0 16.0 dw */
- INT32 s, t; /* 12.20 fp */
+ CARD32 xy, wh; /* 16.0 16.0 */
+ INT32 s, t; /* 12.20 fp */
short y1, y2;
} CookieRec, *CookiePtr;
typedef struct _PortPrivRec {
struct _AdaptorPrivRec * pAdaptor;
I2CDevRec I2CDev;
- int Plug;
- INT32 Attribute[8]; /* Brig, Con, Sat, Hue, Int, Filt */
- FBAreaPtr pFBArea[3];
- int Buffers;
- CARD32 BufferBase[3]; /* x1 */
- CARD32 BufferStride; /* x1 */
- CARD32 BufferPProd; /* PProd(BufferStride / 2) */
- INT32 vx, vy, vw, vh; /* 12.10 fp; int */
+
+ INT32 Attribute[8]; /* Brig, Con, Sat, Hue, Int, Filt, BkgCol, Alpha */
+
+ int BuffersRequested;
+ int BuffersAllocated;
+ FBAreaPtr pFBArea[MAX_BUFFERS];
+ CARD32 BufferBase[MAX_BUFFERS]; /* FB byte offset */
+ CARD32 BufferStride; /* bytes */
+ CARD32 BufferPProd; /* PProd(BufferStride in buffer pixels) */
+
+ INT32 vx, vy, vw, vh; /* 12.10 fp */
int dx, dy, dw, dh;
int fw, fh;
+
CookiePtr pCookies;
int nCookies;
- INT32 dS, dT; /* 12.20 fp */
- int APO;
+ INT32 dS, dT; /* 12.20 fp */
+
+ int Id, Bpp; /* Scaler */
+
+ int Plug;
+ int BkgCol; /* RGB 5:6:5; 5:6:5 */
+ Bool StreamOn; /* buffer <-> hardware */
+ int VideoOn; /* buffer <-> screen */
+ int VideoStdReq;
+
+ int StopDelay;
+
int FramesPerSec, FrameAcc;
- int BkgCol; /* RGB 5:6:5;5:6:5 */
- int VideoOn; /* No, Once, Yes */
- Bool StreamOn;
+
} PortPrivRec, *PortPrivPtr;
+enum { VIDEO_OFF, VIDEO_ONE_SHOT, VIDEO_ON };
+
typedef struct _LFBAreaRec {
struct _LFBAreaRec * Next;
- FBAreaPtr pFBArea;
int Linear;
+ FBAreaPtr pFBArea;
} LFBAreaRec, *LFBAreaPtr;
typedef struct _AdaptorPrivRec {
struct _AdaptorPrivRec * Next;
ScrnInfoPtr pScrn;
+
void * pm2p;
LFBAreaPtr LFBList;
- CARD32 FifoControl;
+
+ CARD32 dFifoControl;
+ CARD32 dDitherMode;
+ CARD32 dAlphaBlendMode;
+ CARD32 dTextureDataFormat;
+
OsTimerPtr Timer;
- int VideoStd;
+ int TimerUsers;
+ int Delay, Instant;
+
int FramesPerSec;
int FrameLines;
- int IntLine; /* Frame */
- int LinePer; /* nsec */
- PortPrivRec Port[2];
-} AdaptorPrivRec, *AdaptorPrivPtr;
+ int IntLine; /* Frame, not field */
+ int LinePer; /* nsec */
-static AdaptorPrivPtr AdaptorPrivList = NULL;
+ Bool VideoIO;
+ int VideoStd;
-#define PORTNUM(p) (((p) == &pAPriv->Port[0]) ? 0 : 1)
-#define BPPSHIFT(g) (2 - (g)->BppShift) /* BytesPerPixel = 1 << BPPSHIFT(pGlint) */
+ PortPrivRec Port[PORTS];
-#undef COLORBARS /* Display them while output is unused, else just shut off */
-#define DEBUG(x) /* x */
+} AdaptorPrivRec, *AdaptorPrivPtr;
+
+static AdaptorPrivPtr AdaptorPrivList = NULL;
#define FreeCookies(pPPriv) \
do { \
@@ -177,25 +191,68 @@ do { \
} \
} while (0)
-/* Forward */
-static CARD32 TimerCallback(OsTimerPtr pTim, CARD32 now, pointer p);
-static void DelayedStopVideo(PortPrivPtr pPPriv);
-static Bool xvipcHandshake(PortPrivPtr pPPriv, int op, Bool block);
+#define PORTNUM(p) ((int)((p) - &pAPriv->Port[0]))
+#define BPPSHIFT(g) (2 - (g)->BppShift) /* Bytes per pixel = 1 << BPPSHIFT(pGlint) */
+
+#define DEBUG(x)
+
+static const Bool ColorBars = FALSE;
+
+
+/*
+ * XF86Config VideoAdaptor options
+ */
+
+typedef enum {
+ OPTION_DEVICE,
+ OPTION_FPS,
+ OPTION_BUFFERS,
+ OPTION_ENCODING,
+ OPTION_EXPOSE /* obsolete, ignored */
+} OptToken;
+static OptionInfoRec AdaptorOptions[] = {
+ { OPTION_DEVICE, "Device", OPTV_STRING, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+static OptionInfoRec InputOptions[] = {
+ { OPTION_BUFFERS, "Buffers", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_FPS, "FramesPerSec", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_ENCODING, "Encoding", OPTV_STRING, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+static OptionInfoRec OutputOptions[] = {
+ { OPTION_BUFFERS, "Buffers", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_EXPOSE, "Expose", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_FPS, "FramesPerSec", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_ENCODING, "Encoding", OPTV_STRING, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+
+/*
+ * Attributes
+ */
+
#define XV_ENCODING "XV_ENCODING"
-#define XV_BRIGHTNESS "XV_BRIGHTNESS"
+#define XV_BRIGHTNESS "XV_BRIGHTNESS"
#define XV_CONTRAST "XV_CONTRAST"
-#define XV_SATURATION "XV_SATURATION"
+#define XV_SATURATION "XV_SATURATION"
#define XV_HUE "XV_HUE"
+
/* Proprietary */
-#define XV_INTERLACE "XV_INTERLACE" /* Integer */
-#define XV_FILTER "XV_FILTER" /* Boolean */
-#define XV_BKGCOLOR "XV_BKGCOLOR" /* Integer */
+
+#define XV_INTERLACE "XV_INTERLACE" /* Interlaced (bool) */
+#define XV_FILTER "XV_FILTER" /* Bilinear filter (bool) */
+#define XV_BKGCOLOR "XV_BKGCOLOR" /* Output background (0x00RRGGBB) */
+#define XV_ALPHA "XV_ALPHA" /* Scaler alpha channel (bool) */
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
static Atom xvEncoding, xvBrightness, xvContrast, xvSaturation, xvHue;
-static Atom xvInterlace, xvFilter, xvBkgColor;
+static Atom xvInterlace, xvFilter, xvBkgColor, xvAlpha;
+
+/* Input */
static XF86VideoEncodingRec
InputVideoEncodings[] =
@@ -211,6 +268,28 @@ InputVideoEncodings[] =
{ 8, "secam-svideo", 704, 576, { 1, 50 }},
};
+static XF86AttributeRec
+InputVideoAttributes[] =
+{
+ { XvSettable | XvGettable, -1000, +1000, XV_BRIGHTNESS },
+ { XvSettable | XvGettable, -3000, +1000, XV_CONTRAST },
+ { XvSettable | XvGettable, -3000, +1000, XV_SATURATION },
+ { XvSettable | XvGettable, -1000, +1000, XV_HUE },
+ { XvSettable | XvGettable, 0, 2, XV_INTERLACE },
+ { XvSettable | XvGettable, 0, 1, XV_FILTER },
+};
+
+static XF86VideoFormatRec
+InputVideoFormats[] =
+{
+ { 8, TrueColor }, /* Dithered */
+ { 15, TrueColor },
+ { 16, TrueColor },
+ { 24, TrueColor },
+};
+
+/* Output */
+
static XF86VideoEncodingRec
OutputVideoEncodings[] =
{
@@ -220,16 +299,17 @@ OutputVideoEncodings[] =
{ 3, "ntsc-svideo", 704, 480, { 1001, 60000 }},
};
-static XF86VideoFormatRec
-InputVideoFormats[] = {
- { 8, TrueColor }, /* Dithered */
- { 15, TrueColor },
- { 16, TrueColor },
- { 24, TrueColor },
+static XF86AttributeRec
+OutputVideoAttributes[] =
+{
+ { XvSettable | XvGettable, 0, 2, XV_INTERLACE },
+ { XvSettable | XvGettable, 0, 1, XV_FILTER },
+ { XvSettable | XvGettable, 0x000000, 0xFFFFFF, XV_BKGCOLOR },
};
static XF86VideoFormatRec
-OutputVideoFormats[] = {
+OutputVideoFormats[] =
+{
{ 8, TrueColor },
{ 8, PseudoColor }, /* Using .. */
{ 8, StaticColor },
@@ -240,6 +320,129 @@ OutputVideoFormats[] = {
{ 24, TrueColor },
};
+/* Scaler */
+
+static XF86VideoEncodingRec
+ScalerEncodings[] =
+{
+ { 0, "XV_IMAGE", 2047, 2047, { 1, 1 }},
+};
+
+static XF86AttributeRec
+ScalerAttributes[] =
+{
+ { XvSettable | XvGettable, 0, 1, XV_FILTER },
+ { XvSettable | XvGettable, 0, 1, XV_ALPHA },
+};
+
+#define ScalerVideoFormats InputVideoFormats
+
+/*
+ * FOURCC from http://www.webartz.com/fourcc
+ * Generic GUID for legacy FOURCC XXXXXXXX-0000-0010-8000-00AA00389B71
+ */
+#define LE4CC(a,b,c,d) (((CARD32)(a)&0xFF)|(((CARD32)(b)&0xFF)<<8)|(((CARD32)(c)&0xFF)<<16)|(((CARD32)(d)&0xFF)<<24))
+#define GUID4CC(a,b,c,d) { a,b,c,d,0,0,0,0x10,0x80,0,0,0xAA,0,0x38,0x9B,0x71 }
+
+#define NoOrder LSBFirst
+
+static XF86ImageRec
+ScalerImages[] =
+{
+ /* Planar YVU 4:2:0 (emulated) */
+ { LE4CC('Y','V','1','2'), XvYUV, NoOrder, GUID4CC('Y','V','1','2'),
+ 12, XvPlanar, 3, 0, 0, 0, 0,
+ 8, 8, 8, 1, 2, 2, 1, 2, 2, "YVU", XvTopToBottom },
+
+ /* Packed YUYV 4:2:2 */
+ { LE4CC('Y','U','Y','2'), XvYUV, NoOrder, GUID4CC('Y','U','Y','2'),
+ 16, XvPacked, 1, 0, 0, 0, 0,
+ 8, 8, 8, 1, 2, 2, 1, 1, 1, "YUYV", XvTopToBottom },
+
+ /* Packed UYVY 4:2:2 */
+ { LE4CC('U','Y','V','Y'), XvYUV, NoOrder, GUID4CC('U','Y','V','Y'),
+ 16, XvPacked, 1, 0, 0, 0, 0,
+ 8, 8, 8, 1, 2, 2, 1, 1, 1, "UYVY", XvTopToBottom },
+
+ /* Packed YUVA 4:4:4 */
+ { LE4CC('Y','U','V','A') /* XXX not registered */, XvYUV, LSBFirst, { 0 },
+ 32, XvPacked, 1, 0, 0, 0, 0,
+ 8, 8, 8, 1, 1, 1, 1, 1, 1, "YUVA", XvTopToBottom },
+
+ /* Packed VUYA 4:4:4 */
+ { LE4CC('V','U','Y','A') /* XXX not registered */, XvYUV, LSBFirst, { 0 },
+ 32, XvPacked, 1, 0, 0, 0, 0,
+ 8, 8, 8, 1, 1, 1, 1, 1, 1, "VUYA", XvTopToBottom },
+
+ /* RGBA 8:8:8:8 */
+ { 0x41, XvRGB, LSBFirst, { 0 },
+ 32, XvPacked, 1, 24, 0x0000FF, 0x00FF00, 0xFF0000,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "RGBA", XvTopToBottom },
+
+ /* RGB 5:6:5 */
+ { 0x42, XvRGB, LSBFirst, { 0 },
+ 16, XvPacked, 1, 16, 0x001F, 0x07E0, 0xF800,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "RGB", XvTopToBottom },
+
+ /* RGBA 5:5:5:1 */
+ { 0x43, XvRGB, LSBFirst, { 0 },
+ 16, XvPacked, 1, 15, 0x001F, 0x03E0, 0x7C00,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "RGBA", XvTopToBottom },
+
+ /* RGBA 4:4:4:4 */
+ { 0x44, XvRGB, LSBFirst, { 0 },
+ 16, XvPacked, 1, 12, 0x000F, 0x00F0, 0x0F00,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "RGBA", XvTopToBottom },
+
+ /* RGBA 2:3:2:1 */
+ { 0x45, XvRGB, NoOrder, { 0 },
+ 8, XvPacked, 1, 7, 0x03, 0x1C, 0x60,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "RGBA", XvTopToBottom },
+
+ /* RGB 3:3:2 */
+ { 0x46, XvRGB, NoOrder, { 0 },
+ 8, XvPacked, 1, 8, 0x07, 0x38, 0xC0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "RGB", XvTopToBottom },
+
+ /* BGRA 8:8:8:8 */
+ { 0x47, XvRGB, LSBFirst, { 0 },
+ 32, XvPacked, 1, 24, 0xFF0000, 0x00FF00, 0x0000FF,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "BGRA", XvTopToBottom },
+
+ /* BGR 5:6:5 */
+ { 0x48, XvRGB, LSBFirst, { 0 },
+ 16, XvPacked, 1, 16, 0xF800, 0x07E0, 0x001F,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "BGR", XvTopToBottom },
+
+ /* BGRA 5:5:5:1 */
+ { 0x49, XvRGB, LSBFirst, { 0 },
+ 16, XvPacked, 1, 15, 0x7C00, 0x03E0, 0x001F,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "BGRA", XvTopToBottom },
+
+ /* BGRA 4:4:4:4 */
+ { 0x4A, XvRGB, LSBFirst, { 0 },
+ 16, XvPacked, 1, 12, 0x0F00, 0x00F0, 0x000F,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "BGRA", XvTopToBottom },
+
+ /* BGRA 2:3:2:1 */
+ { 0x4B, XvRGB, NoOrder, { 0 },
+ 8, XvPacked, 1, 7, 0x60, 0x1C, 0x03,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "BGRA", XvTopToBottom },
+
+ /* BGR 2:3:3 */
+ { 0x4C, XvRGB, NoOrder, { 0 },
+ 8, XvPacked, 1, 8, 0xC0, 0x38, 0x07,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, "BGR", XvTopToBottom },
+};
+
+
+/*
+ * Video codec tables
+ */
+
+#define SAA7111_SLAVE_ADDRESS 0x48
+#define SAA7125_SLAVE_ADDRESS 0x88
+
static I2CByte
DecInitVec[] =
{
@@ -273,7 +476,7 @@ static I2CByte
DecVS[3][8] =
{
{ 0x06, 108, 0x07, 108, 0x08, 0x09, 0x0E, 0x01 },
- { 0x06, 107, 0x07, 107, 0x08, 0x49, 0x0E, 0x31 },
+ { 0x06, 107, 0x07, 107, 0x08, 0x49, 0x0E, 0x01 },
{ 0x06, 108, 0x07, 108, 0x08, 0x01, 0x0E, 0x51 }
};
@@ -296,77 +499,123 @@ EncVS[2][14] =
0x66, (I2CByte)(FSC(SUBCARRIER_FREQ_NTSC) >> 24) }
};
-#undef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
+/* Forward */
+static void StopVideoStream(PortPrivPtr pPPriv, Bool exit);
+static void RestoreVideoStd(AdaptorPrivPtr pAPriv);
+static Bool xvipcHandshake(PortPrivPtr pPPriv, int op, Bool block);
-#undef CLAMP
-#define CLAMP(v, min, max) (((v) < (min)) ? (min) : MIN(v, max))
-#undef ABS
-#define ABS(n) (((n) < 0) ? -(n) : (n))
+/*
+ * Video codec controls
+ */
static int
-SetAttr(PortPrivPtr pPPriv, int i, I2CByte s, I2CByte v)
+SetAttr(PortPrivPtr pPPriv, int i, int value)
{
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int v;
+
+ if (value < InputVideoAttributes[i].min_value)
+ value = InputVideoAttributes[i].min_value;
+ else
+ if (value > InputVideoAttributes[i].max_value)
+ value = InputVideoAttributes[i].max_value;
+
+ switch (i) {
+ case 0:
+ v = 128 + (MIN(value, 999) * 128) / 1000;
+ break;
+
+ case 1:
+ case 2:
+ v = 64 + (MIN(value, 999) * 64) / 1000;
+ break;
+
+ default:
+ v = (MIN(value, 999) * 128) / 1000;
+ break;
+ }
if (pAPriv->pm2p) {
xvipc.a = v << 8;
- return xvipcHandshake(pPPriv, OP_ATTR + i, TRUE) ?
- Success : XvBadAlloc;
- }
- return xf86I2CWriteByte(&pPPriv->I2CDev, s, v) ?
- Success : XvBadAlloc;
+ if (!xvipcHandshake(pPPriv, OP_ATTR + i, TRUE))
+ return XvBadAlloc;
+ } else
+ if (!xf86I2CWriteByte(&pPPriv->I2CDev, 0x0A + i, v))
+ return XvBadAlloc;
+
+ pPPriv->Attribute[i] = value;
+
+ return Success;
}
-static Bool
-SetPlug(PortPrivPtr pPPriv)
+static int
+SetPlug(PortPrivPtr pPPriv, int Plug)
{
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
if (pAPriv->pm2p) {
- xvipc.a = pPPriv->Plug - PORTNUM(pPPriv);
- return xvipcHandshake(pPPriv, OP_PLUG, TRUE);
+ xvipc.a = Plug - (pPPriv == &pAPriv->Port[1]);
+
+ if (!xvipcHandshake(pPPriv, OP_PLUG, TRUE))
+ return XvBadAlloc;
} else {
if (pPPriv == &pAPriv->Port[0]) {
- xf86I2CWriteByte(&pPPriv->I2CDev, 0x02, Dec02[pPPriv->Plug]);
- xf86I2CWriteByte(&pPPriv->I2CDev, 0x09, Dec09[pPPriv->Plug]);
+ if (!xf86I2CWriteByte(&pPPriv->I2CDev, 0x02, Dec02[Plug]) ||
+ !xf86I2CWriteByte(&pPPriv->I2CDev, 0x09, Dec09[Plug]))
+ return XvBadAlloc;
} else {
- if (pPPriv->StreamOn)
- xf86I2CWriteByte(&pPPriv->I2CDev, 0x3A, Enc3A[pPPriv->Plug]);
-#ifdef COLORBARS
- else
- xf86I2CWriteByte(&pPPriv->I2CDev, 0x3A, 0x83);
-#endif
+ if (pPPriv->StreamOn) {
+ if (!xf86I2CWriteByte(&pPPriv->I2CDev, 0x3A, Enc3A[Plug]))
+ return XvBadAlloc;
+ } else
+ if (ColorBars)
+ xf86I2CWriteByte(&pPPriv->I2CDev, 0x3A, 0x83);
}
}
- return TRUE;
+ pPPriv->Plug = Plug;
+
+ return Success;
}
-static Bool
-SetVideoStd(AdaptorPrivPtr pAPriv)
+enum { PAL, NTSC, SECAM };
+
+static int
+SetVideoStd(PortPrivPtr pPPriv, int VideoStd)
{
- Bool r;
+ AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int r = Success;
if (pAPriv->pm2p) {
- xvipc.a = pAPriv->VideoStd;
- r = xvipcHandshake(&pAPriv->Port[0], OP_VIDEOSTD, TRUE);
- pAPriv->VideoStd = xvipc.a; /* Actual */
+ xvipc.a = VideoStd;
+
+ if (!xvipcHandshake(&pAPriv->Port[0], OP_VIDEOSTD, TRUE))
+ return XvBadAlloc;
+
+ VideoStd = xvipc.a; /* Actual */
} else {
- if (pAPriv->VideoStd >= 2)
+ if (VideoStd == SECAM)
xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, 0xC2);
+ /* Disable output, SECAM not supported */
- xf86I2CWriteVec(&pAPriv->Port[0].I2CDev, &DecVS[pAPriv->VideoStd][0], 4);
-
- if (pAPriv->VideoStd < 2)
- xf86I2CWriteVec(&pAPriv->Port[1].I2CDev, &EncVS[pAPriv->VideoStd][0], 7);
+ if (!xf86I2CWriteVec(&pAPriv->Port[0].I2CDev, &DecVS[VideoStd][0], 4)) {
+ pAPriv->VideoStd = -1;
+ return XvBadAlloc;
+ }
- r = TRUE;
+ if (VideoStd != SECAM)
+ if (!xf86I2CWriteVec(&pAPriv->Port[1].I2CDev, &EncVS[VideoStd][0], 7)) {
+ pAPriv->VideoStd = -1;
+ return XvBadAlloc;
+ }
}
- if (pAPriv->VideoStd == 1) {
+ pAPriv->VideoStd = VideoStd;
+ pPPriv->VideoStdReq = VideoStd;
+
+ if (VideoStd == NTSC) {
pAPriv->FramesPerSec = 30;
pAPriv->FrameLines = 525;
pAPriv->IntLine = 513;
@@ -378,158 +627,161 @@ SetVideoStd(AdaptorPrivPtr pAPriv)
pAPriv->LinePer = 64000;
}
-#if 0
+#if 0 /* XF86Config option */
+
pAPriv->Port[0].FramesPerSec = pAPriv->FramesPerSec;
pAPriv->Port[1].FramesPerSec = pAPriv->FramesPerSec;
+
#endif
return r;
}
-/* **FIXME**: 2048 limit */
-static Bool
-AllocOffRec(PortPrivPtr pPPriv, int i)
+/*
+ * Buffer management
+ */
+
+static void
+RemoveAreaCallback(FBAreaPtr pFBArea)
{
+ PortPrivPtr pPPriv = (PortPrivPtr) pFBArea->devPrivate.ptr;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
- ScrnInfoPtr pScrn = pAPriv->pScrn;
- GLINTPtr pGlint = GLINTPTR(pScrn);
- int width, height;
-
- height = (pAPriv->VideoStd == 1) ? 512 : 608;
-
- if (!pPPriv->Attribute[4])
- height >>= 1;
-
- width = (704 << 4) / pScrn->bitsPerPixel;
-
- pPPriv->BufferStride = pScrn->displayWidth << BPPSHIFT(pGlint);
+ DEBUG(ScrnInfoPtr pScrn = pAPriv->pScrn;)
+ int i;
- if (pPPriv->pFBArea[i] != NULL) {
- if (xf86ResizeOffscreenArea(pPPriv->pFBArea[i], width, height))
- return TRUE;
+ for (i = 0; i < MAX_BUFFERS && pPPriv->pFBArea[i] != pFBArea; i++);
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 2,
- "AOR couldn't resize buffer %d,%d-%d,%d to %dx%d\n",
- pPPriv->pFBArea[i]->box.x1, pPPriv->pFBArea[i]->box.y1,
- pPPriv->pFBArea[i]->box.x2, pPPriv->pFBArea[i]->box.y2,
- width, height));
+ if (i >= MAX_BUFFERS)
+ return;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
- "AOR free buffer 0x%08x\n", pPPriv->BufferBase[i]));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "RemoveAreaCallback port #%d, buffer #%d, pFB=%p, off=0x%08x\n",
+ PORTNUM(pPPriv), i, pPPriv->pFBArea[i], pPPriv->BufferBase[i]));
- xf86FreeOffscreenArea(pPPriv->pFBArea[i]);
- pPPriv->pFBArea[i] = NULL;
+ if (pAPriv->VideoIO && PORTNUM(pPPriv) < 2) {
+ StopVideoStream(pPPriv, FALSE);
}
- pPPriv->pFBArea[i] = xf86AllocateOffscreenArea(pScrn->pScreen,
- width, height, 2, NULL, NULL, NULL);
+ for (; i < MAX_BUFFERS - 1; i++)
+ pPPriv->pFBArea[i] = pPPriv->pFBArea[i + 1];
- if (pPPriv->pFBArea[i] != NULL)
- return TRUE;
+ pPPriv->pFBArea[MAX_BUFFERS - 1] = NULL;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 2,
- "AOR couldn't allocate buffer %dx%d\n",
- width, height));
-
- return FALSE;
+ pPPriv->BuffersAllocated--;
}
-static Bool
-AllocOffLin(PortPrivPtr pPPriv, int i)
+static void
+RemoveableBuffers(PortPrivPtr pPPriv, Bool remove)
{
- AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
- ScrnInfoPtr pScrn = pAPriv->pScrn;
- GLINTPtr pGlint = GLINTPTR(pScrn);
- int length;
-
- length = ((704 << 1) * ((pAPriv->VideoStd == 1) ? 512 : 608)) >> BPPSHIFT(pGlint);
+ int i;
- if (!pPPriv->Attribute[4])
- length >>= 1;
+ for (i = 0; i < MAX_BUFFERS; i++)
+ if (pPPriv->pFBArea[i])
+ pPPriv->pFBArea[i]->RemoveAreaCallback =
+ remove ? RemoveAreaCallback : NULL;
+}
- pPPriv->BufferStride = 704 << 1;
+static void
+FreeBuffers(PortPrivPtr pPPriv)
+{
+ DEBUG(AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;)
+ DEBUG(ScrnInfoPtr pScrn = pAPriv->pScrn;)
+ int i;
- if (pPPriv->pFBArea[i] != NULL) {
- xf86FreeOffscreenArea(pPPriv->pFBArea[i]);
- pPPriv->pFBArea[i] = NULL;
- }
+ RemoveableBuffers(pPPriv, FALSE);
- pPPriv->pFBArea[i] = xf86AllocateLinearOffscreenArea(pScrn->pScreen,
- length, 2, NULL, NULL, NULL);
+ for (i = MAX_BUFFERS - 1; i >= 0; i--)
+ if (pPPriv->pFBArea[i]) {
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "FreeBuffers port #%d, buffer #%d, pFB=%p, off=0x%08x\n",
+ PORTNUM(pPPriv), i, pPPriv->pFBArea[i], pPPriv->BufferBase[i]));
- if (pPPriv->pFBArea[i] != NULL)
- return TRUE;
+ xf86FreeOffscreenArea(pPPriv->pFBArea[i]);
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_ERROR, 2,
- "AOL couldn't allocate buffer %d\n",
- length));
+ pPPriv->pFBArea[i] = NULL;
+ }
- return FALSE;
+ pPPriv->BuffersAllocated = 0;
}
-static Bool
-ReallocateOffscreenBuffer(PortPrivPtr pPPriv, int num)
+enum { FORCE_LINEAR = 1, FORCE_RECT };
+
+static int
+AllocateBuffers(PortPrivPtr pPPriv,
+ int w, int h, int bytespp,
+ int num, int force)
{
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
ScrnInfoPtr pScrn = pAPriv->pScrn;
GLINTPtr pGlint = GLINTPTR(pScrn);
- int i;
+ Bool linear = (force != FORCE_RECT);
+ int i, j, retry = 0;
- if (pAPriv->pm2p != NULL)
- return FALSE;
+ FreeBuffers(pPPriv);
- for (i = 2; i >= 0; i--)
- if (pPPriv->pFBArea[i]) {
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
- "ROB free buffer 0x%08x\n", pPPriv->BufferBase[i]));
+ for (i = 0; i < num; i++) {
+ if (linear) {
+ for (j = (w + 31) >> 5; partprodPermedia[j] < 0; j++);
- xf86FreeOffscreenArea(pPPriv->pFBArea[i]);
- pPPriv->pFBArea[i] = NULL;
- }
+ pPPriv->BufferStride = j * bytespp * 32;
+ pPPriv->BufferPProd = partprodPermedia[j];
- if (num <= 0)
- return FALSE;
+ pPPriv->pFBArea[i] = xf86AllocateLinearOffscreenArea(pScrn->pScreen,
+ (pPPriv->BufferStride * h + (1 << BPPSHIFT(pGlint)) - 1) >> BPPSHIFT(pGlint),
+ 8 >> BPPSHIFT(pGlint), NULL, NULL, (pointer) pPPriv);
- while (1) {
- PortPrivPtr pPPrivN = &pAPriv->Port[1 - PORTNUM(pPPriv)];
+ if (pPPriv->pFBArea[i])
+ /* pPPriv->BufferBase[i] = pPPriv->pFBArea[i].linear; */
+ pPPriv->BufferBase[i] =
+ ((pPPriv->pFBArea[i]->box.y1 * pScrn->displayWidth) +
+ pPPriv->pFBArea[i]->box.x1) << BPPSHIFT(pGlint);
- for (i = 0; i < num; i++)
- if (!AllocOffLin(pPPriv, i)) break;
- if (i > 0) break;
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "New linear buffer %dx%d, rec %dx%d -> pFB=%p, off=0x%08x\n",
+ w, h, pPPriv->BufferStride, h, pPPriv->pFBArea[i], pPPriv->BufferBase[i]));
+ } else {
+ pPPriv->BufferStride = pScrn->displayWidth << BPPSHIFT(pGlint);
- for (i = 0; i < num; i++)
- if (!AllocOffRec(pPPriv, i)) break;
- if (i > 0) break;
+ j = pPPriv->BufferStride / bytespp;
- if (pPPrivN->VideoOn <= 0 && pPPrivN->APO >= 0)
- DelayedStopVideo(pPPrivN);
- else
- return FALSE;
- }
+ if (j <= w && j <= 2048 && (j & 31) == 0 &&
+ (pPPriv->BufferPProd = partprodPermedia[j >> 5]) >= 0)
+ {
+ pPPriv->pFBArea[i] = xf86AllocateOffscreenArea(pScrn->pScreen,
+ w, h, 8 >> BPPSHIFT(pGlint), NULL, NULL, (pointer) pPPriv);
- for (i = 0; i <= 2; i++)
- if (pPPriv->pFBArea[i]) {
- pPPriv->BufferBase[i] =
- ((pPPriv->pFBArea[i]->box.y1 * pScrn->displayWidth) +
- pPPriv->pFBArea[i]->box.x1) << BPPSHIFT(pGlint);
+ if (pPPriv->pFBArea[i])
+ pPPriv->BufferBase[i] =
+ ((pPPriv->pFBArea[i]->box.y1 * pScrn->displayWidth) +
+ pPPriv->pFBArea[i]->box.x1) << BPPSHIFT(pGlint);
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
- "ROB buffer #%d 0x%08x str %d\n",
- i, pPPriv->BufferBase[i], pPPriv->BufferStride));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "New rect buffer %dx%d, stride %d, %d -> pFB=%p, off=0x%08x\n",
+ w, h, pPPriv->BufferStride, j, pPPriv->pFBArea[i], pPPriv->BufferBase[i]));
+ }
}
- pPPriv->BufferPProd = partprodPermedia[(pPPriv->BufferStride / 2) >> 5];
+ if (pPPriv->pFBArea[i])
+ continue;
- pPPriv->fw = 704;
- pPPriv->fh = InputVideoEncodings[pAPriv->VideoStd * 3].height >>
- (!pPPriv->Attribute[4]);
+ if (!force && i == 0 && retry++ < 1) {
+ linear ^= TRUE;
+ i = -1;
+ } else
+ break;
+ }
- return TRUE;
+ return pPPriv->BuffersAllocated = i;
}
+
+/*
+ * Blitter
+ */
+
static Bool
-PutCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
+RemakePutCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
{
BoxPtr pBox;
CookiePtr pCookie;
@@ -571,80 +823,139 @@ PutCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
return TRUE;
}
+#define FORMAT_YUYV ((0 << 5) + (1 << 4) + ((19 & 0x10) << 2) + ((19 & 0x0F) << 0))
+#define FORMAT_UYVY ((1 << 5) + (1 << 4) + ((19 & 0x10) << 2) + ((19 & 0x0F) << 0))
+#define FORMAT_YUVA ((0 << 5) + ((18 & 0x10) << 2) + ((18 & 0x0F) << 0))
+#define FORMAT_VUYA ((1 << 5) + ((18 & 0x10) << 2) + ((18 & 0x0F) << 0))
+
static void
-PutYUV(PortPrivPtr pPPriv, int BufferBase)
+PutYUV(PortPrivPtr pPPriv, int BufferBase,
+ int format, int bptshift, int alpha)
{
- ScrnInfoPtr pScrn = pPPriv->pAdaptor->pScrn;
+ AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ ScrnInfoPtr pScrn = pAPriv->pScrn;
GLINTPtr pGlint = GLINTPTR(pScrn);
CookiePtr pCookie = pPPriv->pCookies;
int nCookies = pPPriv->nCookies;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "PutYUV %08x\n", BufferBase));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 5, "PutYUV %08x %08x\n",
+ BufferBase, format));
- if (!nCookies)
- return;
-
- /* Setup */
+ if (!nCookies || (!pGlint->UsePCIRetry && GLINT_READ_REG(InFIFOSpace) < 200))
+ return; /* Denial of service fix, N/A for scaler */
- GLINT_WAIT(25);
CHECKCLIPPING;
- switch (pScrn->depth) {
- case 8:
- GLINT_WRITE_REG((0 << 10) | /* BGR */
- (1 << 1) | /* Dither */
- ((5 & 0x10)<<12) |
- ((5 & 0x0F)<<2) | /* 3:3:2f */
- UNIT_ENABLE, DitherMode);
- break;
- case 15:
- GLINT_WRITE_REG((1 << 10) | /* RGB */
- ((1 & 0x10)<<12)|
- ((1 & 0x0F)<<2) | /* 5:5:5:1f */
- UNIT_ENABLE, DitherMode);
- break;
- case 16:
- GLINT_WRITE_REG((1 << 10) | /* RGB */
- ((16 & 0x10)<<12)|
- ((16 & 0x0F)<<2) | /* 5:6:5f */
- UNIT_ENABLE, DitherMode);
- break;
- case 24:
- GLINT_WRITE_REG((1 << 10) | /* RGB */
- ((0 & 0x10)<<12)|
- ((0 & 0x0F)<<2) | /* 8:8:8:8 */
- UNIT_ENABLE, DitherMode);
- break;
- default:
- return; /* Oops */
- }
-
GLINT_WRITE_REG(1 << 16, dY);
GLINT_WRITE_REG(0, RasterizerMode);
GLINT_WRITE_REG(UNIT_DISABLE, AreaStippleMode);
- GLINT_WRITE_REG(BufferBase >> 1 /* 16 */, PMTextureBaseAddress);
- GLINT_WRITE_REG((1 << 19) /* 16 */ | pPPriv->BufferPProd,
- PMTextureMapFormat);
- GLINT_WRITE_REG((1 << 4) /* No alpha */ |
- ((19 & 0x10) << 2) |
- ((19 & 0x0F) << 0) /* YUYV */,
- PMTextureDataFormat);
+ GLINT_WRITE_REG(UNIT_ENABLE, TextureAddressMode);
+ GLINT_WRITE_REG(pPPriv->dS, dSdx);
+ GLINT_WRITE_REG(0, dSdyDom);
+ GLINT_WRITE_REG(0, dTdx);
+ GLINT_WRITE_REG(pPPriv->dT, dTdyDom);
+ GLINT_WRITE_REG(BufferBase >> bptshift, PMTextureBaseAddress);
+ GLINT_WRITE_REG((bptshift << 19) | pPPriv->BufferPProd, PMTextureMapFormat);
+ GLINT_WRITE_REG(format, PMTextureDataFormat);
GLINT_WRITE_REG((pPPriv->Attribute[5] << 17) | /* FilterMode */
(11 << 13) | (11 << 9) | /* TextureSize log2 */
UNIT_ENABLE, PMTextureReadMode);
GLINT_WRITE_REG((0 << 4) /* RGB */ |
(3 << 1) /* Copy */ |
UNIT_ENABLE, TextureColorMode);
- GLINT_WRITE_REG(UNIT_ENABLE, YUVMode);
- GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ if (alpha)
+ GLINT_WRITE_REG(pAPriv->dAlphaBlendMode, AlphaBlendMode);
+ GLINT_WRITE_REG(pAPriv->dDitherMode, DitherMode);
GLINT_WRITE_REG(UNIT_DISABLE, LogicalOpMode);
+ GLINT_WRITE_REG((alpha << 10) | /* ReadDestination */
+ pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(0xFFFFFFFF, FBHardwareWriteMask);
+ GLINT_WRITE_REG(UNIT_ENABLE, YUVMode);
+
+ for (; nCookies--; pCookie++) {
+ GLINT_WAIT(5);
+ GLINT_WRITE_REG(pCookie->xy, RectangleOrigin);
+ GLINT_WRITE_REG(pCookie->wh, RectangleSize);
+ GLINT_WRITE_REG(pCookie->s, SStart);
+ GLINT_WRITE_REG(pCookie->t, TStart);
+ GLINT_WRITE_REG(PrimitiveRectangle |
+ XPositive |
+ YPositive |
+ TextureEnable, Render);
+ }
+
+ pGlint->x = pGlint->y = -1; /* Force reload */
+ pGlint->w = pGlint->h = -1;
+ pGlint->ROP = 0xFF;
+ pGlint->planemask = 0xFFFFFFFF;
+
+ GLINT_WAIT(8);
+ GLINT_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
+ GLINT_WRITE_REG(pGlint->TexMapFormat, PMTextureMapFormat);
+ GLINT_WRITE_REG(UNIT_DISABLE, PMTextureReadMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, DitherMode);
+ if (alpha) {
+ GLINT_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ }
+ GLINT_WRITE_REG(UNIT_DISABLE, YUVMode);
+}
+
+#define FORMAT_RGB8888 ((0 << 5) + (0 << 4) + ((0 & 0x10) << 2) + ((0 & 0x0F) << 0))
+#define FORMAT_RGB565 ((0 << 5) + (1 << 4) + ((16 & 0x10) << 2) + ((16 & 0x0F) << 0))
+#define FORMAT_RGB5551 ((0 << 5) + (0 << 4) + ((1 & 0x10) << 2) + ((1 & 0x0F) << 0))
+#define FORMAT_RGB4444 ((0 << 5) + (0 << 4) + ((2 & 0x10) << 2) + ((2 & 0x0F) << 0))
+#define FORMAT_RGB332 ((0 << 5) + (1 << 4) + ((5 & 0x10) << 2) + ((5 & 0x0F) << 0))
+#define FORMAT_RGB2321 ((0 << 5) + (0 << 4) + ((9 & 0x10) << 2) + ((9 & 0x0F) << 0))
+#define FORMAT_BGR8888 ((1 << 5) + (0 << 4) + ((0 & 0x10) << 2) + ((0 & 0x0F) << 0))
+#define FORMAT_BGR565 ((1 << 5) + (1 << 4) + ((16 & 0x10) << 2) + ((16 & 0x0F) << 0))
+#define FORMAT_BGR5551 ((1 << 5) + (0 << 4) + ((1 & 0x10) << 2) + ((1 & 0x0F) << 0))
+#define FORMAT_BGR4444 ((1 << 5) + (0 << 4) + ((2 & 0x10) << 2) + ((2 & 0x0F) << 0))
+#define FORMAT_BGR332 ((1 << 5) + (1 << 4) + ((5 & 0x10) << 2) + ((5 & 0x0F) << 0))
+#define FORMAT_BGR2321 ((1 << 5) + (0 << 4) + ((9 & 0x10) << 2) + ((9 & 0x0F) << 0))
+
+static void
+PutRGB(PortPrivPtr pPPriv, int BufferBase, int format, int bptshift, int alpha)
+{
+ AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ ScrnInfoPtr pScrn = pAPriv->pScrn;
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CookiePtr pCookie = pPPriv->pCookies;
+ int nCookies = pPPriv->nCookies;
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 5, "PutRGB %08x %08x\n",
+ BufferBase, format));
+
+ if (!nCookies)
+ return;
+
+ CHECKCLIPPING;
+
+ GLINT_WRITE_REG(1 << 16, dY);
+ GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, AreaStippleMode);
GLINT_WRITE_REG(UNIT_ENABLE, TextureAddressMode);
GLINT_WRITE_REG(pPPriv->dS, dSdx);
GLINT_WRITE_REG(0, dSdyDom);
GLINT_WRITE_REG(0, dTdx);
GLINT_WRITE_REG(pPPriv->dT, dTdyDom);
-
- /* Subsequent */
+ GLINT_WRITE_REG(BufferBase >> bptshift, PMTextureBaseAddress);
+ GLINT_WRITE_REG((bptshift << 19) | pPPriv->BufferPProd, PMTextureMapFormat);
+ GLINT_WRITE_REG(format, PMTextureDataFormat);
+ GLINT_WRITE_REG((pPPriv->Attribute[5] << 17) | /* FilterMode */
+ (11 << 13) | (11 << 9) | /* TextureSize log2 */
+ UNIT_ENABLE, PMTextureReadMode);
+ GLINT_WRITE_REG((0 << 4) /* RGB */ |
+ (3 << 1) /* Copy */ |
+ UNIT_ENABLE, TextureColorMode);
+ if (alpha)
+ GLINT_WRITE_REG(pAPriv->dAlphaBlendMode, AlphaBlendMode);
+ GLINT_WRITE_REG(pAPriv->dDitherMode, DitherMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, LogicalOpMode);
+ GLINT_WRITE_REG((alpha << 10) | /* ReadDestination */
+ pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(0xFFFFFFFF, FBHardwareWriteMask);
for (; nCookies--; pCookie++) {
GLINT_WAIT(5);
@@ -658,18 +969,21 @@ PutYUV(PortPrivPtr pPPriv, int BufferBase)
TextureEnable, Render);
}
- /* Cleanup */
-
pGlint->x = pGlint->y = -1; /* Force reload */
pGlint->w = pGlint->h = -1;
pGlint->ROP = 0xFF;
- GLINT_WAIT(6);
- GLINT_WRITE_REG(pGlint->TexMapFormat, PMTextureMapFormat);
- GLINT_WRITE_REG(UNIT_DISABLE, DitherMode);
- GLINT_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ pGlint->planemask = 0xFFFFFFFF;
+
+ GLINT_WAIT(7);
GLINT_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
+ GLINT_WRITE_REG(pGlint->TexMapFormat, PMTextureMapFormat);
GLINT_WRITE_REG(UNIT_DISABLE, PMTextureReadMode);
- GLINT_WRITE_REG(UNIT_DISABLE, YUVMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, DitherMode);
+ if (alpha) {
+ GLINT_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ }
}
static void
@@ -683,7 +997,7 @@ BlackOut(PortPrivPtr pPPriv, RegionPtr pRegion)
BoxPtr pBox;
int nBox;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 5,
"BlackOut %d,%d,%d,%d -- %d,%d,%d,%d\n",
pPPriv->vx, pPPriv->vy, pPPriv->vw, pPPriv->vh,
pPPriv->dx, pPPriv->dy, pPPriv->dw, pPPriv->dh));
@@ -741,7 +1055,7 @@ BlackOut(PortPrivPtr pPPriv, RegionPtr pRegion)
}
static Bool
-GetCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
+RemakeGetCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
{
BoxPtr pBox;
CookiePtr pCookie;
@@ -759,7 +1073,7 @@ GetCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
if (!pPPriv->pCookies || pPPriv->nCookies < nBox) {
if (!(pCookie = (CookiePtr) xrealloc(pPPriv->pCookies, nBox * sizeof(CookieRec))))
return FALSE;
-
+
pPPriv->pCookies = pCookie;
}
}
@@ -772,8 +1086,11 @@ GetCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
if (pRegion) {
n1 = ((pBox->x1 - pPPriv->dx) * pPPriv->vw + dw1) / pPPriv->dw;
- n2 = ((pBox->x2 - pPPriv->dx) * pPPriv->vw - 1) / pPPriv->dw;
- if (n1 > n2) continue; /* Clip is subpixel */
+ n2 = ((pBox->x2 - pPPriv->dx) * pPPriv->vw - 1) / pPPriv->dw;
+
+ if (n1 > n2)
+ continue; /* Clip is subpixel */
+
pCookie->xy = n1 + pPPriv->vx;
pCookie->wh = n2 - n1 + 1;
pCookie->s = n1 * pPPriv->dS + (pPPriv->dx << 20);
@@ -798,83 +1115,47 @@ GetCookies(PortPrivPtr pPPriv, RegionPtr pRegion)
static void
GetYUV(PortPrivPtr pPPriv)
{
- ScrnInfoPtr pScrn = pPPriv->pAdaptor->pScrn;
+ AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ ScrnInfoPtr pScrn = pAPriv->pScrn;
GLINTPtr pGlint = GLINTPTR(pScrn);
CookiePtr pCookie = pPPriv->pCookies;
int nCookies = pPPriv->nCookies;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "GetYUV\n"));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 5, "GetYUV\n"));
- if (!nCookies)
+ if (!nCookies || (!pGlint->UsePCIRetry && GLINT_READ_REG(InFIFOSpace) < 200))
return;
-
- /* FIXME? clip + filt d-1 */
-
- /* Setup */
-
+
GLINT_WAIT(25);
CHECKCLIPPING;
- switch (pScrn->depth) {
- case 8:
- GLINT_WRITE_REG(UNIT_ENABLE, TexelLUTMode);
- GLINT_WRITE_REG((1 << 4) | /* No alpha */
- ((14 & 0x10) << 2) |
- ((14 & 0x0F) << 0), /* CI8 */
- PMTextureDataFormat);
- break;
-
- case 15:
- GLINT_WRITE_REG((1 << 5) | /* RGB */
- (1 << 4) |
- ((1 & 0x10) << 2) |
- ((1 & 0x0F) << 0), /* 5:5:5:1f */
- PMTextureDataFormat);
- break;
- case 16:
- GLINT_WRITE_REG((1 << 5) |
- (1 << 4) |
- ((16 & 0x10) << 2) |
- ((16 & 0x0F) << 0), /* 5:6:5f */
- PMTextureDataFormat);
- break;
- case 24:
- GLINT_WRITE_REG((1 << 5) |
- (1 << 4) |
- ((0 & 0x10) << 2) |
- ((0 & 0x0F) << 0), /* 8:8:8:8 */
- PMTextureDataFormat);
- break;
- default:
- return;
- }
-
+ GLINT_WRITE_REG(1 << 16, dY);
+ GLINT_WRITE_REG(0, RasterizerMode);
GLINT_WRITE_REG(UNIT_DISABLE, AreaStippleMode);
+ GLINT_WRITE_REG(UNIT_ENABLE, TextureAddressMode);
+ GLINT_WRITE_REG(pPPriv->dS, dSdx);
+ GLINT_WRITE_REG(0, dSdyDom);
+ GLINT_WRITE_REG(0, dTdx);
+ GLINT_WRITE_REG(pPPriv->dT, dTdyDom);
GLINT_WRITE_REG(0, PMTextureBaseAddress);
- GLINT_WRITE_REG((1 << 10) | /* RGB */
- ((16 & 0x10)<<12)|
- ((16 & 0x0F)<<2) | /* 5:6:5f */
- UNIT_ENABLE, DitherMode);
+ GLINT_WRITE_REG(pAPriv->dTextureDataFormat, PMTextureDataFormat);
GLINT_WRITE_REG((pPPriv->Attribute[5] << 17) | /* FilterMode */
(11 << 13) | (11 << 9) | /* TextureSize log2 */
UNIT_ENABLE, PMTextureReadMode);
+ if (pScrn->depth == 8)
+ GLINT_WRITE_REG(UNIT_ENABLE, TexelLUTMode);
GLINT_WRITE_REG((0 << 4) /* RGB */ |
(3 << 1) /* Copy */ |
UNIT_ENABLE, TextureColorMode);
- GLINT_WRITE_REG(0x1, FBReadPixel); /* 16 */
- GLINT_WRITE_REG(UNIT_DISABLE, YUVMode);
- GLINT_WRITE_REG(pPPriv->BufferPProd, FBReadMode);
+ GLINT_WRITE_REG((1 << 10) | /* RGB */
+ ((16 & 0x10) << 12) |
+ ((16 & 0x0F) << 2) | /* 5:6:5f */
+ UNIT_ENABLE, DitherMode);
GLINT_WRITE_REG(UNIT_DISABLE, LogicalOpMode);
- GLINT_WRITE_REG(UNIT_ENABLE, TextureAddressMode);
- GLINT_WRITE_REG(pPPriv->dS, dSdx);
- GLINT_WRITE_REG(0, dSdyDom);
- GLINT_WRITE_REG(0, dTdx);
- GLINT_WRITE_REG(pPPriv->dT, dTdyDom);
- GLINT_WRITE_REG(1 << 16, dY);
- GLINT_WRITE_REG(0, RasterizerMode);
+ GLINT_WRITE_REG(pPPriv->BufferPProd, FBReadMode);
GLINT_WRITE_REG(pPPriv->BufferBase[0] >> 1 /* 16 */, FBWindowBase);
-
- /* Subsequent */
+ GLINT_WRITE_REG(0x1, FBReadPixel); /* 16 */
+ GLINT_WRITE_REG(UNIT_DISABLE, YUVMode);
for (; nCookies--; pCookie++)
if (pCookie->t >= 0) {
@@ -889,68 +1170,203 @@ GetYUV(PortPrivPtr pPPriv)
TextureEnable, Render);
}
- /* Cleanup */
-
pGlint->x = pGlint->y = -1; /* Force reload */
pGlint->w = pGlint->h = -1;
pGlint->ROP = 0xFF;
- GLINT_WAIT(10);
- GLINT_WRITE_REG(0, FBWindowBase);
- GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
- GLINT_WRITE_REG(pGlint->PixelWidth, FBReadPixel);
- GLINT_WRITE_REG(UNIT_DISABLE, DitherMode);
- GLINT_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+
+ GLINT_WAIT(9);
GLINT_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
- GLINT_WRITE_REG(pGlint->TexMapFormat, PMTextureMapFormat);
- GLINT_WRITE_REG(UNIT_DISABLE, TexelLUTMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, DitherMode);
+ if (pScrn->depth == 8)
+ GLINT_WRITE_REG(UNIT_DISABLE, TexelLUTMode);
GLINT_WRITE_REG(UNIT_DISABLE, PMTextureReadMode);
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(0, FBWindowBase);
+ GLINT_WRITE_REG(pGlint->PixelWidth, FBReadPixel);
GLINT_WRITE_REG(UNIT_DISABLE, YUVMode);
}
-static void
-StopVideoStream(AdaptorPrivPtr pAPriv, int which)
+static int
+SetBkgCol(PortPrivPtr pPPriv, int value)
+{
+ pPPriv->Attribute[6] = value;
+
+ pPPriv->BkgCol = ((value & 0xF80000) >> 8) |
+ ((value & 0x00FC00) >> 5) |
+ ((value & 0x0000F8) >> 3);
+
+ pPPriv->BkgCol += pPPriv->BkgCol << 16;
+
+ if (pPPriv->VideoOn) {
+ BlackOut(pPPriv, NULL);
+ GetYUV(pPPriv);
+ }
+
+ return Success;
+}
+
+/* os/WaitFor.c */
+
+static CARD32
+TimerCallback(OsTimerPtr pTim, CARD32 now, pointer p)
{
+ AdaptorPrivPtr pAPriv = (AdaptorPrivPtr) p;
GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
+ PortPrivPtr pPPriv;
+ int i, delay;
- if (which & 1) pAPriv->Port[0].VideoOn = 0;
- if (which & 2) pAPriv->Port[1].VideoOn = 0;
+ if (!pAPriv->pm2p) {
+ pPPriv = &pAPriv->Port[0];
- if (pAPriv->pm2p) {
- /* Hard stop, frees buffers */
+ if (pPPriv->VideoOn > VIDEO_OFF) {
+ pPPriv->FrameAcc += pPPriv->FramesPerSec;
+
+ if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
+ pPPriv->FrameAcc -= pAPriv->FramesPerSec;
+
+ PutYUV(pPPriv, (!pPPriv->pFBArea[1]) ?
+ pPPriv->BufferBase[0] : pPPriv->BufferBase[1 -
+ GLINT_READ_REG(VSABase + VSVideoAddressIndex)], FORMAT_YUYV, 1, 0);
+ }
+ } else
+ if (pPPriv->StopDelay >= 0 && !(pPPriv->StopDelay--)) {
+ StopVideoStream(pPPriv, TRUE);
+ RestoreVideoStd(pAPriv);
+ }
+
+ pPPriv = &pAPriv->Port[1];
+
+ if (pPPriv->VideoOn > VIDEO_OFF) {
+ pPPriv->FrameAcc += pPPriv->FramesPerSec;
+
+ if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
+ pPPriv->FrameAcc -= pAPriv->FramesPerSec;
- if (which & 2) {
- xvipcHandshake(&pAPriv->Port[1], OP_STOP, TRUE);
- pAPriv->Port[1].StreamOn = FALSE;
+ GetYUV(pPPriv);
+ }
+ } else
+ if (pPPriv->StopDelay >= 0 && !(pPPriv->StopDelay--)) {
+ StopVideoStream(pPPriv, TRUE);
+ RestoreVideoStd(pAPriv);
+ }
+ }
+
+ for (i = 2; i <= 5; i++) {
+ if (pAPriv->Port[i].StopDelay >= 0) {
+ if (!(pAPriv->Port[i].StopDelay--)) {
+ FreeBuffers(&pAPriv->Port[i]);
+ FreeCookies(&pAPriv->Port[i]);
+ pAPriv->TimerUsers &= ~(1 << i);
+ }
}
+ }
- if (which & 1) {
- xvipcHandshake(&pAPriv->Port[0], OP_STOP, TRUE);
- pAPriv->Port[0].StreamOn = FALSE;
+ if (!pAPriv->pm2p) {
+ if (pAPriv->Port[0].StreamOn) {
+ delay = GLINT_READ_REG(VSABase + VSCurrentLine);
+
+ if (!(GLINT_READ_REG(VSStatus) & VS_FieldOne0A))
+ delay += pAPriv->FrameLines >> 1;
+
+ if (delay > (pAPriv->IntLine - 16))
+ delay -= pAPriv->FrameLines;
+
+ return (((pAPriv->IntLine - delay) * pAPriv->LinePer) + 999999) / 1000000;
+ } else if (pAPriv->Port[1].StreamOn) {
+ delay = GLINT_READ_REG(VSBBase + VSCurrentLine);
+
+ if (!(GLINT_READ_REG(VSStatus) & VS_FieldOne0B))
+ delay += pAPriv->FrameLines >> 1;
+
+ if (delay > (pAPriv->IntLine - 16))
+ delay -= pAPriv->FrameLines;
+
+ return (((pAPriv->IntLine - delay) * pAPriv->LinePer) + 999999) / 1000000;
}
+ }
+
+ if (pAPriv->TimerUsers)
+ return pAPriv->Instant;
+
+ return 0; /* Cancel */
+}
+
+/*
+ * Video stream (bounce buffer <-> hardware)
+ */
+
+static void
+StopVideoStream(PortPrivPtr pPPriv, Bool exit)
+{
+ AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
+ int VideoOn;
+
+ pPPriv->StopDelay = -1;
+
+ VideoOn = pPPriv->VideoOn;
+ pPPriv->VideoOn = VIDEO_OFF;
+
+ if (!pPPriv->StreamOn)
return;
- }
- if (which & 2) {
- xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x3A, 0x83);
-#ifndef COLORBARS
- xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, 0xC2);
-#endif
- GLINT_WRITE_REG(0, VSBBase + VSControl);
- pAPriv->Port[1].StreamOn = FALSE;
+ if (pAPriv->pm2p) {
+ xvipcHandshake(pPPriv, OP_STOP, TRUE);
+
+ pPPriv->StreamOn = FALSE;
+
+ if (exit)
+ FreeCookies(pPPriv);
+
+ if (VideoOn > VIDEO_OFF && pGlint->NoAccel)
+ Permedia2Sync(pAPriv->pScrn);
+
+ return;
}
- if (which & 1) {
+ if (pPPriv == &pAPriv->Port[0]) {
+ int line, eeek = 0;
+
+ do {
+ if (eeek++ > 1000000) break;
+ line = GLINT_READ_REG(VSABase + VSCurrentLine);
+ } while (line > 15);
+
GLINT_WRITE_REG(0, VSABase + VSControl);
+
pAPriv->Port[0].StreamOn = FALSE;
+
usleep(80000);
+ } else {
+ xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x3A, 0x83);
+ if (!ColorBars)
+ xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, 0xC2);
+
+ GLINT_WRITE_REG(0, VSBBase + VSControl);
+
+ pAPriv->Port[1].StreamOn = FALSE;
}
- if (!(pAPriv->Port[0].StreamOn || pAPriv->Port[1].StreamOn)) {
- if (which & 4)
+ if (!pAPriv->Port[0].StreamOn && !pAPriv->Port[1].StreamOn) {
+ if (exit)
xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, 0xC2);
xf86I2CWriteByte(&pAPriv->Port[0].I2CDev, 0x11, 0x00);
- TimerCancel(pAPriv->Timer);
+ }
+
+ if (exit) {
+ FreeBuffers(pPPriv);
+ FreeCookies(pPPriv);
+
+ if (pAPriv->TimerUsers) {
+ pAPriv->TimerUsers &= ~PORTNUM(pPPriv);
+ if (!pAPriv->TimerUsers)
+ TimerCancel(pAPriv->Timer);
+ }
+
+ if (VideoOn > VIDEO_OFF && pGlint->NoAccel)
+ Permedia2Sync(pAPriv->pScrn);
}
}
@@ -960,16 +1376,19 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
- pPPriv->APO = -1;
+ if (pAPriv->VideoStd < 0)
+ return FALSE;
+
+ pPPriv->StopDelay = -1;
if (pAPriv->pm2p) {
if (pPPriv == &pAPriv->Port[0]) {
- if (!PutCookies(pPPriv, pRegion))
+ if (!RemakePutCookies(pPPriv, pRegion))
return FALSE;
if (pPPriv->StreamOn)
return TRUE;
} else {
- if (!GetCookies(pPPriv, pRegion))
+ if (!RemakeGetCookies(pPPriv, pRegion))
return FALSE;
if (pPPriv->StreamOn) {
BlackOut(pPPriv, pRegion);
@@ -977,7 +1396,7 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
}
}
- xvipc.a = pPPriv->Buffers;
+ xvipc.a = pPPriv->BuffersRequested;
xvipc.b = !pPPriv->Attribute[4];
xvipc.c = 1 + (pPPriv->Attribute[4] & 2);
@@ -993,16 +1412,24 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
} else {
CARD32 Base = (pPPriv == &pAPriv->Port[0]) ? VSABase : VSBBase;
- if (pPPriv->pFBArea[0] == NULL)
- if (!ReallocateOffscreenBuffer(pPPriv, (pPPriv == &pAPriv->Port[0]) ? 2 : 1))
+ if (pPPriv->BuffersAllocated < pPPriv->BuffersRequested) {
+ int height = ((pAPriv->VideoStd == NTSC) ? 512 : 608) >> (!pPPriv->Attribute[4]);
+
+ if (!AllocateBuffers(pPPriv, 704, height, 2, pPPriv->BuffersRequested, 0))
return FALSE;
+ pPPriv->fw = 704;
+ pPPriv->fh = InputVideoEncodings[pAPriv->VideoStd * 3].height >>
+ (!pPPriv->Attribute[4]);
+ }
+
if (pPPriv == &pAPriv->Port[0]) {
- if (!PutCookies(pPPriv, pRegion))
+ if (!RemakePutCookies(pPPriv, pRegion))
return FALSE;
} else {
- if (!GetCookies(pPPriv, pRegion))
+ if (!RemakeGetCookies(pPPriv, pRegion))
return FALSE;
+
BlackOut(pPPriv, pRegion);
}
@@ -1018,14 +1445,12 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
GLINT_WRITE_REG(0, Base + VSCurrentLine);
- if (pAPriv->VideoStd == 1) {
- /* NTSC untested */
+ if (pAPriv->VideoStd == NTSC) {
GLINT_WRITE_REG(16, Base + VSVideoStartLine);
GLINT_WRITE_REG(16 + 240, Base + VSVideoEndLine);
GLINT_WRITE_REG(288 + (8 & ~3) * 2, Base + VSVideoStartData);
GLINT_WRITE_REG(288 + ((8 & ~3) + 704) * 2, Base + VSVideoEndData);
} else {
- /* PAL, SECAM (untested) */
GLINT_WRITE_REG(16, Base + VSVideoStartLine);
GLINT_WRITE_REG(16 + 288, Base + VSVideoEndLine);
GLINT_WRITE_REG(288 + (8 & ~3) * 2, Base + VSVideoStartData);
@@ -1036,22 +1461,29 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
GLINT_WRITE_REG(0, Base + VSVideoAddressIndex);
if (pPPriv == &pAPriv->Port[0]) {
+ int line, eeek = 0;
+
xf86I2CWriteByte(&pAPriv->Port[0].I2CDev, 0x11, 0x0D);
+
+ do {
+ if (eeek++ > 1000000) break;
+ line = GLINT_READ_REG(VSABase + VSCurrentLine);
+ } while (line > 15);
+
GLINT_WRITE_REG(VSA_Video |
(pPPriv->Attribute[4] ?
VSA_CombineFields : VSA_Discard_FieldTwo),
VSABase + VSControl);
-#ifdef COLORBARS
- if (!pAPriv->Port[1].StreamOn) {
- xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x3A, 0x83);
- xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, Enc61[pAPriv->VideoStd]);
- }
-#endif
+ if (ColorBars)
+ if (!pAPriv->Port[1].StreamOn) {
+ xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x3A, 0x83);
+ xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, Enc61[pAPriv->VideoStd]);
+ }
} else {
GLINT_WRITE_REG(VSB_Video |
(pPPriv->Attribute[4] ? VSB_CombineFields : 0) |
/* VSB_GammaCorrect | */
- (16 << 4) | /* 5:6:5 FIXME? */
+ (16 << 4) | /* 5:6:5 */
(1 << 9) | /* 16 */
VSB_RGBOrder, VSBBase + VSControl);
xf86I2CWriteByte(&pAPriv->Port[0].I2CDev, 0x11, 0x0D);
@@ -1059,6 +1491,7 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
xf86I2CWriteByte(&pAPriv->Port[1].I2CDev, 0x61, Enc61[pAPriv->VideoStd]);
}
+ pAPriv->TimerUsers |= 1 << PORTNUM(pPPriv);
TimerSet(pAPriv->Timer, 0, 80, TimerCallback, pAPriv);
return pPPriv->StreamOn = TRUE;
@@ -1067,66 +1500,10 @@ StartVideoStream(PortPrivPtr pPPriv, RegionPtr pRegion)
return FALSE;
}
-/* Pseudo interrupt - better than nothing
- * (not used in kernel backbone mode)
- */
-static CARD32
-TimerCallback(OsTimerPtr pTim, CARD32 now, pointer p)
-{
- AdaptorPrivPtr pAPriv = (AdaptorPrivPtr) p;
- GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
- PortPrivPtr pPPriv;
- int delay;
-
- pPPriv = &pAPriv->Port[0];
-
- if (pPPriv->VideoOn >= 1) {
- pPPriv->FrameAcc += pPPriv->FramesPerSec;
- if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
- pPPriv->FrameAcc -= pAPriv->FramesPerSec;
-
- PutYUV(pPPriv, (!pPPriv->pFBArea[1]) ?
- pPPriv->BufferBase[0] : pPPriv->BufferBase[1 -
- GLINT_READ_REG(VSABase + VSVideoAddressIndex)]);
-
- if (pPPriv->VideoOn == 1)
- pPPriv->VideoOn = 0;
- }
- } else if (pPPriv->APO >= 0 && !(pPPriv->APO--))
- DelayedStopVideo(pPPriv);
-
- pPPriv = &pAPriv->Port[1];
-
- if (pPPriv->VideoOn >= 1) {
- pPPriv->FrameAcc += pPPriv->FramesPerSec;
- if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
- pPPriv->FrameAcc -= pAPriv->FramesPerSec;
-
- GetYUV(pPPriv);
-
- if (pPPriv->VideoOn == 1)
- pPPriv->VideoOn = 0;
- }
- } else if (pPPriv->APO >= 0 && !(pPPriv->APO--))
- DelayedStopVideo(pPPriv);
-
- if (pAPriv->Port[0].StreamOn) {
- delay = GLINT_READ_REG(VSABase + VSCurrentLine);
- if (!(GLINT_READ_REG(VSStatus) & VS_FieldOne0A))
- delay += pAPriv->FrameLines >> 1;
- } else if (pAPriv->Port[1].StreamOn) {
- delay = GLINT_READ_REG(VSBBase + VSCurrentLine);
- if (!(GLINT_READ_REG(VSStatus) & VS_FieldOne0B))
- delay += pAPriv->FrameLines >> 1;
- } else
- delay = pAPriv->IntLine;
-
- if (delay > (pAPriv->IntLine - 16))
- delay -= pAPriv->FrameLines;
-
- return (((pAPriv->IntLine - delay) * pAPriv->LinePer) + 999999) / 1000000;
-}
+/*
+ * Xv interface
+ */
static int
Permedia2PutVideo(ScrnInfoPtr pScrn,
@@ -1136,42 +1513,39 @@ Permedia2PutVideo(ScrnInfoPtr pScrn,
{
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int sw, sh;
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
"PutVideo %d,%d,%d,%d -> %d,%d,%d,%d\n",
vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h));
- if (pPPriv == &pAPriv->Port[0]) {
- int sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
- int sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
-
- if ((vid_x + vid_w) > sw ||
- (vid_y + vid_h) > sh)
- return BadValue;
+ sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
+ sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
- pPPriv->VideoOn = 0;
+ if ((vid_x + vid_w) > sw ||
+ (vid_y + vid_h) > sh)
+ return BadValue;
- pPPriv->vx = ((vid_x << 10) * pPPriv->fw) / sw;
- pPPriv->vy = ((vid_y << 10) * pPPriv->fh) / sh;
- pPPriv->vw = ((vid_w << 10) * pPPriv->fw) / sw;
- pPPriv->vh = ((vid_h << 10) * pPPriv->fh) / sh;
+ pPPriv->VideoOn = VIDEO_OFF;
- pPPriv->dx = drw_x;
- pPPriv->dy = drw_y;
- pPPriv->dw = drw_w;
- pPPriv->dh = drw_h;
+ pPPriv->vx = ((vid_x << 10) * pPPriv->fw) / sw;
+ pPPriv->vy = ((vid_y << 10) * pPPriv->fh) / sh;
+ pPPriv->vw = ((vid_w << 10) * pPPriv->fw) / sw;
+ pPPriv->vh = ((vid_h << 10) * pPPriv->fh) / sh;
- pPPriv->FrameAcc = pAPriv->FramesPerSec;
+ pPPriv->dx = drw_x;
+ pPPriv->dy = drw_y;
+ pPPriv->dw = drw_w;
+ pPPriv->dh = drw_h;
- if (!StartVideoStream(pPPriv, clipBoxes))
- return XvBadAlloc;
+ pPPriv->FrameAcc = pAPriv->FramesPerSec;
- pPPriv->VideoOn = 2;
+ if (!StartVideoStream(pPPriv, clipBoxes))
+ return XvBadAlloc;
- return Success;
- }
+ pPPriv->VideoOn = VIDEO_ON;
- return XvBadAlloc;
+ return Success;
}
static int
@@ -1183,63 +1557,56 @@ Permedia2PutStill(ScrnInfoPtr pScrn,
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
GLINTPtr pGlint = GLINTPTR(pScrn);
+ int sw, sh, r = Success;
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
"PutStill %d,%d,%d,%d -> %d,%d,%d,%d\n",
vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h));
- if (pPPriv == &pAPriv->Port[0]) {
- int sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
- int sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
-
- if ((vid_x + vid_w) > sw ||
- (vid_y + vid_h) > sh)
- return BadValue;
+ sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
+ sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
- pPPriv->VideoOn = 0;
+ if ((vid_x + vid_w) > sw ||
+ (vid_y + vid_h) > sh)
+ return BadValue;
- pPPriv->vx = ((vid_x << 10) * pPPriv->fw) / sw;
- pPPriv->vy = ((vid_y << 10) * pPPriv->fh) / sh;
- pPPriv->vw = ((vid_w << 10) * pPPriv->fw) / sw;
- pPPriv->vh = ((vid_h << 10) * pPPriv->fh) / sh;
+ pPPriv->VideoOn = VIDEO_OFF;
- pPPriv->dx = drw_x;
- pPPriv->dy = drw_y;
- pPPriv->dw = drw_w;
- pPPriv->dh = drw_h;
+ pPPriv->vx = ((vid_x << 10) * pPPriv->fw) / sw;
+ pPPriv->vy = ((vid_y << 10) * pPPriv->fh) / sh;
+ pPPriv->vw = ((vid_w << 10) * pPPriv->fw) / sw;
+ pPPriv->vh = ((vid_h << 10) * pPPriv->fh) / sh;
- {
- Bool r = TRUE;
+ pPPriv->dx = drw_x;
+ pPPriv->dy = drw_y;
+ pPPriv->dw = drw_w;
+ pPPriv->dh = drw_h;
- pPPriv->FrameAcc = pAPriv->FramesPerSec;
+ pPPriv->FrameAcc = pAPriv->FramesPerSec;
- if (!StartVideoStream(pPPriv, clipBoxes))
- return XvBadAlloc;
+ if (!StartVideoStream(pPPriv, clipBoxes))
+ return XvBadAlloc;
- if (pAPriv->pm2p) {
- /* Sleep, not busy wait, until the very next frame is ready.
- Accept memory requests and other window's update events
- in the meantime. */
- for (pPPriv->VideoOn = 1; pPPriv->VideoOn;)
- if (!xvipcHandshake(pPPriv, OP_UPDATE, TRUE)) {
- r = FALSE;
- break;
- }
- } else {
- usleep(80000);
- PutYUV(pPPriv, (!pPPriv->pFBArea[1]) ?
- pPPriv->BufferBase[0] : pPPriv->BufferBase[1 -
- GLINT_READ_REG(VSABase + VSVideoAddressIndex)]);
+ if (pAPriv->pm2p) {
+ /* Sleep, not busy wait, until the very next frame is ready.
+ Accept memory requests and other window's update events
+ in the meantime. */
+ for (pPPriv->VideoOn = VIDEO_ONE_SHOT; pPPriv->VideoOn;)
+ if (!xvipcHandshake(pPPriv, OP_UPDATE, TRUE)) {
+ r = FALSE;
+ break;
}
+ } else {
+ usleep(80000);
- pPPriv->APO = 125; /* Delayed stop: consider PutStill staccato */
-
- if (r)
- return Success;
- }
+ PutYUV(pPPriv, (!pPPriv->pFBArea[1]) ?
+ pPPriv->BufferBase[0] : pPPriv->BufferBase[1 -
+ GLINT_READ_REG(VSABase + VSVideoAddressIndex)], FORMAT_YUYV, 1, 0);
}
- return XvBadAlloc;
+ pPPriv->StopDelay = 125;
+
+ return r;
}
static int
@@ -1250,44 +1617,43 @@ Permedia2GetVideo(ScrnInfoPtr pScrn,
{
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int sw, sh;
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
"GetVideo %d,%d,%d,%d <- %d,%d,%d,%d\n",
vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h));
- if (pPPriv == &pAPriv->Port[1]) {
- int sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
- int sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
+ sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
+ sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
- if ((vid_x + vid_w) > sw ||
- (vid_y + vid_h) > sh)
- return BadValue;
-
- pPPriv->VideoOn = 0;
+ if ((vid_x + vid_w) > sw ||
+ (vid_y + vid_h) > sh) {
+ return BadValue;
+ }
- pPPriv->vx = (vid_x * pPPriv->fw) / sw;
- pPPriv->vy = (vid_y * pPPriv->fh) / sh;
- pPPriv->vw = (vid_w * pPPriv->fw) / sw;
- pPPriv->vh = (vid_h * pPPriv->fh) / sh;
+ pPPriv->VideoOn = VIDEO_OFF;
- pPPriv->dx = drw_x;
- pPPriv->dy = drw_y;
- pPPriv->dw = drw_w;
- pPPriv->dh = drw_h;
+ pPPriv->vx = (vid_x * pPPriv->fw) / sw;
+ pPPriv->vy = (vid_y * pPPriv->fh) / sh;
+ pPPriv->vw = (vid_w * pPPriv->fw) / sw;
+ pPPriv->vh = (vid_h * pPPriv->fh) / sh;
- pPPriv->FrameAcc = pAPriv->FramesPerSec;
+ pPPriv->dx = drw_x;
+ pPPriv->dy = drw_y;
+ pPPriv->dw = drw_w;
+ pPPriv->dh = drw_h;
- if (!StartVideoStream(pPPriv, clipBoxes))
- return XvBadAlloc;
+ pPPriv->FrameAcc = pAPriv->FramesPerSec;
- GetYUV(pPPriv);
+ if (!StartVideoStream(pPPriv, clipBoxes)) {
+ return XvBadAlloc;
+ }
- pPPriv->VideoOn = 2;
+ GetYUV(pPPriv);
- return Success;
- }
+ pPPriv->VideoOn = VIDEO_ON;
- return XvBadAlloc;
+ return Success;
}
static int
@@ -1298,96 +1664,377 @@ Permedia2GetStill(ScrnInfoPtr pScrn,
{
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int sw, sh;
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
"GetStill %d,%d,%d,%d <- %d,%d,%d,%d\n",
vid_x, vid_y, vid_w, vid_h, drw_x, drw_y, drw_w, drw_h));
- if (pPPriv == &pAPriv->Port[1]) {
- int sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
- int sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
+ sw = InputVideoEncodings[pAPriv->VideoStd * 3].width;
+ sh = InputVideoEncodings[pAPriv->VideoStd * 3].height;
- if ((vid_x + vid_w) > sw ||
- (vid_y + vid_h) > sh)
- return BadValue;
+ if ((vid_x + vid_w) > sw ||
+ (vid_y + vid_h) > sh)
+ return BadValue;
- pPPriv->VideoOn = 0;
+ pPPriv->VideoOn = VIDEO_OFF;
- pPPriv->vx = (vid_x * pPPriv->fw) / sw;
- pPPriv->vy = (vid_y * pPPriv->fh) / sh;
- pPPriv->vw = (vid_w * pPPriv->fw) / sw;
- pPPriv->vh = (vid_h * pPPriv->fh) / sh;
+ pPPriv->vx = (vid_x * pPPriv->fw) / sw;
+ pPPriv->vy = (vid_y * pPPriv->fh) / sh;
+ pPPriv->vw = (vid_w * pPPriv->fw) / sw;
+ pPPriv->vh = (vid_h * pPPriv->fh) / sh;
- pPPriv->dx = drw_x;
- pPPriv->dy = drw_y;
- pPPriv->dw = drw_w;
- pPPriv->dh = drw_h;
+ pPPriv->dx = drw_x;
+ pPPriv->dy = drw_y;
+ pPPriv->dw = drw_w;
+ pPPriv->dh = drw_h;
- pPPriv->FrameAcc = pAPriv->FramesPerSec;
+ pPPriv->FrameAcc = pAPriv->FramesPerSec;
- if (!StartVideoStream(pPPriv, clipBoxes))
- return XvBadAlloc;
+ if (!StartVideoStream(pPPriv, clipBoxes))
+ return XvBadAlloc;
- GetYUV(pPPriv);
+ GetYUV(pPPriv);
- /* Remains active until the client (implicitly)
- calls StopVideo for this port, GetStill, or GetVideo */
+ return Success;
+}
- return Success;
+static void
+CopyYV12LE(CARD8 *Y, CARD32 *dst, int width, int height, int pitch)
+{
+ int Y_size = width * height;
+ CARD8 *V = Y + Y_size;
+ CARD8 *U = V + (Y_size >> 2);
+ int pad = (pitch >> 2) - (width >> 1);
+ int x;
+
+ width >>= 1;
+
+ for (height >>= 1; height > 0; height--) {
+ for (x = 0; x < width; Y += 2, x++)
+ *dst++ = Y[0] + (U[x] << 8) + (Y[1] << 16) + (V[x] << 24);
+ dst += pad;
+ for (x = 0; x < width; Y += 2, x++)
+ *dst++ = Y[0] + (U[x] << 8) + (Y[1] << 16) + (V[x] << 24);
+ dst += pad;
+ U += width;
+ V += width;
}
+}
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
- return XvBadAlloc;
+static void
+CopyYV12BE(CARD8 *Y, CARD32 *dst, int width, int height, int pitch)
+{
+ int Y_size = width * height;
+ CARD8 *V = Y + Y_size;
+ CARD8 *U = V + (Y_size >> 2);
+ int pad = (pitch >> 2) - (width >> 1);
+ int x;
+
+ width >>= 1;
+
+ for (height >>= 1; height > 0; height--) {
+ for (x = 0; x < width; Y += 2, x++)
+ *dst++ = V[x] + (Y[1] << 8) + (U[x] << 16) + (Y[0] << 24);
+ dst += pad;
+ for (x = 0; x < width; Y += 2, x++)
+ *dst++ = V[x] + (Y[1] << 8) + (U[x] << 16) + (Y[0] << 24);
+ dst += pad;
+ U += width;
+ V += width;
+ }
}
+#endif /* X_BYTE_ORDER == X_BIG_ENDIAN */
+
static void
-Permedia2StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)
+CopyFlat(CARD8 *src, CARD8 *dst, int width, int height, int pitch)
+{
+ if (width == pitch) {
+ memcpy(dst, src, width * height);
+ return;
+ }
+
+ while (height > 0) {
+ memcpy(dst, src, width);
+ dst += pitch;
+ src += width;
+ height--;
+ }
+}
+
+static int
+Permedia2PutImage(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 id, unsigned char *buf, short width, short height,
+ Bool sync, RegionPtr clipBoxes, pointer data)
{
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
GLINTPtr pGlint = GLINTPTR(pScrn);
+ int i;
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
- "StopVideo port=%d, exit=%d\n",
- PORTNUM(pPPriv), exit));
+ "PutImage %d,%d,%d,%d -> %d,%d,%d,%d id=0x%08x buf=%p w=%d h=%d sync=%d\n",
+ src_x, src_y, src_w, src_h, drw_x, drw_y, drw_w, drw_h,
+ id, buf, width, height, sync));
+
+ if ((src_x + src_w) > width ||
+ (src_y + src_h) > height)
+ return BadValue;
+
+ pPPriv->vx = src_x << 10;
+ pPPriv->vy = src_y << 10;
+ pPPriv->vw = src_w << 10;
+ pPPriv->vh = src_h << 10;
+
+ pPPriv->dx = drw_x;
+ pPPriv->dy = drw_y;
+ pPPriv->dw = drw_w;
+ pPPriv->dh = drw_h;
+
+ if (!RemakePutCookies(pPPriv, clipBoxes))
+ return XvBadAlloc;
+
+ if (pPPriv->BuffersAllocated <= 0 ||
+ id != pPPriv->Id || /* same bpp */
+ width != pPPriv->fw ||
+ height != pPPriv->fh)
+ {
+ for (i = 0; i < ENTRIES(ScalerImages); i++)
+ if (id == ScalerImages[i].id)
+ break;
+
+ if (i >= ENTRIES(ScalerImages))
+ return XvBadAlloc;
+#if 0
+ if (pPPriv->BuffersAllocated <= 0 ||
+ pPPriv->Bpp != ScalerImages[i].bits_per_pixel ||
+ width > pPPriv->fw || height > pPPriv->fw ||
+ pPPriv->fw * pPPriv->fh > width * height * 2)
+#else
+ if (1)
+#endif
+ {
+ Permedia2Sync(pScrn);
- pPPriv->VideoOn = 0;
+ if (!AllocateBuffers(pPPriv, width, height,
+ (ScalerImages[i].bits_per_pixel + 7) >> 3, 1, 0)) {
+ pPPriv->Id = 0;
+ pPPriv->Bpp = 0;
+ pPPriv->fw = 0;
+ pPPriv->fh = 0;
- if (exit) {
- StopVideoStream(pAPriv, 1 << PORTNUM(pPPriv));
- ReallocateOffscreenBuffer(pPPriv, 0);
+ return XvBadAlloc;
+ }
+
+ pPPriv->Id = id;
+ pPPriv->Bpp = ScalerImages[i].bits_per_pixel;
+ pPPriv->fw = width;
+ pPPriv->fh = height;
+
+ RemoveableBuffers(pPPriv, TRUE);
+ } else
+ Permedia2Sync(pScrn);
} else
- pPPriv->APO = 750; /* Delay, appx. 30 sec */
+ Permedia2Sync(pScrn);
- if (pGlint->NoAccel)
+ switch (id) {
+ case LE4CC('Y','V','1','2'):
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ CopyYV12LE(buf, (CARD32 *)((CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0]),
+ width, height, pPPriv->BufferStride);
+#else
+ if (pGlint->FBDev)
+ CopyYV12LE(buf, (CARD32 *)((CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0]),
+ width, height, pPPriv->BufferStride);
+ else
+ CopyYV12BE(buf, (CARD32 *)((CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0]),
+ width, height, pPPriv->BufferStride);
+#endif
+ PutYUV(pPPriv, pPPriv->BufferBase[0], FORMAT_YUYV, 1, 0);
+ break;
+
+ case LE4CC('Y','U','Y','2'):
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutYUV(pPPriv, pPPriv->BufferBase[0], FORMAT_YUYV, 1, 0);
+ break;
+
+ case LE4CC('U','Y','V','Y'):
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutYUV(pPPriv, pPPriv->BufferBase[0], FORMAT_UYVY, 1, 0);
+ break;
+
+ case LE4CC('Y','U','V','A'):
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 2, height, pPPriv->BufferStride);
+ PutYUV(pPPriv, pPPriv->BufferBase[0], FORMAT_YUVA, 2, pPPriv->Attribute[7]);
+ break;
+
+ case LE4CC('V','U','Y','A'):
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 2, height, pPPriv->BufferStride);
+ PutYUV(pPPriv, pPPriv->BufferBase[0], FORMAT_VUYA, 2, pPPriv->Attribute[7]);
+ break;
+
+ case 0x41: /* RGBA 8:8:8:8 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 2, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_RGB8888, 2, pPPriv->Attribute[7]);
+ break;
+
+ case 0x42: /* RGB 5:6:5 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_RGB565, 1, 0);
+ break;
+
+ case 0x43: /* RGB 1:5:5:5 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_RGB5551, 1, pPPriv->Attribute[7]);
+ break;
+
+ case 0x44: /* RGB 4:4:4:4 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_RGB4444, 1, pPPriv->Attribute[7]);
+ break;
+
+ case 0x45: /* RGB 1:2:3:2 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_RGB2321, 0, pPPriv->Attribute[7]);
+ break;
+
+ case 0x46: /* RGB 2:3:3 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_RGB332, 0, 0);
+ break;
+
+ case 0x47: /* BGRA 8:8:8:8 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 2, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_BGR8888, 2, pPPriv->Attribute[7]);
+ break;
+
+ case 0x48: /* BGR 5:6:5 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_BGR565, 1, 0);
+ break;
+
+ case 0x49: /* BGR 1:5:5:5 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_BGR5551, 1, pPPriv->Attribute[7]);
+ break;
+
+ case 0x4A: /* BGR 4:4:4:4 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 1, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_BGR4444, 1, pPPriv->Attribute[7]);
+ break;
+
+ case 0x4B: /* BGR 1:2:3:2 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 0, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_BGR2321, 0, pPPriv->Attribute[7]);
+ break;
+
+ case 0x4C: /* BGR 2:3:3 */
+ CopyFlat(buf, (CARD8 *) pGlint->FbBase + pPPriv->BufferBase[0],
+ width << 0, height, pPPriv->BufferStride);
+ PutRGB(pPPriv, pPPriv->BufferBase[0], FORMAT_BGR332, 0, 0);
+ break;
+
+ default:
+ return XvBadAlloc;
+ }
+
+ pPPriv->StopDelay = pAPriv->Delay;
+
+ if (!pAPriv->TimerUsers) {
+ pAPriv->TimerUsers |= 1 << PORTNUM(pPPriv);
+ TimerSet(pAPriv->Timer, 0, 80, TimerCallback, pAPriv);
+ }
+
+ if (sync) /* sched_yield? */
Permedia2Sync(pScrn);
+
+ return Success;
}
static void
-DelayedStopVideo(PortPrivPtr pPPriv)
+Permedia2StopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)
{
+ PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ GLINTPtr pGlint = GLINTPTR(pScrn);
- DEBUG(xf86DrvMsgVerb(pAPriv->pScrn->scrnIndex, X_INFO, 3,
- "DelayedStopVideo port=%d\n", PORTNUM(pPPriv)));
-
- pPPriv->APO = -1;
- Permedia2StopVideo(pAPriv->pScrn, (pointer) pPPriv, TRUE);
-}
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
+ "StopVideo port=%d, exit=%d\n", PORTNUM(pPPriv), exit));
-/* Remind Port[0].v* are shifted 1 << 10 */
+ if (exit) {
+ if (PORTNUM(pPPriv) < 2) {
+ StopVideoStream(pPPriv, TRUE);
+ RestoreVideoStd(pAPriv);
+ } else {
+ FreeBuffers(pPPriv);
+ FreeCookies(pPPriv);
+ if (pAPriv->TimerUsers) {
+ pAPriv->TimerUsers &= ~PORTNUM(pPPriv);
+ if (!pAPriv->TimerUsers)
+ TimerCancel(pAPriv->Timer);
+ }
+ }
+ } else {
+ pPPriv->VideoOn = VIDEO_OFF;
+ pPPriv->StopDelay = 750; /* appx. 30 sec */
-static void
-AdjustVideoW(PortPrivPtr pPPriv, int num, int denom)
-{
- pPPriv->vx = (pPPriv->vx * num) / denom;
- pPPriv->vw = (pPPriv->vw * num) / denom;
+ if (pGlint->NoAccel)
+ Permedia2Sync(pScrn);
+ }
}
static void
-AdjustVideoH(PortPrivPtr pPPriv, int num, int denom)
+RestartVideo(PortPrivPtr pPPriv, int old_VideoOn)
{
- pPPriv->vy = (pPPriv->vy * num) / denom;
- pPPriv->vh = (pPPriv->vh * num) / denom;
+ AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int new_fh;
+
+ if (pPPriv->VideoOn > VIDEO_OFF ||
+ pAPriv->VideoStd < 0 /* invalid */)
+ return;
+
+ new_fh = InputVideoEncodings[pAPriv->VideoStd * 3].height >>
+ (1 - (pPPriv->Attribute[4] & 1));
+
+ if (new_fh != pPPriv->fh) {
+ pPPriv->vy = (pPPriv->vy * new_fh) / pPPriv->fh;
+ pPPriv->vh = (pPPriv->vh * new_fh) / pPPriv->fh;
+
+ pPPriv->fh = new_fh;
+ }
+
+ if (old_VideoOn) {
+ if (StartVideoStream(pPPriv, NULL)) {
+ pPPriv->VideoOn = old_VideoOn;
+
+ if (pPPriv == &pAPriv->Port[1])
+ GetYUV(pPPriv);
+ } else {
+ DEBUG(xf86DrvMsgVerb(pAPriv->pScrn->scrnIndex, X_INFO, 4,
+ "RestartVideo port=%d suspend\n", PORTNUM(pPPriv)));
+ pPPriv->VideoOn = -old_VideoOn; /* suspend (not off) */
+ }
+ }
}
static int
@@ -1396,142 +2043,162 @@ Permedia2SetPortAttribute(ScrnInfoPtr pScrn,
{
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
+ int old_VideoStd, old_Plug;
+ int VideoStd = -1, Plug = 0;
+ int r;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "SPA attr=%d, val=%d, port=%d\n",
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
+ "SPA attr=%d val=%d port=%d\n",
attribute, value, PORTNUM(pPPriv)));
if (attribute == xvFilter) {
pPPriv->Attribute[5] = !!value;
return Success;
- } else if (attribute == xvInterlace) {
- value %= 3;
+ } else if (attribute == xvAlpha) {
+ pPPriv->Attribute[7] = !!value;
+ return Success;
+ }
- if (value != pPPriv->Attribute[4]) {
- int VideoOn = ABS(pPPriv->VideoOn);
- int fh;
+ if (PORTNUM(pPPriv) >= 2)
+ return BadMatch;
- StopVideoStream(pAPriv, 1 << PORTNUM(pPPriv));
+ if (attribute == xvInterlace) {
+ int old_value = pPPriv->Attribute[4];
- ReallocateOffscreenBuffer(pPPriv, 0);
+ value %= 3;
+ if (value != old_value) {
+ int old_VideoOn = ABS(pPPriv->VideoOn);
+#if 0
+ if (old_VideoOn)
+ return XvBadAlloc;
+#endif
+ StopVideoStream(pPPriv, FALSE);
+ FreeBuffers(pPPriv);
pPPriv->Attribute[4] = value;
+ RestartVideo(pPPriv, old_VideoOn);
- fh = InputVideoEncodings[pAPriv->VideoStd * 3].height >> (1 - (value & 1));
- AdjustVideoH(pPPriv, fh, pPPriv->fh);
- pPPriv->fh = fh;
-
- if (VideoOn) {
- if (StartVideoStream(pPPriv, NULL)) {
- pPPriv->VideoOn = VideoOn;
- if (pPPriv == &pAPriv->Port[1])
- GetYUV(pPPriv);
- } else {
- pPPriv->VideoOn = -VideoOn;
- return XvBadAlloc;
- }
+ if (pPPriv->VideoOn < 0 /* suspended */) {
+ pPPriv->Attribute[4] = old_value;
+ RestartVideo(pPPriv, old_VideoOn);
+ return XvBadAlloc;
}
}
return Success;
}
- if (PORTNUM(pPPriv) == 0) {
+ if (pPPriv == &pAPriv->Port[0]) {
+ /*
+ * Input
+ */
if (attribute == xvEncoding) {
- if (value < 0 || value > 8) {
+ if (value < 0 || value > ENTRIES(InputVideoEncodings))
return XvBadEncoding;
- }
+
+ VideoStd = value / 3;
+ Plug = value % 3;
+
/* Fall through */
- } else if (attribute == xvBrightness) {
- pPPriv->Attribute[0] = value = CLAMP(value, -1000, +1000);
- return SetAttr(&pAPriv->Port[0], 0, 0x0A, 128 + (MIN(value, +999) * 128) / 1000);
- } else if (attribute == xvContrast) {
- pPPriv->Attribute[1] = value = CLAMP(value, -3000, +1000);
- return SetAttr(&pAPriv->Port[0], 1, 0x0B, 64 + (MIN(value, +999) * 64) / 1000);
- } else if (attribute == xvSaturation) {
- pPPriv->Attribute[2] = value = CLAMP(value, -3000, +1000);
- return SetAttr(&pAPriv->Port[0], 2, 0x0C, 64 + (MIN(value, +999) * 64) / 1000);
- } else if (attribute == xvHue) {
- pPPriv->Attribute[3] = value = CLAMP(value, -1000, +1000);
- return SetAttr(&pAPriv->Port[0], 3, 0x0D, (MIN(value, +999) * 128) / 1000);
- } else
- return BadMatch;
- } else { /* Output */
+
+ } else if (attribute == xvBrightness)
+ return SetAttr(&pAPriv->Port[0], 0, value);
+ else if (attribute == xvContrast)
+ return SetAttr(&pAPriv->Port[0], 1, value);
+ else if (attribute == xvSaturation)
+ return SetAttr(&pAPriv->Port[0], 2, value);
+ else if (attribute == xvHue)
+ return SetAttr(&pAPriv->Port[0], 3, value);
+ } else {
+ /*
+ * Output
+ */
if (attribute == xvEncoding) {
- if (value < 0 || value > 3)
+ if (value < 0 || value > ENTRIES(OutputVideoEncodings))
return XvBadEncoding;
- if (++value >= 3) value++;
- } else if (attribute == xvBkgColor) {
- pPPriv->Attribute[6] = value;
- pPPriv->BkgCol = ((value & 0xF80000) >> 8) |
- ((value & 0x00FC00) >> 5) |
- ((value & 0x0000F8) >> 3);
- pPPriv->BkgCol |= pPPriv->BkgCol << 16;
- if (pPPriv->StreamOn) {
- BlackOut(pPPriv, NULL);
- GetYUV(pPPriv);
- }
- return Success;
- } else
- return Success;
- }
- if (attribute == xvEncoding) {
- pPPriv->Plug = value % 3;
+ VideoStd = value / 2;
+ Plug = (value % 2) + 1;
- if (!SetPlug(pPPriv))
- return XvBadAlloc;
+ /* Fall through */
- value /= 3;
+ } else if (attribute == xvBkgColor)
+ return SetBkgCol(pPPriv, value);
+#if 1
+ else if (attribute == xvBrightness ||
+ attribute == xvContrast ||
+ attribute == xvSaturation ||
+ attribute == xvHue)
+ return Success;
+#endif
+ }
- if (value != pAPriv->VideoStd) {
- int VideoOn0 = ABS(pAPriv->Port[0].VideoOn);
- int VideoOn1 = ABS(pAPriv->Port[1].VideoOn);
- int fh;
+ if (attribute != xvEncoding)
+ return BadMatch;
- StopVideoStream(pAPriv, 1 | 2);
+ old_VideoStd = pAPriv->VideoStd;
+ old_Plug = pPPriv->Plug;
- if (value == 1 || pAPriv->VideoStd == 1) {
- ReallocateOffscreenBuffer(&pAPriv->Port[0], 0);
- ReallocateOffscreenBuffer(&pAPriv->Port[1], 0);
- }
+#if 0
+ if (pAPriv->Port[0].VideoOn ||
+ pAPriv->Port[1].VideoOn)
+ return XvBadAlloc;
+#endif
- pAPriv->VideoStd = value;
+ if (Plug != old_Plug)
+ if ((r = SetPlug(pPPriv, Plug)) != Success)
+ return r;
- SetVideoStd(pAPriv);
+ if (VideoStd != old_VideoStd) {
+ int old_VideoOn0 = ABS(pAPriv->Port[0].VideoOn);
+ int old_VideoOn1 = ABS(pAPriv->Port[1].VideoOn);
- fh = InputVideoEncodings[pAPriv->VideoStd * 3].height >> (!pAPriv->Port[0].Attribute[4]);
- AdjustVideoH(&pAPriv->Port[0], fh, pAPriv->Port[0].fh);
- pAPriv->Port[0].fh = fh;
+ StopVideoStream(&pAPriv->Port[0], FALSE);
+ StopVideoStream(&pAPriv->Port[1], FALSE);
- fh = InputVideoEncodings[pAPriv->VideoStd * 3].height >> (!pAPriv->Port[1].Attribute[4]);
- AdjustVideoH(&pAPriv->Port[1], fh, pAPriv->Port[1].fh);
- pAPriv->Port[1].fh = fh;
+ if (VideoStd == NTSC || pAPriv->VideoStd == NTSC) {
+ FreeBuffers(&pAPriv->Port[0]);
+ FreeBuffers(&pAPriv->Port[1]);
+ }
- if (VideoOn0)
- pAPriv->Port[0].VideoOn = (StartVideoStream(&pAPriv->Port[0], NULL)) ?
- VideoOn0 : -VideoOn0;
+ if (SetVideoStd(pPPriv, VideoStd) == Success) {
+ RestartVideo(&pAPriv->Port[0], old_VideoOn0);
+ RestartVideo(&pAPriv->Port[1], old_VideoOn1);
+ }
- if (VideoOn1) {
- if (StartVideoStream(&pAPriv->Port[1], NULL)) {
- pAPriv->Port[1].VideoOn = VideoOn1;
- GetYUV(pPPriv);
- } else
- pAPriv->Port[1].VideoOn = -VideoOn1;
+ if (pAPriv->Port[0].VideoOn < 0 ||
+ pAPriv->Port[1].VideoOn < 0 ||
+ VideoStd != pAPriv->VideoStd) {
+ if (SetVideoStd(pPPriv, old_VideoStd) == Success) {
+ RestartVideo(&pAPriv->Port[0], old_VideoOn0);
+ RestartVideo(&pAPriv->Port[1], old_VideoOn1);
}
- if (pAPriv->Port[0].VideoOn < 0 ||
- pAPriv->Port[1].VideoOn < 0 ||
- pAPriv->VideoStd != value)
- return XvBadAlloc;
+ if (Plug != old_Plug)
+ SetPlug(pPPriv, old_Plug);
+
+ return XvBadAlloc;
}
}
return Success;
}
-/* Should update attrs via XVIPC too,
- * Xv has XvPortNotify but no DDX equivalent.
- */
+static void
+RestoreVideoStd(AdaptorPrivPtr pAPriv)
+{
+ if (pAPriv->Port[0].VideoOn && !pAPriv->Port[1].VideoOn &&
+ pAPriv->Port[0].VideoStdReq != pAPriv->VideoStd)
+ Permedia2SetPortAttribute(pAPriv->pScrn, xvEncoding,
+ pAPriv->Port[0].VideoStdReq * 3 + pAPriv->Port[0].Plug,
+ (pointer) &pAPriv->Port[0]);
+ else
+ if (pAPriv->Port[1].VideoOn && !pAPriv->Port[0].VideoOn &&
+ pAPriv->Port[1].VideoStdReq != pAPriv->VideoStd)
+ Permedia2SetPortAttribute(pAPriv->pScrn, xvEncoding,
+ pAPriv->Port[2].VideoStdReq * 2 + pAPriv->Port[1].Plug - 1,
+ (pointer) &pAPriv->Port[1]);
+}
static int
Permedia2GetPortAttribute(ScrnInfoPtr pScrn,
@@ -1540,9 +2207,20 @@ Permedia2GetPortAttribute(ScrnInfoPtr pScrn,
PortPrivPtr pPPriv = (PortPrivPtr) data;
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
- if (attribute == xvEncoding)
- *value = pAPriv->VideoStd * 3 + pPPriv->Plug;
- else if (attribute == xvBrightness)
+ if (PORTNUM(pPPriv) >= 2 &&
+ attribute != xvFilter &&
+ attribute != xvAlpha)
+ return BadMatch;
+
+ if (attribute == xvEncoding) {
+ if (pAPriv->VideoStd < 0)
+ return XvBadAlloc;
+ else
+ if (pPPriv == &pAPriv->Port[0])
+ *value = pAPriv->VideoStd * 3 + pPPriv->Plug;
+ else
+ *value = pAPriv->VideoStd * 2 + pPPriv->Plug - 1;
+ } else if (attribute == xvBrightness)
*value = pPPriv->Attribute[0];
else if (attribute == xvContrast)
*value = pPPriv->Attribute[1];
@@ -1556,10 +2234,13 @@ Permedia2GetPortAttribute(ScrnInfoPtr pScrn,
*value = pPPriv->Attribute[5];
else if (attribute == xvBkgColor)
*value = pPPriv->Attribute[6];
+ else if (attribute == xvAlpha)
+ *value = pPPriv->Attribute[7];
else
return BadMatch;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "GPA attr=%d, val=%d, port=%d\n",
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
+ "GPA attr=%d val=%d port=%d\n",
attribute, *value, PORTNUM(pPPriv)));
return Success;
@@ -1574,6 +2255,132 @@ Permedia2QueryBestSize(ScrnInfoPtr pScrn, Bool motion,
*p_h = drw_h;
}
+static int
+Permedia2QueryImageAttributes(ScrnInfoPtr pScrn,
+ int id, unsigned short *width, unsigned short *height,
+ int *pitches, int *offsets)
+{
+ int i, pitch;
+
+ *width = CLAMP(*width, 1, 2047);
+ *height = CLAMP(*height, 1, 2047);
+
+ if (offsets)
+ offsets[0] = 0;
+
+ switch (id) {
+ case LE4CC('Y','V','1','2'): /* Planar YVU 4:2:0 (emulated) */
+ *width = CLAMP((*width + 1) & ~1, 2, 2046);
+ *height = CLAMP((*height + 1) & ~1, 2, 2046);
+
+ pitch = *width; /* luma component */
+
+ if (offsets) {
+ offsets[1] = pitch * *height;
+ offsets[2] = offsets[1] + (offsets[1] >> 2);
+ }
+
+ if (pitches) {
+ pitches[0] = pitch;
+ pitches[1] = pitches[2] = pitch >> 1;
+ }
+
+ return pitch * *height * 3 / 2;
+
+ case LE4CC('Y','U','Y','2'): /* Packed YUYV 4:2:2 */
+ case LE4CC('U','Y','V','Y'): /* Packed UYVY 4:2:2 */
+ *width = CLAMP((*width + 1) & ~1, 2, 2046);
+
+ pitch = *width * 2;
+
+ if (pitches)
+ pitches[0] = pitch;
+
+ return pitch * *height;
+
+ default:
+ for (i = 0; i < ENTRIES(ScalerImages); i++)
+ if (ScalerImages[i].id == id)
+ break;
+
+ if (i >= ENTRIES(ScalerImages))
+ break;
+
+ pitch = *width * (ScalerImages[i].bits_per_pixel >> 3);
+
+ if (pitches)
+ pitches[0] = pitch;
+
+ return pitch * *height;
+ }
+
+ return 0;
+}
+
+static void
+RestoreVideo(AdaptorPrivPtr pAPriv)
+{
+ GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
+
+ GLINT_WRITE_REG(pAPriv->dFifoControl, PMFifoControl);
+ GLINT_WRITE_REG(0, VSABase + VSControl);
+ GLINT_WRITE_REG(0, VSBBase + VSControl);
+ usleep(160000);
+ GLINT_MASK_WRITE_REG(VS_UnitMode_ROM, ~VS_UnitMode_Mask, VSConfiguration);
+}
+
+static void
+InitializeVideo(AdaptorPrivPtr pAPriv)
+{
+ GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
+ int i;
+
+ GLINT_WRITE_REG(0, VSABase + VSControl);
+ GLINT_WRITE_REG(0, VSBBase + VSControl);
+
+#if 0
+ GLINT_MASK_WRITE_REG(0, ~(VSAIntFlag | VSBIntFlag), IntEnable);
+ GLINT_WRITE_REG(VSAIntFlag | VSBIntFlag, IntFlags); /* Reset */
+#endif
+
+ for (i = 0x0018; i <= 0x00B0; i += 8) {
+ GLINT_WRITE_REG(0, VSABase + i);
+ GLINT_WRITE_REG(0, VSBBase + i);
+ }
+
+ GLINT_WRITE_REG((0 << 8) | (132 << 0), VSABase + VSFifoControl);
+ GLINT_WRITE_REG((0 << 8) | (132 << 0), VSBBase + VSFifoControl);
+
+ GLINT_MASK_WRITE_REG(
+ VS_UnitMode_AB8 |
+ VS_GPBusMode_A |
+ /* VS_HRefPolarityA | */
+ VS_VRefPolarityA |
+ VS_VActivePolarityA |
+ /* VS_UseFieldA | */
+ VS_FieldPolarityA |
+ /* VS_FieldEdgeA | */
+ /* VS_VActiveVBIA | */
+ VS_InterlaceA |
+ VS_ReverseDataA |
+
+ /* VS_HRefPolarityB | */
+ VS_VRefPolarityB |
+ VS_VActivePolarityB |
+ /* VS_UseFieldB | */
+ VS_FieldPolarityB |
+ /* VS_FieldEdgeB | */
+ /* VS_VActiveVBIB | */
+ VS_InterlaceB |
+ /* VS_ColorSpaceB_RGB | */
+ /* VS_ReverseDataB | */
+ /* VS_DoubleEdgeB | */
+ 0, ~0x1FFFFE0F, VSConfiguration);
+
+ pAPriv->dFifoControl = GLINT_READ_REG(PMFifoControl);
+ GLINT_WRITE_REG((12 << 8) | 8, PMFifoControl);
+}
+
static Bool
xvipcHandshake(PortPrivPtr pPPriv, int op, Bool block)
{
@@ -1582,8 +2389,7 @@ xvipcHandshake(PortPrivPtr pPPriv, int op, Bool block)
xvipc.magic = XVIPC_MAGIC;
xvipc.op = op;
- xvipc.block = block; /* Wait (with timeout), else don't wait for events
- if none are pending. */
+ xvipc.block = block;
if (pPPriv) {
AdaptorPrivPtr pAPriv = pPPriv->pAdaptor;
@@ -1597,8 +2403,9 @@ xvipcHandshake(PortPrivPtr pPPriv, int op, Bool block)
xvipc.port = -1;
}
- while (TRUE) {
- if (brake-- <= 0) return FALSE; /* We have a bug. */
+ for (;;) {
+ if (brake-- <= 0)
+ return FALSE; /* I brake for bugs. */
DEBUG(xf86MsgVerb(X_INFO, 4,
"PM2 XVIPC send op=%d bl=%d po=%d a=%d b=%d c=%d\n",
@@ -1611,127 +2418,148 @@ xvipcHandshake(PortPrivPtr pPPriv, int op, Bool block)
xvipc.op, xvipc.block, xvipc.port, xvipc.a, xvipc.b, xvipc.c, r, errno));
switch (xvipc.op) {
- case OP_ALLOC:
- {
- AdaptorPrivPtr pAPriv = xvipc.pAPriv;
- ScrnInfoPtr pScrn = pAPriv->pScrn;
- GLINTPtr pGlint = GLINTPTR(pScrn);
- FBAreaPtr pFBArea;
- LFBAreaPtr pLFBArea = NULL;
-
- xvipc.a = -1;
+ case OP_ALLOC:
+ {
+ AdaptorPrivPtr pAPriv = xvipc.pAPriv;
+ ScrnInfoPtr pScrn = pAPriv->pScrn;
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ FBAreaPtr pFBArea = NULL;
+ LFBAreaPtr pLFBArea;
+
+ xvipc.a = -1;
+
+ pLFBArea = xalloc(sizeof(LFBAreaRec));
+
+ if (pLFBArea) {
+ pLFBArea->pFBArea = pFBArea =
+ xf86AllocateLinearOffscreenArea(pScrn->pScreen,
+ xvipc.b >> BPPSHIFT(pGlint), 2, NULL, NULL, NULL);
+
+ if (pFBArea) {
+ /* xvipc.a = pFBArea->linear; */
+ pLFBArea->Linear = xvipc.a =
+ ((pFBArea->box.y1 * pScrn->displayWidth) +
+ pFBArea->box.x1) << BPPSHIFT(pGlint);
+ } else
+ xfree(pLFBArea);
+ }
- if ((pFBArea = xf86AllocateLinearOffscreenArea(pScrn->pScreen,
- xvipc.b >> BPPSHIFT(pGlint), 2, NULL, NULL, NULL)))
- xvipc.a = ((pFBArea->box.y1 * pScrn->displayWidth) +
- pFBArea->box.x1) << BPPSHIFT(pGlint);
+ /* Report results */
- if (ioctl(xvipc_fd, VIDIOC_PM2_XVIPC, (void *) &xvipc) != 0) {
- if (pFBArea) xf86FreeOffscreenArea(pFBArea);
+ if (ioctl(xvipc_fd, VIDIOC_PM2_XVIPC, (void *) &xvipc) != 0)
+ if (pFBArea) {
+ xf86FreeOffscreenArea(pFBArea);
+ xfree(pLFBArea);
pFBArea = NULL;
}
- if (pFBArea && (pLFBArea = xalloc(sizeof(LFBAreaRec)))) {
- pLFBArea->Next = pAPriv->LFBList;
- pLFBArea->pFBArea = pFBArea;
- pLFBArea->Linear = xvipc.a;
- pAPriv->LFBList = pLFBArea;
- }
-
- DEBUG(xf86MsgVerb(X_INFO, 3, "PM2 XVIPC alloc addr=%d=0x%08x pFB=%p pLFB=%p\n",
- xvipc.a, xvipc.a, pFBArea, pLFBArea));
-
- goto event;
+ if (pFBArea) {
+ pLFBArea->Next = pAPriv->LFBList;
+ pAPriv->LFBList = pLFBArea;
}
- case OP_FREE:
- {
- AdaptorPrivPtr pAPriv = xvipc.pAPriv;
- LFBAreaPtr pLFBArea, *ppLFBArea;
+ DEBUG(xf86MsgVerb(X_INFO, 3, "PM2 XVIPC alloc addr=%d=0x%08x pFB=%p\n",
+ xvipc.a, xvipc.a, pFBArea));
- for (ppLFBArea = &pAPriv->LFBList; (pLFBArea = *ppLFBArea);
- ppLFBArea = &pLFBArea->Next)
- if (pLFBArea->Linear == xvipc.a)
- break;
+ goto event;
+ }
- if (!pLFBArea)
- xvipc.a = -1;
+ case OP_FREE:
+ {
+ AdaptorPrivPtr pAPriv = xvipc.pAPriv;
+ LFBAreaPtr pLFBArea, *ppLFBArea;
- DEBUG(xf86MsgVerb(X_INFO, 3, "PM2 XVIPC free addr=%d=0x%08x pLFB=%p\n",
- xvipc.a, xvipc.a, pLFBArea));
+ for (ppLFBArea = &pAPriv->LFBList; (pLFBArea = *ppLFBArea);
+ ppLFBArea = &pLFBArea->Next)
+ if (pLFBArea->Linear == xvipc.a)
+ break;
- if (ioctl(xvipc_fd, VIDIOC_PM2_XVIPC, (void *) &xvipc) == 0) {
- xf86FreeOffscreenArea(pLFBArea->pFBArea);
- *ppLFBArea = pLFBArea->Next;
- xfree(pLFBArea);
- pLFBArea = NULL;
- }
+ if (!pLFBArea)
+ xvipc.a = -1;
+
+ DEBUG(xf86MsgVerb(X_INFO, 3, "PM2 XVIPC free addr=%d=0x%08x pFB=%p\n",
+ xvipc.a, xvipc.a, pLFBArea ? pLFBArea->pFBArea : NULL));
- goto event;
+ if (ioctl(xvipc_fd, VIDIOC_PM2_XVIPC, (void *) &xvipc) == 0 && pLFBArea) {
+ xf86FreeOffscreenArea(pLFBArea->pFBArea);
+ *ppLFBArea = pLFBArea->Next;
+ xfree(pLFBArea);
}
- case OP_UPDATE:
- {
- AdaptorPrivPtr pAPriv = xvipc.pAPriv;
- PortPrivPtr pPPriv;
+ goto event;
+ }
- pPPriv = &pAPriv->Port[0];
+ case OP_UPDATE:
+ {
+ AdaptorPrivPtr pAPriv = xvipc.pAPriv;
+ PortPrivPtr pPPriv;
- if (pPPriv->VideoOn >= 1 && xvipc.a > 0) {
- pPPriv->FrameAcc += pPPriv->FramesPerSec;
- if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
- pPPriv->FrameAcc -= pAPriv->FramesPerSec;
+ pPPriv = &pAPriv->Port[0];
- /* Asynchronous resizing caused by kernel app */
+ if (pPPriv->VideoOn > VIDEO_OFF && xvipc.a > 0) {
+ pPPriv->FrameAcc += pPPriv->FramesPerSec;
+ if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
+ pPPriv->FrameAcc -= pAPriv->FramesPerSec;
- if (xvipc.c != pPPriv->fw ||
- xvipc.d != pPPriv->fh) {
- AdjustVideoW(pPPriv, xvipc.c, pPPriv->fw);
- AdjustVideoH(pPPriv, xvipc.d, pPPriv->fh);
- pPPriv->fw = xvipc.c;
- pPPriv->fh = xvipc.d;
- pPPriv->BufferPProd = xvipc.e;
+ /* Asynchronous resizing caused by kernel app */
- PutCookies(pPPriv, NULL);
- }
+ if (xvipc.c != pPPriv->fw ||
+ xvipc.d != pPPriv->fh) {
+ pPPriv->vx = (pPPriv->vx * xvipc.c) / pPPriv->fw;
+ pPPriv->vw = (pPPriv->vw * xvipc.c) / pPPriv->fw;
+ pPPriv->vy = (pPPriv->vy * xvipc.d) / pPPriv->fh;
+ pPPriv->vh = (pPPriv->vh * xvipc.d) / pPPriv->fh;
- PutYUV(pPPriv, xvipc.a);
+ pPPriv->fw = xvipc.c;
+ pPPriv->fh = xvipc.d;
+ pPPriv->BufferPProd = xvipc.e;
- if (pPPriv->VideoOn == 1)
- pPPriv->VideoOn = 0;
+ RemakePutCookies(pPPriv, NULL);
}
- } else if (pPPriv->APO >= 0 && !(pPPriv->APO--))
- DelayedStopVideo(pPPriv);
- pPPriv = &pAPriv->Port[1];
+ PutYUV(pPPriv, xvipc.a, FORMAT_YUYV, 1, 0);
- if (pPPriv->VideoOn >= 1 && xvipc.b > 0) {
- pPPriv->FrameAcc += pPPriv->FramesPerSec;
- if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
- pPPriv->FrameAcc -= pAPriv->FramesPerSec;
+ if (pPPriv->VideoOn == VIDEO_ONE_SHOT)
+ pPPriv->VideoOn = VIDEO_OFF;
+ }
+ } else
+ if (pPPriv->StopDelay >= 0 && !(pPPriv->StopDelay--)) {
+ StopVideoStream(pPPriv, TRUE);
+ RestoreVideoStd(pAPriv);
+ }
- pPPriv->BufferBase[0] = xvipc.b;
+ pPPriv = &pAPriv->Port[1];
- /* Output is always exclusive, no async resizing */
+ if (pPPriv->VideoOn > VIDEO_OFF && xvipc.b > 0) {
+ pPPriv->FrameAcc += pPPriv->FramesPerSec;
+ if (pPPriv->FrameAcc >= pAPriv->FramesPerSec) {
+ pPPriv->FrameAcc -= pAPriv->FramesPerSec;
- GetYUV(pPPriv);
+ pPPriv->BufferBase[0] = xvipc.b;
- if (pPPriv->VideoOn == 1)
- pPPriv->VideoOn = 0;
- }
- } else if (pPPriv->APO >= 0 && !(pPPriv->APO--))
- DelayedStopVideo(pPPriv);
+ /* Output is always exclusive, no async resizing */
- /* Fall through */
- }
+ GetYUV(pPPriv);
- default:
- event:
- if (xvipc.op == op)
- return r == 0;
+ if (pPPriv->VideoOn == VIDEO_ONE_SHOT)
+ pPPriv->VideoOn = VIDEO_OFF;
+ }
+ } else
+ if (pPPriv->StopDelay >= 0 && !(pPPriv->StopDelay--)) {
+ StopVideoStream(pPPriv, TRUE);
+ RestoreVideoStd(pAPriv);
+ }
- xvipc.op = OP_EVENT;
- xvipc.block = block;
+ /* Fall through */
+ }
+
+ default:
+ event:
+ if (xvipc.op == op)
+ return r == 0;
+
+ xvipc.op = OP_EVENT;
+ xvipc.block = block;
}
}
@@ -1744,29 +2572,6 @@ Permedia2ReadInput(int fd, pointer unused)
xvipcHandshake(NULL, OP_EVENT, FALSE);
}
-static void
-AdaptorPrivUninit(AdaptorPrivPtr pAPriv)
-{
- GLINTPtr pGlint = GLINTPTR(pAPriv->pScrn);
-
- if (!pAPriv->pm2p) {
- TimerFree(pAPriv->Timer);
- xf86DestroyI2CDevRec(&pAPriv->Port[0].I2CDev, FALSE);
- xf86DestroyI2CDevRec(&pAPriv->Port[1].I2CDev, FALSE);
- GLINT_MASK_WRITE_REG(VS_UnitMode_ROM, ~VS_UnitMode_Mask, VSConfiguration);
- GLINT_WRITE_REG(pAPriv->FifoControl, PMFifoControl);
- }
-
- FreeCookies(&pAPriv->Port[0]);
- FreeCookies(&pAPriv->Port[1]);
-
- xfree(pAPriv);
-}
-
-/* Only a single file for all heads, the device ID is transmitted at initial
- * handshake and encoded in all subsequent xvipc headers.
- */
-
static Bool
xvipcOpen(char *name, ScrnInfoPtr pScrn)
{
@@ -1780,8 +2585,9 @@ xvipcOpen(char *name, ScrnInfoPtr pScrn)
if (!osname || strcmp(osname, "linux"))
return FALSE;
- while (1) {
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "XVIPC probing device %s\n", name));
+ for (;;) {
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+ "XVIPC probing device %s\n", name));
if ((xvipc_fd = open(name, O_RDWR /* | O_TRUNC */, 0)) < 0)
break;
@@ -1806,16 +2612,9 @@ xvipcOpen(char *name, ScrnInfoPtr pScrn)
break;
}
- /* Typical input devices should be closed when VT switched away, but
- * this is proprietary IPC between this driver and the kernel driver
- * only. Actually, it would be better to continue listening to kernel
- * events, at least keeping the file open, to avoid side effects of
- * repeated dis- and reconnection, shouldn't hurt.
- */
-
xf86AddInputHandler(xvipc_fd, Permedia2ReadInput, NULL);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv driver connected to %s\n", name);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv driver opened %s\n", name);
return TRUE;
}
@@ -1825,48 +2624,142 @@ xvipcOpen(char *name, ScrnInfoPtr pScrn)
xvipc_fd = -1;
- xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Cannot connect to Permedia 2 kernel driver. "
- "Note that using both drivers at the same time "
- "will cause problems.\n");
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Cannot find Permedia 2 kernel driver.\n");
+
return FALSE;
}
+static void
+DeleteAdaptorPriv(AdaptorPrivPtr pAPriv)
+{
+ int i;
+
+ if (pAPriv->VideoIO) {
+ StopVideoStream(&pAPriv->Port[0], TRUE);
+ StopVideoStream(&pAPriv->Port[1], TRUE);
+ }
+
+ for (i = 0; i < 6; i++) {
+ FreeBuffers(&pAPriv->Port[i]);
+ FreeCookies(&pAPriv->Port[i]);
+ }
+
+ TimerFree(pAPriv->Timer);
+
+ if (pAPriv->VideoIO) {
+ if (pAPriv->pm2p)
+ xvipcHandshake(&pAPriv->Port[0], OP_DISCONNECT, TRUE);
+ else {
+ xf86DestroyI2CDevRec(&pAPriv->Port[0].I2CDev, FALSE);
+ xf86DestroyI2CDevRec(&pAPriv->Port[1].I2CDev, FALSE);
+
+ RestoreVideo(pAPriv);
+ }
+ }
+
+ xfree(pAPriv);
+}
+
static AdaptorPrivPtr
-AdaptorPrivInit(ScrnInfoPtr pScrn)
+NewAdaptorPriv(ScrnInfoPtr pScrn, Bool VideoIO)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
AdaptorPrivPtr pAPriv = (AdaptorPrivPtr) xcalloc(1, sizeof(AdaptorPrivRec));
int i;
- if (pAPriv) {
- pAPriv->pScrn = pScrn;
- pAPriv->Port[0].pAdaptor = pAPriv;
- pAPriv->Port[1].pAdaptor = pAPriv;
+ if (!pAPriv)
+ return NULL;
- pAPriv->Port[0].Attribute[0] = 0; /* Brightness (-1000..+1000) */
- pAPriv->Port[0].Attribute[1] = 0; /* Contrast (-3000..+1000) */
- pAPriv->Port[0].Attribute[2] = 0; /* Color saturation (-3000..+1000) */
- pAPriv->Port[0].Attribute[3] = 0; /* Hue (-1000..+1000) */
- pAPriv->Port[0].Attribute[4] = 1; /* Interlaced (0 = not, 1 = yes, 2 = dscan) */
- pAPriv->Port[0].Attribute[5] = 0; /* Bilinear Filter (Bool) */
+ pAPriv->pScrn = pScrn;
+
+ for (i = 0; i < PORTS; i++)
+ pAPriv->Port[i].pAdaptor = pAPriv;
- pAPriv->Port[1].Attribute[4] = 1; /* Interlaced (Bool) */
- pAPriv->Port[1].Attribute[5] = 0; /* Bilinear Filter (Bool) */
- pAPriv->Port[1].Attribute[6] = 0; /* BkgColor 0x00RRGGBB */
- pAPriv->Port[1].BkgCol = 0;
-
- pAPriv->Port[0].Buffers = 2;
- pAPriv->Port[1].Buffers = 1;
-
- for (i = 0; i <= 1; i++) {
- pAPriv->Port[i].fw = 704;
- pAPriv->Port[i].fh = 576;
- pAPriv->Port[i].FramesPerSec = 30;
- pAPriv->Port[i].APO = -1;
- pAPriv->Port[i].BufferPProd = partprodPermedia[704 >> 5];
- }
+ switch (pScrn->depth) {
+ case 8:
+ pAPriv->dDitherMode =
+ (0 << 10) | /* BGR */
+ (1 << 1) | /* Dither */
+ ((5 & 0x10) << 12) |
+ ((5 & 0x0F) << 2) | /* 3:3:2f */
+ UNIT_ENABLE;
+ pAPriv->dAlphaBlendMode =
+ (0 << 13) |
+ ((5 & 0x10) << 12) |
+ ((5 & 0x0F) << 8) |
+ (84 << 1) | /* Blend (decal) RGB */
+ UNIT_ENABLE;
+ pAPriv->dTextureDataFormat =
+ (1 << 4) | /* No alpha */
+ ((14 & 0x10) << 2) |
+ ((14 & 0x0F) << 0); /* CI8 */
+ break;
+
+ case 15:
+ pAPriv->dDitherMode =
+ (1 << 10) | /* RGB */
+ ((1 & 0x10) << 12) |
+ ((1 & 0x0F) << 2) | /* 5:5:5:1f */
+ UNIT_ENABLE;
+ pAPriv->dAlphaBlendMode =
+ (1 << 13) |
+ ((1 & 0x10) << 12) |
+ ((1 & 0x0F) << 8) |
+ (84 << 1) |
+ UNIT_ENABLE;
+ pAPriv->dTextureDataFormat =
+ (1 << 5) | /* RGB */
+ (1 << 4) |
+ ((1 & 0x10) << 2) |
+ ((1 & 0x0F) << 0);
+ break;
+
+ case 16:
+ pAPriv->dDitherMode =
+ (1 << 10) | /* RGB */
+ ((16 & 0x10) << 12) |
+ ((16 & 0x0F) << 2) | /* 5:6:5f */
+ UNIT_ENABLE;
+ pAPriv->dAlphaBlendMode =
+ (1 << 13) |
+ ((16 & 0x10) << 12) |
+ ((16 & 0x0F) << 8) |
+ (84 << 1) |
+ UNIT_ENABLE;
+ pAPriv->dTextureDataFormat =
+ (1 << 5) |
+ (1 << 4) |
+ ((16 & 0x10) << 2) |
+ ((16 & 0x0F) << 0);
+ break;
+
+ case 24:
+ pAPriv->dDitherMode =
+ (1 << 10) | /* RGB */
+ ((0 & 0x10) << 12) |
+ ((0 & 0x0F) << 2) | /* 8:8:8:8 */
+ UNIT_ENABLE;
+ pAPriv->dAlphaBlendMode =
+ (1 << 13) |
+ ((0 & 0x10) << 12) |
+ ((0 & 0x0F) << 8) |
+ (84 << 1) |
+ UNIT_ENABLE;
+ pAPriv->dTextureDataFormat =
+ (1 << 5) |
+ (1 << 4) |
+ ((0 & 0x10) << 2) |
+ ((0 & 0x0F) << 0);
+ break;
+
+ default:
+ xfree(pAPriv);
+ return NULL;
+ }
+ pAPriv->VideoIO = VideoIO;
+
+ if (VideoIO) {
if (xvipc_fd >= 0) {
/* Initial handshake, take over control of this head */
@@ -1889,138 +2782,183 @@ AdaptorPrivInit(ScrnInfoPtr pScrn)
"shared access please start the server first.\n");
else
xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
- "Initialization of Xv support with kernel backbone "
- "failed due to error %d: %s.\n", errno, strerror(errno));
+ "Failed to initialize kernel backbone "
+ "due to error %d: %s.\n", errno, strerror(errno));
goto failed;
}
pAPriv->pm2p = xvipc.pm2p;
-
- SetVideoStd(pAPriv);
} else {
- GLINT_WRITE_REG(0, VSABase + VSControl);
- GLINT_WRITE_REG(0, VSBBase + VSControl);
-#if 0
- GLINT_MASK_WRITE_REG(0, ~(VSAIntFlag | VSBIntFlag), IntEnable);
- GLINT_WRITE_REG(VSAIntFlag | VSBIntFlag, IntFlags); /* Reset */
-#endif
- for (i = 0x0018; i <= 0x00B0; i += 8) {
- GLINT_WRITE_REG(0, VSABase + i);
- GLINT_WRITE_REG(0, VSBBase + i);
- }
-
- GLINT_WRITE_REG((0 << 8) | (132 << 0), VSABase + VSFifoControl);
- GLINT_WRITE_REG((0 << 8) | (132 << 0), VSBBase + VSFifoControl);
-
- GLINT_MASK_WRITE_REG(
- VS_UnitMode_AB8 |
- VS_GPBusMode_A |
- /* VS_HRefPolarityA | */
- VS_VRefPolarityA |
- VS_VActivePolarityA |
- /* VS_UseFieldA | */
- VS_FieldPolarityA |
- /* VS_FieldEdgeA | */
- /* VS_VActiveVBIA | */
- VS_InterlaceA |
- VS_ReverseDataA |
-
- /* VS_HRefPolarityB | */
- VS_VRefPolarityB |
- VS_VActivePolarityB |
- /* VS_UseFieldB | */
- VS_FieldPolarityB |
- /* VS_FieldEdgeB | */
- /* VS_VActiveVBIB | */
- VS_InterlaceB |
- /* VS_ColorSpaceB_RGB | */
- /* VS_ReverseDataB | */
- /* VS_DoubleEdgeB | */
- 0, ~0x1FFFFE0F, VSConfiguration);
-
- pAPriv->FifoControl = GLINT_READ_REG(PMFifoControl);
- GLINT_WRITE_REG((12 << 8) | 8, PMFifoControl); /* FIXME */
+ InitializeVideo(pAPriv);
if (!xf86I2CProbeAddress(pGlint->VSBus, SAA7111_SLAVE_ADDRESS))
- goto failed;
+ goto failed;
- pAPriv->Port[0].I2CDev.DevName = "Decoder";
- pAPriv->Port[0].I2CDev.SlaveAddr = SAA7111_SLAVE_ADDRESS;
+ pAPriv->Port[0].I2CDev.DevName = "Decoder SAA 7111A";
+ pAPriv->Port[0].I2CDev.SlaveAddr = SAA7111_SLAVE_ADDRESS;
pAPriv->Port[0].I2CDev.pI2CBus = pGlint->VSBus;
if (!xf86I2CDevInit(&pAPriv->Port[0].I2CDev))
goto failed;
- if (!xf86I2CWriteVec(&pAPriv->Port[0].I2CDev, DecInitVec,
- (sizeof(DecInitVec) / sizeof(I2CByte)) / 2))
+ if (!xf86I2CWriteVec(&pAPriv->Port[0].I2CDev, DecInitVec, ENTRIES(DecInitVec) / 2))
goto failed;
if (!xf86I2CProbeAddress(pGlint->VSBus, SAA7125_SLAVE_ADDRESS))
goto failed;
- pAPriv->Port[1].I2CDev.DevName = "Encoder";
+ pAPriv->Port[1].I2CDev.DevName = "Encoder SAA 7125";
pAPriv->Port[1].I2CDev.SlaveAddr = SAA7125_SLAVE_ADDRESS;
- pAPriv->Port[1].I2CDev.pI2CBus = pGlint->VSBus;
+ pAPriv->Port[1].I2CDev.pI2CBus = pGlint->VSBus;
if (!xf86I2CDevInit(&pAPriv->Port[1].I2CDev))
goto failed;
- if (!xf86I2CWriteVec(&pAPriv->Port[1].I2CDev, EncInitVec,
- (sizeof(EncInitVec) / sizeof(I2CByte)) / 2))
+ if (!xf86I2CWriteVec(&pAPriv->Port[1].I2CDev, EncInitVec, ENTRIES(EncInitVec) / 2))
goto failed;
+ }
- SetVideoStd(pAPriv);
+ if (SetVideoStd(&pAPriv->Port[0], PAL) != Success ||
+ SetPlug(&pAPriv->Port[0], 0) != Success || /* composite */
+ SetPlug(&pAPriv->Port[1], 1) != Success) /* composite-adaptor */
+ goto failed;
- pAPriv->Timer = TimerSet(NULL, 0, 0, TimerCallback, pAPriv);
+ pAPriv->Port[1].VideoStdReq = pAPriv->Port[0].VideoStdReq;
- if (!pAPriv->Timer)
- goto failed;
+ pAPriv->Port[0].BuffersRequested = 2;
+ pAPriv->Port[1].BuffersRequested = 1;
+
+ for (i = 0; i < 2; i++) {
+ pAPriv->Port[i].fw = 704;
+ pAPriv->Port[i].fh = 576;
+ pAPriv->Port[i].FramesPerSec = 30;
+ pAPriv->Port[i].BufferPProd = partprodPermedia[704 >> 5];
}
- return pAPriv;
+ SetAttr(&pAPriv->Port[0], 0, 0); /* Brightness (-1000..+1000) */
+ SetAttr(&pAPriv->Port[0], 1, 0); /* Contrast (-3000..+1000) */
+ SetAttr(&pAPriv->Port[0], 2, 0); /* Color saturation (-3000..+1000) */
+ SetAttr(&pAPriv->Port[0], 3, 0); /* Hue (-1000..+1000) */
-failed:
- AdaptorPrivUninit(pAPriv);
+ pAPriv->Port[0].Attribute[4] = 1; /* Interlaced (0 = not, 1 = yes,
+ 2 = double scan 50/60 Hz) */
+ pAPriv->Port[0].Attribute[5] = 0; /* Bilinear Filter (Bool) */
+
+ pAPriv->Port[1].Attribute[4] = 1; /* Interlaced (Bool) */
+ pAPriv->Port[1].Attribute[5] = 0; /* Bilinear Filter (Bool) */
+
+ SetBkgCol(&pAPriv->Port[1], 0x000000); /* BkgColor 0x00RRGGBB */
+ } /* VideoIO */
+
+ if (!(pAPriv->Timer = TimerSet(NULL, 0, 0, TimerCallback, pAPriv)))
+ goto failed;
+
+ for (i = 0; i < PORTS; i++)
+ pAPriv->Port[i].StopDelay = -1;
+
+ /* Frontend scaler */
+
+ for (i = 2; i < 6; i++) {
+ pAPriv->Port[i].fw = 0;
+ pAPriv->Port[i].fh = 0;
+ pAPriv->Port[i].BuffersRequested = 1;
+ pAPriv->Delay = 125;
+ pAPriv->Instant = 1000 / 25;
+
+ if (!VideoIO || pAPriv->pm2p) {
+ pAPriv->Delay = 5;
+ pAPriv->Instant = 1000;
+ }
+
+ pAPriv->Port[i].Attribute[5] = 0; /* Bilinear Filter (Bool) */
+ pAPriv->Port[i].Attribute[7] = 0; /* Alpha Enable (Bool) */
}
+ return pAPriv;
+
+failed:
+
+ DeleteAdaptorPriv(pAPriv);
+
return NULL;
}
+
+/*
+ * Glint interface
+ */
+
void
-Permedia2VideoUninit(ScrnInfoPtr pScrn)
+Permedia2VideoEnterVT(ScrnInfoPtr pScrn)
{
- AdaptorPrivPtr pAPriv, *ppAPriv;
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ AdaptorPrivPtr pAPriv;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Xv driver cleanup\n"));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv enter VT\n"));
- for (ppAPriv = &AdaptorPrivList; (pAPriv = *ppAPriv); ppAPriv = &(pAPriv->Next))
+ for (pAPriv = AdaptorPrivList; pAPriv != NULL; pAPriv = pAPriv->Next)
if (pAPriv->pScrn == pScrn) {
- *ppAPriv = pAPriv->Next;
- StopVideoStream(pAPriv, 1 | 2 | 4);
- AdaptorPrivUninit(pAPriv);
+ if (pAPriv->VideoIO) {
+ if (pAPriv->pm2p)
+ xvipcHandshake(&pAPriv->Port[0], OP_ENTER, TRUE);
+ else {
+ InitializeVideo(pAPriv);
+
+ xf86I2CWriteVec(&pAPriv->Port[1].I2CDev, EncInitVec, ENTRIES(EncInitVec) / 2);
+ }
+
+ SetVideoStd(&pAPriv->Port[0], pAPriv->VideoStd);
+ SetPlug(&pAPriv->Port[0], pAPriv->Port[0].Plug);
+ SetPlug(&pAPriv->Port[1], pAPriv->Port[1].Plug);
+ }
+
+ if (pGlint->NoAccel)
+ Permedia2InitializeEngine(pScrn);
+
break;
}
-
- if (xvipc_fd >= 0) {
- close(xvipc_fd);
- xvipc_fd = -1;
- }
}
-/* Required to retire delayed stop (VT switching away) */
-
void
-Permedia2VideoReset(ScrnInfoPtr pScrn)
+Permedia2VideoLeaveVT(ScrnInfoPtr pScrn)
{
AdaptorPrivPtr pAPriv;
for (pAPriv = AdaptorPrivList; pAPriv != NULL; pAPriv = pAPriv->Next)
if (pAPriv->pScrn == pScrn) {
- StopVideoStream(pAPriv, 1 | 2 | 4);
+ if (pAPriv->VideoIO) {
+ StopVideoStream(&pAPriv->Port[0], TRUE);
+ StopVideoStream(&pAPriv->Port[1], TRUE);
+
+ if (pAPriv->pm2p)
+ xvipcHandshake(&pAPriv->Port[0], OP_LEAVE, TRUE);
+ else
+ RestoreVideo(pAPriv);
+ }
break;
}
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Xv driver halted\n"));
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Elvis left the building\n"));
+}
+
+void
+Permedia2VideoUninit(ScrnInfoPtr pScrn)
+{
+ AdaptorPrivPtr pAPriv, *ppAPriv;
+
+ for (ppAPriv = &AdaptorPrivList; (pAPriv = *ppAPriv); ppAPriv = &(pAPriv->Next))
+ if (pAPriv->pScrn == pScrn) {
+ *ppAPriv = pAPriv->Next;
+ DeleteAdaptorPriv(pAPriv);
+ break;
+ }
+
+ if (xvipc_fd >= 0) {
+ close(xvipc_fd);
+ xvipc_fd = -1;
+ }
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv cleanup\n"));
}
void
@@ -2029,83 +2967,95 @@ Permedia2VideoInit(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
GLINTPtr pGlint = GLINTPTR(pScrn);
AdaptorPrivPtr pAPriv;
- DevUnion Private[2];
- XF86VideoAdaptorRec VAR[2];
- XF86VideoAdaptorPtr VARPtrs[2];
pointer options[3];
+ DevUnion Private[PORTS];
+ XF86VideoAdaptorRec VAR[ADAPTORS];
+ XF86VideoAdaptorPtr VARPtrs[ADAPTORS];
Bool VideoIO = TRUE;
int i;
- options[0] = NULL;
- options[1] = NULL;
- options[2] = NULL;
+ switch (pGlint->Chipset) {
+ case PCI_VENDOR_TI_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
+ case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
+ break;
+
+ default:
+ return;
+ }
+
+ options[0] = NULL; /* VideoAdaptor "input" subsection options */
+ options[1] = NULL; /* VideoAdaptor "output" subsection options */
+ options[2] = NULL; /* VideoAdaptor options */
for (i = 0;; i++) {
- char *adaptor;
+ char *adaptor; /* receives VideoAdaptor section identifier */
if (!options[0])
- options[0] = xf86FindXvOptions(pScreen->myNum, i, "input", &adaptor, &options[2]);
+ options[0] = xf86FindXvOptions(pScreen->myNum, i, "input", &adaptor, options[2] ? NULL : &options[2]);
+
if (!options[1])
- options[1] = xf86FindXvOptions(pScreen->myNum, i, "output", &adaptor, NULL);
+ options[1] = xf86FindXvOptions(pScreen->myNum, i, "output", &adaptor, options[2] ? NULL : &options[2]);
+
if (!adaptor) {
- if (!i) VideoIO = FALSE;
+ if (!i) /* VideoAdaptor reference enables Xv vio driver */
+ VideoIO = FALSE;
break;
} else if (options[0] && options[1])
break;
}
- if (!VideoIO) {
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Xv driver disabled\n");
- return;
- }
-
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Initializing Xv driver\n");
-
- switch (pGlint->Chipset) {
- case PCI_VENDOR_TI_CHIP_PERMEDIA2:
- case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2:
- case PCI_VENDOR_3DLABS_CHIP_PERMEDIA2V:
- break;
- default:
- VideoIO = FALSE;
- }
-
- switch (pciReadLong(pGlint->PciTag, PCI_SUBSYSTEM_ID_REG)) {
+ if (VideoIO)
+ switch (pciReadLong(pGlint->PciTag, PCI_SUBSYSTEM_ID_REG)) {
case PCI_SUBSYSTEM_ID_WINNER_2000_P2A:
case PCI_SUBSYSTEM_ID_WINNER_2000_P2C:
case PCI_SUBSYSTEM_ID_GLORIA_SYNERGY_P2A:
case PCI_SUBSYSTEM_ID_GLORIA_SYNERGY_P2C:
break;
+
default:
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 1, "No Xv vio support for this board\n");
VideoIO = FALSE;
- }
+ }
- if (!VideoIO) {
- xf86DrvMsgVerb(pScrn->scrnIndex, X_PROBED, 1, "No Xv support for this board\n");
+ if (pGlint->NoAccel && !VideoIO)
return;
- }
- for (i = 0; i <= 2; i++) {
- xf86ProcessOptions(pScrn->scrnIndex, options[i],
- (i == 0) ? InputOptions : ((i == 1) ? OutputOptions : AdaptorOptions));
- xf86ShowUnusedOptions(pScrn->scrnIndex, options[i]);
- }
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Initializing Xv driver rev. 4\n");
- if (xf86IsOptionSet(AdaptorOptions, OPTION_DEVICE))
- xvipcOpen(xf86GetOptValString(AdaptorOptions, OPTION_DEVICE), pScrn);
+ if (VideoIO) {
+ for (i = 0; i <= 2; i++) {
+ xf86ProcessOptions(pScrn->scrnIndex, options[i],
+ (i == 0) ? InputOptions :
+ (i == 1) ? OutputOptions :
+ AdaptorOptions);
- if (!(pAPriv = AdaptorPrivInit(pScrn))) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, options[i]);
+ }
+
+ if (xf86IsOptionSet(AdaptorOptions, OPTION_DEVICE)) {
+ if (!xvipcOpen(xf86GetOptValString(AdaptorOptions, OPTION_DEVICE), pScrn))
+ VideoIO = FALSE;
+ }
+ }
+
+ if (!(pAPriv = NewAdaptorPriv(pScrn, VideoIO))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv driver initialization failed\n");
return;
}
- for (i = 0; i <= 1; i++) {
+ if (VideoIO) {
int n;
- if (xf86GetOptValInteger(i ? OutputOptions : InputOptions, OPTION_BUFFERS, &n))
- pAPriv->Port[i].Buffers = CLAMP(n, 1, i ? 1 : 2); /* FIXME */
- if (xf86GetOptValInteger(i ? OutputOptions : InputOptions, OPTION_FPS, &n))
- pAPriv->Port[i].FramesPerSec = CLAMP(n, 1, 30);
+ if (xf86GetOptValInteger(InputOptions, OPTION_BUFFERS, &n))
+ pAPriv->Port[0].BuffersRequested = CLAMP(n, 1, 2);
+ if (xf86GetOptValInteger(InputOptions, OPTION_FPS, &n))
+ pAPriv->Port[0].FramesPerSec = CLAMP(n, 1, 30);
+
+ if (xf86GetOptValInteger(OutputOptions, OPTION_BUFFERS, &n))
+ pAPriv->Port[1].BuffersRequested = 1;
+ if (xf86GetOptValInteger(OutputOptions, OPTION_FPS, &n))
+ pAPriv->Port[1].FramesPerSec = CLAMP(n, 1, 30);
}
if (pGlint->NoAccel) {
@@ -2121,43 +3071,82 @@ Permedia2VideoInit(ScreenPtr pScreen)
AvailFBArea.y2 = pGlint->FbMapSize /
(pScrn->displayWidth * pScrn->bitsPerPixel / 8);
- /* if (AvailFBArea.y2 > 2047)
- AvailFBArea.y2 = 2047; */
-
xf86InitFBManager(pScreen, &AvailFBArea);
}
+#if defined(XFree86LOADER) && 0
+ if (xf86LoaderCheckSymbol("xf86InitLinearFBManagerRegion")) {
+ int last = pGlint->FbMapSize / (pScrn->bitsPerPixel / 8) - 1;
+ BoxRec AvailFBArea;
+ RegionPtr Region;
+
+ AvailFBArea.x1 = 0;
+ AvailFBArea.y1 = pScrn->virtualY;
+ AvailFBArea.x2 = last % pScrn->displayWidth + 1;
+ AvailFBArea.y2 = last / pScrn->displayWidth + 1;
+
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+ "Using linear FB %d,%d-%d,%d pitch %d (%dk)\n",
+ AvailFBArea.x1, AvailFBArea.y1, AvailFBArea.x2, AvailFBArea.y2,
+ pScrn->displayWidth, (((AvailFBArea.y2 - AvailFBArea.y1)
+ * pScrn->displayWidth) << BPPSHIFT(pGlint)) / 1024));
+
+ Region = xf86LinearFBRegion(pScreen, &AvailFBArea, pScrn->displayWidth);
+ xf86InitLinearFBManagerRegion(pScreen, Region);
+ REGION_DESTROY(pScreen, Region);
+ }
+#endif
+
memset(VAR, 0, sizeof(VAR));
- for (i = 0; i < 2; i++) {
+ for (i = 0; i < PORTS; i++)
Private[i].ptr = (pointer) &pAPriv->Port[i];
- VARPtrs[i] = &VAR[i];
- VAR[i].type = (i == 0) ? XvInputMask : XvOutputMask;
- VAR[i].type |= XvWindowMask | XvVideoMask | XvStillMask;
- VAR[i].name = "Permedia 2";
+ for (i = 0; i < ADAPTORS; i++) {
+ VARPtrs[i] = &VAR[i];
+ switch (i) {
+ case 0:
+ VAR[i].name = "Permedia 2 Video Input";
+ VAR[i].type = XvInputMask | XvWindowMask | XvVideoMask | XvStillMask;
+ VAR[i].nPorts = 1;
+ VAR[i].pPortPrivates = &Private[0];
+ VAR[i].nAttributes = ENTRIES(InputVideoAttributes);
+ VAR[i].pAttributes = InputVideoAttributes;
+ VAR[i].nEncodings = ENTRIES(InputVideoEncodings);
+ VAR[i].pEncodings = InputVideoEncodings;
+ VAR[i].nFormats = ENTRIES(InputVideoFormats);
+ VAR[i].pFormats = InputVideoFormats;
+ break;
- if (i == 0) {
- VAR[0].nEncodings = sizeof(InputVideoEncodings) / sizeof(InputVideoEncodings[0]);
- VAR[0].pEncodings = InputVideoEncodings;
- VAR[0].nFormats = sizeof(InputVideoFormats) / sizeof(InputVideoFormats[0]);
- VAR[0].pFormats = InputVideoFormats;
- } else {
- Bool expose = FALSE;
+ case 1:
+ VAR[i].name = "Permedia 2 Video Output";
+ VAR[i].type = XvOutputMask | XvWindowMask | XvVideoMask | XvStillMask;
+ VAR[i].nPorts = 1;
+ VAR[i].pPortPrivates = &Private[1];
+ VAR[i].nAttributes = ENTRIES(OutputVideoAttributes);
+ VAR[i].pAttributes = OutputVideoAttributes;
+ VAR[i].nEncodings = ENTRIES(OutputVideoEncodings);
+ VAR[i].pEncodings = OutputVideoEncodings;
+ VAR[i].nFormats = ENTRIES(OutputVideoFormats);
+ VAR[i].pFormats = OutputVideoFormats;
+ break;
-/*
- xf86GetOptValBool(OutputOptions, OPTION_EXPOSE, &expose);
- if (expose) VAR[1].flags = VIDEO_EXPOSE;
-*/
-
- VAR[1].nEncodings = sizeof(OutputVideoEncodings) / sizeof(OutputVideoEncodings[0]);
- VAR[1].pEncodings = OutputVideoEncodings;
- VAR[1].nFormats = sizeof(OutputVideoFormats) / sizeof(OutputVideoFormats[0]);
- VAR[1].pFormats = OutputVideoFormats;
+ case 2:
+ VAR[i].name = "Permedia 2 Frontend Scaler";
+ VAR[i].type = XvInputMask | XvWindowMask | XvImageMask;
+ VAR[i].nPorts = 3;
+ VAR[i].pPortPrivates = &Private[2];
+ VAR[i].nAttributes = ENTRIES(ScalerAttributes);
+ VAR[i].pAttributes = ScalerAttributes;
+ VAR[i].nEncodings = ENTRIES(ScalerEncodings);
+ VAR[i].pEncodings = ScalerEncodings;
+ VAR[i].nFormats = ENTRIES(ScalerVideoFormats);
+ VAR[i].pFormats = ScalerVideoFormats;
+ VAR[i].nImages = ENTRIES(ScalerImages);
+ VAR[i].pImages = ScalerImages;
+ break;
}
- VAR[i].nPorts = 1;
- VAR[i].pPortPrivates = &Private[i];
VAR[i].PutVideo = Permedia2PutVideo;
VAR[i].PutStill = Permedia2PutStill;
VAR[i].GetVideo = Permedia2GetVideo;
@@ -2166,25 +3155,51 @@ Permedia2VideoInit(ScreenPtr pScreen)
VAR[i].SetPortAttribute = Permedia2SetPortAttribute;
VAR[i].GetPortAttribute = Permedia2GetPortAttribute;
VAR[i].QueryBestSize = Permedia2QueryBestSize;
+ VAR[i].PutImage = Permedia2PutImage;
+ VAR[i].QueryImageAttributes = Permedia2QueryImageAttributes;
}
- if (!xf86XVScreenInit(pScreen, VARPtrs, 2)) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv initialization failed\n");
- return;
- }
-
- xvEncoding = MAKE_ATOM(XV_ENCODING);
- xvHue = MAKE_ATOM(XV_HUE);
- xvSaturation = MAKE_ATOM(XV_SATURATION);
- xvBrightness = MAKE_ATOM(XV_BRIGHTNESS);
- xvContrast = MAKE_ATOM(XV_CONTRAST);
- xvInterlace = MAKE_ATOM(XV_INTERLACE);
- xvFilter = MAKE_ATOM(XV_FILTER);
- xvBkgColor = MAKE_ATOM(XV_BKGCOLOR);
+ if (VideoIO ? xf86XVScreenInit(pScreen, &VARPtrs[0], 3) :
+ xf86XVScreenInit(pScreen, &VARPtrs[2], 1)) {
+ char *s;
+
+ xvEncoding = MAKE_ATOM(XV_ENCODING);
+ xvHue = MAKE_ATOM(XV_HUE);
+ xvSaturation = MAKE_ATOM(XV_SATURATION);
+ xvBrightness = MAKE_ATOM(XV_BRIGHTNESS);
+ xvContrast = MAKE_ATOM(XV_CONTRAST);
+ xvInterlace = MAKE_ATOM(XV_INTERLACE);
+ xvFilter = MAKE_ATOM(XV_FILTER);
+ xvBkgColor = MAKE_ATOM(XV_BKGCOLOR);
+ xvAlpha = MAKE_ATOM(XV_ALPHA);
+
+ pAPriv->Next = AdaptorPrivList;
+ AdaptorPrivList = pAPriv;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv frontend scaler enabled\n");
+
+ if (VideoIO) {
+ if ((s = xf86GetOptValString(InputOptions, OPTION_ENCODING)))
+ for (i = 0; i < ENTRIES(InputVideoEncodings); i++)
+ if (!strncmp(s, InputVideoEncodings[i].name, strlen(s))) {
+ Permedia2SetPortAttribute(pScrn, xvEncoding, i, (pointer) &pAPriv->Port[0]);
+ break;
+ }
- pAPriv->Next = AdaptorPrivList;
- AdaptorPrivList = pAPriv;
+ if ((s = xf86GetOptValString(OutputOptions, OPTION_ENCODING)))
+ for (i = 0; i < ENTRIES(OutputVideoEncodings); i++)
+ if (!strncmp(s, OutputVideoEncodings[i].name, strlen(s))) {
+ Permedia2SetPortAttribute(pScrn, xvEncoding, i, (pointer) &pAPriv->Port[1]);
+ break;
+ }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv driver %senabled\n",
- (xvipc_fd >= 0) ? "with kernel backbone " : "");
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Xv vio driver %senabled\n",
+ pAPriv->pm2p ? "with kernel backbone " : "");
+ }
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv initialization failed\n");
+ DeleteAdaptorPriv(pAPriv);
+ }
}
+
+#endif /* XvExtension */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c
index 481cc98b9..84dffef6b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c
@@ -27,7 +27,7 @@
* this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
* Siemens Nixdorf Informationssysteme
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c,v 1.12 1999/07/04 06:39:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm2v_dac.c,v 1.13 2000/05/10 18:55:30 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -203,15 +203,13 @@ Permedia2VInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->DacRegs[PM2VDACRDPixelSize] = 0x00;
pReg->DacRegs[PM2VDACRDColorFormat] = 0x2E;
break;
- case 15:
- pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08;
- pReg->DacRegs[PM2VDACRDPixelSize] = 0x01;
- pReg->DacRegs[PM2VDACRDColorFormat] = 0x61;
- break;
case 16:
pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08;
pReg->DacRegs[PM2VDACRDPixelSize] = 0x01;
- pReg->DacRegs[PM2VDACRDColorFormat] = 0x70;
+ if (pScrn->depth == 15)
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x61;
+ else
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x70;
break;
case 24:
pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c
new file mode 100644
index 000000000..70ae35407
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c
@@ -0,0 +1,1778 @@
+/*
+ * Copyright 1997,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>
+ * Dirk Hohndel, <hohndel@suse.de>
+ * Stefan Dirsch, <sndirsch@suse.de>
+ * Mark Vojkovich, <mvojkovi@ucsd.edu>
+ * Michel Dänzer, <michdaen@iiic.ethz.ch>
+ * Sven Luther, <luther@dpt-info.u-strasbg.fr>
+ *
+ * this work is sponsored by Appian Graphics.
+ *
+ * Permedia 3 accelerated options.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_accel.c,v 1.2 2000/06/14 18:20:34 dawes Exp $ */
+
+#include "Xarch.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+#include "miline.h"
+
+#include "fb.h"
+
+#include "glint_regs.h"
+#include "glint.h"
+
+#include "xaalocal.h" /* For replacements */
+
+#define DEBUG 0
+
+#if DEBUG
+# define TRACE_ENTER(str) ErrorF("pm2_accel: " str " %d\n",pScrn->scrnIndex)
+# define TRACE_EXIT(str) ErrorF("pm2_accel: " str " done\n")
+# define TRACE(str) ErrorF("pm2_accel trace: " str "\n")
+#else
+# define TRACE_ENTER(str)
+# define TRACE_EXIT(str)
+# define TRACE(str)
+#endif
+
+static void Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask);
+static void Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x,
+ int y, int w, int h);
+static void Permedia3SetupForFillRectSolid24bpp(ScrnInfoPtr pScrn,int color,
+ int rop, unsigned int planemask);
+static void Permedia3SubsequentFillRectSolid24bpp(ScrnInfoPtr pScrn, int x,
+ int y, int w, int h);
+static void Permedia3SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2,
+ int y2, int w, int h);
+static void Permedia3SetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
+ int xdir, int ydir, int rop,
+ unsigned int planemask,
+ int transparency_color);
+static void Permedia3SubsequentScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn,
+ int x1, int y1, int x2, int y2, int w, int h);
+static void Permedia3SetupForScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn,
+ int xdir, int ydir, int rop,
+ unsigned int planemask,
+ int transparency_color);
+static void Permedia3SetClippingRectangle(ScrnInfoPtr pScrn, int x, int y,
+ int w, int h);
+static void Permedia3DisableClipping(ScrnInfoPtr pScrn);
+static void Permedia3SetupForSolidLine(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask);
+static void Permedia3SubsequentHorVertLine(ScrnInfoPtr pScrn, int x, int y,
+ int len, int dir);
+static void Permedia3SubsequentSolidBresenhamLine(ScrnInfoPtr pScrn,
+ int x, int y, int dmaj, int dmin, int e,
+ int len, int octant);
+static void Permedia3WriteBitmap(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);
+static void Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn,
+ int patternx, int patterny, int fg, int bg,
+ int rop, unsigned int planemask);
+static void Permedia3SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,
+ int patternx, int patterny, int x, int y,
+ int w, int h);
+static void Permedia3SetupForMono8x8PatternFill24bpp(ScrnInfoPtr pScrn,
+ int patternx, int patterny, int fg, int bg,
+ int rop, unsigned int planemask);
+static void Permedia3SubsequentMono8x8PatternFillRect24bpp(ScrnInfoPtr pScrn,
+ int patternx, int patterny, int x, int y,
+ int w, int h);
+static void Permedia3WritePixmap8bpp(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);
+static void Permedia3WritePixmap16bpp(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);
+#if 0
+static void Permedia3WritePixmap24bpp(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);
+#endif
+static void Permedia3WritePixmap32bpp(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);
+static void Permedia3SetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,unsigned int planemask);
+static void Permedia3SubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h, int skipleft);
+static void Permedia3SetupForScanlineCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int fg, int bg, int rop,
+ unsigned int planemask);
+static void Permedia3SubsequentScanlineCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn, int x,
+ int y, int w, int h, int skipleft);
+static void Permedia3SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno);
+static void Permedia3LoadCoord(ScrnInfoPtr pScrn, int x, int y, int w, int h);
+static void Permedia3PolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pPts);
+static void Permedia3PolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
+ int nseg, xSegment *pSeg);
+
+#define MAX_FIFO_ENTRIES 256
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+# define STIPPLE_SWAP 1<<18 /* Mirror stipple pattern horizontally */
+#else
+# define STIPPLE_SWAP 0
+#endif
+
+void
+Permedia3InitializeEngine(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ /* Initialize the Accelerator Engine to defaults */
+
+ TRACE_ENTER("Permedia3InitializeEngine");
+
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode);
+ GLINT_SLOW_WRITE_REG(UNIT_ENABLE, FBWriteMode);
+ GLINT_SLOW_WRITE_REG(0, dXSub);
+ GLINT_SLOW_WRITE_REG(GWIN_DisableLBUpdate, GLINTWindow);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DitherMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, PMTextureReadMode);
+ GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TexelLUTMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, YUVMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FogMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AntialiasMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaTestMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AreaStippleMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode);
+ GLINT_SLOW_WRITE_REG(0xc00, FilterMode);
+ GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask);
+ GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBSourceOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, WindowOrigin);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBWindowBase);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceBase);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWindowBase);
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ pGlint->RasterizerSwap = 1;
+#else
+ pGlint->RasterizerSwap = 0;
+#endif
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ pGlint->PixelWidth = 0x0; /* 8 Bits */
+ pGlint->TexMapFormat = pGlint->pprod;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ pGlint->RasterizerSwap |= 3<<15; /* Swap host data */
+#endif
+ break;
+ case 16:
+ pGlint->PixelWidth = 0x1; /* 16 Bits */
+ pGlint->TexMapFormat = pGlint->pprod | 1<<19;
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ pGlint->RasterizerSwap |= 2<<15; /* Swap host data */
+#endif
+ break;
+ case 24:
+ pGlint->PixelWidth = 0x4; /* 24 Bits */
+ pGlint->TexMapFormat = pGlint->pprod | 2<<19;
+ break;
+ case 32:
+ pGlint->PixelWidth = 0x2; /* 32 Bits */
+ pGlint->TexMapFormat = pGlint->pprod | 2<<19;
+ break;
+ }
+ pGlint->ClippingOn = FALSE;
+ pGlint->startxdom = 0;
+ pGlint->startxsub = 0;
+ pGlint->starty = 0;
+ pGlint->count = 0;
+ pGlint->dy = 1<<16;
+ pGlint->dxdom = 0;
+ pGlint->x = 0;
+ pGlint->y = 0;
+ pGlint->h = 0;
+ pGlint->w = 0;
+ pGlint->ROP = 0xFF;
+ GLINT_SLOW_WRITE_REG(pGlint->PixelWidth, FBReadPixel);
+ GLINT_SLOW_WRITE_REG(pGlint->TexMapFormat, PMTextureMapFormat);
+ GLINT_SLOW_WRITE_REG(0, RectangleSize);
+ GLINT_SLOW_WRITE_REG(0, RectangleOrigin);
+ GLINT_SLOW_WRITE_REG(0, dXDom);
+ GLINT_SLOW_WRITE_REG(1<<16, dY);
+ GLINT_SLOW_WRITE_REG(0, StartXDom);
+ GLINT_SLOW_WRITE_REG(0, StartXSub);
+ GLINT_SLOW_WRITE_REG(0, StartY);
+ GLINT_SLOW_WRITE_REG(0, GLINTCount);
+
+ TRACE_EXIT("Permedia3InitializeEngine");
+}
+
+Bool
+Permedia3AccelInit(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoPtr;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ BoxRec AvailFBArea;
+
+ pGlint->AccelInfoRec = infoPtr = XAACreateInfoRec();
+ if (!infoPtr) return FALSE;
+
+ Permedia3InitializeEngine(pScrn);
+
+ infoPtr->Flags = PIXMAP_CACHE |
+ OFFSCREEN_PIXMAPS |
+ LINEAR_FRAMEBUFFER;
+
+ infoPtr->Sync = Permedia3Sync;
+
+ infoPtr->SetClippingRectangle = Permedia3SetClippingRectangle;
+ infoPtr->DisableClipping = Permedia3DisableClipping;
+ infoPtr->ClippingFlags = HARDWARE_CLIP_MONO_8x8_FILL;
+
+ infoPtr->SolidFillFlags = 0;
+ infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY;
+ infoPtr->WriteBitmapFlags = 0;
+ if (pScrn->bitsPerPixel == 24) {
+ /* SVEN : This should be bad also,
+ * didn't tested it since 24bpp is broken....
+ infoPtr->SetupForSolidFill =
+ Permedia3SetupForFillRectSolid24bpp;
+ infoPtr->SubsequentSolidFillRect =
+ Permedia3SubsequentFillRectSolid24bpp;
+ */
+ } else {
+ infoPtr->SolidLineFlags = 0;
+ infoPtr->PolySegmentThinSolidFlags = 0;
+ infoPtr->PolylinesThinSolidFlags = 0;
+ infoPtr->SetupForSolidLine = Permedia3SetupForSolidLine;
+ infoPtr->SubsequentSolidHorVertLine = Permedia3SubsequentHorVertLine;
+ if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR))
+ {
+ infoPtr->SubsequentSolidBresenhamLine =
+ Permedia3SubsequentSolidBresenhamLine;
+ }
+ infoPtr->PolySegmentThinSolid = Permedia3PolySegmentThinSolidWrapper;
+ infoPtr->PolylinesThinSolid = Permedia3PolylinesThinSolidWrapper;
+ /* SVEN : This evidently seems to be bad ...
+ infoPtr->SetupForSolidFill = Permedia3SetupForFillRectSolid;
+ infoPtr->SubsequentSolidFillRect = Permedia3SubsequentFillRectSolid;
+ */
+ }
+
+ if (pScrn->bitsPerPixel >= 24) {
+ /* SVEN : This should be bad also,
+ * didn't tested it since 24bpp is broken....
+ infoPtr->SetupForScreenToScreenCopy =
+ Permedia3SetupForScreenToScreenCopy2432bpp;
+ infoPtr->SubsequentScreenToScreenCopy =
+ Permedia3SubsequentScreenToScreenCopy2432bpp;
+ */
+ } else {
+ /* SVEN : This evidently seems to be bad ...
+ infoPtr->SetupForScreenToScreenCopy =
+ Permedia3SetupForScreenToScreenCopy;
+ infoPtr->SubsequentScreenToScreenCopy =
+ Permedia3SubsequentScreenToScreenCopy;
+ */
+ }
+
+ infoPtr->Mono8x8PatternFillFlags =
+ HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
+ HARDWARE_PATTERN_PROGRAMMED_BITS |
+ HARDWARE_PATTERN_SCREEN_ORIGIN;
+
+ if (pScrn->bitsPerPixel == 24) {
+ /* SVEN : This should be bad also,
+ * didn't tested it since 24bpp is broken....
+ infoPtr->SetupForMono8x8PatternFill =
+ Permedia3SetupForMono8x8PatternFill24bpp;
+ infoPtr->SubsequentMono8x8PatternFillRect =
+ Permedia3SubsequentMono8x8PatternFillRect24bpp;
+ */
+ } else {
+ /* SVEN : This evidently seems to be bad ...
+ infoPtr->SetupForMono8x8PatternFill =
+ Permedia3SetupForMono8x8PatternFill;
+ infoPtr->SubsequentMono8x8PatternFillRect =
+ Permedia3SubsequentMono8x8PatternFillRect;
+ */
+ }
+
+/* Didn't try, but anyway, pm3 uses PCIRetry, but i don't know if
+ * it gets declared corectly by glint_driver.c. Need to check this.
+ if (pGlint->UsePCIRetry) {
+ infoPtr->CPUToScreenColorExpandFillFlags = SYNC_AFTER_COLOR_EXPAND |
+ BIT_ORDER_IN_BYTE_LSBFIRST |
+ CPU_TRANSFER_PAD_DWORD;
+
+ infoPtr->ColorExpandBase = pGlint->IOBase + OutputFIFO + 4;
+ infoPtr->SetupForCPUToScreenColorExpandFill =
+ Permedia3SetupForCPUToScreenColorExpandFill;
+ infoPtr->SubsequentCPUToScreenColorExpandFill =
+ Permedia3SubsequentCPUToScreenColorExpandFill;
+ } else {
+ infoPtr->ScanlineCPUToScreenColorExpandFillFlags =
+ BIT_ORDER_IN_BYTE_LSBFIRST;
+
+ infoPtr->NumScanlineColorExpandBuffers = 1;
+ infoPtr->ScanlineColorExpandBuffers =
+ pGlint->XAAScanlineColorExpandBuffers;
+ pGlint->XAAScanlineColorExpandBuffers[0] =
+ pGlint->IOBase + OutputFIFO + 4;
+
+ infoPtr->SetupForScanlineCPUToScreenColorExpandFill =
+ Permedia3SetupForScanlineCPUToScreenColorExpandFill;
+ infoPtr->SubsequentScanlineCPUToScreenColorExpandFill =
+ Permedia3SubsequentScanlineCPUToScreenColorExpandFill;
+ infoPtr->SubsequentColorExpandScanline =
+ Permedia3SubsequentColorExpandScanline;
+ }
+*/
+
+ infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES;
+
+ /* Seems broken also, ...
+ infoPtr->WriteBitmap = Permedia3WriteBitmap;
+
+ if (pScrn->bitsPerPixel == 8)
+ infoPtr->WritePixmap = Permedia3WritePixmap8bpp;
+ else
+ if (pScrn->bitsPerPixel == 16)
+ infoPtr->WritePixmap = Permedia3WritePixmap16bpp;
+ else
+#if 0
+ if (pScrn->bitsPerPixel == 24) {
+ infoPtr->WritePixmap = Permedia3WritePixmap24bpp;
+ infoPtr->WritePixmapFlags |= NO_PLANEMASK;
+ }
+ else
+#endif
+ if (pScrn->bitsPerPixel == 32)
+ infoPtr->WritePixmap = Permedia3WritePixmap32bpp;
+ */
+
+ /* Now fixup if we are 24bpp */
+ if (pScrn->bitsPerPixel == 24) {
+ infoPtr->SolidFillFlags |= NO_PLANEMASK;
+ infoPtr->ScreenToScreenCopyFlags |= NO_PLANEMASK;
+ infoPtr->WriteBitmapFlags |= NO_PLANEMASK;
+ infoPtr->CPUToScreenColorExpandFillFlags |= NO_PLANEMASK;
+ infoPtr->ScanlineCPUToScreenColorExpandFillFlags |= NO_PLANEMASK;
+ infoPtr->Mono8x8PatternFillFlags |= NO_PLANEMASK;
+ }
+
+ AvailFBArea.x1 = 0;
+ AvailFBArea.y1 = 0;
+ AvailFBArea.x2 = pScrn->displayWidth;
+ AvailFBArea.y2 = pGlint->FbMapSize / (pScrn->displayWidth *
+ pScrn->bitsPerPixel / 8);
+
+ if (AvailFBArea.y2 > 2047) AvailFBArea.y2 = 2047;
+
+ xf86InitFBManager(pScreen, &AvailFBArea);
+
+ return(XAAInit(pScreen, infoPtr));
+}
+
+static void Permedia3LoadCoord(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int w, int h
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if ((h != pGlint->h) || (w != pGlint->w)) {
+ pGlint->w = w;
+ pGlint->h = h;
+ GLINT_WRITE_REG(((h&0x0FFF)<<16)|(w&0x0FFF), RectangleSize);
+ }
+ if ((y != pGlint->y) || (x != pGlint->x)) {
+ pGlint->x = x;
+ pGlint->y = y;
+ GLINT_WRITE_REG(((y&0x0FFF)<<16)|(x&0x0FFF), RectangleOrigin);
+ }
+}
+
+
+void
+Permedia3Sync(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ CHECKCLIPPING;
+
+ while (GLINT_READ_REG(DMACount) != 0);
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(0, GlintSync);
+ do {
+ while(GLINT_READ_REG(OutFIFOWords) == 0);
+#define Sync_tag 0x188
+ } while (GLINT_READ_REG(OutputFIFO) != Sync_tag);
+}
+
+static void
+Permedia3SetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ GLINT_WAIT(3);
+ GLINT_WRITE_REG(((y1&0x0fff)<<16)|(x1&0x0fff), ScissorMinXY);
+ GLINT_WRITE_REG(((y2&0x0fff)<<16)|(x2&0x0fff), ScissorMaxXY);
+ GLINT_WRITE_REG(1, ScissorMode);
+ pGlint->ClippingOn = TRUE;
+}
+
+static void
+Permedia3DisableClipping(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CHECKCLIPPING;
+}
+
+static void
+Permedia3SetupForScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn,
+ int xdir, int ydir, int rop,
+ unsigned int planemask, int transparency_color)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ pGlint->BltScanDirection = 0;
+ if (xdir == 1) pGlint->BltScanDirection |= XPositive;
+ if (ydir == 1) pGlint->BltScanDirection |= YPositive;
+
+ if (pScrn->bitsPerPixel == 24) {
+ GLINT_WAIT(4);
+ } else {
+ GLINT_WAIT(5);
+ DO_PLANEMASK(planemask);
+ }
+
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if ((rop == GXset) || (rop == GXclear)) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ if ((rop == GXcopy) || (rop == GXcopyInverted)) {
+ GLINT_WRITE_REG(pGlint->pprod|FBRM_SrcEnable, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod|FBRM_SrcEnable|FBRM_DstEnable,
+ FBReadMode);
+ }
+ }
+ LOADROP(rop);
+}
+
+static void
+Permedia3SubsequentScreenToScreenCopy2432bpp(ScrnInfoPtr pScrn, int x1,
+ int y1, int x2, int y2, int w, int h)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(4);
+ Permedia3LoadCoord(pScrn, x2, y2, w, h);
+ GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | ((x1-x2)&0x0FFF), FBSourceDelta);
+ GLINT_WRITE_REG(PrimitiveRectangle | pGlint->BltScanDirection, Render);
+}
+
+static void
+Permedia3SetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
+ int xdir, int ydir, int rop,
+ unsigned int planemask, int transparency_color)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia3SetupForScreenToScreenCopy");
+
+ pGlint->BltScanDirection = 0;
+ if (xdir == 1) pGlint->BltScanDirection |= XPositive;
+ if (ydir == 1) pGlint->BltScanDirection |= YPositive;
+
+ GLINT_WAIT(4);
+ DO_PLANEMASK(planemask);
+
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if ((rop == GXset) || (rop == GXclear)) {
+ pGlint->FrameBufferReadMode = pGlint->pprod;
+ } else
+ if ((rop == GXcopy) || (rop == GXcopyInverted)) {
+ pGlint->FrameBufferReadMode = pGlint->pprod |FBRM_SrcEnable;
+ } else {
+ pGlint->FrameBufferReadMode = pGlint->pprod | FBRM_SrcEnable |
+ FBRM_DstEnable;
+ }
+ LOADROP(rop);
+ TRACE_EXIT("Permedia3SetupForScreenToScreenCopy");
+}
+
+static void
+Permedia3SubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
+ int x2, int y2, int w, int h)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ char align;
+
+ TRACE_ENTER("Permedia3SubsequentScreenToScreenCopy");
+ /* We can only use GXcopy for Packed modes */
+ if (pGlint->ROP != GXcopy) {
+ GLINT_WAIT(5);
+ GLINT_WRITE_REG(pGlint->FrameBufferReadMode, FBReadMode);
+ Permedia3LoadCoord(pScrn, x2, y2, w, h);
+ GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | ((x1-x2)&0x0FFF), FBSourceDelta);
+ } else {
+ align = (x2 & pGlint->bppalign) - (x1 & pGlint->bppalign);
+ GLINT_WAIT(6);
+ GLINT_WRITE_REG(pGlint->FrameBufferReadMode|FBRM_Packed, FBReadMode);
+ Permedia3LoadCoord(pScrn, x2>>pGlint->BppShift, y2,
+ (w+7)>>pGlint->BppShift, h);
+ GLINT_WRITE_REG(align<<29|x2<<16|(x2+w), PackedDataLimits);
+ GLINT_WRITE_REG(((y1-y2)&0x0FFF)<<16 | (((x1 & ~pGlint->bppalign)-(x2 & ~pGlint->bppalign))&0x0FFF), FBSourceDelta);
+ }
+
+ GLINT_WRITE_REG(PrimitiveRectangle | pGlint->BltScanDirection, Render);
+ TRACE_EXIT("Permedia3SubsequentScreenToScreenCopy");
+}
+
+
+
+static void
+Permedia3PolylinesThinSolidWrapper(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pPts
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
+ pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
+ if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
+ XAAPolyLines(pDraw, pGC, mode, npt, pPts);
+}
+
+static void
+Permedia3PolySegmentThinSolidWrapper(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
+ pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
+ if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
+ XAAPolySegment(pDraw, pGC, nseg, pSeg);
+}
+
+static void
+Permedia3SetupForSolidLine(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(6);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, GLINTColor);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+}
+
+static void
+Permedia3SubsequentHorVertLine(ScrnInfoPtr pScrn,int x,int y,int len,int dir)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(6);
+ GLINT_WRITE_REG(x<<16, StartXDom);
+ GLINT_WRITE_REG(y<<16, StartY);
+ if (dir == DEGREES_0) {
+ GLINT_WRITE_REG(1<<16, dXDom);
+ GLINT_WRITE_REG(0<<16, dY);
+ } else {
+ GLINT_WRITE_REG(0<<16, dXDom);
+ GLINT_WRITE_REG(1<<16, dY);
+ }
+
+ GLINT_WRITE_REG(len, GLINTCount);
+ GLINT_WRITE_REG(PrimitiveLine, Render);
+}
+
+static void
+Permedia3SubsequentSolidBresenhamLine( ScrnInfoPtr pScrn,
+ int x, int y, int dmaj, int dmin, int e, int len, int octant)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if(dmaj == dmin) {
+ GLINT_WAIT(6);
+ if(octant & YDECREASING) {
+ GLINT_WRITE_REG(-1<<16, dY);
+ } else {
+ GLINT_WRITE_REG(1<<16, dY);
+ }
+
+ if(octant & XDECREASING) {
+ GLINT_WRITE_REG(-1<<16, dXDom);
+ } else {
+ GLINT_WRITE_REG(1<<16, dXDom);
+ }
+
+ GLINT_WRITE_REG(x<<16, StartXDom);
+ GLINT_WRITE_REG(y<<16, StartY);
+ GLINT_WRITE_REG(len,GLINTCount);
+ GLINT_WRITE_REG(PrimitiveLine, Render);
+ return;
+ }
+
+ fbBres(pGlint->CurrentDrawable, pGlint->CurrentGC, 0,
+ (octant & XDECREASING) ? -1 : 1,
+ (octant & YDECREASING) ? -1 : 1,
+ (octant & YMAJOR) ? Y_AXIS : X_AXIS,
+ x, y, dmin + e, dmin, -dmaj, len);
+}
+
+static void
+Permedia3SetupForFillRectSolid24bpp(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ pGlint->ForeGroundColor = color;
+
+ GLINT_WAIT(5);
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, ConstantColor);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+}
+
+static void
+Permedia3SetupForFillRectSolid(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia3SetupForFillRectSolid");
+
+ REPLICATE(color);
+
+ GLINT_WAIT(6);
+ DO_PLANEMASK(planemask);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(color, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, ConstantColor);
+ /* We can use Packed mode for filling solid non-GXcopy rasters */
+ GLINT_WRITE_REG(pGlint->pprod|FBRM_DstEnable|FBRM_Packed, FBReadMode);
+ }
+ LOADROP(rop);
+ TRACE_EXIT("Permedia3SetupForFillRectSolid");
+}
+
+static void
+Permedia3SubsequentFillRectSolid24bpp(ScrnInfoPtr pScrn, int x, int y, int w, int h)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ GLINT_WAIT(3);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive, Render);
+}
+
+static void
+Permedia3SubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int speed = 0;
+ TRACE_ENTER("Permedia3SubsequentFillRectSolid");
+
+ if (pGlint->ROP == GXcopy) {
+ GLINT_WAIT(3);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+ speed = FastFillEnable;
+ } else {
+ GLINT_WAIT(4);
+ Permedia3LoadCoord(pScrn, x>>pGlint->BppShift, y,
+ (w+7)>>pGlint->BppShift, h);
+ GLINT_WRITE_REG(x<<16|(x+w), PackedDataLimits);
+ speed = 0;
+ }
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | speed, Render);
+ TRACE_EXIT("Permedia3SubsequentFillRectSolid");
+}
+
+static void MoveBYTE(
+ register CARD32* dest,
+ register unsigned char* src,
+ register int dwords
+)
+{
+ while(dwords) {
+ *dest = *src;
+ src += 1;
+ dest += 1;
+ dwords -= 1;
+ }
+}
+
+static void MoveWORDS(
+ register CARD32* dest,
+ register unsigned short* src,
+ register int dwords
+)
+{
+ while(dwords & ~0x01) {
+ *dest = *src;
+ *(dest + 1) = *(src + 1);
+ src += 2;
+ dest += 2;
+ dwords -= 2;
+ }
+ switch(dwords) {
+ case 0: return;
+ case 1: *dest = *src;
+ return;
+ }
+}
+
+static void MoveDWORDS(
+ 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);
+}
+
+
+static void
+Permedia3SetupForMono8x8PatternFill24bpp(ScrnInfoPtr pScrn,
+ int patternx, int patterny,
+ int fg, int bg, int rop,
+ unsigned int planemask)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if (bg == -1) pGlint->FrameBufferReadMode = -1;
+ else pGlint->FrameBufferReadMode = 0;
+
+ pGlint->ForeGroundColor = fg;
+ pGlint->BackGroundColor = bg;
+ REPLICATE(pGlint->ForeGroundColor);
+ REPLICATE(pGlint->BackGroundColor);
+
+ GLINT_WAIT(12);
+ GLINT_WRITE_REG((patternx & 0xFF), AreaStipplePattern0);
+ GLINT_WRITE_REG((patternx & 0xFF00) >> 8, AreaStipplePattern1);
+ GLINT_WRITE_REG((patternx & 0xFF0000) >> 16, AreaStipplePattern2);
+ GLINT_WRITE_REG((patternx & 0xFF000000) >> 24, AreaStipplePattern3);
+ GLINT_WRITE_REG((patterny & 0xFF), AreaStipplePattern4);
+ GLINT_WRITE_REG((patterny & 0xFF00) >> 8, AreaStipplePattern5);
+ GLINT_WRITE_REG((patterny & 0xFF0000) >> 16, AreaStipplePattern6);
+ GLINT_WRITE_REG((patterny & 0xFF000000) >> 24, AreaStipplePattern7);
+
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+}
+
+static void
+Permedia3SetupForMono8x8PatternFill(ScrnInfoPtr pScrn,
+ int patternx, int patterny,
+ int fg, int bg, int rop,
+ unsigned int planemask)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ TRACE_ENTER("Permedia3SetupForMono8x8PatternFill");
+
+ if (bg == -1) pGlint->FrameBufferReadMode = -1;
+ else pGlint->FrameBufferReadMode = 0;
+
+ pGlint->ForeGroundColor = fg;
+ pGlint->BackGroundColor = bg;
+ REPLICATE(pGlint->ForeGroundColor);
+ REPLICATE(pGlint->BackGroundColor);
+
+#if DEBUG
+ ErrorF("patternx: %x patterny: %x\n", patternx, patterny);
+#endif
+
+ GLINT_WAIT(13);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG((patternx & 0xFF), AreaStipplePattern0);
+ GLINT_WRITE_REG((patternx & 0xFF00) >> 8, AreaStipplePattern1);
+ GLINT_WRITE_REG((patternx & 0xFF0000) >> 16, AreaStipplePattern2);
+ GLINT_WRITE_REG((patternx & 0xFF000000) >> 24, AreaStipplePattern3);
+ GLINT_WRITE_REG((patterny & 0xFF), AreaStipplePattern4);
+ GLINT_WRITE_REG((patterny & 0xFF00) >> 8, AreaStipplePattern5);
+ GLINT_WRITE_REG((patterny & 0xFF0000) >> 16, AreaStipplePattern6);
+ GLINT_WRITE_REG((patterny & 0xFF000000) >> 24, AreaStipplePattern7);
+
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+ TRACE_EXIT("Permedia3SetupForMono8x8PatternFill");
+}
+
+static void
+Permedia3SubsequentMono8x8PatternFillRect24bpp(ScrnInfoPtr pScrn,
+ int patternx, int patterny,
+ int x, int y,
+ int w, int h)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(8);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+
+ if (pGlint->FrameBufferReadMode != -1) {
+ GLINT_WRITE_REG(pGlint->BackGroundColor, ConstantColor);
+ GLINT_WRITE_REG(patternx<<7|patterny<<12| ASM_InvertPattern |
+ STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | XPositive |
+ YPositive | PrimitiveRectangle, Render);
+ }
+
+ GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor);
+ GLINT_WRITE_REG(patternx<<7|patterny<<12|UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | XPositive | YPositive |
+ PrimitiveRectangle, Render);
+}
+
+static void
+Permedia3SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,
+ int patternx, int patterny,
+ int x, int y,
+ int w, int h)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ TRACE_ENTER("Permedia3SubsequentMono8x8PatternFillRect()");
+
+ GLINT_WAIT(9);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+
+ if (pGlint->FrameBufferReadMode != -1) {
+ if (pGlint->ROP == GXcopy) {
+ GLINT_WRITE_REG(pGlint->BackGroundColor, FBBlockColor);
+ GLINT_WRITE_REG(ASM_InvertPattern|patternx<<7|patterny<<12|
+ STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | FastFillEnable |
+ XPositive | YPositive | PrimitiveRectangle, Render);
+ } else {
+ GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor);
+ GLINT_WRITE_REG(pGlint->BackGroundColor, Texel0);
+ GLINT_WRITE_REG(patternx<<7|patterny<<12|
+ STIPPLE_SWAP | UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | XPositive | TextureEnable |
+ YPositive | PrimitiveRectangle, Render);
+ return;
+ }
+ }
+
+ if (pGlint->ROP == GXcopy) {
+ GLINT_WRITE_REG(pGlint->ForeGroundColor, FBBlockColor);
+ pGlint->FrameBufferReadMode = FastFillEnable;
+ } else {
+ GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor);
+ pGlint->FrameBufferReadMode = 0;
+ }
+ GLINT_WRITE_REG(patternx<<7|patterny<<12|STIPPLE_SWAP|UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | pGlint->FrameBufferReadMode |
+ XPositive | YPositive | PrimitiveRectangle, Render);
+
+ TRACE_EXIT("Permedia3SubsequentMono8x8PatternFillRect()");
+}
+
+static void
+Permedia3SetupForCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int dobackground = 0;
+
+ TRACE_ENTER("Permedia3SetupForCPUToScreenColorExpandFill");
+ if (bg != -1) dobackground |= ForceBackgroundColor;
+
+ GLINT_WAIT(7);
+ DO_PLANEMASK(planemask);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+
+ pGlint->ForeGroundColor = fg;
+ pGlint->BackGroundColor = bg;
+ REPLICATE(fg);
+ REPLICATE(bg);
+
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if (dobackground) {
+ GLINT_WRITE_REG(bg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ }
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ pGlint->FrameBufferReadMode = FastFillEnable;
+ } else {
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground|
+ pGlint->RasterizerSwap,RasterizerMode);
+ GLINT_WRITE_REG(fg, ConstantColor);
+ if (dobackground) {
+ pGlint->FrameBufferReadMode = TextureEnable;
+ GLINT_WRITE_REG(bg, Texel0);
+ } else
+ pGlint->FrameBufferReadMode = 0;
+ }
+ LOADROP(rop);
+ TRACE_EXIT("Permedia3SetupForCPUToScreenColorExpandFill");
+}
+
+static void
+Permedia3SubsequentCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int skipleft
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int dwords = ((w + 31) >> 5) * h;
+
+ TRACE_ENTER("Permedia3SubsequentCPUToScreenColorExpandFill");
+ GLINT_WAIT(8);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+
+ if ((pGlint->ROP == GXcopy) && (pGlint->BackGroundColor != -1)) {
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | FastFillEnable, Render);
+ REPLICATE(pGlint->ForeGroundColor)
+ GLINT_WRITE_REG(pGlint->ForeGroundColor, FBBlockColor);
+ }
+
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | SyncOnBitMask |
+ pGlint->FrameBufferReadMode, Render);
+ GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO);
+ GLINT_WAIT(dwords);
+ TRACE_EXIT("Permedia3SubsequentCPUToScreenColorExpandFill");
+}
+
+static void
+Permedia3SetupForScanlineCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int dobackground = 0;
+
+ TRACE_ENTER("Permedia3SetupForScanlineCPUToScreenColorExpandFill");
+ if (bg != -1) dobackground |= ForceBackgroundColor;
+ pGlint->BackGroundColor = bg;
+ pGlint->ForeGroundColor = fg;
+ REPLICATE(fg);
+ REPLICATE(bg);
+ GLINT_WAIT(7);
+ DO_PLANEMASK(planemask);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod|FBRM_DstEnable, FBReadMode);
+ }
+ if ((rop == GXcopy) && (pGlint->BackGroundColor == -1)) {
+ pGlint->FrameBufferReadMode = FastFillEnable;
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ } else {
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(fg, ConstantColor);
+ GLINT_WRITE_REG(BitMaskPackingEachScanline|dobackground|
+ pGlint->RasterizerSwap,RasterizerMode);
+ if (dobackground) {
+ GLINT_WRITE_REG(bg, Texel0);
+ pGlint->FrameBufferReadMode = TextureEnable;
+ } else {
+ pGlint->FrameBufferReadMode = 0;
+ }
+ }
+ LOADROP(rop);
+ TRACE_EXIT("Permedia3SetupForScanlineCPUToScreenColorExpandFill");
+}
+
+static void
+Permedia3SubsequentScanlineCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int skipleft
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ TRACE_ENTER("Permedia3SubsequentScanlineCPUToScreenColorExpandFill");
+
+ pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */
+
+ pGlint->cpucount = h;
+
+ GLINT_WAIT(6);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | pGlint->FrameBufferReadMode | SyncOnBitMask, Render);
+ GLINT_WRITE_REG(((pGlint->dwords*h)-1)<<16 | 0x0D, OutputFIFO);
+ GLINT_WAIT(pGlint->dwords);
+ pGlint->cpucount--;
+ TRACE_EXIT("Permedia3SubsequentScanlineCPUToScreenColorExpandFill");
+}
+
+static void
+Permedia3SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if (pGlint->cpucount--)
+ GLINT_WAIT(pGlint->dwords);
+}
+
+
+static void
+Permedia3WriteBitmap(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);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ unsigned char *srcpntr;
+ int dwords, height, mode;
+ Bool SecondPass = FALSE;
+
+ TRACE_ENTER("Permedia3WriteBitmap");
+
+ w += skipleft;
+ x -= skipleft;
+ dwords = (w + 31) >> 5;
+
+ Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h);
+
+ if (pScrn->bitsPerPixel == 24) {
+ GLINT_WAIT(10);
+ } else {
+ GLINT_WAIT(11);
+ DO_PLANEMASK(planemask);
+ }
+ LOADROP(rop);
+ Permedia3LoadCoord(pScrn, x&0xFFFF, y, w, h);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ mode = FastFillEnable;
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ } else {
+ mode = 0;
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(BitMaskPackingEachScanline|
+ pGlint->RasterizerSwap,RasterizerMode);
+ }
+
+ if(bg == -1) {
+ /* >>>>> set fg <<<<<<<< */
+ REPLICATE(fg);
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, ConstantColor);
+ }
+ } else if(rop == GXcopy) {
+ /* >>>>> set bg <<<<<<< */
+ /* >>>>> draw rect (x,y,w,h) */
+ REPLICATE(bg);
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ GLINT_WRITE_REG(bg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(bg, ConstantColor);
+ }
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |mode,Render);
+ /* >>>>>> set fg <<<<<< */
+ REPLICATE(fg);
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, ConstantColor);
+ }
+ } else {
+ SecondPass = TRUE;
+ /* >>>>> set fg <<<<<<< */
+ REPLICATE(fg);
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, ConstantColor);
+ }
+ }
+
+ /* >>>>>>>>> initiate transfer (x,y,w,h). Skipleft pixels on the
+ left edge will be clipped <<<<<< */
+
+SECOND_PASS:
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive | mode | SyncOnBitMask, Render);
+
+ height = h;
+ srcpntr = src;
+ while(height--) {
+ GLINT_WAIT(dwords);
+ /* 0x0D is the TAG value for BitMaskPattern */
+ GLINT_WRITE_REG(((dwords - 1) << 16) | 0x0D, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32 *)srcpntr, dwords);
+ srcpntr += srcwidth;
+ }
+
+ if(SecondPass) {
+ SecondPass = FALSE;
+ /* >>>>>> invert bitmask and set bg <<<<<<<< */
+ REPLICATE(bg);
+ GLINT_WAIT(3);
+ if ((pScrn->bitsPerPixel != 24) && (rop == GXcopy)) {
+ GLINT_WRITE_REG(InvertBitMask|pGlint->RasterizerSwap,RasterizerMode);
+ GLINT_WRITE_REG(bg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(InvertBitMask|BitMaskPackingEachScanline|
+ pGlint->RasterizerSwap, RasterizerMode);
+ GLINT_WRITE_REG(bg, ConstantColor);
+ }
+ goto SECOND_PASS;
+ }
+
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap, RasterizerMode);
+ Permedia3DisableClipping(pScrn);
+ SET_SYNC_FLAG(infoRec);
+ TRACE_EXIT("Permedia3WriteBitmap");
+}
+
+
+static void
+Permedia3WritePixmap8bpp(
+ 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
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int skipleft, dwords, count;
+ CARD32* srcp;
+ unsigned char *srcpbyte;
+ Bool FastTexLoad = FALSE;
+
+ GLINT_WAIT(3);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_Packed, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+
+ dwords = (w + 3) >> 2;
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ if((!(x&3)) && (!(w&3))) FastTexLoad = TRUE;
+#endif
+ if((rop != GXcopy) || (planemask != ~0))
+ FastTexLoad = FALSE;
+
+ if (rop == GXcopy) {
+ skipleft = 0;
+ } else {
+ if((skipleft = (long)src & 0x03)) {
+ skipleft /= (bpp>>3);
+
+ x -= skipleft;
+ w += skipleft;
+
+ src = (unsigned char*)((long)src & ~0x03);
+ }
+ }
+
+
+ if(FastTexLoad) {
+ int address;
+
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(UNIT_DISABLE, FBWriteMode);
+ Permedia3Sync(pScrn); /* we are not using the rasterizer */
+ while(h--) {
+ count = dwords;
+ address = ((y * pScrn->displayWidth) + x) >> 2;
+ srcp = (CARD32*)src;
+ GLINT_WRITE_REG(address, TextureDownloadOffset);
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x11 << 4) | 0x0D is the TAG for TextureData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) |
+ 0x0D, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ address += MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x11 << 4) | 0x0D is the TAG for TextureData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D,
+ OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ y++;
+ }
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(UNIT_ENABLE, FBWriteMode);
+ } else {
+ char align = (x & pGlint->bppalign);
+
+
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if (rop == GXcopy) {
+ GLINT_WAIT(6);
+ Permedia3LoadCoord(pScrn, x>>pGlint->BppShift, y,
+ (w+pGlint->bppalign)>>pGlint->BppShift, h);
+ GLINT_WRITE_REG(align<<29|x<<16|(x+w), PackedDataLimits);
+ } else {
+ Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h);
+ GLINT_WAIT(5);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+ }
+ LOADROP(rop);
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |
+ SyncOnHostData, Render);
+
+ if (rop == GXcopy) {
+ while(h--) {
+ count = dwords;
+ srcp = (CARD32*)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ }
+ } else {
+ while(h--) {
+ count = w;
+ srcpbyte = (unsigned char *)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (unsigned char *)srcpbyte, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcpbyte += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (unsigned char *)srcpbyte, count);
+ }
+ src += srcwidth;
+ }
+ }
+ }
+
+ Permedia3DisableClipping(pScrn);
+ SET_SYNC_FLAG(infoRec);
+}
+
+static void
+Permedia3WritePixmap16bpp(
+ 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
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int skipleft, dwords, count;
+ CARD32* srcp;
+ unsigned short* srcpword;
+ Bool FastTexLoad;
+
+ TRACE_ENTER("Permedia3WritePixmap16bpp");
+ GLINT_WAIT(3);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_Packed, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+
+ FastTexLoad = FALSE;
+ dwords = (w + 1) >> 1;
+#if X_BYTE_ORDER == X_LITTLE_ENDIAN
+ if((!(x&1)) && (!(w&1))) FastTexLoad = TRUE;
+#endif
+ if((rop != GXcopy) || (planemask != ~0))
+ FastTexLoad = FALSE;
+
+ if (rop == GXcopy) {
+ skipleft = 0;
+ } else {
+ if((skipleft = (long)src & 0x03L)) {
+ skipleft /= (bpp>>3);
+
+ x -= skipleft;
+ w += skipleft;
+
+ src = (unsigned char*)((long)src & ~0x03L);
+ }
+ }
+
+ if(FastTexLoad) {
+ int address;
+
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(UNIT_DISABLE, FBWriteMode);
+ Permedia3Sync(pScrn); /* we are not using the rasterizer */
+ while(h--) {
+ count = dwords;
+ address = ((y * pScrn->displayWidth) + x) >> 1;
+ srcp = (CARD32*)src;
+ GLINT_WRITE_REG(address, TextureDownloadOffset);
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x11 << 4) | 0x0D is the TAG for TextureData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) |
+ 0x0D, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ address += MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x11 << 4) | 0x0D is the TAG for TextureData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D,
+ OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ y++;
+ }
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(UNIT_ENABLE, FBWriteMode);
+ } else {
+ char align = (x & pGlint->bppalign);
+
+
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if (rop == GXcopy) {
+ GLINT_WAIT(6);
+ Permedia3LoadCoord(pScrn, x>>pGlint->BppShift, y,
+ (w+pGlint->bppalign)>>pGlint->BppShift, h);
+ GLINT_WRITE_REG(align<<29|x<<16|(x+w), PackedDataLimits);
+ } else {
+ Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h);
+ GLINT_WAIT(5);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+ }
+ LOADROP(rop);
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |
+ SyncOnHostData, Render);
+
+ if (rop == GXcopy) {
+ while(h--) {
+ count = dwords;
+ srcp = (CARD32*)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ }
+ } else {
+ while(h--) {
+ count = w;
+ srcpword = (unsigned short *)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (unsigned short *)srcpword, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcpword += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (unsigned short *)srcpword, count);
+ }
+ src += srcwidth;
+ }
+ }
+ }
+
+ Permedia3DisableClipping(pScrn);
+ SET_SYNC_FLAG(infoRec);
+ TRACE_EXIT("Permedia3WritePixmap16bpp");
+}
+
+#if 0
+static void
+Permedia3WritePixmap24bpp(
+ 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
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int skipleft = 0, dwords, count;
+ unsigned char* srcpbyte;
+ CARD32* srcp;
+
+ GLINT_WAIT(3);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+
+ dwords = ((w+1)*3)>>2;
+ if((skipleft = (long)src & 0x03L)) {
+ skipleft = 4 - skipleft;
+
+ x -= skipleft;
+ w += skipleft;
+
+ src = (unsigned char*)(src - (3*skipleft));
+ }
+
+ {
+ Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h);
+
+ GLINT_WAIT(4);
+ Permedia3LoadCoord(pScrn, x&0xFFFF, y, w, h);
+ LOADROP(rop);
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |
+ SyncOnHostData, Render);
+
+#if 1
+ while(h--) {
+ count = w;
+ srcpbyte = (unsigned char *)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (unsigned char *)srcpbyte, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcpbyte += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveBYTE((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (unsigned char *)srcpbyte, count);
+ }
+ src += srcwidth;
+#else
+ while(h--) {
+ count = dwords;
+ srcp = (CARD32*)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+#endif
+ }
+ }
+
+ Permedia3DisableClipping(pScrn);
+ SET_SYNC_FLAG(infoRec);
+}
+#endif
+
+
+static void
+Permedia3WritePixmap32bpp(
+ 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
+)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int skipleft, dwords, count;
+ CARD32* srcp;
+ Bool FastTexLoad;
+
+ GLINT_WAIT(3);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(pGlint->RasterizerSwap,RasterizerMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+
+ FastTexLoad = TRUE;
+ dwords = w;
+ if((rop != GXcopy) || (planemask != ~0))
+ FastTexLoad = FALSE;
+
+ if (!FastTexLoad) {
+ if((skipleft = (long)src & 0x03L)) {
+ skipleft /= (bpp>>3);
+
+ x -= skipleft;
+ w += skipleft;
+
+ src = (unsigned char*)((long)src & ~0x03L);
+ }
+ }
+
+ if(FastTexLoad) {
+ int address;
+
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(UNIT_DISABLE, FBWriteMode);
+ Permedia3Sync(pScrn); /* we are not using the rasterizer */
+ while(h--) {
+ count = dwords;
+ address = (y * pScrn->displayWidth) + x;
+ srcp = (CARD32*)src;
+ GLINT_WRITE_REG(address, TextureDownloadOffset);
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x11 << 4) | 0x0D is the TAG for TextureData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x11 << 4) |
+ 0x0D, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ address += MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x11 << 4) | 0x0D is the TAG for TextureData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x11 << 4) | 0x0D,
+ OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ y++;
+ }
+ GLINT_WAIT(1);
+ GLINT_WRITE_REG(UNIT_ENABLE, FBWriteMode);
+ } else {
+ Permedia3SetClippingRectangle(pScrn,x+skipleft,y,x+w,y+h);
+
+ GLINT_WAIT(6);
+ Permedia3LoadCoord(pScrn, x, y, w, h);
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ LOADROP(rop);
+ GLINT_WRITE_REG(PrimitiveRectangle | XPositive | YPositive |
+ SyncOnHostData, Render);
+
+ while(h--) {
+ count = dwords;
+ srcp = (CARD32*)src;
+ while(count >= MAX_FIFO_ENTRIES) {
+ GLINT_WAIT(MAX_FIFO_ENTRIES);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((MAX_FIFO_ENTRIES - 2) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, MAX_FIFO_ENTRIES - 1);
+ count -= MAX_FIFO_ENTRIES - 1;
+ srcp += MAX_FIFO_ENTRIES - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count + 1);
+ /* (0x15 << 4) | 0x05 is the TAG for FBSourceData */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x15 << 4) |
+ 0x05, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ }
+ }
+
+ Permedia3DisableClipping(pScrn);
+ SET_SYNC_FLAG(infoRec);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c
new file mode 100644
index 000000000..7a8f6a440
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c
@@ -0,0 +1,596 @@
+/*
+ * Copyright 1997,1998 by Alan Hourihane <alanh@fairlite.demon.co.uk>
+ *
+ * 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: Sven Luther, <luther@dpt-info.u-strasbg.fr>
+ *
+ *
+ *
+ *
+ * this work is sponsored by Appian Graphics.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm3_dac.c,v 1.3 2000/06/12 10:11:38 alanh Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+#include "glint_regs.h"
+#include "glint.h"
+
+#define DEBUG 0
+
+#if DEBUG
+# define TRACE_ENTER(str) ErrorF("glint: " str " %d\n",pScrn->scrnIndex)
+# define TRACE_EXIT(str) ErrorF("glint: " str " done\n")
+# define TRACE(str) ErrorF("glint trace: " str "\n")
+#else
+# define TRACE_ENTER(str)
+# define TRACE_EXIT(str)
+# define TRACE(str)
+#endif
+
+void
+Permedia3PreInit(ScrnInfoPtr pScrn, GLINTPtr pGlint)
+{
+ TRACE_ENTER("Permedia3PreInit");
+ if ((pGlint->PciInfo->subsysVendor == 0x1097) &&
+ (pGlint->PciInfo->subsysCard == 0x3d32)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Appian Jeronimo 2000 board detected and initialized.\n\t"
+ "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n",
+ pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard);
+ /* Memory timings for the Appian J2000 board.
+ * This is needed for the second head which is left unitilialized
+ * by the bios, thus freezing the machine.
+ */
+ GLINT_SLOW_WRITE_REG(0xffffffff, PM3MemBypassWriteMask);
+ GLINT_SLOW_WRITE_REG(0x02e311B8, PM3LocalMemCaps);
+ GLINT_SLOW_WRITE_REG(0x07424905, PM3LocalMemTimings);
+ GLINT_SLOW_WRITE_REG(0x0c000003, PM3LocalMemControl);
+ GLINT_SLOW_WRITE_REG(0x00000069, PM3LocalMemRefresh);
+ }
+ else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Unknown Glint Permedia3 board detected.\n\t"
+ "subsysVendor = 0x%04x, subsysCard = 0x%04x.\n",
+ pGlint->PciInfo->subsysVendor, pGlint->PciInfo->subsysCard);
+ }
+ TRACE_EXIT("Permedia3PreInit");
+}
+
+int
+PM3QuickFillMemory(ScrnInfoPtr pScrn,int size)
+{
+ GLINTPtr pGlint;
+ unsigned int * p;
+ unsigned int p_content;
+ unsigned int i, j;
+ long savemapsize;
+
+ pGlint = GLINTPTR (pScrn);
+ savemapsize = pGlint->FbMapSize;
+ pGlint->FbMapSize = size*1024*1024;
+
+ pGlint->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
+ pGlint->PciTag, pGlint->FbAddress, pGlint->FbMapSize);
+ if (pGlint->FbBase == NULL) {
+ pGlint->FbMapSize = savemapsize;
+ return FALSE;
+ }
+
+ /* Set pointer to Aperture1 */
+ p = (unsigned int *) pGlint->FbBase;
+ /* Fill in megs number of megabytes */
+ for(i=0;i<size;i++)
+ for(j=0;j<1024*256;j+=1024)
+ p[j+(i*1024*256)] = j + (i * 1024*256);
+
+ /* Set pointer to Aperture1 */
+ p = (unsigned int *) pGlint->FbBase;
+
+ /* If original ptr is 0x0 then no rollover occured */
+ p_content = p[0];
+ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pGlint->FbBase,
+ pGlint->FbMapSize);
+ pGlint->FbBase = NULL;
+ pGlint->FbMapSize = savemapsize;
+ if (p_content == 0x0)
+ return TRUE;
+ else return FALSE;
+}
+int
+Permedia3MemorySizeDetect(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint;
+ int size = 1;
+ pGlint = GLINTPTR (pScrn);
+ /* Fill memory until get a rollover of dram to 0
+ * fill in powers of 2, 1,2,4,8,16,32
+ */
+ while(PM3QuickFillMemory(pScrn,size))
+ {
+ size = size*2;
+ if(size == 64) break;
+ }
+ /* Correct memory amount since fail */
+ size = size / 2;
+ /* Just to make sure */
+ if (PM3QuickFillMemory(pScrn,size))
+ return size*1024;
+ return 16*1024;
+}
+
+static int
+Shiftbpp(ScrnInfoPtr pScrn, int value)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ /* shift horizontal timings for 128bit SGRAMs or SDRAMs */
+ int logbytesperaccess = 4;
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ value >>= logbytesperaccess;
+ pGlint->BppShift = logbytesperaccess;
+ break;
+ case 16:
+ if (pGlint->DoubleBuffer) {
+ value >>= (logbytesperaccess-2);
+ pGlint->BppShift = logbytesperaccess-2;
+ } else {
+ value >>= (logbytesperaccess-1);
+ pGlint->BppShift = logbytesperaccess-1;
+ }
+ break;
+ case 24:
+ value *= 3;
+ value >>= logbytesperaccess;
+ pGlint->BppShift = logbytesperaccess;
+ break;
+ case 32:
+ value >>= (logbytesperaccess-2);
+ pGlint->BppShift = logbytesperaccess-2;
+ break;
+ }
+ return (value);
+}
+
+static unsigned long
+PM3DAC_CalculateClock
+(
+ unsigned long reqclock, /* In kHz units */
+ unsigned long refclock, /* In kHz units */
+ unsigned char *prescale, /* ClkPreScale */
+ unsigned char *feedback, /* ClkFeedBackScale */
+ unsigned char *postscale /* ClkPostScale */
+ )
+{
+ int f, pre, post;
+ unsigned long freq;
+ long freqerr = 1000;
+ unsigned long actualclock = 0;
+
+ for (f=1;f<256;f++) {
+ for (pre=1;pre<256;pre++) {
+ for (post=0;post<5;post++) {
+ /* P3Lib multiplies it by two here lets try it alsos
+ * Didn't work at all, don't know why, ...
+ */
+ freq = ((2*refclock * f) / (pre * (1 << post)));
+ if ((reqclock > freq - freqerr)&&(reqclock < freq + freqerr)){
+ freqerr = (reqclock > freq) ?
+ reqclock - freq : freq - reqclock;
+ *feedback = f;
+ *prescale = pre;
+ *postscale = post;
+ actualclock = freq;
+ }
+ }
+ }
+ }
+ return(actualclock);
+}
+
+Bool
+Permedia3Init(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ GLINTRegPtr pReg = &pGlint->ModeReg;
+ CARD32 temp1, temp2, temp3, temp4;
+
+ /* Memory timings for the Appian J2000 board
+ * This is not ideal, since the work here is duplicated
+ * in the Permedia3PreInit function :(((
+ */
+ if ((pGlint->PciInfo->subsysVendor == 0x1097) &&
+ (pGlint->PciInfo->subsysCard == 0x3d32)) {
+ pReg->glintRegs[PM3MemBypassWriteMask >> 3] = 0xffffffff;
+ pReg->glintRegs[PM3LocalMemCaps >> 3] = 0x02e311B8;
+ pReg->glintRegs[PM3LocalMemTimings >> 3] = 0x07424905;
+ pReg->glintRegs[PM3LocalMemControl >> 3] = 0x0c000003;
+ pReg->glintRegs[PM3LocalMemRefresh >> 3] = 0x00000069;
+ pReg->glintRegs[PM3LocalMemPowerDown >> 3] = 0x00000000;
+ pReg->glintRegs[PM3ByAperture1Mode >> 3] = 0x00000000;
+ pReg->glintRegs[PM3ByAperture2Mode >> 3] = 0x00000000;
+ }
+
+ pReg->glintRegs[Aperture0 >> 3] = 0;
+ pReg->glintRegs[Aperture1 >> 3] = 0;
+
+ if (pGlint->UsePCIRetry) {
+ pReg->glintRegs[DFIFODis >> 3] = 1;
+ pReg->glintRegs[FIFODis >> 3] = 3;
+ } else {
+ pReg->glintRegs[DFIFODis >> 3] = 0;
+ pReg->glintRegs[FIFODis >> 3] = 1;
+ }
+
+ temp1 = mode->CrtcHSyncStart - mode->CrtcHDisplay;
+ temp2 = mode->CrtcVSyncStart - mode->CrtcVDisplay;
+ temp3 = mode->CrtcHSyncEnd - mode->CrtcHSyncStart;
+ temp4 = mode->CrtcVSyncEnd - mode->CrtcVSyncStart;
+
+ pReg->glintRegs[PMHTotal >> 3] = Shiftbpp(pScrn,mode->CrtcHTotal);
+ pReg->glintRegs[PMHsEnd >> 3] = Shiftbpp(pScrn, temp1 + temp3);
+ pReg->glintRegs[PMHsStart >> 3] = Shiftbpp(pScrn, temp1);
+ pReg->glintRegs[PMHbEnd >> 3] =
+ Shiftbpp(pScrn,mode->CrtcHTotal-mode->CrtcHDisplay);
+ pReg->glintRegs[PMHgEnd >> 3] = pReg->glintRegs[PMHbEnd >> 3];
+ pReg->glintRegs[PMScreenStride >> 3] =
+ Shiftbpp(pScrn,pScrn->displayWidth);
+
+ pReg->glintRegs[PMVTotal >> 3] = mode->CrtcVTotal;
+ pReg->glintRegs[PMVsEnd >> 3] = temp2 + temp4;
+ pReg->glintRegs[PMVsStart >> 3] = temp2;
+ pReg->glintRegs[PMVbEnd >> 3] = mode->CrtcVTotal - mode->CrtcVDisplay;
+
+ pReg->glintRegs[PMHTotal >> 3] -= 1;
+ pReg->glintRegs[PMVTotal >> 3] -= 1;
+ pReg->glintRegs[PMVsStart >> 3] -= 1;
+ pReg->glintRegs[PMVsEnd >> 3] -= 1;
+
+ /* The hw cursor needs /VSYNC to recognize vert retrace. We'll stick
+ both sync lines to active high (???) here and if needed invert them
+ using the RAMDAC's RDSyncControl below. */
+ pReg->glintRegs[PMVideoControl >> 3] =
+ (1 << 5) | (1 << 3) | 1;
+
+ pReg->glintRegs[VClkCtl >> 3] = (GLINT_READ_REG(VClkCtl) & 0xFFFFFFFC);
+ pReg->glintRegs[PMScreenBase >> 3] = 0;
+
+ pReg->glintRegs[ChipConfig >> 3] = GLINT_READ_REG(ChipConfig) & 0xFFFFFFDD;
+ pReg->DacRegs[PM2VDACRDDACControl] = 0x00;
+
+ {
+ /* Get the programmable clock values */
+ unsigned char m,n,p;
+ unsigned long clockused;
+
+ clockused = PM3DAC_CalculateClock(mode->Clock,pGlint->RefClock,
+ &m,&n,&p);
+ pReg->DacRegs[PM2VDACRDDClk0PreScale] = m;
+ pReg->DacRegs[PM2VDACRDDClk0FeedbackScale] = n;
+ pReg->DacRegs[PM2VDACRDDClk0PostScale] = p;
+ }
+
+ pReg->DacRegs[PM2VDACRDIndexControl] = 0x00;
+
+ if (pScrn->rgbBits == 8)
+ pReg->DacRegs[PM2VDACRDMiscControl] = 0x01; /* 8bit DAC */
+ else
+ pReg->DacRegs[PM2VDACRDMiscControl] = 0x00; /* 6bit DAC */
+
+ pReg->DacRegs[PM2VDACRDSyncControl] = 0x00;
+ if (!(mode->Flags & V_PHSYNC))
+ pReg->DacRegs[PM2VDACRDSyncControl] |= 0x01; /* invert hsync */
+ if (!(mode->Flags & V_PVSYNC))
+ pReg->DacRegs[PM2VDACRDSyncControl] |= 0x04; /* invert vsync */
+
+ switch (pScrn->bitsPerPixel)
+ {
+ case 8:
+ pReg->DacRegs[PM2VDACRDPixelSize] = 0x00;
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x2E;
+ break;
+ case 16:
+ pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08;
+ pReg->DacRegs[PM2VDACRDPixelSize] = 0x01;
+ if (pScrn->depth == 15)
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x61;
+ else
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x70;
+ break;
+ case 24:
+ pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08;
+ pReg->DacRegs[PM2VDACRDPixelSize] = 0x04;
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x60;
+ break;
+ case 32:
+ pReg->DacRegs[PM2VDACRDMiscControl] |= 0x08;
+ pReg->DacRegs[PM2VDACRDPixelSize] = 0x02;
+ pReg->DacRegs[PM2VDACRDColorFormat] = 0x20;
+ if (pScrn->overlayFlags & OVERLAY_8_32_PLANAR) {
+ pReg->DacRegs[PM2VDACRDMiscControl] |= 0x10;
+ pReg->DacRegs[PM2VDACRDOverlayKey] = 0xFF;
+ }
+ break;
+ }
+
+ return(TRUE);
+}
+
+void
+Permedia3Save(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int i;
+
+ /* Permedia 3 memory Timings */
+ glintReg->glintRegs[PM3MemBypassWriteMask >> 3] =
+ GLINT_READ_REG(PM3MemBypassWriteMask);
+ glintReg->glintRegs[PM3LocalMemCaps >> 3] =
+ GLINT_READ_REG(PM3LocalMemCaps);
+ glintReg->glintRegs[PM3LocalMemTimings >> 3] =
+ GLINT_READ_REG(PM3LocalMemTimings);
+ glintReg->glintRegs[PM3LocalMemControl >> 3] =
+ GLINT_READ_REG(PM3LocalMemControl);
+ glintReg->glintRegs[PM3LocalMemRefresh >> 3] =
+ GLINT_READ_REG(PM3LocalMemRefresh);
+ glintReg->glintRegs[PM3LocalMemPowerDown >> 3] =
+ GLINT_READ_REG(PM3LocalMemPowerDown);
+ glintReg->glintRegs[PM3ByAperture1Mode >> 3] =
+ GLINT_READ_REG(PM3ByAperture1Mode);
+ glintReg->glintRegs[PM3ByAperture2Mode >> 3] =
+ GLINT_READ_REG(PM3ByAperture2Mode);
+
+ glintReg->glintRegs[ChipConfig >> 3] = GLINT_READ_REG(ChipConfig);
+ glintReg->glintRegs[Aperture0 >> 3] = GLINT_READ_REG(Aperture0);
+ glintReg->glintRegs[Aperture1 >> 3] = GLINT_READ_REG(Aperture1);
+
+ glintReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis);
+ glintReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis);
+ glintReg->glintRegs[PMHTotal >> 3] = GLINT_READ_REG(PMHTotal);
+ glintReg->glintRegs[PMHbEnd >> 3] = GLINT_READ_REG(PMHbEnd);
+ glintReg->glintRegs[PMHbEnd >> 3] = GLINT_READ_REG(PMHgEnd);
+ glintReg->glintRegs[PMScreenStride >> 3] = GLINT_READ_REG(PMScreenStride);
+ glintReg->glintRegs[PMHsStart >> 3] = GLINT_READ_REG(PMHsStart);
+ glintReg->glintRegs[PMHsEnd >> 3] = GLINT_READ_REG(PMHsEnd);
+ glintReg->glintRegs[PMVTotal >> 3] = GLINT_READ_REG(PMVTotal);
+ glintReg->glintRegs[PMVbEnd >> 3] = GLINT_READ_REG(PMVbEnd);
+ glintReg->glintRegs[PMVsStart >> 3] = GLINT_READ_REG(PMVsStart);
+ glintReg->glintRegs[PMVsEnd >> 3] = GLINT_READ_REG(PMVsEnd);
+ glintReg->glintRegs[PMScreenBase >> 3] = GLINT_READ_REG(PMScreenBase);
+ glintReg->glintRegs[PMVideoControl >> 3] = GLINT_READ_REG(PMVideoControl);
+ glintReg->glintRegs[VClkCtl >> 3] = GLINT_READ_REG(VClkCtl);
+
+ for (i=0;i<768;i++) {
+ Permedia2ReadAddress(pScrn, i);
+ glintReg->cmap[i] = Permedia2ReadData(pScrn);
+ }
+
+ glintReg->DacRegs[PM2VDACRDIndexControl] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDIndexControl);
+ glintReg->DacRegs[PM2VDACRDOverlayKey] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDOverlayKey);
+ glintReg->DacRegs[PM2VDACRDSyncControl] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDSyncControl);
+ glintReg->DacRegs[PM2VDACRDMiscControl] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDMiscControl);
+ glintReg->DacRegs[PM2VDACRDDACControl] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDDACControl);
+ glintReg->DacRegs[PM2VDACRDPixelSize] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDPixelSize);
+ glintReg->DacRegs[PM2VDACRDColorFormat] =
+ Permedia2vInIndReg(pScrn, PM2VDACRDColorFormat);
+
+ glintReg->DacRegs[PM2VDACRDDClk0PreScale] = Permedia2vInIndReg(pScrn, PM2VDACRDDClk0PreScale);
+ glintReg->DacRegs[PM2VDACRDDClk0FeedbackScale] = Permedia2vInIndReg(pScrn, PM2VDACRDDClk0FeedbackScale);
+ glintReg->DacRegs[PM2VDACRDDClk0PostScale] = Permedia2vInIndReg(pScrn, PM2VDACRDDClk0PostScale);
+}
+
+void
+Permedia3Restore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CARD32 temp;
+ int i;
+
+#if 0
+ GLINT_SLOW_WRITE_REG(0, ResetStatus);
+ while(GLINT_READ_REG(ResetStatus) != 0) {
+ xf86MsgVerb(X_INFO, 2, "Resetting Engine - Please Wait.\n");
+ };
+#endif
+
+ /* Permedia 3 memory Timings */
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3MemBypassWriteMask >> 3],
+ PM3MemBypassWriteMask);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemCaps >> 3],
+ PM3LocalMemCaps);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemTimings >> 3],
+ PM3LocalMemTimings);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemControl >> 3],
+ PM3LocalMemControl);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemRefresh >> 3],
+ PM3LocalMemRefresh);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3LocalMemPowerDown >> 3],
+ PM3LocalMemPowerDown);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3ByAperture1Mode >> 3],
+ PM3ByAperture1Mode);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PM3ByAperture2Mode >> 3],
+ PM3ByAperture2Mode);
+
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[ChipConfig >> 3], ChipConfig);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture0 >> 3], Aperture0);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture1 >> 3], Aperture1);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[DFIFODis >> 3], DFIFODis);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FIFODis >> 3], FIFODis);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVideoControl >> 3],
+ PMVideoControl);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHbEnd >> 3], PMHgEnd);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMScreenBase >> 3], PMScreenBase);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VClkCtl >> 3], VClkCtl);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMScreenStride >> 3],
+ PMScreenStride);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHTotal >> 3], PMHTotal);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHbEnd >> 3], PMHbEnd);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHsStart >> 3], PMHsStart);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMHsEnd >> 3], PMHsEnd);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVTotal >> 3], PMVTotal);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVbEnd >> 3], PMVbEnd);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVsStart >> 3], PMVsStart);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[PMVsEnd >> 3], PMVsEnd);
+
+ Permedia2vOutIndReg(pScrn, PM2VDACRDIndexControl, 0x00,
+ glintReg->DacRegs[PM2VDACRDIndexControl]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDOverlayKey, 0x00,
+ glintReg->DacRegs[PM2VDACRDOverlayKey]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDSyncControl, 0x00,
+ glintReg->DacRegs[PM2VDACRDSyncControl]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDMiscControl, 0x00,
+ glintReg->DacRegs[PM2VDACRDMiscControl]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDDACControl, 0x00,
+ glintReg->DacRegs[PM2VDACRDDACControl]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDPixelSize, 0x00,
+ glintReg->DacRegs[PM2VDACRDPixelSize]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDColorFormat, 0x00,
+ glintReg->DacRegs[PM2VDACRDColorFormat]);
+
+ for (i=0;i<768;i++) {
+ Permedia2WriteAddress(pScrn, i);
+ Permedia2WriteData(pScrn, glintReg->cmap[i]);
+ }
+
+ temp = Permedia2vInIndReg(pScrn, PM2VDACIndexClockControl) & 0xFC;
+ Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0PreScale, 0x00,
+ glintReg->DacRegs[PM2VDACRDDClk0PreScale]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0FeedbackScale, 0x00,
+ glintReg->DacRegs[PM2VDACRDDClk0FeedbackScale]);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDDClk0PostScale, 0x00,
+ glintReg->DacRegs[PM2VDACRDDClk0PostScale]);
+ Permedia2vOutIndReg(pScrn, PM2VDACIndexClockControl, 0x00, temp|0x03);
+}
+
+static void
+Permedia3ShowCursor(ScrnInfoPtr pScrn)
+{
+ /* Enable cursor - X11 mode */
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorMode, 0x00, 0x11);
+}
+
+static void
+Permedia3HideCursor(ScrnInfoPtr pScrn)
+{
+ /* Disable cursor - X11 mode */
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorMode, 0x00, 0x10);
+}
+
+static void
+Permedia3LoadCursorImage(
+ ScrnInfoPtr pScrn,
+ unsigned char *src
+)
+{
+ int i;
+
+ for (i=0; i<1024; i++)
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPattern+i, 0x00, *(src++));
+}
+
+static void
+Permedia3SetCursorPosition(
+ ScrnInfoPtr pScrn,
+ int x, int y
+)
+{
+ x += 64;
+ y += 64;
+
+ /* Output position - "only" 11 bits of location documented */
+
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorHotSpotX, 0x00, 0x3f);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorHotSpotY, 0x00, 0x3f);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorXLow, 0x00, x & 0xFF);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorXHigh, 0x00, (x>>8) & 0x0F);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorYLow, 0x00, y & 0xFF);
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorYHigh, 0x00, (y>>8) & 0x0F);
+ Permedia2vOutIndReg(pScrn, PM2DACCursorControl, 0x00, 0x00);
+}
+
+
+static void
+Permedia3SetCursorColor(
+ ScrnInfoPtr pScrn,
+ int index,
+ int color
+)
+{
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3*(14-index)+0,
+ 0x00, 0xff & (color >>16));
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3*(14-index)+1,
+ 0x00, 0xff & (color >>8));
+ Permedia2vOutIndReg(pScrn, PM2VDACRDCursorPalette+3*(14-index)+2,
+ 0x00, 0xff & color);
+}
+
+static void
+Permedia3SetCursorColors(
+ ScrnInfoPtr pScrn,
+ int bg, int fg
+)
+{
+ Permedia3SetCursorColor (pScrn, 0, bg);
+ Permedia3SetCursorColor (pScrn, 1, fg);
+}
+
+static Bool
+Permedia3UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+{
+ return TRUE;
+}
+
+Bool
+Permedia3HWCursorInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ xf86CursorInfoPtr infoPtr;
+
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ pGlint->CursorInfoRec = infoPtr;
+
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_1;
+ infoPtr->SetCursorColors = Permedia3SetCursorColors;
+ infoPtr->SetCursorPosition = Permedia3SetCursorPosition;
+ infoPtr->LoadCursorImage = Permedia3LoadCursorImage;
+ infoPtr->HideCursor = Permedia3HideCursor;
+ infoPtr->ShowCursor = Permedia3ShowCursor;
+ infoPtr->UseHWCursor = Permedia3UseHWCursor;
+
+ return(xf86InitCursor(pScreen, infoPtr));
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c
index 9c9df3836..7daaed8cf 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c
@@ -28,7 +28,7 @@
*
* Permedia accelerated options.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c,v 1.17 2000/01/21 01:12:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/pm_accel.c,v 1.19 2000/06/21 13:35:52 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -213,8 +213,11 @@ PermediaAccelInit(ScreenPtr pScreen)
infoPtr->PolylinesThinSolidFlags = 0;
infoPtr->SetupForSolidLine = PermediaSetupForSolidLine;
infoPtr->SubsequentSolidHorVertLine = PermediaSubsequentHorVertLine;
- infoPtr->SubsequentSolidBresenhamLine =
+ if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR))
+ {
+ infoPtr->SubsequentSolidBresenhamLine =
PermediaSubsequentSolidBresenhamLine;
+ }
infoPtr->PolySegmentThinSolid = PermediaPolySegmentThinSolidWrapper;
infoPtr->PolylinesThinSolid = PermediaPolylinesThinSolidWrapper;
@@ -1239,6 +1242,7 @@ PermediaPolySegmentThinSolidWrapper(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
XAAPolySegment(pDraw, pGC, nseg, pSeg);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/sx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/sx_accel.c
new file mode 100644
index 000000000..6b550b860
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/sx_accel.c
@@ -0,0 +1,926 @@
+/*
+ * Copyright 1997,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>
+ * Dirk Hohndel, <hohndel@suse.de>
+ * Stefan Dirsch, <sndirsch@suse.de>
+ *
+ * this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
+ * Siemens Nixdorf Informationssysteme
+ *
+ * GLINT 300SX accelerated options.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/sx_accel.c,v 1.3 2000/04/12 14:44:41 tsi Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+#include "fb.h"
+
+#include "miline.h"
+
+#include "glint_regs.h"
+#include "glint.h"
+
+#include "xaalocal.h" /* For replacements */
+
+static void SXSync(ScrnInfoPtr pScrn);
+static void SXSetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask);
+static void SXSubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y,
+ int w, int h);
+static void SXSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx,
+ int patterny,
+ int fg, int bg, int rop,
+ unsigned int planemask);
+static void SXSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx,
+ int patterny, int x, int y,
+ int w, int h);
+static void SXSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir,
+ int rop, unsigned int planemask,
+ int transparency_color);
+static void SXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1,
+ int x2, int y2, int w, int h);
+static void SXWriteBitmap(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);
+static void SXSetClippingRectangle(ScrnInfoPtr pScrn, int x1, int y1,
+ int x2,int y2);
+static void SXDisableClipping(ScrnInfoPtr pScrn);
+static void SXWritePixmap(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ unsigned char *src, int srcwidth, int rop,
+ unsigned int planemask, int trans,
+ int bpp, int depth);
+static void SXSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg,
+ int bg, int rop, unsigned int planemask);
+static void SXSubsequentCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x,
+ int y, int w, int h, int skipleft);
+static void SXSetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg,
+ int bg, int rop, unsigned int planemask);
+static void SXSubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x,
+ int y, int w, int h, int skipleft);
+static void SXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno);
+static void SXLoadCoord(ScrnInfoPtr pScrn, int x, int y, int w, int h,
+ int a, int d);
+static void SXSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
+ unsigned int planemask);
+static void SXSubsequentHorVertLine(ScrnInfoPtr pScrn, int x1, int y1,
+ int len, int dir);
+static void SXSubsequentSolidBresenhamLine(ScrnInfoPtr pScrn,
+ int x, int y, int dmaj, int dmin, int e,
+ int len, int octant);
+static void SXPolylinesThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
+ int mode, int npt, DDXPointPtr pPts);
+static void SXPolySegmentThinSolidWrapper(DrawablePtr pDraw, GCPtr pGC,
+ int nseg, xSegment *pSeg);
+
+#define MAX_FIFO_ENTRIES 15
+
+void
+SXInitializeEngine(ScrnInfoPtr pScrn)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ /* Initialize the Accelerator Engine to defaults */
+
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DitherMode);
+ GLINT_SLOW_WRITE_REG(0x400, FilterMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ScissorMode);
+ GLINT_SLOW_WRITE_REG(pGlint->pprod, LBReadMode);
+ GLINT_SLOW_WRITE_REG(pGlint->pprod, FBReadMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWriteMode);
+ GLINT_SLOW_WRITE_REG(UNIT_ENABLE, FBWriteMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureColorMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureReadMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTWindow);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaBlendMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FogMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AntialiasMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AlphaTestMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StencilMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, AreaStippleMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LineStippleMode);
+ GLINT_SLOW_WRITE_REG(0, UpdateLineStippleCounters);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LogicalOpMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, DepthMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, StatisticMode);
+ GLINT_SLOW_WRITE_REG(0xffffffff, FBHardwareWriteMask);
+ GLINT_SLOW_WRITE_REG(0xffffffff, FBSoftwareWriteMask);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RasterizerMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, GLINTDepth);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBSourceOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBPixelOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBSourceOffset);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, WindowOrigin);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, FBWindowBase);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, LBWindowBase);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, TextureAddressMode);
+ GLINT_SLOW_WRITE_REG(UNIT_DISABLE, RouterMode);
+
+ pGlint->ROP = 0xFF;
+ pGlint->ClippingOn = FALSE;
+ pGlint->startxsub = 0;
+ pGlint->startxdom = 0;
+ pGlint->starty = 0;
+ pGlint->count = 0;
+ pGlint->dxdom = 0;
+ pGlint->dy = 1;
+ pGlint->planemask = 0;
+ GLINT_SLOW_WRITE_REG(0, StartXSub);
+ GLINT_SLOW_WRITE_REG(0, StartXDom);
+ GLINT_SLOW_WRITE_REG(0, StartY);
+ GLINT_SLOW_WRITE_REG(0, GLINTCount);
+ GLINT_SLOW_WRITE_REG(0, dXDom);
+ GLINT_SLOW_WRITE_REG(0, dXSub);
+ GLINT_SLOW_WRITE_REG(1<<16, dY);
+}
+
+Bool
+SXAccelInit(ScreenPtr pScreen)
+{
+ XAAInfoRecPtr infoPtr;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ long memory = pGlint->FbMapSize;
+ BoxRec AvailFBArea;
+
+ pGlint->AccelInfoRec = infoPtr = XAACreateInfoRec();
+ if (!infoPtr) return FALSE;
+
+ SXInitializeEngine(pScrn);
+
+ infoPtr->Flags = PIXMAP_CACHE |
+ LINEAR_FRAMEBUFFER |
+ OFFSCREEN_PIXMAPS;
+
+ infoPtr->Sync = SXSync;
+
+ infoPtr->SetClippingRectangle = SXSetClippingRectangle;
+ infoPtr->DisableClipping = SXDisableClipping;
+ infoPtr->ClippingFlags = HARDWARE_CLIP_MONO_8x8_FILL |
+ HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY |
+ HARDWARE_CLIP_SOLID_FILL;
+
+ infoPtr->SolidFillFlags = 0;
+ infoPtr->SetupForSolidFill = SXSetupForFillRectSolid;
+ infoPtr->SubsequentSolidFillRect = SXSubsequentFillRectSolid;
+
+ infoPtr->SolidLineFlags = 0;
+ infoPtr->PolySegmentThinSolidFlags = 0;
+ infoPtr->PolylinesThinSolidFlags = 0;
+ infoPtr->SetupForSolidLine = SXSetupForSolidLine;
+ infoPtr->SubsequentSolidHorVertLine = SXSubsequentHorVertLine;
+ infoPtr->SubsequentSolidBresenhamLine =
+ SXSubsequentSolidBresenhamLine;
+ infoPtr->PolySegmentThinSolid = SXPolySegmentThinSolidWrapper;
+ infoPtr->PolylinesThinSolid = SXPolylinesThinSolidWrapper;
+
+ infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY |
+ ONLY_LEFT_TO_RIGHT_BITBLT;
+ infoPtr->SetupForScreenToScreenCopy = SXSetupForScreenToScreenCopy;
+ infoPtr->SubsequentScreenToScreenCopy = SXSubsequentScreenToScreenCopy;
+
+ infoPtr->Mono8x8PatternFillFlags = HARDWARE_PATTERN_PROGRAMMED_ORIGIN |
+ HARDWARE_PATTERN_SCREEN_ORIGIN |
+ HARDWARE_PATTERN_PROGRAMMED_BITS;
+ infoPtr->SetupForMono8x8PatternFill = SXSetupForMono8x8PatternFill;
+ infoPtr->SubsequentMono8x8PatternFillRect =
+ SXSubsequentMono8x8PatternFillRect;
+
+#if 0
+ if (!pGlint->UsePCIRetry) {
+ infoPtr->ScanlineCPUToScreenColorExpandFillFlags =
+ TRANSPARENCY_ONLY |
+ BIT_ORDER_IN_BYTE_LSBFIRST;
+
+ pGlint->XAAScanlineColorExpandBuffers[0] =
+ xnfalloc(((pScrn->virtualX + 63)/32) *4* (pScrn->bitsPerPixel / 8));
+ pGlint->XAAScanlineColorExpandBuffers[1] =
+ xnfalloc(((pScrn->virtualX + 63)/32) *4* (pScrn->bitsPerPixel / 8));
+
+ infoPtr->NumScanlineColorExpandBuffers = 2;
+ infoPtr->ScanlineColorExpandBuffers =
+ pGlint->XAAScanlineColorExpandBuffers;
+
+ infoPtr->SetupForScanlineCPUToScreenColorExpandFill =
+ SXSetupForScanlineCPUToScreenColorExpandFill;
+ infoPtr->SubsequentScanlineCPUToScreenColorExpandFill =
+ SXSubsequentScanlineCPUToScreenColorExpandFill;
+ infoPtr->SubsequentColorExpandScanline =
+ SXSubsequentColorExpandScanline;
+ } else {
+ infoPtr->CPUToScreenColorExpandFillFlags = TRANSPARENCY_ONLY |
+ SYNC_AFTER_COLOR_EXPAND |
+ CPU_TRANSFER_PAD_DWORD |
+ BIT_ORDER_IN_BYTE_LSBFIRST;
+ infoPtr->ColorExpandBase = pGlint->IOBase + OutputFIFO + 4;
+ infoPtr->SetupForCPUToScreenColorExpandFill =
+ SXSetupForCPUToScreenColorExpandFill;
+ infoPtr->SubsequentCPUToScreenColorExpandFill =
+ SXSubsequentCPUToScreenColorExpandFill;
+ }
+ infoPtr->WriteBitmap = SXWriteBitmap;
+ infoPtr->ColorExpandRange = MAX_FIFO_ENTRIES;
+
+ infoPtr->WritePixmap = SXWritePixmap;
+#endif
+
+ AvailFBArea.x1 = 0;
+ AvailFBArea.y1 = 0;
+ AvailFBArea.x2 = pScrn->displayWidth;
+ if (memory > (16383*1024)) memory = 16383*1024;
+ AvailFBArea.y2 = memory / (pScrn->displayWidth *
+ pScrn->bitsPerPixel / 8);
+
+ xf86InitFBManager(pScreen, &AvailFBArea);
+
+ return (XAAInit(pScreen, infoPtr));
+}
+
+static void SXLoadCoord(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int w, int h,
+ int a, int d
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if (w != pGlint->startxsub) {
+ GLINT_WRITE_REG(w<<16, StartXSub);
+ pGlint->startxsub = w;
+ }
+ if (x != pGlint->startxdom) {
+ GLINT_WRITE_REG(x<<16,StartXDom);
+ pGlint->startxdom = x;
+ }
+ if (y != pGlint->starty) {
+ GLINT_WRITE_REG(y<<16,StartY);
+ pGlint->starty = y;
+ }
+ if (h != pGlint->count) {
+ GLINT_WRITE_REG(h,GLINTCount);
+ pGlint->count = h;
+ }
+ if (a != pGlint->dxdom) {
+ GLINT_WRITE_REG(a<<16,dXDom);
+ pGlint->dxdom = a;
+ }
+ if (d != pGlint->dy) {
+ GLINT_WRITE_REG(d<<16,dY);
+ pGlint->dy = d;
+ }
+}
+
+static void MoveDWORDS(
+ 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);
+}
+
+static void
+SXSync(
+ ScrnInfoPtr pScrn
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CARD32 readValue;
+
+ CHECKCLIPPING;
+
+ while (GLINT_READ_REG(DMACount) != 0);
+ GLINT_WAIT(3);
+ GLINT_WRITE_REG(0x400, FilterMode);
+ GLINT_WRITE_REG(0, GlintSync);
+ do {
+ while(GLINT_READ_REG(OutFIFOWords) == 0);
+#define Sync_tag 0x188
+ readValue = GLINT_READ_REG(OutputFIFO);
+ } while (readValue != Sync_tag);
+}
+
+static void
+SXSetupForFillRectSolid(
+ ScrnInfoPtr pScrn,
+ int color, int rop,
+ unsigned int planemask
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ pGlint->ForeGroundColor = color;
+
+ GLINT_WAIT(6);
+ REPLICATE(color);
+ DO_PLANEMASK(planemask);
+ if (pScrn->bitsPerPixel >= 24) {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, ConstantColor);
+ pGlint->FrameBufferReadMode = 0;
+ } else
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, FBBlockColor);
+ pGlint->FrameBufferReadMode = FastFillEnable;
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(color, ConstantColor);
+ pGlint->FrameBufferReadMode = 0;
+ }
+ LOADROP(rop);
+}
+
+static void
+SXSubsequentFillRectSolid(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int w, int h
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(8);
+ SXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
+ GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode,Render);
+}
+
+static void
+SXSetClippingRectangle(
+ ScrnInfoPtr pScrn,
+ int x1, int y1,
+ int x2, int y2
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(5);
+ GLINT_WRITE_REG((y1&0xFFFF)<<16|(x1&0xFFFF), ScissorMinXY);
+ GLINT_WRITE_REG((y2&0xFFFF)<<16|(x2&0xFFFF), ScissorMaxXY);
+ GLINT_WRITE_REG(1, ScissorMode); /* Enable Scissor Mode */
+ pGlint->ClippingOn = TRUE;
+}
+
+static void
+SXDisableClipping(
+ ScrnInfoPtr pScrn
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CHECKCLIPPING;
+}
+
+static void
+SXSetupForScreenToScreenCopy(
+ ScrnInfoPtr pScrn,
+ int xdir, int ydir,
+ int rop,
+ unsigned int planemask,
+ int transparency_color
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ pGlint->BltScanDirection = ydir;
+
+ GLINT_WAIT(6);
+ DO_PLANEMASK(planemask);
+
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_SrcEnable, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_SrcEnable | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+}
+
+static void
+SXSubsequentScreenToScreenCopy(
+ ScrnInfoPtr pScrn,
+ int x1, int y1,
+ int x2, int y2,
+ int w, int h
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int srcaddr, dstaddr;
+
+ GLINT_WAIT(10);
+
+ srcaddr = y1 * pScrn->displayWidth + x1;
+ dstaddr = y2 * pScrn->displayWidth + x2;
+ GLINT_WRITE_REG(srcaddr - dstaddr, FBSourceOffset);
+
+ if (pGlint->BltScanDirection != 1) {
+ y1 += h - 1;
+ y2 += h - 1;
+ SXLoadCoord(pScrn, x2, y2, x2+w, h, 0, -1);
+ } else {
+ SXLoadCoord(pScrn, x2, y2, x2+w, h, 0, 1);
+ }
+
+ GLINT_WRITE_REG(PrimitiveTrapezoid, Render);
+}
+
+static void
+SXSetupForScanlineCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ REPLICATE(fg);
+ REPLICATE(bg);
+ GLINT_WAIT(6);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(0, RasterizerMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode);
+ pGlint->FrameBufferReadMode = FastFillEnable;
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode);
+ pGlint->FrameBufferReadMode = FastFillEnable | SpanOperation;
+ GLINT_WRITE_REG(fg, PatternRamData0);
+ }
+ LOADROP(rop);
+}
+
+static void
+SXSubsequentScanlineCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int skipleft
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ pGlint->dwords = ((w + 31) >> 5); /* dwords per scanline */
+
+ pGlint->cpucount = y;
+ pGlint->cpuheight = h;
+ GLINT_WAIT(6);
+ SXLoadCoord(pScrn, x, pGlint->cpucount, x+w, 1, 0, 1);
+}
+
+static void
+SXSubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno)
+{
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CARD32 *src;
+ int dwords = pGlint->dwords;
+
+ GLINT_WAIT(7);
+ SXLoadCoord(pScrn, pGlint->startxdom, pGlint->cpucount, pGlint->startxsub, 1, 0, 1);
+
+ GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode | SyncOnBitMask,
+ Render);
+
+ src = (CARD32*)pGlint->XAAScanlineColorExpandBuffers[bufno];
+ while (dwords >= infoRec->ColorExpandRange) {
+ GLINT_WAIT(infoRec->ColorExpandRange);
+ GLINT_WRITE_REG((infoRec->ColorExpandRange - 2)<<16 | 0x0D, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src,
+ infoRec->ColorExpandRange - 1);
+ dwords -= (infoRec->ColorExpandRange - 1);
+ src += (infoRec->ColorExpandRange - 1);
+ }
+ if (dwords) {
+ GLINT_WAIT(dwords);
+ GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4), src,dwords);
+ }
+ pGlint->cpucount += 1;
+}
+
+static void
+SXSetupForCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int fg, int bg,
+ int rop,
+ unsigned int planemask
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ REPLICATE(fg);
+
+ DO_PLANEMASK(planemask);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ GLINT_WRITE_REG(UNIT_DISABLE, PatternRamMode);
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ pGlint->FrameBufferReadMode = FastFillEnable;
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ GLINT_WRITE_REG(UNIT_ENABLE, PatternRamMode);
+ GLINT_WRITE_REG(fg, PatternRamData0);
+ pGlint->FrameBufferReadMode = FastFillEnable | SpanOperation;
+ }
+ LOADROP(rop);
+}
+
+static void
+SXSubsequentCPUToScreenColorExpandFill(
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ int skipleft
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int dwords = ((w + 31) >> 5) * h;
+
+ SXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
+ GLINT_WRITE_REG(PrimitiveTrapezoid | pGlint->FrameBufferReadMode |
+ SyncOnBitMask, Render);
+ GLINT_WRITE_REG((dwords - 1)<<16 | 0x0D, OutputFIFO);
+}
+
+void SXSetupForMono8x8PatternFill(
+ ScrnInfoPtr pScrn,
+ int patternx, int patterny,
+ int fg, int bg, int rop,
+ unsigned int planemask
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ if (bg == -1) pGlint->FrameBufferReadMode = -1;
+ else pGlint->FrameBufferReadMode = 0;
+ pGlint->ForeGroundColor = fg;
+ pGlint->BackGroundColor = bg;
+ REPLICATE(pGlint->ForeGroundColor);
+ REPLICATE(pGlint->BackGroundColor);
+
+ GLINT_WAIT(13);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG((patternx & 0x000000FF), AreaStipplePattern0);
+ GLINT_WRITE_REG((patternx & 0x0000FF00) >> 8, AreaStipplePattern1);
+ GLINT_WRITE_REG((patternx & 0x00FF0000) >> 16, AreaStipplePattern2);
+ GLINT_WRITE_REG((patternx & 0xFF000000) >> 24, AreaStipplePattern3);
+ GLINT_WRITE_REG((patterny & 0x000000FF), AreaStipplePattern4);
+ GLINT_WRITE_REG((patterny & 0x0000FF00) >> 8, AreaStipplePattern5);
+ GLINT_WRITE_REG((patterny & 0x00FF0000) >> 16, AreaStipplePattern6);
+ GLINT_WRITE_REG((patterny & 0xFF000000) >> 24, AreaStipplePattern7);
+
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ if (rop == GXcopy)
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ else
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ LOADROP(rop);
+}
+
+static void
+SXSubsequentMono8x8PatternFillRect(
+ ScrnInfoPtr pScrn,
+ int patternx, int patterny,
+ int x, int y,
+ int w, int h
+){
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int span = 0;
+
+ GLINT_WAIT(12);
+ SXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
+
+ if (pGlint->FrameBufferReadMode != -1) {
+ GLINT_WRITE_REG(pGlint->BackGroundColor, ConstantColor);
+ GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|ASM_InvertPattern |
+ UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | PrimitiveTrapezoid, Render);
+ }
+
+ GLINT_WRITE_REG(pGlint->ForeGroundColor, ConstantColor);
+ GLINT_WRITE_REG(2<<1|2<<4|patternx<<7|patterny<<12|
+ UNIT_ENABLE, AreaStippleMode);
+ GLINT_WRITE_REG(AreaStippleEnable | PrimitiveTrapezoid, Render);
+}
+
+static void
+SXWriteBitmap(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);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ unsigned char *srcpntr;
+ int dwords, height, mode;
+ Bool SecondPass = FALSE;
+ register int count;
+ register CARD32* pattern;
+
+ w += skipleft;
+ x -= skipleft;
+ dwords = (w + 31) >> 5;
+
+ SXSetClippingRectangle(pScrn,x+skipleft, y, x+w, y+h);
+
+ GLINT_WAIT(11);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(0, RasterizerMode);
+ LOADROP(rop);
+ if (rop == GXcopy) {
+ mode = FastFillEnable;
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ mode = 0;
+ GLINT_WRITE_REG(UNIT_ENABLE, ColorDDAMode);
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ SXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
+
+ if(bg == -1) {
+ /* >>>>> set fg <<<<<<<< */
+ REPLICATE(fg);
+ GLINT_WAIT(3);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, PatternRamData0);
+ }
+ } else if(rop == GXcopy) {
+ REPLICATE(bg);
+ GLINT_WAIT(5);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(bg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(bg, PatternRamData0);
+ }
+ GLINT_WRITE_REG(PrimitiveTrapezoid |mode|FastFillEnable,Render);
+ REPLICATE(fg);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, PatternRamData0);
+ }
+ } else {
+ SecondPass = TRUE;
+ REPLICATE(fg);
+ GLINT_WAIT(3);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(fg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(fg, PatternRamData0);
+ }
+ }
+
+SECOND_PASS:
+ GLINT_WRITE_REG(PrimitiveTrapezoid | FastFillEnable | mode | SyncOnBitMask, Render);
+
+ height = h;
+ srcpntr = src;
+ while(height--) {
+ count = dwords >> 3;
+ pattern = (CARD32*)srcpntr;
+ while(count--) {
+ GLINT_WAIT(8);
+ GLINT_WRITE_REG(*(pattern), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+1), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+2), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+3), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+4), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+5), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+6), BitMaskPattern);
+ GLINT_WRITE_REG(*(pattern+7), BitMaskPattern);
+ pattern+=8;
+ }
+ count = dwords & 0x07;
+ GLINT_WAIT(count);
+ while (count--)
+ GLINT_WRITE_REG(*(pattern++), BitMaskPattern);
+ srcpntr += srcwidth;
+ }
+
+ if(SecondPass) {
+ SecondPass = FALSE;
+ REPLICATE(bg);
+ GLINT_WAIT(4);
+ GLINT_WRITE_REG(InvertBitMask, RasterizerMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(bg, FBBlockColor);
+ } else {
+ GLINT_WRITE_REG(bg, PatternRamData0);
+ }
+ goto SECOND_PASS;
+ }
+
+ GLINT_WAIT(2);
+ GLINT_WRITE_REG(0, RasterizerMode);
+ CHECKCLIPPING;
+ SET_SYNC_FLAG(infoRec);
+}
+
+static void
+SXWritePixmap(
+ 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);
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ CARD32 *srcp;
+ int count,dwords, skipleft, Bpp = bpp >> 3;
+
+ if((skipleft = (long)src & 0x03L)) {
+ skipleft /= Bpp;
+
+ x -= skipleft;
+ w += skipleft;
+
+ src = (unsigned char*)((long)src & ~0x03L);
+ }
+
+ switch(Bpp) {
+ case 1: dwords = (w + 3) >> 2;
+ break;
+ case 2: dwords = (w + 1) >> 1;
+ break;
+ case 4: dwords = w;
+ break;
+ default: return;
+ }
+
+ SXSetClippingRectangle(pScrn,x+skipleft, y, x+w, y+h);
+
+ GLINT_WAIT(12);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+ SXLoadCoord(pScrn, x, y, x+w, h, 0, 1);
+ GLINT_WRITE_REG(PrimitiveTrapezoid | SyncOnHostData, Render);
+
+ while(h--) {
+ count = dwords;
+ srcp = (CARD32*)src;
+ while(count >= infoRec->ColorExpandRange) {
+ GLINT_WAIT(infoRec->ColorExpandRange);
+ /* (0x0f << 4) | 0x0e is the TAG for GLINTColor */
+ GLINT_WRITE_REG(((infoRec->ColorExpandRange - 2) << 16) | (0x0F << 4) |
+ 0x0E, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, infoRec->ColorExpandRange - 1);
+ count -= infoRec->ColorExpandRange - 1;
+ srcp += infoRec->ColorExpandRange - 1;
+ }
+ if(count) {
+ GLINT_WAIT(count);
+ /* (0x0F << 4) | 0x0E is the TAG for GLINTColor */
+ GLINT_WRITE_REG(((count - 1) << 16) | (0x0f << 4) |
+ 0x0e, OutputFIFO);
+ MoveDWORDS((CARD32*)((char*)pGlint->IOBase + OutputFIFO + 4),
+ (CARD32*)srcp, count);
+ }
+ src += srcwidth;
+ }
+ CHECKCLIPPING;
+ SET_SYNC_FLAG(infoRec);
+}
+
+static void
+SXPolylinesThinSolidWrapper(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int mode,
+ int npt,
+ DDXPointPtr pPts
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
+ pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
+ if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
+ XAAPolyLines(pDraw, pGC, mode, npt, pPts);
+}
+
+static void
+SXPolySegmentThinSolidWrapper(
+ DrawablePtr pDraw,
+ GCPtr pGC,
+ int nseg,
+ xSegment *pSeg
+){
+ XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_GC(pGC);
+ GLINTPtr pGlint = GLINTPTR(infoRec->pScrn);
+ pGlint->CurrentGC = pGC;
+ pGlint->CurrentDrawable = pDraw;
+ if(infoRec->NeedToSync) (*infoRec->Sync)(infoRec->pScrn);
+ XAAPolySegment(pDraw, pGC, nseg, pSeg);
+}
+
+static void
+SXSetupForSolidLine(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(7);
+ DO_PLANEMASK(planemask);
+ GLINT_WRITE_REG(color, GLINTColor);
+ GLINT_WRITE_REG(UNIT_DISABLE, ColorDDAMode);
+ if (rop == GXcopy) {
+ GLINT_WRITE_REG(pGlint->pprod, FBReadMode);
+ } else {
+ GLINT_WRITE_REG(pGlint->pprod | FBRM_DstEnable, FBReadMode);
+ }
+ LOADROP(rop);
+}
+
+static void
+SXSubsequentHorVertLine(ScrnInfoPtr pScrn,int x,int y,int len,int dir)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+
+ GLINT_WAIT(9);
+ if (dir == DEGREES_0) {
+ SXLoadCoord(pScrn, x, y, 0, len, 1, 0);
+ } else {
+ SXLoadCoord(pScrn, x, y, 0, len, 0, 1);
+ }
+
+ GLINT_WRITE_REG(PrimitiveLine, Render);
+}
+
+static void
+SXSubsequentSolidBresenhamLine( ScrnInfoPtr pScrn,
+ int x, int y, int dmaj, int dmin, int e, int len, int octant)
+{
+ GLINTPtr pGlint = GLINTPTR(pScrn);
+ int dxdom, dy;
+
+ if(dmaj == dmin) {
+ GLINT_WAIT(9);
+ if(octant & YDECREASING) {
+ dy = -1;
+ } else {
+ dy = 1;
+ }
+
+ if(octant & XDECREASING) {
+ dxdom = -1;
+ } else {
+ dxdom = 1;
+ }
+
+ SXLoadCoord(pScrn, x, y, 0, len, dxdom, dy);
+ GLINT_WRITE_REG(PrimitiveLine, Render);
+ return;
+ }
+
+ fbBres(pGlint->CurrentDrawable, pGlint->CurrentGC, 0,
+ (octant & XDECREASING) ? -1 : 1,
+ (octant & YDECREASING) ? -1 : 1,
+ (octant & YMAJOR) ? Y_AXIS : X_AXIS,
+ x, y, dmin + e, dmin, -dmaj, len);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c
index 4a6aa676a..2f08ac36d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c
@@ -28,7 +28,7 @@
*
* GLINT 500TX / MX accelerated options.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.19 2000/01/21 01:12:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_accel.c,v 1.22 2000/05/10 20:01:32 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -209,8 +209,11 @@ TXAccelInit(ScreenPtr pScreen)
infoPtr->PolylinesThinSolidFlags = 0;
infoPtr->SetupForSolidLine = TXSetupForSolidLine;
infoPtr->SubsequentSolidHorVertLine = TXSubsequentHorVertLine;
- infoPtr->SubsequentSolidBresenhamLine =
+ if (!(pScrn->overlayFlags & OVERLAY_8_32_PLANAR))
+ {
+ infoPtr->SubsequentSolidBresenhamLine =
TXSubsequentSolidBresenhamLine;
+ }
infoPtr->PolySegmentThinSolid = TXPolySegmentThinSolidWrapper;
infoPtr->PolylinesThinSolid = TXPolylinesThinSolidWrapper;
@@ -282,6 +285,7 @@ static void TXLoadCoord(
){
GLINTPtr pGlint = GLINTPTR(pScrn);
+#ifndef XF86DRI
if (w != pGlint->startxsub) {
GLINT_WRITE_REG(w<<16, StartXSub);
pGlint->startxsub = w;
@@ -306,6 +310,20 @@ static void TXLoadCoord(
GLINT_WRITE_REG(d<<16,dY);
pGlint->dy = d;
}
+#else
+ GLINT_WRITE_REG(w<<16, StartXSub);
+ pGlint->startxsub = w;
+ GLINT_WRITE_REG(x<<16,StartXDom);
+ pGlint->startxdom = x;
+ GLINT_WRITE_REG(y<<16,StartY);
+ pGlint->starty = y;
+ GLINT_WRITE_REG(h,GLINTCount);
+ pGlint->count = h;
+ GLINT_WRITE_REG(a<<16,dXDom);
+ pGlint->dxdom = a;
+ GLINT_WRITE_REG(d<<16,dY);
+ pGlint->dy = d;
+#endif
}
static void MoveDWORDS(
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c
index c2cc94452..eaab5bb5b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c
@@ -27,7 +27,7 @@
* this work is sponsored by S.u.S.E. GmbH, Fuerth, Elsa GmbH, Aachen and
* Siemens Nixdorf Informationssysteme
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c,v 1.8 1999/03/28 15:32:39 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/glint/tx_dac.c,v 1.10 2000/05/10 18:55:30 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -37,6 +37,7 @@
#include "xf86Pci.h"
#include "IBM.h"
+#include "TI.h"
#include "glint_regs.h"
#include "glint.h"
@@ -46,7 +47,8 @@ Shiftbpp(ScrnInfoPtr pScrn, int value)
GLINTPtr pGlint = GLINTPTR(pScrn);
int logbytesperaccess;
- if (pGlint->RamDac->RamDacType == (IBM640_RAMDAC))
+ if ( (pGlint->RamDac->RamDacType == (IBM640_RAMDAC)) ||
+ (pGlint->RamDac->RamDacType == (TI3030_RAMDAC)) )
logbytesperaccess = 4;
else
logbytesperaccess = 3;
@@ -91,11 +93,14 @@ TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->glintRegs[Aperture1 >> 3] = 0;
if (pGlint->UsePCIRetry) {
- pReg->glintRegs[DFIFODis >> 3] = 1;
- pReg->glintRegs[FIFODis >> 3] = 3;
+ pReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis) | 0x01;
+ if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA)
+ pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x01;
+ else
+ pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x03;
} else {
- pReg->glintRegs[DFIFODis >> 3] = 0;
- pReg->glintRegs[FIFODis >> 3] = 1;
+ pReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis) & 0xFFFFFFFE;
+ pReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis) | 0x01;
}
temp1 = mode->CrtcHSyncStart - mode->CrtcHDisplay;
@@ -124,7 +129,7 @@ TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
* tell DAC to use the ICD chip clock 0 as ref clock
* and set up some more video timining generator registers
*/
- pReg->glintRegs[VTGSerialClk >> 3] = 0x05;
+ pReg->glintRegs[VTGSerialClk >> 3] = 0x05;
/* This is ugly */
if (pGlint->UseFireGL3000) {
@@ -141,6 +146,21 @@ TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->glintRegs[VTGModeCtl >> 3] = 0x44;
}
+ /* Override FBModeSel for 300SX chip */
+ if (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_300SX) {
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ pReg->glintRegs[FBModeSel >> 3] = 0x905;
+ break;
+ case 16:
+ pReg->glintRegs[FBModeSel >> 3] = 0x903;
+ break;
+ case 32:
+ pReg->glintRegs[FBModeSel >> 3] = 0x901;
+ break;
+ }
+ }
+
switch (pGlint->RamDac->RamDacType) {
case IBM526DB_RAMDAC:
case IBM526_RAMDAC:
@@ -208,6 +228,49 @@ TXInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
ramdacReg->DacRegs[RGB640_VRAM_MASK2] = 0x0F;
pReg->glintRegs[VTGModeCtl >> 3] = 0x04;
+ break;
+
+ case TI3026_RAMDAC:
+ case TI3030_RAMDAC:
+ {
+ /* Get the programmable clock values */
+ unsigned long m=0,n=0,p=0;
+ unsigned long clock;
+ int count;
+ unsigned long q, status, VCO;
+
+ clock = TIramdacCalculateMNPForClock(pGlint->RefClock,
+ mode->Clock, 1, pGlint->MinClock, pGlint->MaxClock, &m, &n, &p);
+
+ ramdacReg->DacRegs[TIDAC_PIXEL_N] = ((n & 0x3f) | 0xC0);
+ ramdacReg->DacRegs[TIDAC_PIXEL_M] = (m & 0x3f) ;
+ ramdacReg->DacRegs[TIDAC_PIXEL_P] = ((p & 0x03) | 0xbc);
+ ramdacReg->DacRegs[TIDAC_PIXEL_VALID] = TRUE;
+
+ if (pGlint->RamDac->RamDacType == (TI3026_RAMDAC))
+ n = 65 - ((64 << 2) / pScrn->bitsPerPixel);
+ else
+ n = 65 - ((128 << 2) / pScrn->bitsPerPixel);
+ m = 61;
+ p = 0;
+ for (q = 0; q < 8; q++) {
+ if (q > 0) p = 3;
+ for ( ; p < 4; p++) {
+ VCO = ((clock * (q + 1) * (65 - m)) / (65 - n)) << (p + 1);
+ if (VCO >= 110000) { break; }
+ }
+ if (VCO >= 110000) { break; }
+ }
+ ramdacReg->DacRegs[TIDAC_clock_ctrl] = (q | 0x38);
+
+ ramdacReg->DacRegs[TIDAC_LOOP_N] = ((n & 0x3f) | 0xC0);
+ ramdacReg->DacRegs[TIDAC_LOOP_M] = (m & 0x3f) ;
+ ramdacReg->DacRegs[TIDAC_LOOP_P] = ((p & 0x03) | 0xF0);
+ ramdacReg->DacRegs[TIDAC_LOOP_VALID] = TRUE;
+ }
+ if (pGlint->RamDac->RamDacType == (TI3030_RAMDAC))
+ pReg->glintRegs[VTGModeCtl >> 3] = 0x04;
+ break;
}
/* Now use helper routines to setup bpp for this driver */
@@ -224,8 +287,14 @@ TXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
glintReg->glintRegs[Aperture0 >> 3] = GLINT_READ_REG(Aperture0);
glintReg->glintRegs[Aperture1 >> 3] = GLINT_READ_REG(Aperture1);
- glintReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis);
- glintReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis);
+ if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA))
+ glintReg->glintRegs[DFIFODis >> 3] = GLINT_READ_REG(DFIFODis);
+
+ if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_300SX) {
+ glintReg->glintRegs[FIFODis >> 3] = GLINT_READ_REG(FIFODis);
+ glintReg->glintRegs[VTGModeCtl >> 3] = GLINT_READ_REG(VTGModeCtl);
+ }
glintReg->glintRegs[VClkCtl >> 3] = GLINT_READ_REG(VClkCtl);
glintReg->glintRegs[VTGPolarity >> 3] = GLINT_READ_REG(VTGPolarity);
@@ -241,7 +310,6 @@ TXSave(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
glintReg->glintRegs[VTGVGateEnd >> 3] = GLINT_READ_REG(VTGVGateEnd);
glintReg->glintRegs[VTGSerialClk >> 3] = GLINT_READ_REG(VTGSerialClk);
glintReg->glintRegs[FBModeSel >> 3] = GLINT_READ_REG(FBModeSel);
- glintReg->glintRegs[VTGModeCtl >> 3] = GLINT_READ_REG(VTGModeCtl);
glintReg->glintRegs[VTGHGateStart >> 3] = GLINT_READ_REG(VTGHGateStart);
glintReg->glintRegs[VTGHGateEnd >> 3] = GLINT_READ_REG(VTGHGateEnd);
}
@@ -251,23 +319,21 @@ TXRestore(ScrnInfoPtr pScrn, GLINTRegPtr glintReg)
{
GLINTPtr pGlint = GLINTPTR(pScrn);
-#if 1
- GLINT_SLOW_WRITE_REG(0, ResetStatus);
- while(GLINT_READ_REG(ResetStatus) != 0) {
- xf86MsgVerb(X_INFO, 2, "Resetting Engine - Please Wait.\n");
- };
-#endif
-
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture0 >> 3], Aperture0);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[Aperture1 >> 3], Aperture1);
- GLINT_SLOW_WRITE_REG(glintReg->glintRegs[DFIFODis >> 3], DFIFODis);
- GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FIFODis >> 3], FIFODis);
+ if ((pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_DELTA) ||
+ (pGlint->Chipset == PCI_VENDOR_3DLABS_CHIP_GAMMA))
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[DFIFODis >> 3], DFIFODis);
+
+ if (pGlint->Chipset != PCI_VENDOR_3DLABS_CHIP_300SX) {
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[FIFODis >> 3], FIFODis);
+ GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGModeCtl >> 3], VTGModeCtl);
+ }
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGPolarity >> 3], VTGPolarity);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VClkCtl >> 3], VClkCtl);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGSerialClk >> 3], VTGSerialClk);
- GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGModeCtl >> 3], VTGModeCtl);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHLimit >> 3], VTGHLimit);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHSyncStart >> 3],VTGHSyncStart);
GLINT_SLOW_WRITE_REG(glintReg->glintRegs[VTGHSyncEnd >> 3], VTGHSyncEnd);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp b/xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp
index 41150123e..9cced26d4 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp,v 1.1 2000/03/03 01:05:38 dawes Exp $
-.TH I740 __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740.cpp,v 1.4 2000/06/14 02:13:10 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH I740 __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
i740 \- Intel i740 video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""i740"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qi740\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B i740
is an XFree86 driver for Intel i740 video cards.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_accel.c
index 4195a8e49..21f5bbbab 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_accel.c
@@ -25,7 +25,7 @@ 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/drivers/i740/i740_accel.c,v 1.3 2000/02/23 04:47:13 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740_accel.c,v 1.4 2000/04/05 18:13:47 dawes Exp $ */
/*
* Authors:
@@ -33,7 +33,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
+#if 0
#include <math.h>
+#endif
#include "xf86.h"
#include "xf86_OSproc.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c
index 44a78034f..ec6e2b9e7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c
@@ -25,7 +25,7 @@ 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/drivers/i740/i740_driver.c,v 1.18 2000/03/06 23:54:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i740/i740_driver.c,v 1.21 2000/06/21 17:28:07 dawes Exp $ */
/*
* Authors:
@@ -361,7 +361,6 @@ I740Probe(DriverPtr drv, int flags) {
int i, numUsed, numDevSections, *usedChips;
GDevPtr *devSections = NULL;
Bool foundScreen = FALSE;
- EntityInfoPtr pEnt;
/*
Find the config file Device sections that match this
@@ -384,37 +383,31 @@ I740Probe(DriverPtr drv, int flags) {
drv, &usedChips);
if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i=0; i<numUsed; i++) {
- pEnt = xf86GetEntityInfo(usedChips[i]);
-
- if (pEnt->active) {
- ScrnInfoPtr pScrn;
-
- /* Allocate new ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = I740_DRIVER_NAME;
- pScrn->name = I740_NAME;
- pScrn->Probe = I740Probe;
- pScrn->PreInit = I740PreInit;
- pScrn->ScreenInit = I740ScreenInit;
- pScrn->SwitchMode = I740SwitchMode;
- pScrn->AdjustFrame = I740AdjustFrame;
- pScrn->EnterVT = I740EnterVT;
- pScrn->LeaveVT = I740LeaveVT;
- pScrn->FreeScreen = I740FreeScreen;
- pScrn->ValidMode = I740ValidMode;
- foundScreen = TRUE;
-
- xf86ConfigActivePciEntity(pScrn, usedChips[i], I740PciChipsets, 0, 0, 0, 0, 0);
- }
- xfree(pEnt);
- }
- xfree(usedChips);
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i=0; i<numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ /* Allocate new ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ I740PciChipsets, 0, 0, 0, 0, 0))) {
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = I740_DRIVER_NAME;
+ pScrn->name = I740_NAME;
+ pScrn->Probe = I740Probe;
+ pScrn->PreInit = I740PreInit;
+ pScrn->ScreenInit = I740ScreenInit;
+ pScrn->SwitchMode = I740SwitchMode;
+ pScrn->AdjustFrame = I740AdjustFrame;
+ pScrn->EnterVT = I740EnterVT;
+ pScrn->LeaveVT = I740LeaveVT;
+ pScrn->FreeScreen = I740FreeScreen;
+ pScrn->ValidMode = I740ValidMode;
+ foundScreen = TRUE;
+
+ }
+ }
}
+
/* Look for Real3D based chips */
numUsed = xf86MatchPciInstances(I740_NAME, PCI_VENDOR_REAL3D,
@@ -423,53 +416,42 @@ I740Probe(DriverPtr drv, int flags) {
drv, &usedChips);
if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i=0; i<numUsed; i++) {
- pEnt = xf86GetEntityInfo(usedChips[i]);
-
- if (pEnt->active) {
- ScrnInfoPtr pScrn;
-
- /* Allocate new ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = I740_DRIVER_NAME;
- pScrn->name = I740_NAME;
- pScrn->Probe = I740Probe;
- pScrn->PreInit = I740PreInit;
- pScrn->ScreenInit = I740ScreenInit;
- pScrn->SwitchMode = I740SwitchMode;
- pScrn->AdjustFrame = I740AdjustFrame;
- pScrn->EnterVT = I740EnterVT;
- pScrn->LeaveVT = I740LeaveVT;
- pScrn->FreeScreen = I740FreeScreen;
- pScrn->ValidMode = I740ValidMode;
- foundScreen = TRUE;
-
- xf86ConfigActivePciEntity(pScrn, usedChips[i], I740PciChipsets, 0, 0, 0, 0, 0);
- }
- xfree(pEnt);
- }
- xfree(usedChips);
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i=0; i<numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ I740PciChipsets, 0, 0, 0, 0, 0))) {
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = I740_DRIVER_NAME;
+ pScrn->name = I740_NAME;
+ pScrn->Probe = I740Probe;
+ pScrn->PreInit = I740PreInit;
+ pScrn->ScreenInit = I740ScreenInit;
+ pScrn->SwitchMode = I740SwitchMode;
+ pScrn->AdjustFrame = I740AdjustFrame;
+ pScrn->EnterVT = I740EnterVT;
+ pScrn->LeaveVT = I740LeaveVT;
+ pScrn->FreeScreen = I740FreeScreen;
+ pScrn->ValidMode = I740ValidMode;
+ foundScreen = TRUE;
+ }
+ }
}
-
+
if (devSections)
- xfree(devSections);
-
+ xfree(devSections);
+
return foundScreen;
}
-extern xf86MonPtr ConfiguredMonitor;
-
void
I740ProbeDDC(ScrnInfoPtr pScrn, int index)
{
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
pVbe = VBEInit(NULL,index);
- ConfiguredMonitor = vbeDoEDID(pVbe);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
}
}
@@ -738,7 +720,7 @@ I740PreInit(ScrnInfoPtr pScrn, int flags) {
pI740->MaxClock = 86000;
}
}
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next=NULL;
clockRanges->minClock= 12000; /* !!! What's the min clock? !!! */
clockRanges->maxClock=pI740->MaxClock;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
index 331396f38..c40e94225 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v 1.4 2000/03/03 01:05:38 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/Imakefile,v 1.9 2000/06/30 17:15:11 dawes Exp $
XCOMM
XCOMM This is the Imakefile for the i810 driver.
XCOMM
@@ -6,23 +6,19 @@ XCOMM
#define IHaveModules
#include <Server.tmpl>
-#
-# Uncomment these to build with DRI support when available
-#
-#undef BuildXF86DRI
#if BuildXF86DRI
-DRISRCS = i810_dri.c i810_drm.c
-DRIOBJS = i810_dri.o i810_drm.o
+DRISRCS = i810_dri.c
+DRIOBJS = i810_dri.o
DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \
- -I$(XF86OSSRC)/linux/drm/kernel
+ -I$(XF86OSSRC)/linux/drm/kernel -I$(TOP)/include
DRIDEFINES = $(GLX_DEFINES)
#endif
SRCS = i810_driver.c i810_cursor.c i810_accel.c i810_io.c \
- i810_memory.c i810_wmark.c $(DRISRCS)
+ i810_memory.c i810_wmark.c i810_dga.c $(DRISRCS)
OBJS = i810_driver.o i810_cursor.o i810_accel.o i810_io.o \
- i810_memory.o i810_wmark.o $(DRIOBJS)
+ i810_memory.o i810_wmark.o i810_dga.o $(DRIOBJS)
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
@@ -32,7 +28,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(XF86SRC)/xaa -I$(XF86SRC)/rac \
-I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \
-I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \
- -I$(SERVERSRC)/Xext \
+ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf24_32bpp \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-I$(EXTINCSRC) \
$(DRIINCLUDES)
@@ -61,13 +57,12 @@ InstallDriverSDKNonExecFile(i810.h,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_accel.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_cursor.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_driver.c,$(DRIVERSDKDIR)/drivers/i810)
+InstallDriverSDKNonExecFile(i810_dga.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_dri.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_dri.h,$(DRIVERSDKDIR)/drivers/i810)
-InstallDriverSDKNonExecFile(i810_dripriv.h,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_io.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_memory.c,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_wmark.c,$(DRIVERSDKDIR)/drivers/i810)
-InstallDriverSDKNonExecFile(i810_macros.h,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKNonExecFile(i810_reg.h,$(DRIVERSDKDIR)/drivers/i810)
InstallDriverSDKObjectModule(i810,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp
index 2587db57d..88a1c572b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp,v 1.1 2000/03/03 01:05:39 dawes Exp $
-.TH I810 __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.cpp,v 1.4 2000/06/14 02:13:10 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH I810 __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
i810 \- Intel i810 video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""i810"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qi810\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B i810
is an XFree86 driver for Intel i810 video cards.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
index 6aceea540..c0418c046 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h
@@ -25,7 +25,7 @@ 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/drivers/i810/i810.h,v 1.4 2000/03/02 16:07:48 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810.h,v 1.9 2000/06/22 17:44:03 alanh Exp $ */
/*
* Authors:
@@ -36,16 +36,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef _I810_H_
#define _I810_H_
-
+#include "compiler.h"
#include "xf86PciInfo.h"
#include "xf86Pci.h"
#include "i810_reg.h"
#include "xaa.h"
#include "xf86Cursor.h"
-#undef XF86DRI
-
-
#ifdef XF86DRI
#include "xf86drm.h"
#include "sarea.h"
@@ -57,15 +54,22 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#endif
+#define I810_VERSION 4000
+#define I810_NAME "I810"
+#define I810_DRIVER_NAME "i810"
+#define I810_MAJOR_VERSION 1
+#define I810_MINOR_VERSION 0
+#define I810_PATCHLEVEL 0
+
/* Globals */
typedef struct _I810Rec *I810Ptr;
-typedef void (*I810WriteIndexedByteFunc)(I810Ptr pI810, int addr,
- char index, char value);
-typedef char (*I810ReadIndexedByteFunc)(I810Ptr pI810, int addr, char index);
-typedef void (*I810WriteByteFunc)(I810Ptr pI810, int addr, char value);
-typedef char (*I810ReadByteFunc)(I810Ptr pI810, int addr);
+typedef void (*I810WriteIndexedByteFunc)(I810Ptr pI810, int addr,
+ CARD8 index, CARD8 value);
+typedef CARD8 (*I810ReadIndexedByteFunc)(I810Ptr pI810, int addr, CARD8 index);
+typedef void (*I810WriteByteFunc)(I810Ptr pI810, int addr, CARD8 value);
+typedef CARD8 (*I810ReadByteFunc)(I810Ptr pI810, int addr);
extern void I810SetTiledMemory(ScrnInfoPtr pScrn,
@@ -86,7 +90,7 @@ typedef struct {
typedef struct {
int tail_mask;
I810MemRange mem;
- char *virtual_start;
+ unsigned char *virtual_start;
int head;
int tail;
int space;
@@ -147,6 +151,11 @@ typedef struct _I810Rec {
int CursorPhysical;
int CursorStart;
+ DGAModePtr DGAModes;
+ int numDGAModes;
+ Bool DGAactive;
+ int DGAViewportStatus;
+
int Chipset;
int LinearAddr;
int MMIOAddr;
@@ -211,8 +220,8 @@ typedef struct _I810Rec {
extern Bool I810DRIScreenInit(ScreenPtr pScreen);
extern void I810DRICloseScreen(ScreenPtr pScreen);
extern Bool I810DRIFinishScreenInit(ScreenPtr pScreen);
-extern Bool I810drmInitDma(ScrnInfoPtr pScrn);
-extern Bool I810drmCleanupDma(ScrnInfoPtr pScrn);
+extern Bool I810InitDma(ScrnInfoPtr pScrn);
+extern Bool I810CleanupDma(ScrnInfoPtr pScrn);
#define I810PTR(p) ((I810Ptr)((p)->driverPrivate))
#define I810REGPTR(p) (&(I810PTR(p)->ModeReg))
@@ -237,7 +246,8 @@ extern void I810SetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
extern int I810AllocateGARTMemory( ScrnInfoPtr pScrn );
extern void I810FreeGARTMemory( ScrnInfoPtr pScrn );
-
+extern Bool I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+extern void I810AdjustFrame(int scrnIndex, int x, int y, int flags);
extern void I810SetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
int ydir, int rop,
@@ -276,7 +286,7 @@ extern void I810EmitInvarientState(ScrnInfoPtr pScrn);
#define BEGIN_LP_RING(n) \
unsigned int outring, ringmask; \
- volatile char *virt; \
+ volatile unsigned char *virt; \
if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) I810Sync( pScrn ); \
if (pI810->LpRing.space < n*4) I810WaitLpRing( pScrn, n*4, 0); \
pI810->LpRing.space -= n*4; \
@@ -333,6 +343,25 @@ extern int I810_DEBUG;
*/
#define I810_REG_SIZE 0x80000
+
+#ifndef PCI_CHIP_I810
+#define PCI_CHIP_I810 0x7121
+#define PCI_CHIP_I810_DC100 0x7123
+#define PCI_CHIP_I810_E 0x7125
+#define PCI_CHIP_I815 0x1132
+#define PCI_CHIP_I810_BRIDGE 0x7120
+#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
+#define PCI_CHIP_I810_E_BRIDGE 0x7124
+#define PCI_CHIP_I815_BRIDGE 0x1130
+#endif
+
+
+#define IS_I810(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I810 || \
+ pI810->PciInfo->chipType == PCI_CHIP_I810_DC100 || \
+ pI810->PciInfo->chipType == PCI_CHIP_I810_E)
+#define IS_I815(pI810) (pI810->PciInfo->chipType == PCI_CHIP_I815)
+
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c
index 0f67180d2..e918ad6e1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c
@@ -25,6 +25,7 @@ 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/drivers/i810/i810_accel.c,v 1.5 2000/06/17 18:23:23 dawes Exp $ */
/*
* Authors:
@@ -271,6 +272,7 @@ I810WaitLpRing( ScrnInfoPtr pScrn, int n, int timeout_millis )
DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]);
}
#endif
+ pI810->AccelInfoRec = NULL; /* Stops recursive behavior */
FatalError("lockup\n");
}
@@ -301,13 +303,9 @@ I810Sync( ScrnInfoPtr pScrn )
#ifdef XF86DRI
/* VT switching tries to do this.
*/
- if (!pI810->LockHeld) {
+ if (!pI810->LockHeld && pI810->directRenderingEnabled) {
return;
}
-
-
-/* if (pI810->directRenderingEnabled) */
-/* DRIUnlockLockQueiscent( pScrn->pScreen ); */
#endif
/* Send a flush instruction and then wait till the ring is empty.
@@ -635,12 +633,13 @@ I810RefreshRing(ScrnInfoPtr pScrn)
}
-
+/* Emit on gaining VT?
+ */
void
I810EmitInvarientState(ScrnInfoPtr pScrn)
{
I810Ptr pI810 = I810PTR(pScrn);
- BEGIN_LP_RING( 8 );
+ BEGIN_LP_RING( 10 );
OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 );
@@ -658,5 +657,8 @@ I810EmitInvarientState(ScrnInfoPtr pScrn)
OUT_RING( 0 );
OUT_RING( 0 );
+/* OUT_RING( CMD_OP_Z_BUFFER_INFO ); */
+/* OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */
+
ADVANCE_LP_RING();
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c
new file mode 100644
index 000000000..82b15514e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
+ *
+ * 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>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dga.c,v 1.1 2000/06/22 17:44:03 alanh Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "i810.h"
+#include "i810_reg.h"
+#include "dgaproc.h"
+
+static Bool I810_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
+ int *, int *, int *);
+static Bool I810_SetMode(ScrnInfoPtr, DGAModePtr);
+static void I810_Sync(ScrnInfoPtr);
+static int I810_GetViewport(ScrnInfoPtr);
+static void I810_SetViewport(ScrnInfoPtr, int, int, int);
+static void I810_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
+static void I810_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
+static void I810_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int,
+ unsigned long);
+
+static
+DGAFunctionRec I810DGAFuncs = {
+ I810_OpenFramebuffer,
+ NULL,
+ I810_SetMode,
+ I810_SetViewport,
+ I810_GetViewport,
+ I810_Sync,
+ I810_FillRect,
+ I810_BlitRect,
+#if 0
+ I810_BlitTransRect
+#else
+ NULL
+#endif
+};
+
+Bool
+I810DGAInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ I810Ptr pI810 = I810PTR(pScrn);
+ DGAModePtr modes = NULL, newmodes = NULL, currentMode;
+ DisplayModePtr pMode, firstMode;
+ int Bpp = pScrn->bitsPerPixel >> 3;
+ int num = 0;
+ Bool oneMore;
+
+ pMode = firstMode = pScrn->modes;
+
+ while(pMode) {
+
+ if(0 /*pScrn->displayWidth != pMode->HDisplay*/) {
+ newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+ newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+ xfree(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+
+SECOND_PASS:
+
+ currentMode = modes + num;
+ num++;
+
+ currentMode->mode = pMode;
+ currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
+ currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
+ if(pMode->Flags & V_DBLSCAN)
+ currentMode->flags |= DGA_DOUBLESCAN;
+ if(pMode->Flags & V_INTERLACE)
+ currentMode->flags |= DGA_INTERLACED;
+ currentMode->byteOrder = pScrn->imageByteOrder;
+ currentMode->depth = pScrn->depth;
+ currentMode->bitsPerPixel = pScrn->bitsPerPixel;
+ currentMode->red_mask = pScrn->mask.red;
+ currentMode->green_mask = pScrn->mask.green;
+ currentMode->blue_mask = pScrn->mask.blue;
+ currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
+ currentMode->viewportWidth = pMode->HDisplay;
+ currentMode->viewportHeight = pMode->VDisplay;
+ currentMode->xViewportStep = 1;
+ currentMode->yViewportStep = 1;
+ currentMode->viewportFlags = DGA_FLIP_RETRACE;
+ currentMode->offset = 0;
+ currentMode->address = pI810->FbBase;
+
+ if(oneMore) { /* first one is narrow width */
+ currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pMode->HDisplay;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ oneMore = FALSE;
+ goto SECOND_PASS;
+ } else {
+ currentMode->bytesPerScanline =
+ ((pScrn->displayWidth * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pScrn->displayWidth;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ }
+
+ pMode = pMode->next;
+ if(pMode == firstMode)
+ break;
+ }
+
+ pI810->numDGAModes = num;
+ pI810->DGAModes = modes;
+
+ return DGAInit(pScreen, &I810DGAFuncs, modes, num);
+}
+
+
+static Bool
+I810_SetMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr pMode
+){
+ static int OldDisplayWidth[MAXSCREENS];
+ int index = pScrn->pScreen->myNum;
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if(!pMode) { /* restore the original mode */
+ /* put the ScreenParameters back */
+
+ pScrn->displayWidth = OldDisplayWidth[index];
+
+ I810SwitchMode(index, pScrn->currentMode, 0);
+ pI810->DGAactive = FALSE;
+ } else {
+ if(!pI810->DGAactive) { /* save the old parameters */
+ OldDisplayWidth[index] = pScrn->displayWidth;
+
+ pI810->DGAactive = TRUE;
+ }
+
+ pScrn->displayWidth = pMode->bytesPerScanline /
+ (pMode->bitsPerPixel >> 3);
+
+ I810SwitchMode(index, pMode->mode, 0);
+ }
+
+ return TRUE;
+}
+
+static int
+I810_GetViewport(
+ ScrnInfoPtr pScrn
+){
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ return pI810->DGAViewportStatus;
+}
+
+static void
+I810_SetViewport(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int flags
+){
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ I810AdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+ pI810->DGAViewportStatus = 0; /* I810AdjustFrame loops until finished */
+}
+
+static void
+I810_FillRect (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+){
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if(pI810->AccelInfoRec) {
+ (*pI810->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
+ (*pI810->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
+ SET_SYNC_FLAG(pI810->AccelInfoRec);
+ }
+}
+
+static void
+I810_Sync(
+ ScrnInfoPtr pScrn
+){
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if(pI810->AccelInfoRec) {
+ (*pI810->AccelInfoRec->Sync)(pScrn);
+ }
+}
+
+static void
+I810_BlitRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+){
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ if(pI810->AccelInfoRec) {
+ int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
+ int ydir = (srcy < dsty) ? -1 : 1;
+
+ (*pI810->AccelInfoRec->SetupForScreenToScreenCopy)(
+ pScrn, xdir, ydir, GXcopy, ~0, -1);
+ (*pI810->AccelInfoRec->SubsequentScreenToScreenCopy)(
+ pScrn, srcx, srcy, dstx, dsty, w, h);
+ SET_SYNC_FLAG(pI810->AccelInfoRec);
+ }
+}
+
+
+static void
+I810_BlitTransRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+){
+ /* this one should be separate since the XAA function would
+ prohibit usage of ~0 as the key */
+}
+
+
+static Bool
+I810_OpenFramebuffer(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ I810Ptr pI810 = I810PTR(pScrn);
+
+ *name = NULL; /* no special device */
+ *mem = (unsigned char*)pI810->LinearAddr;
+ *size = pI810->FbMapSize;
+ *offset = 0;
+ *flags = DGA_NEED_ROOT;
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
index c63f9ed20..ebaeba30d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.2 2000/03/02 16:07:49 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.c,v 1.6 2000/06/23 23:43:44 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -20,10 +20,6 @@
#include "i810.h"
#include "i810_dri.h"
-#include "xf86drm.h"
-#include "dristruct.h"
-
-
static char I810KernelDriverName[] = "i810";
static char I810ClientDriverName[] = "i810";
@@ -62,6 +58,44 @@ static int i810_pitch_flags[] = {
0
};
+Bool I810CleanupDma(ScrnInfoPtr pScrn)
+{
+ I810Ptr pI810 = I810PTR(pScrn);
+ Bool ret_val;
+
+ ret_val = drmI810CleanupDma(pI810->drmSubFD);
+ if (ret_val == FALSE)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "I810 Dma Cleanup Failed\n");
+ return ret_val;
+}
+
+Bool I810InitDma(ScrnInfoPtr pScrn)
+{
+ I810Ptr pI810 = I810PTR(pScrn);
+ I810RingBuffer *ring = &(pI810->LpRing);
+ drmI810Init info;
+ Bool ret_val;
+
+ info.start = ring->mem.Start;
+ info.end = ring->mem.End;
+ info.size = ring->mem.Size;
+ info.ring_map_idx = 6;
+ info.buffer_map_idx = 5;
+ info.sarea_off = sizeof(XF86DRISAREARec);
+
+ info.front_offset = 0;
+ info.back_offset = pI810->BackBuffer.Start;
+ info.depth_offset = pI810->DepthBuffer.Start;
+ info.w = pScrn->virtualX;
+ info.h = pScrn->virtualY;
+ info.pitch = pI810->auxPitch;
+ info.pitch_bits = pI810->auxPitchBits;
+
+ ret_val = drmI810InitDma(pI810->drmSubFD, &info);
+ if(ret_val == FALSE) ErrorF("I810 Dma Initialization Failed\n");
+ return ret_val;
+}
+
static Bool
I810InitVisualConfigs(ScreenPtr pScreen)
{
@@ -71,6 +105,7 @@ I810InitVisualConfigs(ScreenPtr pScreen)
__GLXvisualConfig *pConfigs = 0;
I810ConfigPrivPtr pI810Configs = 0;
I810ConfigPrivPtr *pI810ConfigPtrs = 0;
+ int accum, stencil, db, depth;
int i;
switch (pScrn->bitsPerPixel) {
@@ -79,25 +114,20 @@ I810InitVisualConfigs(ScreenPtr pScreen)
case 32:
break;
case 16:
- numConfigs = 4;
+ numConfigs = 8;
- if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
- numConfigs))) {
+ pConfigs = (__GLXvisualConfig *) xnfcalloc(sizeof(__GLXvisualConfig), numConfigs);
+ if (!pConfigs)
return FALSE;
- }
- if (!(pI810Configs =
- (I810ConfigPrivPtr)xnfcalloc(sizeof(I810ConfigPrivRec),
- numConfigs)))
- {
+ pI810Configs = (I810ConfigPrivPtr) xnfcalloc(sizeof(I810ConfigPrivRec), numConfigs);
+ if (!pI810Configs) {
xfree(pConfigs);
return FALSE;
}
- if (!(pI810ConfigPtrs =
- (I810ConfigPrivPtr*)xnfcalloc(sizeof(I810ConfigPrivPtr),
- numConfigs)))
- {
+ pI810ConfigPtrs = (I810ConfigPrivPtr *) xnfcalloc(sizeof(I810ConfigPrivPtr), numConfigs);
+ if (!pI810ConfigPtrs) {
xfree(pConfigs);
xfree(pI810Configs);
return FALSE;
@@ -106,126 +136,61 @@ I810InitVisualConfigs(ScreenPtr pScreen)
for (i=0; i<numConfigs; i++)
pI810ConfigPtrs[i] = &pI810Configs[i];
- /* config 0: db=FALSE, depth=0
- config 1: db=FALSE, depth=16
- config 2: db=TRUE, depth=0;
- config 3: db=TRUE, depth=16
- */
- pConfigs[0].vid = -1;
- pConfigs[0].class = -1;
- pConfigs[0].rgba = TRUE;
- pConfigs[0].redSize = 5;
- pConfigs[0].greenSize = 6;
- pConfigs[0].blueSize = 5;
- pConfigs[0].redMask = 0x0000F800;
- pConfigs[0].greenMask = 0x000007E0;
- pConfigs[0].blueMask = 0x0000001F;
- pConfigs[0].alphaMask = 0;
- pConfigs[0].accumRedSize = 0;
- pConfigs[0].accumGreenSize = 0;
- pConfigs[0].accumBlueSize = 0;
- pConfigs[0].accumAlphaSize = 0;
- pConfigs[0].doubleBuffer = FALSE;
- pConfigs[0].stereo = FALSE;
- pConfigs[0].bufferSize = 16;
- pConfigs[0].depthSize = 16;
- pConfigs[0].stencilSize = 0;
- pConfigs[0].auxBuffers = 0;
- pConfigs[0].level = 0;
- pConfigs[0].visualRating = 0;
- pConfigs[0].transparentPixel = 0;
- pConfigs[0].transparentRed = 0;
- pConfigs[0].transparentGreen = 0;
- pConfigs[0].transparentBlue = 0;
- pConfigs[0].transparentAlpha = 0;
- pConfigs[0].transparentIndex = 0;
-
- pConfigs[1].vid = -1;
- pConfigs[1].class = -1;
- pConfigs[1].rgba = TRUE;
- pConfigs[1].redSize = 5;
- pConfigs[1].greenSize = 6;
- pConfigs[1].blueSize = 5;
- pConfigs[1].redMask = 0x0000F800;
- pConfigs[1].greenMask = 0x000007E0;
- pConfigs[1].blueMask = 0x0000001F;
- pConfigs[1].alphaMask = 0;
- pConfigs[1].accumRedSize = 0;
- pConfigs[1].accumGreenSize = 0;
- pConfigs[1].accumBlueSize = 0;
- pConfigs[1].accumAlphaSize = 0;
- pConfigs[1].doubleBuffer = FALSE;
- pConfigs[1].stereo = FALSE;
- pConfigs[1].bufferSize = 16;
- pConfigs[1].depthSize = 16;
- pConfigs[1].stencilSize = 0;
- pConfigs[1].auxBuffers = 0;
- pConfigs[1].level = 0;
- pConfigs[1].visualRating = 0;
- pConfigs[1].transparentPixel = 0;
- pConfigs[1].transparentRed = 0;
- pConfigs[1].transparentGreen = 0;
- pConfigs[1].transparentBlue = 0;
- pConfigs[1].transparentAlpha = 0;
- pConfigs[1].transparentIndex = 0;
-
- pConfigs[2].vid = -1;
- pConfigs[2].class = -1;
- pConfigs[2].rgba = TRUE;
- pConfigs[2].redSize = 5;
- pConfigs[2].greenSize = 6;
- pConfigs[2].blueSize = 5;
- pConfigs[2].redMask = 0x0000F800;
- pConfigs[2].greenMask = 0x000007E0;
- pConfigs[2].blueMask = 0x0000001F;
- pConfigs[2].alphaMask = 0;
- pConfigs[2].accumRedSize = 0;
- pConfigs[2].accumGreenSize = 0;
- pConfigs[2].accumBlueSize = 0;
- pConfigs[2].accumAlphaSize = 0;
- pConfigs[2].doubleBuffer = TRUE;
- pConfigs[2].stereo = FALSE;
- pConfigs[2].bufferSize = 16;
- pConfigs[2].depthSize = 16;
- pConfigs[2].stencilSize = 0;
- pConfigs[2].auxBuffers = 0;
- pConfigs[2].level = 0;
- pConfigs[2].visualRating = 0;
- pConfigs[2].transparentPixel = 0;
- pConfigs[2].transparentRed = 0;
- pConfigs[2].transparentGreen = 0;
- pConfigs[2].transparentBlue = 0;
- pConfigs[2].transparentAlpha = 0;
- pConfigs[2].transparentIndex = 0;
-
- pConfigs[3].vid = -1;
- pConfigs[3].class = -1;
- pConfigs[3].rgba = TRUE;
- pConfigs[3].redSize = 5;
- pConfigs[3].greenSize = 6;
- pConfigs[3].blueSize = 5;
- pConfigs[3].redMask = 0x0000F800;
- pConfigs[3].greenMask = 0x000007E0;
- pConfigs[3].blueMask = 0x0000001F;
- pConfigs[3].alphaMask = 0;
- pConfigs[3].accumRedSize = 0;
- pConfigs[3].accumGreenSize = 0;
- pConfigs[3].accumBlueSize = 0;
- pConfigs[3].accumAlphaSize = 0;
- pConfigs[3].doubleBuffer = TRUE;
- pConfigs[3].stereo = FALSE;
- pConfigs[3].bufferSize = 16;
- pConfigs[3].depthSize = 16;
- pConfigs[3].stencilSize = 0;
- pConfigs[3].auxBuffers = 0;
- pConfigs[3].level = 0;
- pConfigs[3].visualRating = 0;
- pConfigs[3].transparentPixel = 0;
- pConfigs[3].transparentRed = 0;
- pConfigs[3].transparentGreen = 0;
- pConfigs[3].transparentBlue = 0;
- pConfigs[3].transparentAlpha = 0;
- pConfigs[3].transparentIndex = 0;
+ i = 0;
+ depth = 1;
+ for (accum = 0; accum <= 1; accum++) {
+ for (stencil = 0; stencil <= 1; stencil++) {
+ for (db = 0; db <= 1; db++) {
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+ pConfigs[i].alphaMask = 0;
+ if (accum) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 16;
+ }
+ else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ pConfigs[i].doubleBuffer = db ? TRUE : FALSE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if (depth)
+ pConfigs[i].depthSize = 16;
+ else
+ pConfigs[i].depthSize = 0;
+ if (stencil)
+ pConfigs[i].stencilSize = 8;
+ else
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (stencil)
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ else
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ assert(i == numConfigs);
break;
}
pI810->numVisualConfigs = numConfigs;
@@ -260,12 +225,36 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
int width = pScrn->displayWidth * pI810->cpp;
int i;
- /* ToDo : save agpHandles? */
+ /* Hardware 3D rendering only implemented for 16bpp */
+ if (pScrn->bitsPerPixel != 16)
+ return FALSE;
+ /* Check that the GLX, DRI, and DRM modules have been loaded by testing
+ * for known symbols in each module. */
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "TDFXDRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ DRIQueryVersion(&major, &minor, &patch);
+ if (major != 3 || minor != 0 || patch < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "I810DRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n",
+ major, minor, patch);
+ return FALSE;
+ }
+ }
+
pDRIInfo = DRICreateInfoRec();
if (!pDRIInfo) {
- ErrorF("DRICreateInfoRec failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "DRICreateInfoRec failed\n");
return FALSE;
}
@@ -279,13 +268,14 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
pDRIInfo->drmDriverName = I810KernelDriverName;
pDRIInfo->clientDriverName = I810ClientDriverName;
pDRIInfo->busIdString = xalloc(64);
+
sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
((pciConfigPtr)pI810->PciInfo->thisCard)->busnum,
((pciConfigPtr)pI810->PciInfo->thisCard)->devnum,
((pciConfigPtr)pI810->PciInfo->thisCard)->funcnum);
- pDRIInfo->ddxDriverMajorVersion = 0;
- pDRIInfo->ddxDriverMinorVersion = 1;
- pDRIInfo->ddxDriverPatchVersion = 0;
+ pDRIInfo->ddxDriverMajorVersion = I810_MAJOR_VERSION;
+ pDRIInfo->ddxDriverMinorVersion = I810_MINOR_VERSION;
+ pDRIInfo->ddxDriverPatchVersion = I810_PATCHLEVEL;
pDRIInfo->frameBufferPhysicalAddress = pI810->LinearAddr;
pDRIInfo->frameBufferSize = (((pScrn->displayWidth *
pScrn->virtualY * pI810->cpp) +
@@ -302,8 +292,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
/* For now the mapping works by using a fixed size defined
* in the SAREA header
*/
- if (sizeof(XF86DRISAREARec)+sizeof(drm_i810_sarea_t)>SAREA_MAX) {
- ErrorF("Data does not fit in SAREA\n");
+ if (sizeof(XF86DRISAREARec)+sizeof(I810SAREARec)>SAREA_MAX) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n");
return FALSE;
}
pDRIInfo->SAREASize = SAREA_MAX;
@@ -329,7 +319,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
* to allocate it. Scary stuff, hold on...
*/
if (!DRIScreenInit(pScreen, pDRIInfo, &pI810->drmSubFD)) {
- ErrorF("DRIScreenInit failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "DRIScreenInit failed\n");
xfree(pDRIInfo->devPrivate);
pDRIInfo->devPrivate=0;
DRIDestroyInfoRec(pI810->pDRIInfo);
@@ -337,10 +327,31 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
+ /* Check the i810 DRM version */
+ {
+ drmVersionPtr version = drmGetVersion(pI810->drmSubFD);
+ if (version) {
+ if (version->version_major != 1 ||
+ version->version_minor != 0 ||
+ version->version_patchlevel < 0) {
+ /* incompatible drm version */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "I810DRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ I810DRICloseScreen(pScreen);
+ drmFreeVersion(version);
+ return FALSE;
+ }
+ drmFreeVersion(version);
+ }
+ }
+
pI810DRI->regsSize=I810_REG_SIZE;
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->MMIOAddr,
pI810DRI->regsSize, DRM_REGISTERS, 0, &pI810DRI->regs)<0) {
- ErrorF("drmAddMap(regs) failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(regs) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -357,30 +368,30 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
/* Agp Support - Need this just to get the framebuffer.
*/
if(drmAgpAcquire(pI810->drmSubFD) < 0) {
- ErrorF("drmAgpAquire failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAquire failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
pI810->agpAcquired = TRUE;
if (drmAgpEnable(pI810->drmSubFD, 0) < 0) {
- ErrorF("drmAgpEnable failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpEnable failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
- xf86memset (&pI810->DcacheMem, 0, sizeof(I810MemRange));
- xf86memset (&pI810->BackBuffer, 0, sizeof(I810MemRange));
- xf86memset (&pI810->DepthBuffer, 0, sizeof(I810MemRange));
+ memset (&pI810->DcacheMem, 0, sizeof(I810MemRange));
+ memset (&pI810->BackBuffer, 0, sizeof(I810MemRange));
+ memset (&pI810->DepthBuffer, 0, sizeof(I810MemRange));
pI810->CursorPhysical = 0;
/* Dcache - half the speed of normal ram, but has use as a Z buffer
* under the DRI.
*/
- dcacheHandle = drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL);
+ drmAgpAlloc(pI810->drmSubFD, 4096 * 1024, 1, NULL, &dcacheHandle);
pI810->dcacheHandle = dcacheHandle;
-
+ xf86DrvMsg(pScreen->myNum, X_INFO, "dcacheHandle : %p\n", dcacheHandle);
#define Elements(x) sizeof(x)/sizeof(*x)
for (pitch_idx = 0 ; pitch_idx < Elements(i810_pitches) ; pitch_idx++)
@@ -394,31 +405,37 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
else {
- back_size = i810_pitches[pitch_idx] * pScrn->virtualY;
+ back_size = i810_pitches[pitch_idx] * (pScrn->virtualY + 4);
back_size = ((back_size + 4096 - 1) / 4096) * 4096;
}
sysmem_size = pScrn->videoRam * 1024;
- if(dcacheHandle != 0) {
- if(back_size > 4*1024*1024) {
- ErrorF("Backsize is larger then 4 meg\n");
+ if (dcacheHandle != 0) {
+ if (back_size > 4*1024*1024) {
+ xf86DrvMsg(pScreen->myNum, X_INFO, "Backsize is larger then 4 meg\n");
sysmem_size = sysmem_size - 2*back_size;
drmAgpFree(pI810->drmSubFD, dcacheHandle);
pI810->dcacheHandle = dcacheHandle = 0;
- } else {
+ }
+ else {
sysmem_size = sysmem_size - back_size;
}
- } else {
+ }
+ else {
sysmem_size = sysmem_size - 2*back_size;
}
-
- sysmem_size -= 4096;
- if(sysmem_size > ((48*1024*1024) - 1) ) {
- sysmem_size = (48*1024*1024) - (2*4096);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "User requested more memory then fits in the agp aperture\n"
+
+ if(sysmem_size > 48*1024*1024) {
+ sysmem_size = 48*1024*1024;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "User requested more memory then fits in the agp aperture\n"
"Truncating to %d bytes of memory\n",
sysmem_size);
}
+
+ sysmem_size -= 4096; /* remove 4k for the hw cursor */
+
pI810->SysMem.Start = 0;
pI810->SysMem.Size = sysmem_size;
pI810->SysMem.End = sysmem_size;
@@ -428,9 +445,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
if (dcacheHandle != 0) {
/* The Z buffer is always aligned to the 48 mb mark in the aperture */
-
if(drmAgpBind(pI810->drmSubFD, dcacheHandle, 48*1024*1024) == 0) {
- xf86memset (&pI810->DcacheMem, 0, sizeof(I810MemRange));
+ memset (&pI810->DcacheMem, 0, sizeof(I810MemRange));
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: Found 4096K Z buffer memory\n");
pI810->DcacheMem.Start = 48*1024*1024;
@@ -454,10 +470,10 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: no dcache memory found\n");
}
- agpHandle = drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL);
+ drmAgpAlloc(pI810->drmSubFD, back_size, 0, NULL, &agpHandle);
pI810->backHandle = agpHandle;
- if(agpHandle != 0) {
+ if (agpHandle != 0) {
/* The backbuffer is always aligned to the 56 mb mark in the aperture */
if(drmAgpBind(pI810->drmSubFD, agpHandle, 56*1024*1024) == 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -481,8 +497,8 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
if(dcacheHandle == 0) {
/* The Z buffer is always aligned to the 48 mb mark in the aperture */
- agpHandle = drmAgpAlloc(pI810->drmSubFD, back_size, 0,
- NULL);
+ drmAgpAlloc(pI810->drmSubFD, back_size, 0,
+ NULL, &agpHandle);
pI810->zHandle = agpHandle;
if(agpHandle != 0) {
@@ -509,43 +525,43 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
/* Now allocate and bind the agp space. This memory will include the
* regular framebuffer as well as texture memory.
*/
-
- agpHandle = drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL);
- if(agpHandle == 0) {
- ErrorF("drmAgpAlloc failed\n");
+ drmAgpAlloc(pI810->drmSubFD, sysmem_size, 0, NULL, &agpHandle);
+ if (agpHandle == 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpAlloc failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
pI810->sysmemHandle = agpHandle;
- if(drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) {
- ErrorF("drmAgpBind failed\n");
+ if (drmAgpBind(pI810->drmSubFD, agpHandle, 0) != 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAgpBind failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
- agpHandle = drmAgpAlloc(pI810->drmSubFD, 4096, 2,
- (unsigned long *)&pI810->CursorPhysical);
+ drmAgpAlloc(pI810->drmSubFD, 4096, 2,
+ (unsigned long *)&pI810->CursorPhysical, &agpHandle);
pI810->cursorHandle = agpHandle;
if (agpHandle != 0) {
tom = sysmem_size;
- if(drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) {
+ if (drmAgpBind(pI810->drmSubFD, agpHandle, tom) == 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: Allocated 4K for mouse cursor image\n");
pI810->CursorStart = tom;
tom += 4096;
- } else {
+ }
+ else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor bind failed\n");
pI810->CursorPhysical = 0;
}
- } else {
+ }
+ else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "GART: cursor alloc failed\n");
pI810->CursorPhysical = 0;
}
-
I810SetTiledMemory(pScrn, 1,
pI810->DepthBuffer.Start,
i810_pitches[pitch_idx],
@@ -558,14 +574,13 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
pI810->auxPitch = i810_pitches[pitch_idx];
pI810->auxPitchBits = i810_pitch_flags[pitch_idx];
-
pI810->SavedDcacheMem = pI810->DcacheMem;
-
pI810DRI->backbufferSize = pI810->BackBuffer.Size;
+
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BackBuffer.Start,
pI810->BackBuffer.Size, DRM_AGP, 0,
&pI810DRI->backbuffer) < 0) {
- ErrorF("drmAddMap(backbuffer) failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(backbuffer) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -574,7 +589,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->DepthBuffer.Start,
pI810->DepthBuffer.Size, DRM_AGP, 0,
&pI810DRI->depthbuffer) < 0) {
- ErrorF("drmAddMap(depthbuffer) failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(depthbuffer) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -586,10 +601,21 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
I810AllocHigh( &(pI810->BufferMem), &(pI810->SysMem),
I810_DMA_BUF_NR * I810_DMA_BUF_SZ);
- if(drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start,
+ xf86DrvMsg(pScreen->myNum, X_INFO, "Buffer map : %lx\n",
+ pI810->BufferMem.Start);
+
+ if (pI810->BufferMem.Start == 0 ||
+ pI810->BufferMem.End - pI810->BufferMem.Start >
+ I810_DMA_BUF_NR * I810_DMA_BUF_SZ) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "Not enough memory for dma buffers\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->BufferMem.Start,
pI810->BufferMem.Size, DRM_AGP, 0,
&pI810->buffer_map) < 0) {
- ErrorF("drmAddMap(buffer_map) failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(buffer_map) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -600,7 +626,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->LpRing.mem.Start,
pI810->LpRing.mem.Size, DRM_AGP, 0,
&pI810->ring_map) < 0) {
- ErrorF("drmAddMap(ring_map) failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(ring_map) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -608,7 +634,6 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
/* Use the rest of memory for textures. */
pI810DRI->textureSize = pI810->SysMem.Size;
-
i = mylog2(pI810DRI->textureSize / I810_NR_TEX_REGIONS);
if (i < I810_LOG_MIN_TEX_REGION_SIZE)
@@ -617,20 +642,19 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
pI810DRI->logTextureGranularity = i;
pI810DRI->textureSize = (pI810DRI->textureSize >> i) << i; /* truncate */
-
if(pI810DRI->textureSize < 512*1024) {
ErrorF("Less then 512k for textures\n");
DRICloseScreen(pScreen);
+ return FALSE;
}
I810AllocLow( &(pI810->TexMem), &(pI810->SysMem),
pI810DRI->textureSize);
-
if (drmAddMap(pI810->drmSubFD, (drmHandle)pI810->TexMem.Start,
pI810->TexMem.Size, DRM_AGP, 0,
&pI810DRI->textures) < 0) {
- ErrorF("drmAddMap(textures) failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "drmAddMap(textures) failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -650,7 +674,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] added %d %d byte DMA buffers\n",
bufs, I810_DMA_BUF_SZ);
- I810drmInitDma(pScrn);
+ I810InitDma(pScrn);
/* Okay now initialize the dma engine */
@@ -701,7 +725,7 @@ Bool I810DRIScreenInit(ScreenPtr pScreen)
pI810DRI->auxPitchBits = pI810->auxPitchBits;
if (!(I810InitVisualConfigs(pScreen))) {
- ErrorF("I810InitVisualConfigs failed\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "I810InitVisualConfigs failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
@@ -718,7 +742,7 @@ I810DRICloseScreen(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
I810Ptr pI810 = I810PTR(pScrn);
- I810drmCleanupDma(pScrn);
+ I810CleanupDma(pScrn);
if(pI810->dcacheHandle) drmAgpFree(pI810->drmSubFD, pI810->dcacheHandle);
if(pI810->backHandle) drmAgpFree(pI810->drmSubFD, pI810->backHandle);
@@ -768,8 +792,8 @@ I810DestroyContext(ScreenPtr pScreen, drmContext hwContext,
Bool
I810DRIFinishScreenInit(ScreenPtr pScreen)
{
- drm_i810_sarea_t *sPriv = (drm_i810_sarea_t *)DRIGetSAREAPrivate(pScreen);
- xf86memset( sPriv, 0, sizeof(sPriv) );
+ I810SAREARec *sPriv = (I810SAREARec *)DRIGetSAREAPrivate(pScreen);
+ memset( sPriv, 0, sizeof(sPriv) );
return DRIFinishScreenInit(pScreen);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h
index e593f36b2..bbb0cc927 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h
@@ -1,10 +1,10 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h,v 1.2 2000/03/02 16:07:49 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_dri.h,v 1.3 2000/06/17 00:03:18 martin Exp $ */
#ifndef _I810_DRI_
#define _I810_DRI_
#include <xf86drm.h>
-#include "i810_drm_public.h"
+#include <xf86drmI810.h>
#define I810_MAX_DRAWABLES 256
@@ -53,6 +53,45 @@ typedef struct {
} I810DRIRec, *I810DRIPtr;
+/* WARNING: Do not change the SAREA structure without changing the kernel
+ * as well */
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} I810TexRegionRec, *I810TexRegionPtr;
+
+typedef struct {
+ unsigned int nbox;
+ XF86DRIClipRectRec boxes[I810_NR_SAREA_CLIPRECTS];
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+ I810TexRegionRec texList[I810_NR_TEX_REGIONS+1]; /* Last elt is sentinal */
+
+ int texAge; /* last time texture was uploaded */
+
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+
+ int ctxOwner; /* last context to upload state */
+} I810SAREARec, *I810SAREAPtr;
+
typedef struct {
/* Nothing here yet */
int dummy;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
index e489d17c9..c02b14da4 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c
@@ -25,7 +25,7 @@ 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/drivers/i810/i810_driver.c,v 1.7 2000/03/02 16:07:50 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_driver.c,v 1.15 2000/06/22 17:44:04 alanh Exp $ */
/*
* Authors:
@@ -64,11 +64,13 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "cfb16.h"
#include "cfb24.h"
#include "cfb32.h"
-#include "i810.h"
+#include "cfb24_32.h"
#include "miscstruct.h"
#include "xf86xv.h"
#include "Xv.h"
+#include "i810.h"
+
#ifdef XF86DRI
#include "dri.h"
#endif
@@ -83,8 +85,6 @@ static Bool I810EnterVT(int scrnIndex, int flags);
static void I810LeaveVT(int scrnIndex, int flags);
static Bool I810CloseScreen(int scrnIndex, ScreenPtr pScreen);
static Bool I810SaveScreen(ScreenPtr pScreen, Bool unblank);
-static Bool I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
-static void I810AdjustFrame(int scrnIndex, int x, int y, int flags);
static void I810FreeScreen(int scrnIndex, int flags);
static int I810ValidMode(int scrnIndex, DisplayModePtr mode, Bool
verbose, int flags);
@@ -95,15 +95,8 @@ static void I810DisplayPowerManagementSet(ScrnInfoPtr pScrn,
int flags);
#endif
-#define VERSION 4000
-#define I810_NAME "I810"
-#define I810_DRIVER_NAME "i810"
-#define I810_MAJOR_VERSION 1
-#define I810_MINOR_VERSION 0
-#define I810_PATCHLEVEL 0
-
DriverRec I810 = {
- VERSION,
+ I810_VERSION,
"Accelerated driver for Intel i810 cards",
I810Identify,
I810Probe,
@@ -111,20 +104,12 @@ DriverRec I810 = {
0
};
-#ifndef PCI_CHIP_I810
-#define PCI_CHIP_I810 0x7121
-#define PCI_CHIP_I810_DC100 0x7123
-#define PCI_CHIP_I810_E 0x7125
-#define PCI_CHIP_I810_BRIDGE 0x7120
-#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
-#define PCI_CHIP_I810_E_BRIDGE 0x7124
-#endif
-
/* Chipsets */
static SymTabRec I810Chipsets[] = {
{ PCI_CHIP_I810, "i810"},
{ PCI_CHIP_I810_DC100, "i810-dc100"},
{ PCI_CHIP_I810_E, "i810e"},
+ { PCI_CHIP_I815, "i815"},
{ -1, NULL }
};
@@ -132,6 +117,7 @@ static PciChipsets I810PciChipsets[] = {
{ PCI_CHIP_I810, PCI_CHIP_I810, RES_SHARED_VGA },
{ PCI_CHIP_I810_DC100, PCI_CHIP_I810_DC100, RES_SHARED_VGA },
{ PCI_CHIP_I810_E, PCI_CHIP_I810_E, RES_SHARED_VGA },
+ { PCI_CHIP_I815, PCI_CHIP_I815, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED }
};
@@ -204,34 +190,29 @@ static const char *ramdacSymbols[] = {
NULL
};
+/*
+ * This is intentionally screen-independent. It indicates the binding
+ * choice made in the first PreInit.
+ */
+static int pix24bpp = 0;
#ifdef XF86DRI
static const char *drmSymbols[] = {
+ "drmAvailable",
"drmAddBufs",
"drmAddMap",
- "drmAvailable",
- "drmCtlAddCommand",
"drmCtlInstHandler",
"drmGetInterruptFromBusID",
- "drmMapBufs",
- "drmMarkBufs",
- "drmUnmapBufs",
"drmAgpAcquire",
"drmAgpRelease",
"drmAgpEnable",
"drmAgpAlloc",
"drmAgpFree",
"drmAgpBind",
- "drmAgpUnbind",
- "drmAgpVersionMajor",
- "drmAgpVersionMinor",
- "drmAgpGetMode",
- "drmAgpBase",
- "drmAgpSize",
- "drmAgpMemoryUsed",
- "drmAgpMemoryAvail",
- "drmAgpVendorId",
- "drmAgpDeviceId",
+ "drmI810CleanupDma",
+ "drmI810InitDma",
+ "drmFreeVersion",
+ "drmGetVersion",
NULL
};
@@ -248,6 +229,7 @@ static const char *driSymbols[] = {
"DRIUnlock",
"DRIGetSAREAPrivate",
"DRIGetContext",
+ "DRIQueryVersion",
"GlxSetVisualConfigs",
NULL
};
@@ -388,7 +370,6 @@ I810Probe(DriverPtr drv, int flags) {
int i, numUsed, numDevSections, *usedChips;
GDevPtr *devSections;
Bool foundScreen = 0;
- EntityInfoPtr pEnt;
/*
Find the config file Device sections that match this
@@ -411,32 +392,24 @@ I810Probe(DriverPtr drv, int flags) {
drv, &usedChips);
for (i=0; i<numUsed; i++) {
- pEnt = xf86GetEntityInfo(usedChips[i]);
-
- if (pEnt->active) {
- ScrnInfoPtr pScrn;
-
- /* Allocate new ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = I810_DRIVER_NAME;
- pScrn->name = I810_NAME;
- pScrn->Probe = I810Probe;
- pScrn->PreInit = I810PreInit;
- pScrn->ScreenInit = I810ScreenInit;
- pScrn->SwitchMode = I810SwitchMode;
- pScrn->AdjustFrame = I810AdjustFrame;
- pScrn->EnterVT = I810EnterVT;
- pScrn->LeaveVT = I810LeaveVT;
- pScrn->FreeScreen = I810FreeScreen;
- pScrn->ValidMode = I810ValidMode;
- foundScreen = TRUE;
-
- xf86ConfigActivePciEntity(pScrn, usedChips[i], I810PciChipsets,
- 0, 0, 0, 0, 0);
+ ScrnInfoPtr pScrn = NULL;
+ /* Allocate new ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ I810PciChipsets, 0, 0, 0, 0, 0))){
+ pScrn->driverVersion = I810_VERSION;
+ pScrn->driverName = I810_DRIVER_NAME;
+ pScrn->name = I810_NAME;
+ pScrn->Probe = I810Probe;
+ pScrn->PreInit = I810PreInit;
+ pScrn->ScreenInit = I810ScreenInit;
+ pScrn->SwitchMode = I810SwitchMode;
+ pScrn->AdjustFrame = I810AdjustFrame;
+ pScrn->EnterVT = I810EnterVT;
+ pScrn->LeaveVT = I810LeaveVT;
+ pScrn->FreeScreen = I810FreeScreen;
+ pScrn->ValidMode = I810ValidMode;
+ foundScreen = TRUE;
}
- xfree(pEnt);
}
if (numUsed) xfree(usedChips);
@@ -494,7 +467,7 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) {
/* No support for 32bpp.
*/
- flags24=Support24bppFb | PreferConvert32to24;
+ flags24=Support24bppFb | PreferConvert32to24 | SupportConvert32to24;
if (!xf86SetDepthBpp(pScrn, 8, 8, 8, flags24)) {
return FALSE;
} else {
@@ -512,6 +485,9 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) {
}
xf86PrintDepthBpp(pScrn);
+ /* Get the depth24 pixmap format */
+ if (pScrn->depth == 24 && pix24bpp == 0)
+ pix24bpp = xf86GetBppFromDepth(pScrn, 24);
pScrn->rgbBits=8;
if (xf86ReturnOptValBool(I810Options, OPTION_DAC_6BIT, FALSE))
@@ -693,7 +669,7 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) {
pI810->MaxClock = 86000;
}
}
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next=NULL;
clockRanges->minClock= 12000; /* !!! What's the min clock? !!! */
clockRanges->maxClock=pI810->MaxClock;
@@ -743,8 +719,13 @@ I810PreInit(ScrnInfoPtr pScrn, int flags) {
reqSym = "cfb16ScreenInit";
break;
case 24:
- mod = "cfb24";
- reqSym = "cfb24ScreenInit";
+ if (pix24bpp == 24) {
+ mod = "cfb24";
+ reqSym = "cfb24ScreenInit";
+ } else {
+ mod = "xf24_32bpp";
+ reqSym = "cfb24_32ScreenInit";
+ }
break;
case 32:
mod = "cfb32";
@@ -1528,7 +1509,7 @@ I810AllocateFront(ScrnInfoPtr pScrn) {
if(pI810->DoneFrontAlloc)
return TRUE;
- xf86memset(&(pI810->FbMemBox), 0, sizeof(BoxRec));
+ memset(&(pI810->FbMemBox), 0, sizeof(BoxRec));
/* Alloc FrontBuffer/Ring/Accel memory */
pI810->FbMemBox.x1=0;
pI810->FbMemBox.x2=pScrn->displayWidth;
@@ -1551,9 +1532,8 @@ I810AllocateFront(ScrnInfoPtr pScrn) {
pI810->FbMemBox.y2 *
pI810->cpp) + 4095) & ~4095);
- xf86memset( &(pI810->LpRing), 0, sizeof( I810RingBuffer ) );
+ memset( &(pI810->LpRing), 0, sizeof( I810RingBuffer ) );
if(I810AllocLow( &(pI810->LpRing.mem), &(pI810->SysMem), 16*4096 )) {
-
if (I810_DEBUG & DEBUG_VERBOSE_MEMORY)
ErrorF( "ring buffer at local %lx\n",
pI810->LpRing.mem.Start);
@@ -1607,6 +1587,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
/* Have to init the DRM earlier than in other drivers to get agp
* memory. Wonder if this is going to be a problem...
*/
+
#ifdef XF86DRI
/*
* Setup DRI after visuals have been established, but before cfbScreenInit
@@ -1657,11 +1638,19 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
return FALSE;
break;
case 24:
- if (!cfb24ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth))
- return FALSE;
+ if (pix24bpp == 24) {
+ if (!cfb24ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth))
+ return FALSE;
+ } else {
+ if (!cfb24_32ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth))
+ return FALSE;
+ }
break;
case 32:
if (!cfb32ScreenInit(pScreen, pI810->FbBase + pScrn->fbOffset,
@@ -1679,6 +1668,8 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
xf86SetBlackWhitePixels(pScreen);
+ I810DGAInit(pScreen);
+
if (pScrn->bitsPerPixel>8) {
visual = pScreen->visuals + pScreen->numVisuals;
while (--visual >= pScreen->visuals) {
@@ -1729,6 +1720,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
}
}
#endif
+
#ifdef XF86DRI
if (!pI810->directRenderingEnabled) {
pI810->DoneFrontAlloc = FALSE;
@@ -1737,6 +1729,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
I810AllocateFront(pScrn);
}
#endif
+
if (!xf86InitFBManager(pScreen, &(pI810->FbMemBox))) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -1762,7 +1755,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
}
}
-#if XF86DRI
+#ifdef XF86DRI
if (pI810->LpRing.mem.Start == 0) {
pI810->directRenderingEnabled = 0;
I810DRICloseScreen(pScreen);
@@ -1798,7 +1791,7 @@ I810ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
return TRUE;
}
-static Bool
+Bool
I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) {
ScrnInfoPtr pScrn =xf86Screens[scrnIndex];
@@ -1808,7 +1801,7 @@ I810SwitchMode(int scrnIndex, DisplayModePtr mode, int flags) {
return I810ModeInit(pScrn, mode);
}
-static void
+void
I810AdjustFrame(int scrnIndex, int x, int y, int flags) {
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
I810Ptr pI810 = I810PTR(pScrn);
@@ -1852,11 +1845,12 @@ I810AdjustFrame(int scrnIndex, int x, int y, int flags) {
static Bool
I810EnterVT(int scrnIndex, int flags) {
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+#ifdef XF86DRI
I810Ptr pI810 = I810PTR(pScrn);
-
+#endif
if (I810_DEBUG & DEBUG_VERBOSE_DRI)
- ErrorF("\n\n\ENTER VT\n");
+ ErrorF("\n\nENTER VT\n");
#ifdef XF86DRI
if (pI810->directRenderingEnabled) {
@@ -1876,10 +1870,7 @@ static void
I810LeaveVT(int scrnIndex, int flags) {
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
-#ifdef XF86DRI
I810Ptr pI810 = I810PTR(pScrn);
-#endif
-
if (I810_DEBUG & DEBUG_VERBOSE_DRI)
ErrorF("\n\n\nLeave VT\n");
@@ -1893,8 +1884,10 @@ I810LeaveVT(int scrnIndex, int flags) {
}
#endif
- I810RefreshRing( pScrn );
- I810Sync( pScrn );
+ if(pI810->AccelInfoRec != NULL) {
+ I810RefreshRing( pScrn );
+ I810Sync( pScrn );
+ }
I810Restore(pScrn);
vgaHWLock(hwp);
}
@@ -1950,7 +1943,8 @@ I810CloseScreen(int scrnIndex, ScreenPtr pScreen)
static void
I810FreeScreen(int scrnIndex, int flags) {
I810FreeRec(xf86Screens[scrnIndex]);
- vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+ if (vgaHWFreeHWRec)
+ vgaHWFreeHWRec(xf86Screens[scrnIndex]);
}
static int
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_io.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_io.c
index 4378e060d..972f3f5a8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_io.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_io.c
@@ -24,7 +24,7 @@ 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/drivers/i810/i810_io.c,v 1.2 2000/02/23 04:47:16 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_io.c,v 1.3 2000/05/11 18:14:34 tsi Exp $ */
/*
* Authors:
@@ -39,21 +39,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "i810.h"
-static void I810WriteControlPIO(I810Ptr pI810, int addr, char index, char val) {
+static void
+I810WriteControlPIO(I810Ptr pI810, int addr, CARD8 index, CARD8 val) {
outb(addr, index);
outb(addr+1, val);
}
-static char I810ReadControlPIO(I810Ptr pI810, int addr, char index) {
+static CARD8
+I810ReadControlPIO(I810Ptr pI810, int addr, CARD8 index) {
outb(addr, index);
return inb(addr+1);
}
-static void I810WriteStandardPIO(I810Ptr pI810, int addr, char val) {
+static void
+I810WriteStandardPIO(I810Ptr pI810, int addr, CARD8 val) {
outb(addr, val);
}
-static char I810ReadStandardPIO(I810Ptr pI810, int addr) {
+static CARD8
+I810ReadStandardPIO(I810Ptr pI810, int addr) {
return inb(addr);
}
@@ -64,21 +68,25 @@ void I810SetPIOAccess(I810Ptr pI810) {
pI810->readStandard=I810ReadStandardPIO;
}
-static void I810WriteControlMMIO(I810Ptr pI810, int addr, char index, char val) {
+static void
+I810WriteControlMMIO(I810Ptr pI810, int addr, CARD8 index, CARD8 val) {
moutb(addr, index);
moutb(addr+1, val);
}
-static char I810ReadControlMMIO(I810Ptr pI810, int addr, char index) {
+static CARD8
+I810ReadControlMMIO(I810Ptr pI810, int addr, CARD8 index) {
moutb(addr, index);
return minb(addr+1);
}
-static void I810WriteStandardMMIO(I810Ptr pI810, int addr, char val) {
+static void
+I810WriteStandardMMIO(I810Ptr pI810, int addr, CARD8 val) {
moutb(addr, val);
}
-static char I810ReadStandardMMIO(I810Ptr pI810, int addr) {
+static CARD8
+I810ReadStandardMMIO(I810Ptr pI810, int addr) {
return minb(addr);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
index 2cedd9682..b5c07798d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c
@@ -1,4 +1,4 @@
-
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_memory.c,v 1.9 2000/06/20 05:08:46 dawes Exp $ */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -32,22 +32,24 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
-
-#include "X.h"
-#include "input.h"
-#include "screenint.h"
-#include "compiler.h"
+#ifndef XFree86LOADER
#include "xf86.h"
-#include "xf86Priv.h"
-#include "xf86_OSlib.h"
+#include "xf86_ansic.h"
+#endif
-/* #include "xf86_ansic.h" */
+#ifdef linux
+#include <asm/ioctl.h>
+#include <linux/agpgart.h>
+#endif
+
+#ifdef XFree86LOADER
+#include "xf86.h"
+#include "xf86_ansic.h"
+#endif
#include "i810.h"
#include "i810_reg.h"
-#include <linux/agpgart.h>
-
int I810AllocLow( I810MemRange *result, I810MemRange *pool, int size )
{
if (size > pool->Size) return 0;
@@ -72,17 +74,9 @@ int I810AllocHigh( I810MemRange *result, I810MemRange *pool, int size )
}
-#define XCONFIG_PROBED "()"
-#define NAME "i810"
-
-extern int xf86open(const char *path, int flags, ...);
-extern int xf86close(int fd );
-extern int xf86ioctl(int fd, unsigned long request, pointer argp);
-extern int xf86errno;
-
-
int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
{
+#ifdef linux
struct _agp_info agpinf;
struct _agp_bind bind;
struct _agp_allocate alloc;
@@ -91,16 +85,16 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
long tom = 0;
int gartfd = -1;
- gartfd = xf86open("/dev/agpgart", O_RDWR, 0);
+ gartfd = open("/dev/agpgart", O_RDWR, 0);
if (gartfd == -1) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "unable to open /dev/agpgart\n");
return FALSE;
}
- if (xf86ioctl(gartfd, AGPIOC_ACQUIRE, 0) != 0) {
+ if (ioctl(gartfd, AGPIOC_ACQUIRE, 0) != 0) {
if(pI810->agpAcquired2d == TRUE) {
- xf86close(gartfd);
+ close(gartfd);
return TRUE;
}
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "AGPIOC_ACQUIRE failed\n");
@@ -111,9 +105,9 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
pI810->agpAcquired2d = TRUE;
pI810->gartfd = gartfd;
- if (xf86ioctl(pI810->gartfd, AGPIOC_INFO, &agpinf) != 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_INFO, &agpinf) != 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "error doing xf86ioctl(AGPIOC_INFO)\n");
+ "error doing ioctl(AGPIOC_INFO)\n");
return FALSE;
}
@@ -132,7 +126,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
alloc.pg_count = pages;
alloc.type = 0;
- if (xf86ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"AGPGART: allocation of %d pages failed\n", pages);
return FALSE;
@@ -141,7 +135,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
bind.pg_start = 0;
bind.key = alloc.key;
- if (xf86ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: allocation of %d pages failed\n", pages);
return FALSE;
@@ -172,11 +166,11 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
tom += 0x7ffff;
tom &= ~0x7ffff;
- if (xf86ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) == 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) == 0) {
bind.pg_start = tom / 4096;
bind.key = alloc.key;
- if (xf86ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: allocation of %d DCACHE pages failed\n",
alloc.pg_count);
@@ -197,7 +191,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
alloc.type = 2;
- if (xf86ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_ALLOCATE, &alloc) != 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: No physical memory available for mouse\n",
alloc.pg_count);
@@ -205,7 +199,7 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
bind.pg_start = tom / 4096;
bind.key = alloc.key;
- if (xf86ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
+ if (ioctl(pI810->gartfd, AGPIOC_BIND, &bind) != 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"GART: allocation of %d physical pages failed\n",
alloc.pg_count);
@@ -220,18 +214,23 @@ int I810AllocateGARTMemory( ScrnInfoPtr pScrn )
return TRUE;
+#else
+ return FALSE;
+#endif
}
void I810FreeGARTMemory( ScrnInfoPtr pScrn )
{
+#ifdef linux
I810Ptr pI810 = I810PTR(pScrn);
if (pI810->gartfd != -1) {
- xf86close( pI810->gartfd );
+ close( pI810->gartfd );
pI810->gartfd = -1;
}
+#endif
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile
new file mode 100644
index 000000000..14eab93ed
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile
@@ -0,0 +1,52 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/Imakefile,v 1.2 2000/06/14 01:56:08 dawes Exp $
+/*
+ *
+ * Copyright 2000 Ani Joshi <ajoshi@unixbox.com>
+ *
+ */
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = imstt_driver.c imstt_accel.c
+
+OBJS = imstt_driver.o imstt_accel.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \
+ -I$(XF86SRC)/xf1bpp -I$(XF86SRC)/xf4bpp \
+ -I$(XF86SRC)/xf24_32bpp -I$(SERVERSRC)/Xext \
+ -I$(XF86SRC)/vgahw -I$(XF86SRC)/ramdac \
+ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \
+ -I$(XF86SRC)/fbdevhw \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(FONTINCSRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+NormalAsmObjectRule()
+
+ModuleObjectRule()
+ObjectModuleTarget(imstt, $(OBJS))
+
+InstallObjectModule(imstt,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(imstt,)
+InstallModuleManPage(imstt)
+#endif
+
+DependTarget()
+
+InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/imstt)
+InstallDriverSDKNonExecFile(imstt.h,$(DRIVERSDKDIR)/drivers/imstt)
+InstallDriverSDKNonExecFile(imstt_reg.h,$(DRIVERSDKDIR)/drivers/imstt)
+InstallDriverSDKNonExecFile(imstt_driver.c,$(DRIVERSDKDIR)/drivers/imstt)
+InstallDriverSDKNonExecFile(imstt_accel.c,$(DRIVERSDKDIR)/drivers/imstt)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp
new file mode 100644
index 000000000..a5354d3b7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.cpp,v 1.2 2000/06/14 02:13:11 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH IMSTT __drivermansuffix__ "Version 4.0.1" "XFree86"
+.SH NAME
+imstt \- Integrated Micro Solutions Twin Turbo 128 driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qimstt\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B imstt
+is an XFree86 driver for Integrated Micro Solutions Twin Turbo 128 video chips.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B imstt
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h
new file mode 100644
index 000000000..7a0b625dc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h
@@ -0,0 +1,63 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt.h,v 1.1 2000/06/14 00:16:09 dawes Exp $ */
+
+#ifndef _IMSTT_H
+#define _IMSTT_H
+
+#include "xf86.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xaa.h"
+#include "xf86_ansic.h"
+
+
+typedef struct _IMSTTRec {
+ pciVideoPtr PciInfo;
+ PCITAG PciTag;
+ EntityInfoPtr pEnt;
+ CARD32 IOAddress;
+ CARD32 FBAddress;
+ unsigned char * FBBase;
+ unsigned long * MMIOBase;
+ unsigned char * CMAPBase;
+ long FBMapSize;
+ unsigned long videoRam;
+ unsigned long ramdac;
+ OptionInfoPtr Options;
+ unsigned int Flags;
+ CARD32 Bus;
+ XAAInfoRecPtr AccelInfoRec;
+/* xf86CursorInfoPtr CursorInfoRec; */
+ Bool NoAccel;
+ Bool HWCursor;
+ Bool InitDAC;
+ Bool FBDev;
+ int Chipset, ChipRev;
+ unsigned long pitch;
+ unsigned long ll;
+ unsigned long bltctl;
+ unsigned short hes;
+ unsigned short heb;
+ unsigned short hsb;
+ unsigned short ht;
+ unsigned short ves;
+ unsigned short veb;
+ unsigned short vsb;
+ unsigned short vt;
+ unsigned short vil;
+ unsigned char pclk_m;
+ unsigned char pclk_n;
+ unsigned char pclk_p;
+ unsigned char mlc[3];
+ unsigned char lckl_p[3];
+} IMSTTRec, *IMSTTPtr;
+
+
+#define IMSTTPTR(p) ((IMSTTPtr)((p)->driverPrivate))
+
+#define PCI_IMSTT128 0x9128 /* IMS,tt128mbA */
+#define PCI_IMSTT3D 0x9135 /* IMS,tt3d */
+
+#define RAMDAC_IBM 1
+#define RAMDAC_TVP 2
+
+#endif /* _IMSTT_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c
new file mode 100644
index 000000000..53f46bb13
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c
@@ -0,0 +1,143 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_accel.c,v 1.2 2000/06/14 02:36:07 dawes Exp $ */
+
+/*
+ * Copyright 2000 Ani Joshi <ajoshi@unixbox.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 of Ani Joshi not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Ani Joshi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANI JOSHI 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 "Xarch.h"
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xaa.h"
+#include "xf86PciInfo.h"
+
+#include "imstt.h"
+#include "imstt_reg.h"
+
+
+
+static void IMSTTSync(ScrnInfoPtr pScrn)
+{
+ IMSTTPtr iptr = IMSTTPTR(pScrn);
+ IMSTTMMIO_VARS();
+
+ while(INREG(IMSTT_SSTATUS) & 0x80);
+ while(INREG(IMSTT_SSTATUS) & 0x40);
+ return;
+}
+
+
+static void IMSTTSetupForSolidFill(ScrnInfoPtr pScrn, int color,
+ int rop, unsigned int planemask)
+{
+ IMSTTPtr iptr = IMSTTPTR(pScrn);
+ IMSTTMMIO_VARS();
+
+ OUTREG(IMSTT_BI, 0xffffffff);
+ OUTREG(IMSTT_MBC, 0xffffffff);
+ OUTREG(IMSTT_CLR, color);
+ OUTREG(IMSTT_DP_OCTL, (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3)));
+}
+
+
+static void IMSTTSubsequentSolidFillRect(ScrnInfoPtr pScrn,
+ int x, int y, int w, int h)
+{
+ IMSTTPtr iptr = IMSTTPTR(pScrn);
+ IMSTTMMIO_VARS();
+
+ OUTREG(IMSTT_DSA, y + x);
+ OUTREG(IMSTT_CNT, (h << 16) | w);
+ OUTREG(IMSTT_BLTCTL, 0x840);
+}
+
+
+static void IMSTTSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir,
+ int ydir, int rop, unsigned int planemask,
+ int trans_color)
+{
+ IMSTTPtr iptr = IMSTTPTR(pScrn);
+ IMSTTMMIO_VARS();
+ unsigned long sp, dp, ll, cnt;
+
+ iptr->bltctl = 0x05;
+ ll = pScrn->displayWidth * (pScrn->bitsPerPixel >> 3);
+ iptr->ll = ll;
+ sp = ll << 16;
+ cnt = pScrn->virtualY << 16;
+ if (xdir >= 0) {
+ dp = -(ll) & 0xffff;
+ sp |= dp;
+ }
+ if (ydir >= 0) {
+ iptr->bltctl |= 0x80;
+ cnt |= -(pScrn->displayWidth) & 0xffff;
+ } else {
+ cnt |= pScrn->displayWidth;
+ }
+
+ OUTREG(IMSTT_SP, sp);
+ OUTREG(IMSTT_CNT, cnt);
+ OUTREG(IMSTT_DP_OCTL, dp);
+}
+
+
+static void IMSTTSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn,
+ int x1, int y1,
+ int x2, int y2,
+ int w, int h)
+{
+ IMSTTPtr iptr = IMSTTPTR(pScrn);
+ IMSTTMMIO_VARS();
+
+ OUTREG(IMSTT_S1SA, x1 * iptr->ll * y1);
+ OUTREG(IMSTT_DSA, x2 * iptr->ll * y2);
+ OUTREG(IMSTT_BLTCTL, iptr->bltctl);
+}
+
+
+
+
+Bool IMSTTAccelInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ IMSTTPtr iptr = IMSTTPTR(pScrn);
+ XAAInfoRecPtr xaaptr;
+
+ if (!(xaaptr = iptr->AccelInfoRec = XAACreateInfoRec()))
+ return FALSE;
+
+ xaaptr->Flags = (PIXMAP_CACHE | OFFSCREEN_PIXMAPS | LINEAR_FRAMEBUFFER);
+
+ xaaptr->Sync = IMSTTSync;
+ xaaptr->SetupForSolidFill = IMSTTSetupForSolidFill;
+ xaaptr->SubsequentSolidFillRect = IMSTTSubsequentSolidFillRect;
+ xaaptr->ScreenToScreenCopyFlags = 0;
+ xaaptr->SetupForScreenToScreenCopy = IMSTTSetupForScreenToScreenCopy;
+ xaaptr->SubsequentScreenToScreenCopy = IMSTTSubsequentScreenToScreenCopy;
+
+ return XAAInit(pScreen, xaaptr);
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c
new file mode 100644
index 000000000..c234619bd
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c
@@ -0,0 +1,1292 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_driver.c,v 1.6 2000/06/22 16:59:28 tsi Exp $ */
+
+/*
+ * Copyright 2000 Ani Joshi <ajoshi@unixbox.com>
+ *
+ * XFree86 4.0 driver for the Integrated Micro Solutions
+ * Twin Turbo 128 chipset
+ *
+ * Credits:
+ * Sigurdur Asgeirsson, Jeffrey Kuskin, Ryan Nielsen
+ * for their work on imsttfb
+ *
+ * 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 Ani Joshi not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission. Ani Joshi makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as-is" without express or implied warranty.
+ *
+ * ANI JOSHI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL ANI JOSHI 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.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#include "xf86Version.h"
+#include "xf86Resources.h"
+#include "xf86fbman.h"
+#include "xaa.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include "mibstore.h"
+#include "fbdevhw.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb24.h"
+#include "cfb32.h"
+
+#include "xf86cmap.h"
+
+#include "imstt.h"
+#include "imstt_reg.h"
+
+
+/* To get it to build on non-PPC */
+#ifndef __powerpc__
+#define eieio()
+#endif
+
+/*
+ * prototypes
+ */
+static OptionInfoPtr IMSTTAvailableOptions(int chipid, int busid);
+static void IMSTTIdentify(int flags);
+static Bool IMSTTProbe(DriverPtr drv, int flags);
+static Bool IMSTTPreInit(ScrnInfoPtr pScrn, int flags);
+
+static Bool IMSTTEnterVT(int scrnIndex, int flags);
+static void IMSTTLeaveVT(int scrnIndex, int flags);
+static void IMSTTSave(ScrnInfoPtr pScrn);
+static Bool IMSTTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc,
+ char **argv);
+static int IMSTTInternalScreenInit(int scrnIndex, ScreenPtr pScreen);
+static ModeStatus IMSTTValidMode(int index, DisplayModePtr mode,
+ Bool verbose, int flags);
+
+static Bool IMSTTMapMem(ScrnInfoPtr pScrn);
+static void IMSTTUnmapMem(ScrnInfoPtr pScrn);
+static Bool IMSTTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static void IMSTTAdjustFrame(int scrnIndex, int x, int y, int flags);
+static Bool IMSTTCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool IMSTTSaveSCreen(ScreenPtr pScreen, int mode);
+static void IMSTTLoadPalette(ScrnInfoPtr pScrn, int numColors,
+ int *indicies, LOCO *colors,
+ VisualPtr pVisual);
+
+static void IMSTTGetVideoMemSize(ScrnInfoPtr pScrn);
+static void IMSTTSetClock(ScrnInfoPtr pScrn, unsigned long mhz);
+static void IMSTTWriteMode(ScrnInfoPtr pScrn);
+
+#define DRIVER_NAME "imstt"
+#define DRIVER_VERSION "1.0.0"
+#define VERSION_MAJOR 1
+#define VERSION_MINOR 0
+#define PATCHLEVEL 0
+#define IMSTT_VERSION ((VERSION_MAJOR << 24) | \
+ (VERSION_MINOR << 16) | \
+ PATCHLEVEL)
+
+
+DriverRec IMSTT =
+{
+ IMSTT_VERSION,
+ DRIVER_NAME,
+ IMSTTIdentify,
+ IMSTTProbe,
+ IMSTTAvailableOptions,
+ NULL,
+ 0
+};
+
+
+/* supported chipsets */
+static SymTabRec IMSTTChipsets[] = {
+ { PCI_IMSTT128, "imstt128" },
+ { PCI_IMSTT3D, "imstt3d" },
+ { -1, NULL }
+};
+
+static PciChipsets IMSTTPciChipsets[] = {
+ { PCI_IMSTT128, PCI_IMSTT128, RES_SHARED_VGA },
+ { PCI_IMSTT3D, PCI_IMSTT3D, RES_SHARED_VGA },
+ { -1, -1, RES_UNDEFINED }
+};
+
+typedef enum {
+ OPTION_NOACCEL,
+ OPTION_SWCURSOR,
+ OPTION_INITDAC,
+ OPTION_FBDEV
+} IMSTTOpts;
+
+static OptionInfoRec IMSTTOptions[] =
+{
+ { OPTION_NOACCEL, "noaccel", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_SWCURSOR, "swcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_INITDAC, "initdac", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE }
+};
+
+
+static const char *cfbSymbols[] = {
+ "cfbScreenInit",
+ "cfb16ScreenInit",
+ "cfb24ScreenInit",
+ "cfb32ScreenInit",
+ "cfb16BresS",
+ "cfb24BresS",
+ NULL
+};
+
+
+static const char *xaaSymbols[] = {
+ "XAADestroyInfoRec",
+ "XAACreateInfoRec",
+ "XAAInit",
+ "XAAScreenIndex",
+ NULL
+};
+
+
+static const char *fbdevHWSymbols[] = {
+ "fbdevHWInit",
+ "fbdevHWUseBuildinMode",
+ "fbdevHWGetDepth",
+ "fbdevHWGetVidmem",
+ "fbdevHWLoadPalette",
+ "fbdevHWSwitchMode",
+ "fbdevHWAdjustFrame",
+ "fbdevHWEnterVT",
+ "fbdevHWLeaveVT",
+ "fbdevHWValidMode",
+ "fbdevHWRestore",
+ "fbdevHWModeInit",
+ "fbdevHWUnmapMMIO",
+ "fbdevHWUnmapVidmem",
+ "fbdevHWMapMMIO",
+ "fbdevHWMapVidmem",
+ NULL
+};
+
+
+#ifdef XFree86LOADER
+static pointer IMSTTSetup(pointer module, pointer opts, int *errmaj,
+ int *errmin);
+
+static XF86ModuleVersionInfo IMSTTVersRec = {
+ "imstt",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0, 0, 0, 0}
+};
+
+XF86ModuleData IMSTTModuleData = { &IMSTTVersRec, IMSTTSetup, NULL };
+
+static pointer IMSTTSetup(pointer module, pointer opts, int *errmaj,
+ int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&IMSTT, module, 0);
+ LoaderRefSymLists(0, cfbSymbols, xaaSymbols, 0, 9, fbdevHWSymbols, 0, 0, 0, NULL);
+ return (pointer) 1;
+ } else {
+ if (errmaj)
+ *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+
+#endif /* XFree86LOADER */
+
+
+static Bool IMSTTGetRec(ScrnInfoPtr pScrn)
+{
+ if (pScrn->driverPrivate)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(IMSTTRec), 1);
+ return TRUE;
+}
+
+
+static void IMSTTFreeRec(ScrnInfoPtr pScrn)
+{
+ if (!pScrn->driverPrivate)
+ return;
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+ IMSTTUnmapMem(pScrn);
+}
+
+
+static OptionInfoPtr IMSTTAvailableOptions(int chipid, int busid)
+{
+ return IMSTTOptions;
+}
+
+
+static void IMSTTIdentify(int flags)
+{
+ xf86PrintChipsets("imstt", "driver (version " DRIVER_VERSION " for IMS TwinTurbo chipsets ",
+ IMSTTChipsets);
+}
+
+
+static Bool IMSTTProbe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+
+ /* sanity checks */
+ if ((numDevSections = xf86MatchDevice("imstt", &devSections)) <= 0)
+ return FALSE;
+ if (xf86GetPciVideoInfo() == NULL)
+ return FALSE;
+
+ numUsed = xf86MatchPciInstances("imstt", PCI_VENDOR_IMS,
+ IMSTTChipsets, IMSTTPciChipsets,
+ devSections, numDevSections, drv,
+ &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i=0; i<numUsed; i++) {
+ ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0);
+
+ pScrn->driverVersion = VERSION_MAJOR;
+ pScrn->driverName = DRIVER_NAME;
+ pScrn->name = "imstt";
+ pScrn->Probe = IMSTTProbe;
+ pScrn->PreInit = IMSTTPreInit;
+ pScrn->ScreenInit = IMSTTScreenInit;
+/* pScrn->SwitchMode = IMSTTSwitchMode; */
+ pScrn->AdjustFrame = IMSTTAdjustFrame;
+/* pScrn->EnterVT = IMSTTEnterVT;
+ pScrn->LeaveVT = IMSTTLeaveVT; */
+ pScrn->FreeScreen = NULL;
+/* pScrn->ValidMode = IMSTTValidMode; */
+ foundScreen = TRUE;
+ xf86ConfigActivePciEntity(pScrn, usedChips[i], IMSTTPciChipsets,
+ NULL, NULL, NULL, NULL, NULL);
+ }
+
+ xfree(usedChips);
+ return foundScreen;
+}
+
+
+static Bool IMSTTPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ EntityInfoPtr pEnt;
+ IMSTTPtr iptr;
+ MessageType from = X_DEFAULT;
+ int i;
+ ClockRangePtr clockRanges;
+ char *mod = NULL;
+ const char *reqSym = NULL;
+ rgb zeros = {0, 0, 0};
+ Gamma gzeros = {0.0, 0.0, 0.0};
+
+
+ if (flags & PROBE_DETECT)
+ return FALSE;
+
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb | Support32bppFb |
+ SupportConvert32to24 | PreferConvert32to24))
+ return FALSE;
+ else {
+ switch (pScrn->depth) {
+ case 8:
+ case 15:
+ case 16:
+ case 24:
+ case 32:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ xf86PrintDepthBpp(pScrn);
+
+ if (pScrn->depth > 8) {
+ if (!xf86SetWeight(pScrn, zeros, zeros))
+ return FALSE;
+ }
+
+ if (pScrn->depth == 8)
+ pScrn->rgbBits = 8;
+
+ pScrn->progClock = TRUE;
+
+ if (!IMSTTGetRec(pScrn))
+ return FALSE;
+ iptr = IMSTTPTR(pScrn);
+
+ xf86CollectOptions(pScrn, NULL);
+
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, IMSTTOptions);
+
+ if (xf86ReturnOptValBool(IMSTTOptions, OPTION_NOACCEL, FALSE)) {
+ iptr->NoAccel = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: NoAccel - acceleration disabled\n");
+ } else
+ iptr->NoAccel = FALSE;
+#if 0
+ if (xf86ReturnOptValBool(IMSTTOptions, OPTION_SWCURSOR, FALSE))
+ iptr->HWCursor = FALSE;
+ else
+ iptr->HWCursor = TRUE;
+#else
+ /* HW cursor support not ready yet... */
+ iptr->HWCursor = FALSE;
+#endif
+
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using %s cursor\n",
+ iptr->HWCursor ? "HW" : "SW");
+
+ if (xf86ReturnOptValBool(IMSTTOptions, OPTION_INITDAC, FALSE)) {
+ iptr->InitDAC = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: not initalizing DACn");
+ } else {
+ iptr->InitDAC = FALSE;
+ }
+
+ if (xf86ReturnOptValBool(IMSTTOptions, OPTION_FBDEV, FALSE)) {
+ iptr->FBDev = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using framebuffer device\n");
+ } else {
+ iptr->FBDev = FALSE;
+ }
+
+ if (iptr->FBDev) {
+ if (!xf86LoadSubModule(pScrn, "fbdevhw"))
+ return FALSE;
+ xf86LoaderReqSymLists(fbdevHWSymbols, NULL);
+ if (!fbdevHWInit(pScrn, iptr->PciInfo, NULL))
+ return FALSE;
+ pScrn->SwitchMode = fbdevHWSwitchMode;
+ pScrn->AdjustFrame = fbdevHWAdjustFrame;
+ pScrn->EnterVT = fbdevHWEnterVT;
+ pScrn->LeaveVT = fbdevHWLeaveVT;
+ pScrn->ValidMode = fbdevHWValidMode;
+ }
+
+ if (pScrn->numEntities > 1) {
+ IMSTTFreeRec(pScrn);
+ return FALSE;
+ }
+
+ pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+ if (pEnt->resources) {
+ xfree(pEnt);
+ IMSTTFreeRec(pScrn);
+ return FALSE;
+ }
+
+ iptr->PciInfo = xf86GetPciInfoForEntity(pEnt->index);
+ xf86RegisterResources(pEnt->index, NULL, ResNone);
+ xf86SetOperatingState(RES_SHARED_VGA, pEnt->index, ResUnusedOpr);
+ xf86SetOperatingState(resVgaMemShared, pEnt->index, ResDisableOpr);
+
+ if (pEnt->device->chipset && *pEnt->device->chipset) {
+ pScrn->chipset = pEnt->device->chipset;
+ iptr->Chipset = xf86StringToToken(IMSTTChipsets, pScrn->chipset);
+ } else if (pEnt->device->chipID >= 0) {
+ iptr->Chipset = pEnt->device->chipID;
+ pScrn->chipset = (char *)xf86TokenToString(IMSTTChipsets,
+ iptr->Chipset);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipID override: 0x%04X\n",
+ iptr->Chipset);
+ } else {
+ iptr->Chipset = iptr->PciInfo->chipType;
+ pScrn->chipset = (char *)xf86TokenToString(IMSTTChipsets,
+ iptr->Chipset);
+ }
+
+ if (pEnt->device->chipRev >= 0) {
+ iptr->ChipRev = pEnt->device->chipRev;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
+ iptr->ChipRev);
+ } else
+ iptr->ChipRev = iptr->PciInfo->chipRev;
+
+ xfree(pEnt);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Chipset: \"%s\"\n", pScrn->chipset);
+
+ iptr->PciTag = pciTag(iptr->PciInfo->bus, iptr->PciInfo->device,
+ iptr->PciInfo->func);
+
+ if (!xf86SetGamma(pScrn, gzeros))
+ return FALSE;
+
+ if (iptr->Chipset == PCI_IMSTT3D) {
+ iptr->ramdac = RAMDAC_TVP;
+ iptr->videoRam = 0x800000;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "using %s ramdac\n", iptr->ramdac == RAMDAC_TVP ? "TVP" : "IBM");
+
+ if (!IMSTTMapMem(pScrn)) {
+ IMSTTFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (!pScrn->videoRam) {
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
+ "probed videoram = %dk\n",
+ (iptr->videoRam / 1024));
+ pScrn->videoRam = (iptr->videoRam / 1024);
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "videoram = %dk\n",
+ pScrn->videoRam);
+ }
+
+ /* XXX this is sorta a guess, got some info from the TVP3030 manual */
+ pScrn->numClocks = 2;
+ pScrn->clock[0] = 110000;
+ pScrn->clock[1] = 220000;
+
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
+ clockRanges->next = NULL;
+ clockRanges->minClock = 20000;
+ clockRanges->maxClock = 120000; /* i don't want to blow up anything */
+ clockRanges->clockIndex = -1;
+ clockRanges->interlaceAllowed = FALSE; /* ? */
+ clockRanges->doubleScanAllowed = FALSE; /* ? */
+
+ i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
+ pScrn->display->modes, clockRanges,
+ NULL, 256, 2048, pScrn->bitsPerPixel,
+ 128, 2048, pScrn->virtualX,
+ pScrn->display->virtualY,
+ iptr->videoRam, LOOKUP_BEST_REFRESH);
+
+ if (i < 1 && iptr->FBDev) {
+ fbdevHWUseBuildinMode(pScrn);
+ pScrn->displayWidth = pScrn->virtualX; /* XXX */
+ i = i;
+ }
+
+ if (i == -1) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "no valid modes left\n");
+ IMSTTFreeRec(pScrn);
+ return FALSE;
+ }
+
+ xf86PruneDriverModes(pScrn);
+
+ if (i == 0 || pScrn->modes == NULL) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n");
+ IMSTTFreeRec(pScrn);
+ return FALSE;
+ }
+
+ xf86SetCrtcForModes(pScrn, 0);
+ pScrn->currentMode = pScrn->modes;
+ xf86PrintModes(pScrn);
+ xf86SetDpi(pScrn, 0, 0);
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ mod = "cfb";
+ reqSym = "cfbScreenInit";
+ break;
+ case 16:
+ mod = "cfb16";
+ reqSym = "cfb16ScreenInit";
+ break;
+ case 32:
+ mod = "cfb32";
+ reqSym = "cfb32ScreenInit";
+ break;
+ }
+ if (mod && xf86LoadSubModule(pScrn, mod) == NULL) {
+ IMSTTFreeRec(pScrn);
+ return FALSE;
+ }
+
+ xf86LoaderReqSymbols(reqSym, NULL);
+
+ if (!iptr->NoAccel) {
+ if (!xf86LoadSubModule(pScrn, "xaa"))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+
+static Bool IMSTTMapMem(ScrnInfoPtr pScrn)
+{
+ IMSTTPtr iptr;
+
+ iptr = IMSTTPTR(pScrn);
+
+ if (iptr->FBDev) {
+ iptr->MMIOBase = fbdevHWMapMMIO(pScrn);
+ } else {
+ iptr->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, iptr->PciTag,
+ iptr->PciInfo->memBase[0] + 0x800000,
+ 0x1000);
+ }
+ if (!iptr->MMIOBase) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Internal error: could not map MMIO\n");
+ return FALSE;
+ }
+
+ IMSTTGetVideoMemSize(pScrn);
+
+ if (iptr->FBDev) {
+ iptr->FBBase = fbdevHWMapVidmem(pScrn);
+ } else {
+ iptr->FBBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER, iptr->PciTag,
+ iptr->PciInfo->memBase[0],
+ iptr->videoRam);
+ }
+ if (!iptr->FBBase) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Internal error: could not map framebuffer\n");
+ return FALSE;
+ }
+
+ if (iptr->InitDAC) {
+ iptr->CMAPBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_MMIO, iptr->PciTag,
+ iptr->PciInfo->memBase[0] + 0x840000,
+ 0x1000);
+ if (!iptr->CMAPBase) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Internal error: could not map CMAP\n");
+ return FALSE;
+ }
+ }
+
+ pScrn->fbOffset = 0;
+
+ return TRUE;
+}
+
+
+static void IMSTTUnmapMem(ScrnInfoPtr pScrn)
+{
+ IMSTTPtr iptr;
+
+ iptr = IMSTTPTR(pScrn);
+
+ if (iptr->FBDev) {
+ fbdevHWUnmapMMIO(pScrn);
+ } else {
+ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)iptr->MMIOBase,
+ 0x1000);
+ }
+
+ if (iptr->InitDAC) {
+ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)iptr->CMAPBase,
+ 0x1000);
+ }
+
+ if (iptr->FBDev) {
+ fbdevHWUnmapVidmem(pScrn);
+ } else {
+ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)iptr->FBBase,
+ iptr->videoRam);
+ }
+
+ return;
+}
+
+
+
+static void IMSTTGetVideoMemSize(ScrnInfoPtr pScrn)
+{
+ IMSTTPtr iptr;
+ IMSTTMMIO_VARS();
+ unsigned long tmp;
+
+ tmp = INREG(IMSTT_PRC);
+ if (iptr->ramdac == RAMDAC_IBM)
+ iptr->videoRam = (tmp & 0x0004) ? 0x400000 : 0x200000;
+ else
+ iptr->videoRam = 0x800000;
+
+ return;
+}
+
+
+static Bool IMSTTScreenInit(int scrnIndex, ScreenPtr pScreen,
+ int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ IMSTTPtr iptr;
+ IMSTTMMIO_VARS();
+ unsigned long tmp;
+ VisualPtr visual;
+ int r = TRUE;
+
+ pScrn = xf86Screens[pScreen->myNum];
+ iptr = IMSTTPTR(pScrn);
+
+ /* initialize the card */
+ tmp = INREG(IMSTT_STGCTL);
+ OUTREG(IMSTT_STGCTL, tmp & ~0x1);
+ OUTREG(IMSTT_SSR, 0);
+
+ if (iptr->InitDAC) {
+ /* set default values for DAC registers */
+ if (iptr->ramdac == RAMDAC_IBM) {
+ iptr->CMAPBase[IBM624_PPMASK] = 0xff; eieio();
+ iptr->CMAPBase[IBM624_PIDXHI] = 0; eieio();
+ OUTREGPI(IBM624_CLKCTL, 0x21);
+ OUTREGPI(IBM624_SYNCCTL, 0x00);
+ OUTREGPI(IBM624_HSYNCPOS, 0x00);
+ OUTREGPI(IBM624_PWRMNGMT, 0x00);
+ OUTREGPI(IBM624_DACOP, 0x02);
+ OUTREGPI(IBM624_PALETCTL, 0x00);
+ OUTREGPI(IBM624_SYSCLKCTL, 0x01);
+ OUTREGPI(IBM624_BPP8, 0x00);
+ OUTREGPI(IBM624_BPP16, 0x01);
+ OUTREGPI(IBM624_BPP24, 0x00);
+ OUTREGPI(IBM624_BPP32, 0x00);
+ OUTREGPI(IBM624_PIXCTL1, 0x05);
+ OUTREGPI(IBM624_PIXCTL2, 0x00);
+ OUTREGPI(IBM624_SYSCLKN, 0x08);
+ OUTREGPI(IBM624_SYSCLKM, 0x4f);
+ OUTREGPI(IBM624_SYSCLKP, 0x00);
+ OUTREGPI(IBM624_SYSCLKC, 0x00);
+ OUTREGPI(IBM624_CURSCTL, 0x00);
+ OUTREGPI(IBM624_CURSACCTL, 0x01);
+ OUTREGPI(IBM624_CURSACATTR, 0xa8);
+ OUTREGPI(IBM624_CURS1R, 0xff);
+ OUTREGPI(IBM624_CURS1G, 0xff);
+ OUTREGPI(IBM624_CURS1B, 0xff);
+ OUTREGPI(IBM624_CURS2R, 0xff);
+ OUTREGPI(IBM624_CURS2G, 0xff);
+ OUTREGPI(IBM624_CURS2B, 0xff);
+ OUTREGPI(IBM624_CURS3R, 0xff);
+ OUTREGPI(IBM624_CURS3G, 0xff);
+ OUTREGPI(IBM624_CURS3B, 0xff);
+ OUTREGPI(IBM624_BORDR, 0xff);
+ OUTREGPI(IBM624_BORDG, 0xff);
+ OUTREGPI(IBM624_BORDB, 0xff);
+ OUTREGPI(IBM624_MISCTL1, 0x01);
+ OUTREGPI(IBM624_MISCTL2, 0x45);
+ OUTREGPI(IBM624_MISCTL3, 0x00);
+ OUTREGPI(IBM624_KEYCTL, 0x00);
+ } else {
+ OUTREGPT(TVP_IRICC, 0x00);
+ OUTREGPT(TVP_IRBRC, 0xe4);
+ OUTREGPT(TVP_IRLAC, 0x06);
+ OUTREGPT(TVP_IRTCC, 0x80);
+ OUTREGPT(TVP_IRMXC, 0x4d);
+ OUTREGPT(TVP_IRCLS, 0x05);
+ OUTREGPT(TVP_IRPPG, 0x00);
+ OUTREGPT(TVP_IRGEC, 0x00);
+ OUTREGPT(TVP_IRMIC, 0x08);
+ OUTREGPT(TVP_IRCKL, 0xff);
+ OUTREGPT(TVP_IRCKH, 0xff);
+ OUTREGPT(TVP_IRCRL, 0xff);
+ OUTREGPT(TVP_IRCRH, 0xff);
+ OUTREGPT(TVP_IRCGL, 0xff);
+ OUTREGPT(TVP_IRCGH, 0xff);
+ OUTREGPT(TVP_IRCBL, 0xff);
+ OUTREGPT(TVP_IRCBH, 0xff);
+ OUTREGPT(TVP_IRCKC, 0x00);
+ OUTREGPT(TVP_IRPLA, 0x00);
+ OUTREGPT(TVP_IRPPD, 0xc0);
+ OUTREGPT(TVP_IRPPD, 0xd5);
+ OUTREGPT(TVP_IRPPD, 0xea);
+ OUTREGPT(TVP_IRPLA, 0x00);
+ OUTREGPT(TVP_IRMPD, 0xb9);
+ OUTREGPT(TVP_IRMPD, 0x3a);
+ OUTREGPT(TVP_IRMPD, 0xb1);
+ OUTREGPT(TVP_IRPLA, 0x00);
+ OUTREGPT(TVP_IRLPD, 0xc1);
+ OUTREGPT(TVP_IRLPD, 0x3d);
+ OUTREGPT(TVP_IRLPD, 0xf3);
+ }
+ }
+
+ if (iptr->FBDev) {
+ if (!fbdevHWModeInit(pScrn, pScrn->currentMode))
+ return FALSE;
+ } else {
+ if (!IMSTTModeInit(pScrn, pScrn->currentMode))
+ return FALSE;
+ }
+
+ pScrn->AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ miClearVisualTypes();
+
+ 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;
+ }
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ r = cfbScreenInit(pScreen, iptr->FBBase, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth);
+ break;
+ case 16:
+ r = cfb16ScreenInit(pScreen, iptr->FBBase, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth);
+ break;
+ case 24:
+ r = cfb24ScreenInit(pScreen, iptr->FBBase, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth);
+ break;
+ case 32:
+ r = cfb32ScreenInit(pScreen, iptr->FBBase, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth);
+ break;
+ default:
+ r = FALSE;
+ break;
+ }
+
+ if (!r) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "ScreenInit failed\n");
+ return FALSE;
+ }
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ 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;
+ }
+ }
+ }
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+
+ if (!iptr->NoAccel) {
+ if (IMSTTAccelInit(pScreen)) {
+ xf86DrvMsg(scrnIndex, X_INFO, "Acceleration enabled\n");
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Acceleration initailizatino failed\n");
+ xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n");
+ }
+ } else {
+ xf86DrvMsg(scrnIndex, X_INFO, "Acceleration disabled\n");
+ }
+
+ miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
+
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ if (!xf86HandleColormaps(pScreen, 256, 8, (iptr->FBDev ? fbdevHWLoadPalette : NULL),
+ NULL, CMAP_RELOAD_ON_MODE_SWITCH))
+ return FALSE;
+
+ if (serverGeneration == 1)
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+
+ return TRUE;
+}
+
+
+
+
+static Bool IMSTTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ IMSTTPtr iptr;
+ IMSTTMMIO_VARS();
+ unsigned long mhz;
+ unsigned short hes, heb, veb, htp, vtp;
+
+ iptr = IMSTTPTR(pScrn);
+
+ if (iptr->ramdac == RAMDAC_IBM) {
+ switch (pScrn->displayWidth) {
+ case 640:
+ hes = 0x0008;
+ heb = 0x0012;
+ veb = 0x002a;
+ htp = 10;
+ vtp = 2;
+ mhz = 30;
+ break;
+ case 832:
+ hes = 0x0005;
+ heb = 0x0020;
+ veb = 0x0028;
+ htp = 8;
+ vtp = 3;
+ mhz = 57;
+ break;
+ case 1024:
+ hes = 0x000a;
+ heb = 0x001c;
+ veb = 0x0020;
+ htp = 8;
+ vtp = 3;
+ mhz = 80;
+ break;
+ case 1152:
+ hes = 0x0012;
+ heb = 0x0022;
+ veb = 0x0031;
+ htp = 4;
+ vtp = 3;
+ mhz = 101;
+ break;
+ case 1280:
+ hes = 0x0012;
+ heb = 0x002f;
+ veb = 0x0029;
+ htp = 4;
+ vtp = 1;
+ mhz = 135; /* XXX check for 1280x960 */
+ break;
+ case 1600:
+ hes = 0x0018;
+ heb = 0x0040;
+ veb = 0x002a;
+ htp = 4;
+ vtp = 3;
+ mhz = 200;
+ break;
+ default:
+ return FALSE;
+ }
+
+ IMSTTSetClock(pScrn, mhz);
+
+ iptr->hes = hes;
+ iptr->heb = heb;
+ iptr->hsb = heb + (pScrn->displayWidth >> 3);
+ iptr->ht = iptr->hsb + htp;
+ iptr->ves = 0x0003;
+ iptr->veb = veb;
+ iptr->vsb = veb + pScrn->virtualY;
+ iptr->vt = iptr->vsb + vtp;
+ iptr->vil = iptr->vsb;
+ iptr->pitch = pScrn->displayWidth;
+ } else {
+ iptr->pitch = pScrn->displayWidth;
+ switch (pScrn->displayWidth) {
+ case 640:
+ iptr->hes = 0x0004;
+ iptr->heb = 0x0009;
+ iptr->hsb = 0x0031;
+ iptr->ht = 0x0036;
+ iptr->ves = 0x0003;
+ iptr->veb = 0x002a;
+ iptr->vsb = 0x020a;
+ iptr->vt = 0x020d;
+ iptr->vil = 0x020a;
+ iptr->pclk_m = 0xef;
+ iptr->pclk_n = 0x2e;
+ iptr->pclk_p = 0xb2;
+ iptr->mlc[0] = 0x39;
+ iptr->mlc[1] = 0x39;
+ iptr->mlc[2] = 0x38;
+ iptr->lckl_p[0] = 0xf3;
+ iptr->lckl_p[1] = 0xf3;
+ iptr->lckl_p[2] = 0xf3;
+ case 800:
+ iptr->hes = 0x0005;
+ iptr->heb = 0x000e;
+ iptr->hsb = 0x0040;
+ iptr->ht = 0x0042;
+ iptr->ves = 0x0003;
+ iptr->veb = 0x0018;
+ iptr->vsb = 0x0270;
+ iptr->vt = 0x0271;
+ iptr->vil = 0x0270;
+ iptr->pclk_m = 0xf6;
+ iptr->pclk_n = 0x2e;
+ iptr->pclk_p = 0xf2;
+ iptr->mlc[0] = 0x3a;
+ iptr->mlc[1] = 0x39;
+ iptr->mlc[2] = 0x38;
+ iptr->lckl_p[0] = 0xf3;
+ iptr->lckl_p[1] = 0xf3;
+ iptr->lckl_p[2] = 0xf3;
+ case 832:
+ iptr->hes = 0x0004;
+ iptr->heb = 0x0011;
+ iptr->hsb = 0x0045;
+ iptr->ht = 0x0048;
+ iptr->ves = 0x0003;
+ iptr->veb = 0x002a;
+ iptr->vsb = 0x029a;
+ iptr->vt = 0x029b;
+ iptr->vil = 0x0000;
+ iptr->pclk_m = 0xfe;
+ iptr->pclk_n = 0x3e;
+ iptr->pclk_p = 0xf1;
+ iptr->mlc[0] = 0x39;
+ iptr->mlc[1] = 0x38;
+ iptr->mlc[2] = 0x38;
+ iptr->lckl_p[0] = 0xf3;
+ iptr->lckl_p[1] = 0xf3;
+ iptr->lckl_p[2] = 0xf2;
+ case 1024:
+ iptr->hes = 0x0006;
+ iptr->heb = 0x0210;
+ iptr->hsb = 0x0250;
+ iptr->ht = 0x0053;
+ iptr->ves = 0x1003;
+ iptr->veb = 0x0021;
+ iptr->vsb = 0x0321;
+ iptr->vt = 0x0324;
+ iptr->vil = 0x0000;
+ iptr->pclk_m = 0xfc;
+ iptr->pclk_n = 0x3a;
+ iptr->pclk_p = 0xf1;
+ iptr->mlc[0] = 0x39;
+ iptr->mlc[1] = 0x38;
+ iptr->mlc[2] = 0x38;
+ iptr->lckl_p[0] = 0xf3;
+ iptr->lckl_p[1] = 0xf3;
+ iptr->lckl_p[2] = 0xf2;
+ case 1152:
+ iptr->hes = 0x0009;
+ iptr->heb = 0x0011;
+ iptr->hsb = 0x0059;
+ iptr->ht = 0x005b;
+ iptr->ves = 0x0003;
+ iptr->veb = 0x0031;
+ iptr->vsb = 0x0397;
+ iptr->vt = 0x039a;
+ iptr->vil = 0x0000;
+ iptr->pclk_m = 0xfd;
+ iptr->pclk_n = 0x3a;
+ iptr->pclk_p = 0xf1;
+ iptr->mlc[0] = 0x39;
+ iptr->mlc[1] = 0x38;
+ iptr->mlc[2] = 0x38;
+ iptr->lckl_p[0] = 0xf3;
+ iptr->lckl_p[1] = 0xf3;
+ iptr->lckl_p[2] = 0xf2;
+ case 1280:
+ iptr->hes = 0x0009;
+ iptr->heb = 0x0018;
+ iptr->hsb = 0x0068;
+ iptr->ht = 0x006a;
+ iptr->ves = 0x0003;
+ iptr->veb = 0x0029;
+ iptr->vsb = 0x0429;
+ iptr->vt = 0x042a;
+ iptr->vil = 0x0000;
+ iptr->pclk_m = 0xf0;
+ iptr->pclk_n = 0x2d;
+ iptr->pclk_p = 0xf0;
+ iptr->mlc[0] = 0x38;
+ iptr->mlc[1] = 0x38;
+ iptr->mlc[2] = 0x38;
+ iptr->lckl_p[0] = 0xf3;
+ iptr->lckl_p[1] = 0xf2;
+ iptr->lckl_p[2] = 0xf1;
+ default:
+ return FALSE;
+ }
+ }
+
+ /* do it! */
+ IMSTTWriteMode(pScrn);
+ IMSTTAdjustFrame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
+ return TRUE;
+}
+
+
+
+
+static void IMSTTSetClock(ScrnInfoPtr pScrn, unsigned long mhz)
+{
+ IMSTTPtr iptr;
+ unsigned long clk_m, clk_n, clk_p, x, stage, spilled;
+
+ iptr = IMSTTPTR(pScrn);
+ clk_m = clk_n = clk_p = 0;
+ stage = spilled = 0;
+
+ for (;;) {
+ switch (stage) {
+ case 0:
+ clk_m++;
+ break;
+ case 1:
+ clk_n++;
+ break;
+ }
+ x = 20 * (clk_m + 1) / ((clk_n + 1) * (clk_p ? 2 * clk_p : 1));
+ if (x == mhz)
+ break;
+ if (x > mhz) {
+ spilled = 1;
+ stage = 1;
+ } else if (spilled && x < mhz) {
+ stage = 0;
+ }
+ }
+
+ iptr->pclk_m = clk_m;
+ iptr->pclk_n = clk_n;
+ iptr->pclk_p = clk_p;
+}
+
+
+static void IMSTTWriteMode(ScrnInfoPtr pScrn)
+{
+ IMSTTPtr iptr;
+ unsigned char pixformat;
+ unsigned long ctl, pitch, byteswap, scr;
+ unsigned char tcc, mxc, lckl_n, mic, mlc, lckl_p;
+ IMSTTMMIO_VARS();
+
+ iptr = IMSTTPTR(pScrn);
+
+ pixformat = (pScrn->bitsPerPixel >> 3) + 2;
+
+ if (iptr->InitDAC && (pScrn->bitsPerPixel == 16)) {
+ if (iptr->ramdac == RAMDAC_IBM) {
+ iptr->CMAPBase[IBM624_PIDXHI] = 0; eieio();
+ iptr->CMAPBase[IBM624_PIDXLO] = IBM624_BPP16; eieio();
+ iptr->CMAPBase[IBM624_PIDXDATA] = 0x03; eieio();
+ } else {
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRTCC; eieio();
+ iptr->CMAPBase[TVP_IDATA] = 0x45; eieio();
+ }
+ }
+
+ /* XXX do for 15bpp */
+
+ if ((iptr->ramdac == RAMDAC_IBM) && (iptr->InitDAC)) {
+ iptr->CMAPBase[IBM624_PIDXHI] = 0; eieio();
+ iptr->CMAPBase[IBM624_PIDXLO] = IBM624_PIXM0; eieio();
+ iptr->CMAPBase[IBM624_PIDXDATA] = iptr->pclk_m; eieio();
+ iptr->CMAPBase[IBM624_PIDXLO] = IBM624_PIXN0; eieio();
+ iptr->CMAPBase[IBM624_PIDXDATA] = iptr->pclk_n; eieio();
+ iptr->CMAPBase[IBM624_PIDXLO] = IBM624_PIXP0; eieio();
+ iptr->CMAPBase[IBM624_PIDXDATA] = iptr->pclk_p; eieio();
+ iptr->CMAPBase[IBM624_PIDXLO] = IBM624_PIXC0; eieio();
+ iptr->CMAPBase[IBM624_PIDXDATA] = 0x02; eieio();
+ iptr->CMAPBase[IBM624_PIDXLO] = IBM624_PIXFMT; eieio();
+ iptr->CMAPBase[IBM624_PIDXDATA] = pixformat; eieio();
+ }
+
+ if ((iptr->ramdac == RAMDAC_TVP) && (iptr->InitDAC)) {
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ tcc = 0x80;
+ mxc = 0x4d;
+ lckl_n = 0xc1;
+ mlc = iptr->mlc[0];
+ lckl_p = iptr->lckl_p[0];
+ break;
+ case 16:
+ tcc = 0x44;
+ mxc = 0x55;
+ lckl_n = 0xe1;
+ mlc = iptr->mlc[1];
+ lckl_p = iptr->lckl_p[1];
+ break;
+ case 24:
+ tcc = 0x5e;
+ mxc = 0x5d;
+ lckl_n = 0xf1;
+ mlc = iptr->mlc[2];
+ lckl_p = iptr->lckl_p[2];
+ break;
+ case 32:
+ tcc = 0x46;
+ mxc = 0x5d;
+ lckl_n = 0xf1;
+ mlc = iptr->mlc[2];
+ lckl_p = iptr->lckl_p[2];
+ break;
+ }
+
+ mic = 0x08;
+
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPLA; eieio();
+ iptr->CMAPBase[TVP_IDATA] = 0x00; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPPD; eieio();
+ iptr->CMAPBase[TVP_IDATA] = iptr->pclk_m; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPPD; eieio();
+ iptr->CMAPBase[TVP_IDATA] = iptr->pclk_n; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPPD; eieio();
+ iptr->CMAPBase[TVP_IDATA] = iptr->pclk_p; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRTCC; eieio();
+ iptr->CMAPBase[TVP_IDATA] = tcc; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRMXC; eieio();
+ iptr->CMAPBase[TVP_IDATA] = mxc; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRMIC; eieio();
+ iptr->CMAPBase[TVP_IDATA] = mic; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPLA; eieio();
+ iptr->CMAPBase[TVP_IDATA] = 0x00; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRLPD; eieio();
+ iptr->CMAPBase[TVP_IDATA] = lckl_n; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPLA; eieio();
+ iptr->CMAPBase[TVP_IDATA] = 0x15; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRMLC; eieio();
+ iptr->CMAPBase[TVP_IDATA] = mlc; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRPLA; eieio();
+ iptr->CMAPBase[TVP_IDATA] = 0x2a; eieio();
+ iptr->CMAPBase[TVP_ADDRW] = TVP_IRLPD; eieio();
+ iptr->CMAPBase[TVP_IDATA] = lckl_p; eieio();
+ }
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ ctl = 0x17b1;
+ pitch = iptr->pitch >> 2;
+ byteswap = 0x000;
+ break;
+ case 16:
+ ctl = 0x17b3;
+ pitch = iptr->pitch >> 1;
+ byteswap = 0x100;
+ break;
+ case 24:
+ ctl = 0x17b9;
+ pitch = iptr->pitch - (iptr->pitch >> 2);
+ byteswap = 0x200;
+ break;
+ case 32:
+ ctl = 0x17b5;
+ pitch = iptr->pitch;
+ byteswap = 0x300;
+ break;
+ }
+
+ if (iptr->ramdac == RAMDAC_TVP)
+ ctl -= 0x30;
+
+ OUTREG(IMSTT_HES, iptr->hes);
+ OUTREG(IMSTT_HEB, iptr->heb);
+ OUTREG(IMSTT_HSB, iptr->hsb);
+ OUTREG(IMSTT_HT, iptr->ht);
+ OUTREG(IMSTT_VES, iptr->ves);
+ OUTREG(IMSTT_VEB, iptr->veb);
+ OUTREG(IMSTT_VSB, iptr->vsb);
+ OUTREG(IMSTT_VT, iptr->vt);
+ OUTREG(IMSTT_VIL, iptr->vil);
+ OUTREG(IMSTT_HCIV, 1);
+ OUTREG(IMSTT_VCIV, 1);
+ OUTREG(IMSTT_TCDR, 4);
+ OUTREG(IMSTT_RRCIV, 1);
+ OUTREG(IMSTT_RRSC, 0x980);
+ OUTREG(IMSTT_RRCR, 0x11);
+
+ if (iptr->ramdac == RAMDAC_IBM) {
+ OUTREG(IMSTT_HRIR, 0x0100);
+ OUTREG(IMSTT_CMR, 0x00ff);
+ OUTREG(IMSTT_SRGCTL, 0x0073);
+ } else {
+ OUTREG(IMSTT_HRIR, 0x0200);
+ OUTREG(IMSTT_CMR, 0x01ff);
+ OUTREG(IMSTT_SRGCTL, 0x0003);
+ }
+
+ switch (iptr->videoRam) {
+ case 0x200000:
+ scr = 0x059d | byteswap;
+ break;
+ default:
+ /* 0x400000 and 0x800000 */
+ pitch >>= 1;
+ scr = 0x150dd | byteswap;
+ break;
+ }
+
+ OUTREG(IMSTT_SCR, scr);
+ OUTREG(IMSTT_SPR, pitch);
+ OUTREG(IMSTT_STGCTL, ctl);
+
+ return;
+}
+
+
+
+static void IMSTTAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ IMSTTPtr iptr;
+ IMSTTMMIO_VARS();
+ unsigned long offset;
+
+ iptr = IMSTTPTR(pScrn);
+
+ offset = y * pScrn->displayWidth + x;
+ offset &= ~7;
+
+ OUTREG(IMSTT_SSR, offset);
+
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h
new file mode 100644
index 000000000..17fef3279
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h
@@ -0,0 +1,215 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/imstt/imstt_reg.h,v 1.2 2000/06/19 15:01:02 tsi Exp $ */
+
+#ifndef _IMSTT_REG_H
+#define _IMSTT_REG_H
+
+
+
+#if defined(__powerpc__)
+
+static inline void regw(unsigned long base_addr, unsigned long regindex, unsigned long regdata)
+{
+ asm volatile ("stwbrx %1,%2,%3; eieio"
+ : "=m" (*(volatile unsigned *)(base_addr+regindex))
+ : "r" (regdata), "b" (regindex), "r" (base_addr));
+}
+
+
+static inline unsigned long regr(unsigned long base_addr, unsigned long regindex)
+{
+ register unsigned long val;
+
+ asm volatile ("lwbrx %0,%1,%2; eieio"
+ : "=r" (val)
+ : "b" (regindex), "r" (base_addr),
+ "m" (*(volatile unsigned *)(base_addr+regindex)));
+
+ return (val);
+}
+
+
+#define INREG(addr) regr(((unsigned long)IMSTTMMIO), (addr))
+#define OUTREG(addr, val) regw(((unsigned long)IMSTTMMIO), (addr), (val))
+
+#else
+
+#define INREG(addr) MMIO_IN32(IMSTTMMIO, addr)
+#define OUTREG(addr, val) MMIO_OUT32(IMSTTMMIO, addr, val)
+
+#endif
+
+#define OUTREGPI(addr, val) iptr->CMAPBase[IBM624_PIDXLO] = addr; eieio(); \
+ iptr->CMAPBase[IBM624_PIDXDATA] = val; eieio()
+#define OUTREGPT(addr, val) iptr->CMAPBase[TVP_ADDRW] = addr; eieio(); \
+ iptr->CMAPBase[TVP_IDATA] = val; eieio()
+
+#define IMSTTMMIO_VARS() \
+ unsigned long *IMSTTMMIO = IMSTTPTR(pScrn)->MMIOBase
+
+
+/* TwinTurbo (Cosmo) registers */
+
+#define IMSTT_S1SA 0x00
+#define IMSTT_S2SA 0x04
+#define IMSTT_SP 0x08
+#define IMSTT_DSA 0x0c
+#define IMSTT_CNT 0x10
+#define IMSTT_DP_OCTL 0x14
+#define IMSTT_CLR 0x18
+#define IMSTT_BI 0x20
+#define IMSTT_MBC 0x24
+#define IMSTT_BLTCTL 0x28
+
+/* scan timing generator registers */
+
+#define IMSTT_HES 0x30
+#define IMSTT_HEB 0x34
+#define IMSTT_HSB 0x38
+#define IMSTT_HT 0x3c
+#define IMSTT_VES 0x40
+#define IMSTT_VEB 0x44
+#define IMSTT_VSB 0x48
+#define IMSTT_VT 0x4c
+#define IMSTT_HCIV 0x50
+#define IMSTT_VCIV 0x54
+#define IMSTT_TCDR 0x58
+#define IMSTT_VIL 0x5c
+#define IMSTT_STGCTL 0x60
+
+/* screen refresh generator registers */
+
+#define IMSTT_SSR 0x64
+#define IMSTT_HRIR 0x68
+#define IMSTT_SPR 0x6c
+#define IMSTT_CMR 0x70
+#define IMSTT_SRGCTL 0x74
+
+/* RAM refresh generator registers */
+
+#define IMSTT_RRCIV 0x78
+#define IMSTT_RRSC 0x7c
+#define IMSTT_RRCR 0x88
+
+/* system registers */
+
+#define IMSTT_GIOE 0x80
+#define IMSTT_GIO 0x84
+#define IMSTT_SCR 0x8c
+#define IMSTT_SSTATUS 0x90
+#define IMSTT_PRC 0x94
+
+
+/* IBM 624 RAMDAC direct registers */
+
+#define IBM624_PADDRW 0x00
+#define IBM624_PDATA 0x04
+#define IBM624_PPMASK 0x08
+#define IBM624_PADDRR 0x0c
+#define IBM624_PIDXLO 0x10
+#define IBM624_PIDXHI 0x14
+#define IBM624_PIDXDATA 0x18
+#define IBM624_PIDXCTL 0x1c
+
+/* IBM 624 RAMDAC indirect registers */
+
+#define IBM624_CLKCTL 0x02 /* Misc Clock Control */
+#define IBM624_SYNCCTL 0x03 /* Sync Control */
+#define IBM624_HSYNCPOS 0x04 /* Horiz Sync Position */
+#define IBM624_PWRMNGMT 0x05 /* Power Management */
+#define IBM624_DACOP 0x06 /* DAC Operation */
+#define IBM624_PALETCTL 0x07 /* Palette Control */
+#define IBM624_SYSCLKCTL 0x08 /* System Clock Control */
+#define IBM624_PIXFMT 0x0a /* Pixel Format [bpp >> 3 + 2] */
+#define IBM624_BPP8 0x0b /* 8bpp */
+#define IBM624_BPP16 0x0c /* 16bpp */
+#define IBM624_BPP24 0x0d /* 24bpp */
+#define IBM624_BPP32 0x0e /* 32bpp */
+#define IBM624_PIXCTL1 0x10 /* Pixel PLL Control 1 */
+#define IBM624_PIXCTL2 0x11 /* Pixel PLL Control 2 */
+#define IBM624_SYSCLKN 0x15 /* System Clock N */
+#define IBM624_SYSCLKM 0x16 /* System Clock M */
+#define IBM624_SYSCLKP 0x17 /* System Clock P */
+#define IBM624_SYSCLKC 0x18 /* System Clock C */
+#define IBM624_PIXM0 0x20 /* Pixel M 0 */
+#define IBM624_PIXN0 0x21 /* Pixel N 0 */
+#define IBM624_PIXP0 0x22 /* Pixel P 0 */
+#define IBM624_PIXC0 0x23 /* Pixel C 0 */
+#define IBM624_CURSCTL 0x30 /* Cursor Control */
+#define IBM624_CURSXLO 0x31 /* Cursor X position, low 8 bits */
+#define IBM624_CURSXHI 0x32 /* Cursor X position, high 8 bits */
+#define IBM624_CURSYLO 0x33 /* Cursor Y position, low 8 bits */
+#define IBM624_CURSYHI 0x34 /* Cursor Y postition, high 8 bits */
+#define IBM624_CURSHOTX 0x35 /* Cursor Hot Spot X */
+#define IBM624_CURSHOTY 0x36 /* Cursor Hot Spot Y */
+#define IBM624_CURSACCTL 0x37 /* Advanced Cursor Control Enable */
+#define IBM624_CURSACATTR 0x38 /* Advanced Cursor Attribute */
+#define IBM624_CURS1R 0x40 /* Cursor 1 red */
+#define IBM624_CURS1G 0x41 /* Cursor 1 green */
+#define IBM624_CURS1B 0x42 /* Cursor 1 blue */
+#define IBM624_CURS2R 0x43 /* Cursor 2 red */
+#define IBM624_CURS2G 0x44 /* Cursor 2 green */
+#define IBM624_CURS2B 0x45 /* Cursor 2 blue */
+#define IBM624_CURS3R 0x46 /* Cursor 3 red */
+#define IBM624_CURS3G 0x47 /* Cursor 3 green */
+#define IBM624_CURS3B 0x48 /* Cursor 3 blue */
+#define IBM624_BORDR 0x60 /* Border color red */
+#define IBM624_BORDG 0x61 /* Border color green */
+#define IBM624_BORDB 0x62 /* Border color blue */
+#define IBM624_MISCTL1 0x70 /* Misc control 1 */
+#define IBM624_MISCTL2 0x71 /* Misc control 2 */
+#define IBM624_MISCTL3 0x72 /* Misc control 3 */
+#define IBM624_KEYCTL 0x78 /* Key Control/DB operation */
+
+/* TI TVP 3030 RAMDAC direct registers */
+
+#define TVP_ADDRW 0x00
+#define TVP_PDATA 0x04
+#define TVP_PMASK 0x08
+#define TVP_PADRR 0x0c
+#define TVP_CADRW 0x10
+#define TVP_CDATA 0x14
+#define TVP_CADRR 0x1c
+#define TVP_DCCTL 0x24
+#define TVP_IDATA 0x28
+#define TVP_CRDAT 0x2c
+#define TVP_CXPOL 0x30
+#define TVP_CXPOH 0x34
+#define TVP_CYPOL 0x38
+#define TVP_CYPOH 0x3c
+
+/* TI TVP 3030 RAMDAC indirect registers */
+
+
+#define TVP_IRREV 0x01
+#define TVP_IRICC 0x06
+#define TVP_IRBRC 0x07
+#define TVP_IRLAC 0x0f
+#define TVP_IRTCC 0x18
+#define TVP_IRMXC 0x19
+#define TVP_IRCLS 0x1a
+#define TVP_IRPPG 0x1c
+#define TVP_IRGEC 0x1d
+#define TVP_IRMIC 0x1e
+#define TVP_IRPLA 0x2c
+#define TVP_IRPPD 0x2d
+#define TVP_IRMPD 0x2e
+#define TVP_IRLPD 0x2f
+#define TVP_IRCKL 0x30
+#define TVP_IRCKH 0x31
+#define TVP_IRCRL 0x32
+#define TVP_IRCRH 0x33
+#define TVP_IRCGL 0x34
+#define TVP_IRCGH 0x35
+#define TVP_IRCBL 0x36
+#define TVP_IRCBH 0x37
+#define TVP_IRCKC 0x38
+#define TVP_IRMLC 0x39
+#define TVP_IRSEN 0x3a
+#define TVP_IRTMD 0x3b
+#define TVP_IRRML 0x3c
+#define TVP_IRRMM 0x3d
+#define TVP_IRRMS 0x3e
+#define TVP_IRDID 0x3f
+#define TVP_IRRES 0xff
+
+#endif /* _IMSTT_REG_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile
index 3150ec756..48a7cca7a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile,v 1.32 2000/02/28 19:53:12 alanh Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/Imakefile,v 1.33 2000/06/17 00:03:19 martin Exp $
XCOMM
XCOMM This is an Imakefile for the MGA driver.
XCOMM
@@ -6,15 +6,13 @@ XCOMM
#define IHaveModules
#include <Server.tmpl>
-#if 0
#if BuildXF86DRI
-DRISRCS = mga_dri.c mga_warp.c mga_drm.c
-DRIOBJS = mga_dri.o mga_warp.o mga_drm.o
+DRISRCS = mga_dri.c mga_warp.c mga_wrap.c
+DRIOBJS = mga_dri.o mga_warp.o mga_wrap.o
DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri \
- -I$(XF86OSSRC)/linux/drm/kernel
+ -I$(XF86OSSRC)/linux/drm/kernel -I$(TOP)/include
DRIDEFINES = $(GLX_DEFINES)
#endif
-#endif
SRCS = mga_driver.c mga_hwcurs.c /* mga_cmap.c */ mga_dac3026.c mga_dacG.c \
mga_storm8.c mga_storm16.c mga_storm24.c mga_storm32.c mga_arc.c \
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp
index 87f97e2e0..2bfe824fc 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp,v 1.13 2000/03/07 01:37:49 dawes Exp $
-.TH MGA __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.cpp,v 1.17 2000/06/14 02:13:11 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH MGA __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
mga \- Matrox video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""mga"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qmga\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B mga
is an XFree86 driver for Matrox video cards. The driver is fully
@@ -49,7 +49,7 @@ driver.
The driver auto-detects the chipset type, but the following
.B ChipSet
names may optionally be specified in the config file
-.B """Device"""
+.B \*qDevice\*q
section, and will override the auto-detection:
.PP
.RS 4
@@ -63,68 +63,74 @@ to 4096\ kBytes. When using a Millennium II, the actual amount of video
memory should be specified with a
.B VideoRam
entry in the config file
-.B """Device"""
+.B \*qDevice\*q
section.
.PP
The following driver
.B Options
are supported:
.TP
-.BI "Option ""ColorKey"" """ integer """
+.BI "Option \*qColorKey\*q \*q" integer \*q
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.
.TP
-.BI "Option ""HWCursor"" """ boolean """
+.BI "Option \*qHWCursor\*q \*q" boolean \*q
Enable or disable the HW cursor. Default: on.
.TP
-.BI "Option ""MGASDRAM"" """ boolean """
+.BI "Option \*qMGASDRAM\*q \*q" boolean \*q
Specify whether G100 and G200 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 prescence SDRAM on secondary heads in multihead configurations.
Default: auto-detected.
.TP
-.BI "Option ""NoAccel"" """ boolean """
+.BI "Option \*qNoAccel\*q \*q" boolean \*q
Disable or enable acceleration. Default: acceleration is enabled.
.TP
-.BI "Option ""OverclockMem""
+.BI "Option \*qOverclockMem\*q"
Set clocks to values used by some commercial X-Servers (G100, G200 and G400
only). Default: off.
.TP
-.BI "Option ""Overlay""
+.BI "Option \*qOverlay\*q"
Enable 8+24 overlay mode. Only appropriate for depth 24.
.RB ( Note:
the G100 is unaccelerated in the 8+24 overlay mode due to a missing
hardware feature) Default: off.
.TP
-.BI "Option ""PciRetry"" """ boolean """
+.BI "Option \*qPciRetry\*q \*q" boolean \*q
Enable or disable PCI retries. Default: off.
.TP
-.BI "Option ""Rotate"" ""CW""
+.BI "Option \*qRotate\*q \*qCW\*q"
.TP
-.BI "Option ""Rotate"" ""CCW""
+.BI "Option \*qRotate\*q \*qCCW\*q"
Rotate the display clockwise or counterclockwise. This mode is unaccelerated.
Default: no rotation.
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
Enable or disable use of the shadow framebuffer layer. See
shadowfb(__drivermansuffix__) for further information. Default: off.
.TP
-.BI "Option ""SyncOnGreen"" """ boolean """
+.BI "Option \*qSyncOnGreen\*q \*q" boolean \*q
Enable or disable combining the sync signals with the green signal.
Default: off.
.TP
-.BI "Option ""UseFBDev"" """ boolean """
+.BI "Option \*qUseFBDev\*q \*q" boolean \*q
Enable or disable use of on OS-specific fb interface (and is not supported
on all OSs). See fbdevhw(__drivermansuffix__) for further information.
Default: off.
.TP
-.BI "Option ""VideoKey"" """ integer """
+.BI "Option \*qVideoKey\*q \*q" integer \*q
This sets the default pixel value for the YUV video overlay key.
Default: undefined.
+.TP
+.BI "Option \*qTexturedVideo\*q \*q" boolean \*q
+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.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: Radoslaw Kapitan, Mark Vojkovich, and also David Dawes, Guy
Desbief, Dirk Hohndel, Doug Merritt, Andrew E. Mileski, Andrew van der Stock,
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h
index 2027171da..7fd8f77b5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.57 2000/02/27 02:50:47 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga.h,v 1.59 2000/06/17 00:03:19 martin Exp $ */
/*
* MGA Millennium (MGA2064W) functions
*
@@ -14,9 +14,6 @@
#ifndef MGA_H
#define MGA_H
-/* Temporarily turn off building in DRI support */
-#undef XF86DRI
-
#include "compiler.h"
#include "xaa.h"
#include "xf86Cursor.h"
@@ -33,7 +30,6 @@
#include "dri.h"
#include "GL/glxint.h"
#include "mga_dri.h"
-#include "mga_dripriv.h"
#endif
#if !defined(EXTRADEBUG)
@@ -60,6 +56,13 @@ void dbg_outreg32(ScrnInfoPtr,int,int);
#define PORT_OFFSET (0x1F00 - 0x300)
+#define MGA_VERSION 4000
+#define MGA_NAME "MGA"
+#define MGA_DRIVER_NAME "mga"
+#define MGA_MAJOR_VERSION 1
+#define MGA_MINOR_VERSION 0
+#define MGA_PATCHLEVEL 0
+
typedef struct {
unsigned char ExtVga[6];
unsigned char DacClk[6];
@@ -70,6 +73,18 @@ typedef struct {
} MGARegRec, *MGARegPtr;
typedef struct {
+ unsigned char brightness;
+ unsigned char contrast;
+ FBAreaPtr area;
+ RegionRec clip;
+ CARD32 colorKey;
+ CARD32 videoStatus;
+ Time offTime;
+ Time freeTime;
+ int lastPort;
+} MGAPortPrivRec, *MGAPortPrivPtr;
+
+typedef struct {
Bool isHwCursor;
int CursorMaxWidth;
int CursorMaxHeight;
@@ -103,7 +118,6 @@ typedef struct {
DisplayModePtr mode;
} MGAFBLayout;
-
/* Card-specific driver information */
#define MGAPTR(p) ((MGAPtr)((p)->driverPrivate))
@@ -206,21 +220,29 @@ typedef struct {
MGAFBLayout CurrentLayout;
Bool DrawTransparent;
int MaxBlitDWORDS;
-
+ Bool TexturedVideo;
+ MGAPortPrivPtr portPrivate;
+ int numXAALines;
#ifdef XF86DRI
- Bool directRenderingEnabled;
- DRIInfoPtr pDRIInfo;
- int drmSubFD;
- int numVisualConfigs;
- __GLXvisualConfig* pVisualConfigs;
- MGAConfigPrivPtr pVisualConfigsPriv;
- MGARegRec DRContextRegs;
- MGADRIServerPrivatePtr DRIServerInfo;
+ Bool have_quiescense;
+ Bool directRenderingEnabled;
+ DRIInfoPtr pDRIInfo;
+ int drmSubFD;
+ int numVisualConfigs;
+ __GLXvisualConfig* pVisualConfigs;
+ MGAConfigPrivPtr pVisualConfigsPriv;
+ MGARegRec DRContextRegs;
+ MGADRIServerPrivatePtr DRIServerInfo;
#endif
-
XF86VideoAdaptorPtr adaptor;
} MGARec, *MGAPtr;
+#ifdef XF86DRI
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **configprivs);
+#endif
+
+
extern CARD32 MGAAtype[16];
extern CARD32 MGAAtypeNoBLK[16];
@@ -240,9 +262,9 @@ extern CARD32 MGAAtypeNoBLK[16];
#define TRANSPARENCY_KEY 255
#define KEY_COLOR 0
-#define MGA_FRONT 0
-#define MGA_BACK 1
-#define MGA_DEPTH 2
+#define MGA_FRONT 0x1
+#define MGA_BACK 0x2
+#define MGA_DEPTH 0x4
/* Prototypes */
@@ -271,14 +293,15 @@ Bool MGADRIScreenInit(ScreenPtr pScreen);
void MGADRICloseScreen(ScreenPtr pScreen);
Bool MGADRIFinishScreenInit(ScreenPtr pScreen);
void MGASwapContext(ScreenPtr pScreen);
-void MGALostContext(ScreenPtr pScreen);
-void MGASelectBuffer(MGAPtr pMGA, int which);
Bool mgaConfigureWarp(ScrnInfoPtr pScrn);
unsigned int mgaInstallMicrocode(ScreenPtr pScreen, int agp_offset);
unsigned int mgaGetMicrocodeSize(ScreenPtr pScreen);
-Bool mgadrmCleanupDma(ScrnInfoPtr pScrn);
-Bool mgadrmInitDma(ScrnInfoPtr pScrn, int prim_size);
-
+void MGASelectBuffer(ScrnInfoPtr pScrn, int which);
+Bool MgaCleanupDma(ScrnInfoPtr pScrn);
+Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size);
+#ifdef XF86DRI
+Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags);
+#endif
void MGARefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void MGARefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void MGARefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c
index 2844302ff..424989b21 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c
@@ -19,7 +19,7 @@ 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/xfree86/drivers/mga/mga_arc.c,v 1.7 1999/08/22 05:57:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_arc.c,v 1.9 2000/06/25 12:46:00 alanh Exp $ */
#include "X.h"
@@ -34,6 +34,8 @@ in this Software without prior written authorization from The Open Group.
#include "scrnintstr.h"
#include "xaa.h"
#include "xaalocal.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
#include "xf86_ansic.h"
#include "xf86Pci.h"
@@ -69,6 +71,8 @@ MGAZeroArc(
Bool do360;
DDXPointRec org, orgo;
+ CHECK_DMA_QUIESCENT( pMga, infoRec->pScrn );
+
(*infoRec->SetupForSolidFill)(infoRec->pScrn, pGC->fgPixel,
pGC->alu, pGC->planemask);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
index 5b853ccb2..e6510dfeb 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c
@@ -2,7 +2,7 @@
* MGA-1064, MGA-G100, MGA-G200, MGA-G400 RAMDAC driver
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c,v 1.33 1999/12/03 04:03:52 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dacG.c,v 1.36 2000/06/17 00:03:19 martin Exp $ */
/*
* This is a first cut at a non-accelerated version to work with the
@@ -24,6 +24,7 @@
#include "mga_bios.h"
#include "mga_reg.h"
+#include "mga_macros.h"
#include "mga.h"
#include "xf86DDC.h"
@@ -46,6 +47,8 @@
#define OPTION2_MASK 0xFFFFFFFF
#define OPTION3_MASK 0xFFFFFFFF
+#define OPTION1_MASK_PRIMARY 0xFFFC0FF
+
/*
* Read/write to the DAC via MMIO
*/
@@ -363,6 +366,8 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->Option = 0x50044120;
}
}
+ if(pMga->HasSDRAM)
+ pReg->Option &= ~(1 << 14);
pReg->Option2 = 0x01003000;
break;
case PCI_CHIP_MGAG200:
@@ -473,12 +478,6 @@ MGAGInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
else
pReg->ExtVga[3] = ((1 << BppShift) - 1) | 0x80;
-#if 0
- /* Set viddelay (CRTCEXT3 Bits 3-4). */
- pReg->ExtVga[3] |= (pScrn->videoRam == 8192 ? 0x10
- : pScrn->videoRam == 2048 ? 0x08 : 0x00);
-#endif
-
pReg->ExtVga[4] = 0;
pVga->CRTC[0] = ht - 4;
@@ -592,8 +591,10 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
Bool restoreFonts)
{
int i;
+ CARD32 optionMask;
MGAPtr pMga = MGAPTR(pScrn);
+ CHECK_DMA_QUIESCENT( pMga, pScrn );
/*
* Code is needed to get things back to bank zero.
*/
@@ -614,8 +615,12 @@ MGAGRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
outMGAdac(i, mgaReg->DacRegs[i]);
}
+ /* Do not set the memory config for primary cards as it
+ should be correct already */
+ optionMask = (pMga->Primary) ? OPTION1_MASK_PRIMARY : OPTION1_MASK;
+
/* restore pci_option register */
- pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, OPTION1_MASK,
+ pciSetBitsLong(pMga->PciTag, PCI_OPTION_REG, optionMask,
mgaReg->Option);
if (pMga->Chipset != PCI_CHIP_MGA1064)
pciSetBitsLong(pMga->PciTag, PCI_MGA_OPTION2, OPTION2_MASK,
@@ -670,7 +675,9 @@ MGAGSave(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, MGARegPtr mgaReg,
{
int i;
MGAPtr pMga = MGAPTR(pScrn);
-
+
+ CHECK_DMA_QUIESCENT( pMga, pScrn );
+
/* Allocate the DacRegs space if not done already */
if (mgaReg->DacRegs == NULL) {
mgaReg->DacRegs = xnfcalloc(DACREGSIZE, 1);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
index df23db4f6..8c90596f7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.1 2000/02/11 17:25:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.c,v 1.5 2000/06/23 23:43:44 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -22,7 +22,7 @@
#include "mga.h"
#include "mga_macros.h"
#include "mga_dri.h"
-#include "mga_dripriv.h"
+#include "mga_wrap.h"
static char MGAKernelDriverName[] = "mga";
static char MGAClientDriverName[] = "mga";
@@ -51,250 +51,310 @@ extern void Mga32DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index);
extern void Mga32DRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
RegionPtr prgnSrc, CARD32 index);
+Bool MgaCleanupDma(ScrnInfoPtr pScrn)
+{
+ MGAPtr pMGA = MGAPTR(pScrn);
+ Bool ret_val;
+
+ ret_val = drmMgaCleanupDma(pMGA->drmSubFD);
+ if (ret_val == FALSE)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Mga Dma Cleanup Failed\n");
+
+ return ret_val;
+}
+
+Bool MgaLockUpdate(ScrnInfoPtr pScrn, drmLockFlags flags)
+{
+ MGAPtr pMGA = MGAPTR(pScrn);
+ Bool ret_val;
+
+ ret_val = drmMgaLockUpdate(pMGA->drmSubFD, flags);
+ if (ret_val == FALSE)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "LockUpdate failed\n");
+
+ return ret_val;
+}
+
+Bool MgaInitDma(ScrnInfoPtr pScrn, int prim_size)
+{
+ MGAPtr pMGA = MGAPTR(pScrn);
+ MGADRIPtr pMGADRI = (MGADRIPtr)pMGA->pDRIInfo->devPrivate;
+ MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo;
+ drmMgaInit init;
+ Bool ret_val;
+
+ memset(&init, 0, sizeof(drmMgaInit));
+ init.reserved_map_agpstart = 0;
+ init.reserved_map_idx = 3;
+ init.buffer_map_idx = 4;
+ init.sarea_priv_offset = sizeof(XF86DRISAREARec);
+ init.primary_size = prim_size;
+ init.warp_ucode_size = pMGADRIServer->warp_ucode_size;
+
+ switch(pMGA->Chipset) {
+ case PCI_CHIP_MGAG400:
+ init.chipset = MGA_CARD_TYPE_G400;
+ break;
+ case PCI_CHIP_MGAG200:
+ init.chipset = MGA_CARD_TYPE_G200;
+ break;
+ case PCI_CHIP_MGAG200_PCI:
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] Direct rendering not supported on this card/chipset\n");
+ return FALSE;
+ }
+
+ init.frontOffset = pMGADRI->frontOffset;
+ init.backOffset = pMGADRI->backOffset;
+ init.depthOffset = pMGADRI->depthOffset;
+ init.textureOffset = pMGADRI->textureOffset;
+ init.textureSize = pMGADRI->textureSize;
+ init.agpTextureSize = pMGADRI->agpTextureSize;
+ init.cpp = pMGADRI->cpp;
+ init.stride = pMGADRI->frontPitch;
+ init.mAccess = pMGA->MAccess;
+ init.sgram = !pMGA->HasSDRAM;
+
+ memcpy(&init.WarpIndex, &pMGADRIServer->WarpIndex,
+ sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Mga Dma Initialization start\n");
+
+ ret_val = drmMgaInitDma(pMGA->drmSubFD, &init);
+ if (ret_val == FALSE)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Mga Dma Initialization Failed\n");
+ else
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Mga Dma Initialization done\n");
+ return ret_val;
+}
+
static Bool
MGAInitVisualConfigs(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMGA = MGAPTR(pScrn);
- int numConfigs = 0;
- __GLXvisualConfig *pConfigs = 0;
- MGAConfigPrivPtr pMGAConfigs = 0;
- MGAConfigPrivPtr *pMGAConfigPtrs = 0;
- int i;
-
- switch (pScrn->bitsPerPixel) {
- case 8:
- case 24:
- case 32:
- break;
- case 16:
- numConfigs = 4;
-
- if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
- numConfigs))) {
- return FALSE;
- }
- if (!(pMGAConfigs = (MGAConfigPrivPtr)xnfcalloc(sizeof(MGAConfigPrivRec),
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMGA = MGAPTR(pScrn);
+ int numConfigs = 0;
+ __GLXvisualConfig *pConfigs = 0;
+ MGAConfigPrivPtr pMGAConfigs = 0;
+ MGAConfigPrivPtr *pMGAConfigPtrs = 0;
+ int i, db, depth, stencil, accum;
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ case 24:
+ case 32:
+ break;
+ case 16:
+ numConfigs = 4;
+
+ if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
numConfigs))) {
- xfree(pConfigs);
- return FALSE;
- }
- if (!(pMGAConfigPtrs = (MGAConfigPrivPtr*)xnfcalloc(sizeof(MGAConfigPrivPtr),
- numConfigs))) {
- xfree(pConfigs);
- xfree(pMGAConfigs);
- return FALSE;
- }
- for (i=0; i<numConfigs; i++)
- pMGAConfigPtrs[i] = &pMGAConfigs[i];
+ return FALSE;
+ }
+ if (!(pMGAConfigs = (MGAConfigPrivPtr)xnfcalloc(sizeof(MGAConfigPrivRec),
+ numConfigs))) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+ if (!(pMGAConfigPtrs = (MGAConfigPrivPtr*)xnfcalloc(sizeof(MGAConfigPrivPtr),
+ numConfigs))) {
+ xfree(pConfigs);
+ xfree(pMGAConfigs);
+ return FALSE;
+ }
+ for (i=0; i<numConfigs; i++)
+ pMGAConfigPtrs[i] = &pMGAConfigs[i];
+
+ i = 0;
+ depth = 1;
+ for (accum = 0; accum <= 1; accum++) {
+ for (stencil = 0; stencil <= 0; stencil++) { /* no stencil for now */
+ for (db=0; db<=1; db++) {
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+ pConfigs[i].alphaMask = 0;
+ if (accum) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ if (db)
+ pConfigs[i].doubleBuffer = TRUE;
+ else
+ pConfigs[i].doubleBuffer = FALSE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if (depth)
+ pConfigs[i].depthSize = 16;
+ else
+ pConfigs[i].depthSize = 0;
+ if (stencil)
+ pConfigs[i].stencilSize = 8;
+ else
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (stencil)
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ else
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ if (i != numConfigs) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] Incorrect initialization of visuals\n");
+ return FALSE;
+ }
+ break;
+ default:
+ ; /* unexpected bits/pixelx */
+ }
+ pMGA->numVisualConfigs = numConfigs;
+ pMGA->pVisualConfigs = pConfigs;
+ pMGA->pVisualConfigsPriv = pMGAConfigs;
+ GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pMGAConfigPtrs);
+ return TRUE;
+}
- /* config 0: db=FALSE, depth=0
- config 1: db=FALSE, depth=16
- config 2: db=TRUE, depth=0;
- config 3: db=TRUE, depth=16
- */
- pConfigs[0].vid = -1;
- pConfigs[0].class = -1;
- pConfigs[0].rgba = TRUE;
- pConfigs[0].redSize = 8;
- pConfigs[0].greenSize = 8;
- pConfigs[0].blueSize = 8;
- pConfigs[0].redMask = 0x00FF0000;
- pConfigs[0].greenMask = 0x0000FF00;
- pConfigs[0].blueMask = 0x000000FF;
- pConfigs[0].alphaMask = 0;
- pConfigs[0].accumRedSize = 0;
- pConfigs[0].accumGreenSize = 0;
- pConfigs[0].accumBlueSize = 0;
- pConfigs[0].accumAlphaSize = 0;
- pConfigs[0].doubleBuffer = FALSE;
- pConfigs[0].stereo = FALSE;
- pConfigs[0].bufferSize = 16;
- pConfigs[0].depthSize = 0;
- pConfigs[0].stencilSize = 0;
- pConfigs[0].auxBuffers = 0;
- pConfigs[0].level = 0;
- pConfigs[0].visualRating = 0;
- pConfigs[0].transparentPixel = 0;
- pConfigs[0].transparentRed = 0;
- pConfigs[0].transparentGreen = 0;
- pConfigs[0].transparentBlue = 0;
- pConfigs[0].transparentAlpha = 0;
- pConfigs[0].transparentIndex = 0;
-
- pConfigs[1].vid = -1;
- pConfigs[1].class = -1;
- pConfigs[1].rgba = TRUE;
- pConfigs[1].redSize = 8;
- pConfigs[1].greenSize = 8;
- pConfigs[1].blueSize = 8;
- pConfigs[1].redMask = 0x00FF0000;
- pConfigs[1].greenMask = 0x0000FF00;
- pConfigs[1].blueMask = 0x000000FF;
- pConfigs[1].alphaMask = 0;
- pConfigs[1].accumRedSize = 0;
- pConfigs[1].accumGreenSize = 0;
- pConfigs[1].accumBlueSize = 0;
- pConfigs[1].accumAlphaSize = 0;
- pConfigs[1].doubleBuffer = FALSE;
- pConfigs[1].stereo = FALSE;
- pConfigs[1].bufferSize = 16;
- pConfigs[1].depthSize = 16;
- pConfigs[1].stencilSize = 0;
- pConfigs[1].auxBuffers = 0;
- pConfigs[1].level = 0;
- pConfigs[1].visualRating = 0;
- pConfigs[1].transparentPixel = 0;
- pConfigs[1].transparentRed = 0;
- pConfigs[1].transparentGreen = 0;
- pConfigs[1].transparentBlue = 0;
- pConfigs[1].transparentAlpha = 0;
- pConfigs[1].transparentIndex = 0;
-
- pConfigs[2].vid = -1;
- pConfigs[2].class = -1;
- pConfigs[2].rgba = TRUE;
- pConfigs[2].redSize = 8;
- pConfigs[2].greenSize = 8;
- pConfigs[2].blueSize = 8;
- pConfigs[2].redMask = 0x00FF0000;
- pConfigs[2].greenMask = 0x0000FF00;
- pConfigs[2].blueMask = 0x000000FF;
- pConfigs[2].alphaMask = 0;
- pConfigs[2].accumRedSize = 0;
- pConfigs[2].accumGreenSize = 0;
- pConfigs[2].accumBlueSize = 0;
- pConfigs[2].accumAlphaSize = 0;
- pConfigs[2].doubleBuffer = TRUE;
- pConfigs[2].stereo = FALSE;
- pConfigs[2].bufferSize = 16;
- pConfigs[2].depthSize = 0;
- pConfigs[2].stencilSize = 0;
- pConfigs[2].auxBuffers = 0;
- pConfigs[2].level = 0;
- pConfigs[2].visualRating = 0;
- pConfigs[2].transparentPixel = 0;
- pConfigs[2].transparentRed = 0;
- pConfigs[2].transparentGreen = 0;
- pConfigs[2].transparentBlue = 0;
- pConfigs[2].transparentAlpha = 0;
- pConfigs[2].transparentIndex = 0;
-
- pConfigs[3].vid = -1;
- pConfigs[3].class = -1;
- pConfigs[3].rgba = TRUE;
- pConfigs[3].redSize = 8;
- pConfigs[3].greenSize = 8;
- pConfigs[3].blueSize = 8;
- pConfigs[3].redMask = 0x00FF0000;
- pConfigs[3].greenMask = 0x0000FF00;
- pConfigs[3].blueMask = 0x000000FF;
- pConfigs[3].alphaMask = 0;
- pConfigs[3].accumRedSize = 0;
- pConfigs[3].accumGreenSize = 0;
- pConfigs[3].accumBlueSize = 0;
- pConfigs[3].accumAlphaSize = 0;
- pConfigs[3].doubleBuffer = TRUE;
- pConfigs[3].stereo = FALSE;
- pConfigs[3].bufferSize = 16;
- pConfigs[3].depthSize = 16;
- pConfigs[3].stencilSize = 0;
- pConfigs[3].auxBuffers = 0;
- pConfigs[3].level = 0;
- pConfigs[3].visualRating = 0;
- pConfigs[3].transparentPixel = 0;
- pConfigs[3].transparentRed = 0;
- pConfigs[3].transparentGreen = 0;
- pConfigs[3].transparentBlue = 0;
- pConfigs[3].transparentAlpha = 0;
- pConfigs[3].transparentIndex = 0;
- break;
- }
- pMGA->numVisualConfigs = numConfigs;
- pMGA->pVisualConfigs = pConfigs;
- pMGA->pVisualConfigsPriv = pMGAConfigs;
- GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pMGAConfigPtrs);
- return TRUE;
+static unsigned int mylog2(unsigned int n)
+{
+ unsigned int log2 = 1;
+ while (n>1) n >>= 1, log2++;
+ return log2;
}
+
Bool MGADRIScreenInit(ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMGA = MGAPTR(pScrn);
- DRIInfoPtr pDRIInfo;
- MGADRIPtr pMGADRI;
- MGADRIServerPrivatePtr pMGADRIServer;
- int bufs;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMGA = MGAPTR(pScrn);
+ DRIInfoPtr pDRIInfo;
+ MGADRIPtr pMGADRI;
+ MGADRIServerPrivatePtr pMGADRIServer;
+ int bufs, size;
int prim_size;
int init_offset;
+ int i;
+
+ /* Check that the GLX, DRI, and DRM modules have been loaded by testing
+ * for canonical symbols in each module. */
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "TDFXDRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ DRIQueryVersion(&major, &minor, &patch);
+ if (major != 3 || minor != 0 || patch < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] MGADRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n",
+ major, minor, patch);
+ return FALSE;
+ }
+ }
- pDRIInfo = DRICreateInfoRec();
- if (!pDRIInfo) return FALSE;
- pMGA->pDRIInfo = pDRIInfo;
-
- pDRIInfo->drmDriverName = MGAKernelDriverName;
- pDRIInfo->clientDriverName = MGAClientDriverName;
- pDRIInfo->busIdString = xalloc(64);
- sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
- ((pciConfigPtr)pMGA->PciInfo->thisCard)->busnum,
- ((pciConfigPtr)pMGA->PciInfo->thisCard)->devnum,
- ((pciConfigPtr)pMGA->PciInfo->thisCard)->funcnum);
- pDRIInfo->ddxDriverMajorVersion = 0;
- pDRIInfo->ddxDriverMinorVersion = 1;
- pDRIInfo->ddxDriverPatchVersion = 0;
- pDRIInfo->frameBufferPhysicalAddress = pMGA->FbAddress;
- pDRIInfo->frameBufferSize = pMGA->FbMapSize;
- pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8);
- pDRIInfo->ddxDrawableTableEntry = MGA_MAX_DRAWABLES;
-
- if (SAREA_MAX_DRAWABLES < MGA_MAX_DRAWABLES)
- pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
- else
- pDRIInfo->maxDrawableTableEntry = MGA_MAX_DRAWABLES;
-
-#ifdef NOT_DONE
- /* FIXME need to extend DRI protocol to pass this size back to client
- * for SAREA mapping that includes a device private record
- */
- pDRIInfo->SAREASize =
- ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */
- /* + shared memory device private rec */
-#else
- /* For now the mapping works by using a fixed size defined
- * in the SAREA header
- */
- if (sizeof(XF86DRISAREARec)+sizeof(drm_mga_sarea_t)>SAREA_MAX) {
- ErrorF("Data does not fit in SAREA\n");
- return FALSE;
- }
- pDRIInfo->SAREASize = SAREA_MAX;
-#endif
+ if ((pScrn->bitsPerPixel / 8) != 2) {
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Direct Rendering only supported in 16 bpp mode\n");
+ return FALSE;
+ }
+
+ pDRIInfo = DRICreateInfoRec();
+ if (!pDRIInfo)
+ return FALSE;
+ pMGA->pDRIInfo = pDRIInfo;
+
+ pDRIInfo->drmDriverName = MGAKernelDriverName;
+ pDRIInfo->clientDriverName = MGAClientDriverName;
+ pDRIInfo->busIdString = xalloc(64);
+ sprintf(pDRIInfo->busIdString, "PCI:%d:%d:%d",
+ ((pciConfigPtr)pMGA->PciInfo->thisCard)->busnum,
+ ((pciConfigPtr)pMGA->PciInfo->thisCard)->devnum,
+ ((pciConfigPtr)pMGA->PciInfo->thisCard)->funcnum);
+ pDRIInfo->ddxDriverMajorVersion = MGA_MAJOR_VERSION;
+ pDRIInfo->ddxDriverMinorVersion = MGA_MINOR_VERSION;
+ pDRIInfo->ddxDriverPatchVersion = MGA_PATCHLEVEL;
+ pDRIInfo->frameBufferPhysicalAddress = pMGA->FbAddress;
+ pDRIInfo->frameBufferSize = pMGA->FbMapSize;
+ pDRIInfo->frameBufferStride = pScrn->displayWidth*(pScrn->bitsPerPixel/8);
+ pDRIInfo->ddxDrawableTableEntry = MGA_MAX_DRAWABLES;
+
+ MGADRIWrapFunctions( pScreen, pDRIInfo );
+
+ if (SAREA_MAX_DRAWABLES < MGA_MAX_DRAWABLES)
+ pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
+ else
+ pDRIInfo->maxDrawableTableEntry = MGA_MAX_DRAWABLES;
+
+ /* For now the mapping works by using a fixed size defined
+ * in the SAREA header
+ */
+ if (sizeof(XF86DRISAREARec)+sizeof(MGASAREARec)>SAREA_MAX) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] Data does not fit in SAREA\n");
+ return FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] Sarea %d+%d: %d\n",
+ sizeof(XF86DRISAREARec), sizeof(MGASAREARec),
+ sizeof(XF86DRISAREARec) + sizeof(MGASAREARec));
- if (!(pMGADRI = (MGADRIPtr)xnfcalloc(sizeof(MGADRIRec),1))) {
- DRIDestroyInfoRec(pMGA->pDRIInfo);
- pMGA->pDRIInfo=0;
- ErrorF("Failed to allocate memory for private record \n");
- return FALSE;
- }
+ pDRIInfo->SAREASize = SAREA_MAX;
+
+ if (!(pMGADRI = (MGADRIPtr)xnfcalloc(sizeof(MGADRIRec),1))) {
+ DRIDestroyInfoRec(pMGA->pDRIInfo);
+ pMGA->pDRIInfo=0;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to allocate memory for private record\n");
+ return FALSE;
+ }
if (!(pMGADRIServer = (MGADRIServerPrivatePtr)
- xnfcalloc(sizeof(MGADRIServerPrivate),1))) {
- xfree(pMGADRI);
- DRIDestroyInfoRec(pMGA->pDRIInfo);
- pMGA->pDRIInfo=0;
- ErrorF("Failed to allocate memory for private record \n");
- return FALSE;
- }
+ xnfcalloc(sizeof(MGADRIServerPrivateRec),1))) {
+ xfree(pMGADRI);
+ DRIDestroyInfoRec(pMGA->pDRIInfo);
+ pMGA->pDRIInfo=0;
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "[drm] Failed to allocate memory for private record\n");
+ return FALSE;
+ }
- pDRIInfo->devPrivate = pMGADRI;
- pMGA->DRIServerInfo = pMGADRIServer;
- pDRIInfo->devPrivateSize = sizeof(MGADRIRec);
- pDRIInfo->contextSize = sizeof(MGADRIContextRec);
+ pDRIInfo->devPrivate = pMGADRI;
+ pMGA->DRIServerInfo = pMGADRIServer;
+ pDRIInfo->devPrivateSize = sizeof(MGADRIRec);
+ pDRIInfo->contextSize = sizeof(MGADRIContextRec);
- pDRIInfo->CreateContext = MGACreateContext;
- pDRIInfo->DestroyContext = MGADestroyContext;
- pDRIInfo->SwapContext = MGADRISwapContext;
+ pDRIInfo->CreateContext = MGACreateContext;
+ pDRIInfo->DestroyContext = MGADestroyContext;
+ pDRIInfo->SwapContext = MGADRISwapContext;
- switch( pScrn->bitsPerPixel ) {
+ switch( pScrn->bitsPerPixel ) {
case 8:
pDRIInfo->InitBuffers = Mga8DRIInitBuffers;
pDRIInfo->MoveBuffers = Mga8DRIMoveBuffers;
@@ -307,172 +367,271 @@ Bool MGADRIScreenInit(ScreenPtr pScreen)
case 32:
pDRIInfo->InitBuffers = Mga32DRIInitBuffers;
pDRIInfo->MoveBuffers = Mga32DRIMoveBuffers;
- }
+ }
- pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+ pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+
+ if (!DRIScreenInit(pScreen, pDRIInfo, &pMGA->drmSubFD)) {
+ xfree(pMGADRIServer);
+ pMGA->DRIServerInfo = 0;
+ xfree(pDRIInfo->devPrivate);
+ pDRIInfo->devPrivate = 0;
+ DRIDestroyInfoRec(pMGA->pDRIInfo);
+ pMGA->pDRIInfo = 0;
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] DRIScreenInit Failed\n");
+ return FALSE;
+ }
- if (!DRIScreenInit(pScreen, pDRIInfo, &pMGA->drmSubFD)) {
- xfree(pMGADRIServer);
- pMGA->DRIServerInfo = 0;
- xfree(pDRIInfo->devPrivate);
- pDRIInfo->devPrivate = 0;
- DRIDestroyInfoRec(pMGA->pDRIInfo);
- pMGA->pDRIInfo = 0;
- ErrorF("DRIScreenInit Failed\n");
- return FALSE;
- }
+ /* Check the MGA DRM version */
+ {
+ drmVersionPtr version = drmGetVersion(pMGA->drmSubFD);
+ if (version) {
+ if (version->version_major != 1 ||
+ version->version_minor != 0 ||
+ version->version_patchlevel < 0) {
+ /* incompatible drm version */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] MGADRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ MGADRICloseScreen(pScreen);
+ drmFreeVersion(version);
+ return FALSE;
+ }
+ drmFreeVersion(version);
+ }
+ }
- pMGADRIServer->regsSize = MGAIOMAPSIZE;
- if (drmAddMap(pMGA->drmSubFD, (drmHandle)pMGA->IOAddress,
- pMGADRIServer->regsSize, DRM_REGISTERS, 0,
- &pMGADRIServer->regs)<0) {
- DRICloseScreen(pScreen);
- ErrorF("drmAddMap failed Register MMIO region\n");
- return FALSE;
- }
- xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n",
- pMGADRIServer->regs);
+ pMGADRIServer->regsSize = MGAIOMAPSIZE;
+ if (drmAddMap(pMGA->drmSubFD, (drmHandle)pMGA->IOAddress,
+ pMGADRIServer->regsSize, DRM_REGISTERS, 0,
+ &pMGADRIServer->regs)<0) {
+ DRICloseScreen(pScreen);
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmAddMap failed Register MMIO region\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Registers = 0x%08lx\n",
+ pMGADRIServer->regs);
- /* Agp Support */
- if(drmAgpAcquire(pMGA->drmSubFD) < 0) {
- DRICloseScreen(pScreen);
- ErrorF("drmAgpAcquire failed\n");
- return FALSE;
- }
- pMGADRIServer->warp_ucode_size = mgaGetMicrocodeSize(pScreen);
- if(pMGADRIServer->warp_ucode_size == 0) {
- ErrorF("microcodeSize is zero\n");
+ /* Agp Support */
+ pMGADRIServer->agpAcquired = FALSE;
+ pMGADRIServer->agpHandle = 0;
+ pMGADRIServer->agpSizep = 0;
+ pMGADRIServer->agp_map = 0;
+
+ if (drmAgpAcquire(pMGA->drmSubFD) < 0) {
+ DRICloseScreen(pScreen);
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpAcquire failed\n");
+ return FALSE;
+ }
+ pMGADRIServer->agpAcquired = TRUE;
+
+ pMGADRIServer->warp_ucode_size = mgaGetMicrocodeSize(pScreen);
+ if (pMGADRIServer->warp_ucode_size == 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] microcodeSize is zero\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD);
+ /* Default to 1X agp mode */
+ pMGADRIServer->agpMode &= ~0x00000002;
+ if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[drm] drmAgpEnable failed\n");
DRICloseScreen(pScreen);
return FALSE;
}
+ ErrorF("[drm] drmAgpEnabled succeeded\n");
- prim_size = 65536;
- init_offset = ((prim_size + pMGADRIServer->warp_ucode_size +
+ prim_size = 65536;
+ init_offset = ((prim_size + pMGADRIServer->warp_ucode_size +
4096 - 1) / 4096) * 4096;
- pMGADRIServer->agpSizep = drmAgpSize(pMGA->drmSubFD);
- pMGADRIServer->agpBase = drmAgpBase(pMGA->drmSubFD);
- if (drmAddMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agpBase,
- init_offset, DRM_AGP, 0,
- &pMGADRIServer->agp_private) < 0) {
- DRICloseScreen(pScreen);
- ErrorF("drmAddMap failed on AGP aperture\n");
- return FALSE;
- }
+ pMGADRIServer->agpSizep = init_offset;
+ pMGADRI->agpSize = (drmAgpSize(pMGA->drmSubFD)) - init_offset;
+
+ pMGADRIServer->agpBase = (drmAddress) drmAgpBase(pMGA->drmSubFD);
+ if (drmAddMap(pMGA->drmSubFD, 0,
+ init_offset, DRM_AGP, 0,
+ &pMGADRIServer->agp_private) < 0) {
+ DRICloseScreen(pScreen);
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmAddMap failed on AGP aperture\n");
+ return FALSE;
+ }
- if (drmMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agp_private,
- init_offset,
- (drmAddressPtr)&pMGADRIServer->agp_map) < -1) {
- DRICloseScreen(pScreen);
- ErrorF("drmMap failed on AGP aperture\n");
- return FALSE;
- }
+ if (drmMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agp_private,
+ init_offset,
+ (drmAddressPtr)&pMGADRIServer->agp_map) < -1) {
+ DRICloseScreen(pScreen);
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmMap failed on AGP aperture\n");
+ return FALSE;
+ }
+
+ /* Now allocate and bind a default of 8 megs */
+ drmAgpAlloc(pMGA->drmSubFD, 0x00800000, 0, 0,
+ &pMGADRIServer->agpHandle);
- /* Now allocate and bind a default of 8 megs */
+ if (pMGADRIServer->agpHandle == 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmAgpAlloc failed\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ if (drmAgpBind(pMGA->drmSubFD, pMGADRIServer->agpHandle, 0) < 0) {
+ DRICloseScreen(pScreen);
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] drmAgpBind failed\n");
+ return FALSE;
+ }
- pMGADRIServer->agpHandle = drmAgpAlloc(pMGA->drmSubFD, 0x00800000, 0, 0);
- if(pMGADRIServer->agpHandle == 0) {
- ErrorF("drmAgpAlloc failed\n");
- DRICloseScreen(pScreen);
- return FALSE;
- }
- if(drmAgpBind(pMGA->drmSubFD, pMGADRIServer->agpHandle, 0) < 0) {
- DRICloseScreen(pScreen);
- ErrorF("drmAgpBind failed\n");
- return FALSE;
- }
+ mgaInstallMicrocode(pScreen, prim_size);
- mgaInstallMicrocode(pScreen, prim_size);
+ if (drmAddMap(pMGA->drmSubFD, (drmHandle)init_offset,
+ pMGADRI->agpSize, DRM_AGP, 0,
+ &pMGADRI->agp) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to map public agp area\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
- ErrorF("init_offset: %x\n", init_offset);
- pMGADRI->agpSize = pMGADRIServer->agpSizep - init_offset;
- ErrorF("pMGADRI->agpSize: %x\n", pMGADRI->agpSize);
-
- if(drmAddMap(pMGA->drmSubFD, (drmHandle)pMGADRIServer->agpBase + init_offset,
- pMGADRI->agpSize, DRM_AGP, 0,
- &pMGADRI->agp) < 0) {
- ErrorF("Failed to map public agp area\n");
- DRICloseScreen(pScreen);
- return FALSE;
- }
- ErrorF("Mapped public agp area\n");
- /* Here is where we need to do initialization of the dma engine */
-
- pMGADRIServer->agpMode = drmAgpGetMode(pMGA->drmSubFD);
- /* Default to 1X agp mode */
- pMGADRIServer->agpMode &= ~0x00000002;
- if (drmAgpEnable(pMGA->drmSubFD, pMGADRIServer->agpMode) < 0) {
- ErrorF("drmAgpEnable failed\n");
- DRICloseScreen(pScreen);
- return FALSE;
- }
- ErrorF("drmAgpEnabled succeeded\n");
- if((bufs = drmAddBufs(pMGA->drmSubFD,
- /*63*/ 15,
- /* 65536 */ 524288,
- DRM_AGP_BUFFER,
- init_offset)) <= 0) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] failure adding %d %d byte DMA buffers\n",
- /* 63 */ 15,
- /* 65536 */ 524288);
- DRICloseScreen(pScreen);
- return FALSE;
- }
+ switch(pMGA->Chipset) {
+ case PCI_CHIP_MGAG400:
+ pMGADRI->chipset = MGA_CARD_TYPE_G400;
+ break;
+ case PCI_CHIP_MGAG200:
+ pMGADRI->chipset = MGA_CARD_TYPE_G200;
+ break;
+ case PCI_CHIP_MGAG200_PCI:
+ default:
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Direct rendering not supported on this card/chipset\n");
+ return FALSE;
+ }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] added %d %d byte DMA buffers\n",
- bufs, /* 65536 */ 524288);
+ pMGADRI->width = pScrn->virtualX;
+ pMGADRI->height = pScrn->virtualY;
+ pMGADRI->mem = pScrn->videoRam * 1024;
+ pMGADRI->cpp = pScrn->bitsPerPixel / 8;
+ pMGADRI->frontPitch = pScrn->displayWidth * (pScrn->bitsPerPixel / 8);
- if((mgadrmInitDma(pScrn, prim_size)) != TRUE) {
- ErrorF("Failed to initialize dma engine\n");
- DRICloseScreen(pScreen);
- return FALSE;
- }
-
- ErrorF("Initialized Dma Engine\n");
+ pMGADRI->frontOffset = 0; /* pMGA->YDstOrg * (pScrn->bitsPerPixel / 8) */
+ pMGADRI->backOffset = ((pScrn->virtualY + pMGA->numXAALines + 1) *
+ pScrn->displayWidth *
+ (pScrn->bitsPerPixel / 8) + 4095) & ~0xFFF;
-
- if(drmMarkBufs(pMGA->drmSubFD, 0.133333, 0.266666) != 0) {
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] calced backoffset: 0x%x\n",
+ pMGADRI->backOffset);
+
+
+#if 0
+ size = 2 * pScrn->virtualX * pScrn->virtualY;
+ pMGADRI->depthOffset = (pMGADRI->backOffset + size + 4095) & ~0xFFF;
+ pMGADRI->textureOffset = pMGADRI->depthOffset + size;
+ pMGADRI->textureSize = pMGA->FbUsableSize - pMGADRI->textureOffset;
+#else
+ size = 2 * pScrn->virtualX * pScrn->virtualY;
+ size += 4095;
+ size &= ~4095;
+ pMGADRI->depthOffset = pMGA->FbUsableSize - size;
+ pMGADRI->depthOffset &= ~4095;
+ pMGADRI->textureOffset = pMGADRI->backOffset + size;
+ pMGADRI->textureSize = pMGADRI->depthOffset - pMGADRI->textureOffset;
+
+ if (pMGADRI->depthOffset < pMGADRI->textureOffset + 512*1024) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Insufficient memory for direct rendering\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+#endif
+
+ pMGADRI->mAccess = pMGA->MAccess;
+
+ i = mylog2(pMGADRI->textureSize / MGA_NR_TEX_REGIONS);
+ if (i < MGA_LOG_MIN_TEX_REGION_SIZE)
+ i = MGA_LOG_MIN_TEX_REGION_SIZE;
+
+ pMGADRI->logTextureGranularity = i;
+ pMGADRI->textureSize = (pMGADRI->textureSize >> i) << i; /* truncate */
+
+
+ /* Here is where we need to do initialization of the dma engine */
+ if((bufs = drmAddBufs(pMGA->drmSubFD,
+ MGA_DMA_BUF_NR,
+ MGA_DMA_BUF_SZ,
+ DRM_AGP_BUFFER,
+ init_offset)) <= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] failure marking DMA buffers\n");
+ "[drm] failure adding %d %d byte DMA buffers\n",
+ MGA_DMA_BUF_NR,
+ MGA_DMA_BUF_SZ);
DRICloseScreen(pScreen);
return FALSE;
- }
- if (!(pMGADRIServer->drmBufs = drmMapBufs(pMGA->drmSubFD))) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] failure mapping DMA buffers\n");
- DRICloseScreen(pScreen);
- return FALSE;
- }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] buffers mapped with %p\n",
- pMGADRIServer->drmBufs);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "[drm] %d DMA buffers mapped\n",
- pMGADRIServer->drmBufs->count);
- if (!pMGADRIServer->irq) {
- pMGADRIServer->irq = drmGetInterruptFromBusID(pMGA->drmSubFD,
- ((pciConfigPtr)pMGA->PciInfo
+ }
+
+ pMGADRI->agpBufferOffset = init_offset + pMGADRIServer->agp_private;
+
+ /* Calculate texture constants for AGP texture space
+ */
+ {
+ CARD32 agpTextureOffset = MGA_DMA_BUF_SZ * MGA_DMA_BUF_NR;
+ CARD32 agpTextureSize = pMGADRI->agpSize - agpTextureOffset;
+
+ i = mylog2(agpTextureSize / MGA_NR_TEX_REGIONS);
+ if (i < MGA_LOG_MIN_TEX_REGION_SIZE)
+ i = MGA_LOG_MIN_TEX_REGION_SIZE;
+
+ pMGADRI->logAgpTextureGranularity = i;
+ pMGADRI->agpTextureSize = (agpTextureSize >> i) << i;
+ pMGADRI->agpTextureOffset = agpTextureOffset;
+ }
+
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[drm] added %d %d byte DMA buffers\n",
+ bufs, MGA_DMA_BUF_SZ);
+
+
+ if ((MgaInitDma(pScrn, prim_size)) != TRUE) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to initialize dma engine\n");
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ xf86DrvMsg(pScreen->myNum, X_INFO, "[drm] Initialized Dma Engine\n");
+
+ if (!pMGADRIServer->irq) {
+ pMGADRIServer->irq = drmGetInterruptFromBusID(pMGA->drmSubFD,
+ ((pciConfigPtr)pMGA->PciInfo
->thisCard)->busnum,
((pciConfigPtr)pMGA->PciInfo
->thisCard)->devnum,
((pciConfigPtr)pMGA->PciInfo
->thisCard)->funcnum);
- drmCtlInstHandler(pMGA->drmSubFD, pMGADRIServer->irq);
- }
+ drmCtlInstHandler(pMGA->drmSubFD, pMGADRIServer->irq);
+ }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] dma control initialized, using IRQ %d\n",
- pMGADRIServer->irq);
-
-
- if (!(MGAInitVisualConfigs(pScreen))) {
- DRICloseScreen(pScreen);
- return FALSE;
- }
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" );
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[drm] dma control initialized, using IRQ %d\n",
+ pMGADRIServer->irq);
- return TRUE;
+
+ if (!(MGAInitVisualConfigs(pScreen))) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "visual configs initialized\n" );
+
+ return TRUE;
}
void
@@ -481,16 +640,26 @@ MGADRICloseScreen(ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
MGAPtr pMGA = MGAPTR(pScrn);
MGADRIServerPrivatePtr pMGADRIServer = pMGA->DRIServerInfo;
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "[drm] unmapping %d buffers\n",
- pMGADRIServer->drmBufs->count);
- if (drmUnmapBufs(pMGADRIServer->drmBufs)) {
- xf86DrvMsg(pScreen->myNum, X_INFO,
- "[drm] unable to unmap DMA buffers\n");
+
+ MgaCleanupDma(pScrn);
+
+ if(pMGADRIServer->agp_map) {
+ ErrorF("Unmapped agp region\n");
+ drmUnmap(pMGADRIServer->agp_map, pMGADRIServer->agpSizep);
+ pMGADRIServer->agp_map = 0;
}
- mgadrmCleanupDma(pScrn);
-
+ if(pMGADRIServer->agpHandle) {
+ ErrorF("Freeing agp memory\n");
+ drmAgpFree(pMGA->drmSubFD, pMGADRIServer->agpHandle);
+ pMGADRIServer->agpHandle = 0;
+ pMGADRIServer->agpSizep = 0;
+ }
+ if(pMGADRIServer->agpAcquired == TRUE) {
+ ErrorF("releasing agp module\n");
+ drmAgpRelease(pMGA->drmSubFD);
+ pMGADRIServer->agpAcquired = FALSE;
+ }
+
DRICloseScreen(pScreen);
if (pMGA->pDRIInfo) {
@@ -518,9 +687,6 @@ MGACreateContext(ScreenPtr pScreen, VisualPtr visual,
drmContext hwContext, void *pVisualConfigPriv,
DRIContextType contextStore)
{
- MGADRIContextPtr ctx;
-
- ctx = (MGADRIContextPtr)contextStore;
return TRUE;
}
@@ -528,106 +694,121 @@ static void
MGADestroyContext(ScreenPtr pScreen, drmContext hwContext,
DRIContextType contextStore)
{
- MGADRIContextPtr ctx;
- ctx = (MGADRIContextPtr)contextStore;
}
Bool
MGADRIFinishScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGASAREAPtr sPriv;
MGAPtr pMGA = MGAPTR(pScrn);
- MGADRIPtr pMGADRI;
- int size;
+ if (!pMGA->pDRIInfo) return FALSE;
+
+ sPriv = (MGASAREAPtr)DRIGetSAREAPrivate(pScreen);
pMGA->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
- /* pMGA->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */
-
- pMGADRI = (MGADRIPtr)pMGA->pDRIInfo->devPrivate;
- pMGADRI->deviceID = pMGA->PciInfo->chipType;
- pMGADRI->width = pScrn->virtualX;
- pMGADRI->height = pScrn->virtualY;
- pMGADRI->mem = pScrn->videoRam * 1024;
- pMGADRI->cpp = pScrn->bitsPerPixel / 8;
- pMGADRI->stride = pScrn->displayWidth * (pScrn->bitsPerPixel / 8);
- pMGADRI->backOffset = ((pScrn->virtualY+129) * pScrn->displayWidth *
- (pScrn->bitsPerPixel / 8) + 4095) & ~0xFFF;
- size = 2 * pScrn->virtualX * pScrn->virtualY;
- pMGADRI->depthOffset = (pMGADRI->backOffset + size + 4095) & ~0xFFF;
- pMGADRI->textureOffset = pMGADRI->depthOffset + size;
- /*
- * The rest of the framebuffer is for textures except for the
- * memory for the hardware cursor.
- */
- pMGADRI->textureSize = pMGA->FbUsableSize - pMGADRI->textureOffset;
- pMGADRI->fbOffset = pMGA->YDstOrg * (pScrn->bitsPerPixel / 8);
+
+ xf86memset( sPriv, 0, sizeof(MGASAREARec) );
return DRIFinishScreenInit(pScreen);
}
-void MGASwapContext(ScreenPtr pScreen)
+
+void mgaGetQuiescence( ScrnInfoPtr pScrn )
{
-#if 0
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMga = MGAPTR(pScrn);
- MGAFBLayout *pLayout = &pMga->CurrentLayout;
-
- usleep(500);
- ErrorF("Syncing : swap\n");
- MGABUSYWAIT();
- ErrorF("Sync : swap 1\n");
- MGAStormSync(pScrn);
- ErrorF("Syncing done\n");
- pMga->AccelInfoRec->NeedToSync = TRUE;
-
- WAITFIFO(12);
- OUTREG(MGAREG_MACCESS, pMga->MAccess);
- OUTREG(MGAREG_PITCH, pLayout->displayWidth);
- OUTREG(MGAREG_YDSTORG, pMga->YDstOrg);
- OUTREG(MGAREG_PLNWT, pMga->PlaneMask);
- OUTREG(MGAREG_BCOL, pMga->BgColor);
- OUTREG(MGAREG_FCOL, pMga->FgColor);
- OUTREG(MGAREG_SRCORG, pMga->SrcOrg);
- OUTREG(MGAREG_DSTORG, pMga->DstOrg);
- OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT);
- OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */
- OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */
- OUTREG(MGAREG_YBOT, 0x007FFFFF); /* maxPixelPointer */
- pMga->AccelFlags &= ~CLIPPER_ON;
-#endif
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ pMga->have_quiescense = 1;
+
+ if (pMga->directRenderingEnabled) {
+ MGAFBLayout *pLayout = &pMga->CurrentLayout;
+
+ MgaLockUpdate(pScrn, (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH));
+
+ WAITFIFO(12);
+ OUTREG(MGAREG_MACCESS, pMga->MAccess);
+ OUTREG(MGAREG_PITCH, pLayout->displayWidth);
+ OUTREG(MGAREG_YDSTORG, pMga->YDstOrg);
+ OUTREG(MGAREG_PLNWT, pMga->PlaneMask);
+ OUTREG(MGAREG_BCOL, pMga->BgColor);
+ OUTREG(MGAREG_FCOL, pMga->FgColor);
+ pMga->SrcOrg = 0;
+ OUTREG(MGAREG_SRCORG, 0);
+ OUTREG(MGAREG_DSTORG, pMga->DstOrg);
+ OUTREG(MGAREG_OPMODE, MGAOPM_DMA_BLIT);
+ OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */
+ OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */
+ OUTREG(MGAREG_YBOT, 0x007FFFFF); /* maxPixelPointer */
+ pMga->AccelFlags &= ~CLIPPER_ON;
+ }
}
-void MGALostContext(ScreenPtr pScreen)
+
+
+void MGASwapContext(ScreenPtr pScreen)
{
-#if 0
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMga = MGAPTR(pScrn);
- MGAFBLayout *pLayout = &pMga->CurrentLayout;
-
- ErrorF("Syncing : lost\n");
- MGAStormSync(pScrn);
- ErrorF("Sync : lost 1\n");
- MGABUSYWAIT();
- ErrorF("Syncing done\n");
-#endif
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ /* Arrange for dma_quiescence and xaa sync to be called as
+ * appropriate.
+ */
+ pMga->have_quiescense = 0;
+ pMga->AccelInfoRec->NeedToSync = TRUE;
}
+
+
+/* This is really only called from validate/postvalidate as we
+ * override the dri lock/unlock. Want to remove validate/postvalidate
+ * processing, but need to remove all client-side use of drawable lock
+ * first (otherwise there is noone recover when a client dies holding
+ * the drawable lock).
+ *
+ * What does this mean?
+ *
+ * - The above code gets executed every time a
+ * window changes shape or the focus changes, which isn't really
+ * optimal.
+ * - The X server therefore believes it needs to do an XAA sync
+ * *and* a dma quiescense ioctl each time that happens.
+ *
+ * We don't wrap wakeuphandler any longer, so at least we can say that
+ * this doesn't happen *every time the mouse moves*...
+ */
static void
MGADRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
DRIContextType oldContextType, void *oldContext,
DRIContextType newContextType, void *newContext)
{
- if ((syncType == DRI_3D_SYNC) && (oldContextType == DRI_2D_CONTEXT) &&
- (newContextType == DRI_2D_CONTEXT)) { /* Entering from Wakeup */
- MGASwapContext(pScreen);
- }
- if ((syncType == DRI_2D_SYNC) && (oldContextType == DRI_NO_CONTEXT) &&
- (newContextType == DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
- MGALostContext(pScreen);
- }
+ if (syncType == DRI_3D_SYNC &&
+ oldContextType == DRI_2D_CONTEXT &&
+ newContextType == DRI_2D_CONTEXT)
+ {
+ MGASwapContext(pScreen);
+ }
}
-/* Needs to be written */
-void MGASelectBuffer(MGAPtr pMGA, int which)
+
+void
+MGASelectBuffer(ScrnInfoPtr pScrn, int which)
{
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGADRIPtr pMGADRI = (MGADRIPtr)pMga->pDRIInfo->devPrivate;
+
+ switch (which) {
+ case MGA_BACK:
+ OUTREG(MGAREG_DSTORG, pMGADRI->backOffset);
+ OUTREG(MGAREG_SRCORG, pMGADRI->backOffset);
+ break;
+ case MGA_DEPTH:
+ OUTREG(MGAREG_DSTORG, pMGADRI->depthOffset);
+ OUTREG(MGAREG_SRCORG, pMGADRI->depthOffset);
+ break;
+ default:
+ case MGA_FRONT:
+ OUTREG(MGAREG_DSTORG, pMGADRI->frontOffset);
+ OUTREG(MGAREG_SRCORG, pMGADRI->frontOffset);
+ break;
+ }
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h
index 7196bc954..28d710353 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h
@@ -1,12 +1,14 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h,v 1.1 2000/02/11 17:25:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_dri.h,v 1.3 2000/06/22 03:58:25 tsi Exp $ */
#ifndef _MGA_DRI_
#define _MGA_DRI_
#include <xf86drm.h>
-#include "mga_drm_public.h"
+#include <xf86drmMga.h>
-typedef struct _mga_dri_server_private {
+#define MGA_MAX_DRAWABLES 256
+
+typedef struct {
int reserved_map_agpstart;
int reserved_map_idx;
int buffer_map_idx;
@@ -17,6 +19,7 @@ typedef struct _mga_dri_server_private {
int sgram;
unsigned long agpMode;
unsigned long agpHandle;
+ Bool agpAcquired;
drmHandle agp_private;
drmSize agpSizep;
drmAddress agpBase;
@@ -24,27 +27,115 @@ typedef struct _mga_dri_server_private {
drmHandle regs;
drmSize regsSize;
drmAddress regsMap;
- mgaWarpIndex WarpIndex[MGA_MAX_WARP_PIPES];
+ drmMgaWarpIndex WarpIndex[MGA_MAX_WARP_PIPES];
drmBufMapPtr drmBufs;
CARD8 *agp_map;
-} MGADRIServerPrivate, *MGADRIServerPrivatePtr;
+} MGADRIServerPrivateRec, *MGADRIServerPrivatePtr;
typedef struct {
- int deviceID;
- int width;
- int height;
- int mem;
- int cpp;
- int stride;
- int fbOffset;
- int backOffset;
- int depthOffset;
- int textureOffset;
- int textureSize;
- drmHandle agp;
- drmSize agpSize;
+ int chipset;
+ int width;
+ int height;
+ int mem;
+ int cpp;
+ unsigned int frontOffset;
+ unsigned int frontPitch;
+
+ unsigned int backOffset;
+ unsigned int backPitch;
+
+ unsigned int depthOffset;
+ unsigned int depthPitch;
+
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ int logTextureGranularity;
+
+ /* Allow calculation of setup dma addresses.
+ */
+ unsigned int agpBufferOffset;
+
+ unsigned int agpTextureOffset;
+ unsigned int agpTextureSize;
+ int logAgpTextureGranularity;
+
+ /* Redundant?
+ */
+ unsigned int frontOrg;
+ unsigned int backOrg;
+ unsigned int depthOrg;
+
+ unsigned int mAccess;
+
+ drmHandle agp;
+ drmSize agpSize;
} MGADRIRec, *MGADRIPtr;
+/* WARNING: Do not change the SAREA structure without changing the kernel
+ * as well */
+typedef struct {
+ unsigned char next, prev;
+ unsigned char in_use;
+ unsigned int age;
+} MGATexRegionRec, *MGATexRegionPtr;
+
+typedef struct {
+ /* The channel for communication of state information to the kernel
+ * on firing a vertex dma buffer.
+ */
+ unsigned int ContextState[MGA_CTX_SETUP_SIZE];
+ unsigned int ServerState[MGA_2D_SETUP_SIZE];
+ unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
+ unsigned int WarpPipe;
+ unsigned int dirty;
+
+ unsigned int nbox;
+ XF86DRIClipRectRec boxes[MGA_NR_SAREA_CLIPRECTS];
+
+ /* Information about the most recently used 3d drawable. The
+ * client fills in the req_* fields, the server fills in the
+ * exported_ fields and puts the cliprects into boxes, above.
+ *
+ * The client clears the exported_drawable field before
+ * clobbering the boxes data.
+ */
+ unsigned int req_drawable; /* the X drawable id */
+ unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
+
+ unsigned int exported_drawable;
+ unsigned int exported_index;
+ unsigned int exported_stamp;
+ unsigned int exported_buffers;
+ int exported_nfront;
+ int exported_nback;
+ int exported_back_x, exported_front_x, exported_w;
+ int exported_back_y, exported_front_y, exported_h;
+ XF86DRIClipRectRec exported_boxes[MGA_NR_SAREA_CLIPRECTS];
+
+ /* Counters for aging textures and for client-side throttling.
+ */
+ unsigned int last_enqueue; /* last time a buffer was enqueued */
+ unsigned int last_dispatch; /* age of the most recently dispatched buffer */
+ unsigned int last_quiescent; /* */
+
+ /* LRU lists for texture memory in agp space and on the card */
+
+ MGATexRegionRec texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
+ unsigned int texAge[MGA_NR_TEX_HEAPS];
+ /* Mechanism to validate card state.
+ */
+ int ctxOwner;
+} MGASAREARec, *MGASAREAPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} MGAConfigPrivRec, *MGAConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} MGADRIContextRec, *MGADRIContextPtr;
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
index 6aabc62c3..f7fecbf51 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c
@@ -43,7 +43,7 @@
* Fixed 32bpp hires 8MB horizontal line glitch at middle right
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.149 2000/03/07 01:37:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_driver.c,v 1.163 2000/06/29 21:03:11 mvojkovi Exp $ */
/*
* This is a first cut at a non-accelerated version to work with the
@@ -148,12 +148,6 @@ static void MGASave(ScrnInfoPtr pScrn);
static void MGARestore(ScrnInfoPtr pScrn);
static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-#define VERSION 4000
-#define MGA_NAME "MGA"
-#define MGA_DRIVER_NAME "mga"
-#define MGA_MAJOR_VERSION 1
-#define MGA_MINOR_VERSION 0
-#define MGA_PATCHLEVEL 0
/*
* This contains the functions needed by the server after loading the
@@ -164,7 +158,7 @@ static Bool MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
*/
DriverRec MGA = {
- VERSION,
+ MGA_VERSION,
MGA_DRIVER_NAME,
#if 0
"accelerated driver for Matrox Millennium and Mystique cards",
@@ -216,7 +210,9 @@ typedef enum {
OPTION_SET_MCLK,
OPTION_OVERCLOCK_MEM,
OPTION_VIDEO_KEY,
- OPTION_ROTATE
+ OPTION_ROTATE,
+ OPTION_TEXTURED_VIDEO,
+ OPTION_XAALINES
} MGAOpts;
static OptionInfoRec MGAOptions[] = {
@@ -235,6 +231,8 @@ static OptionInfoRec MGAOptions[] = {
{ OPTION_OVERCLOCK_MEM, "OverclockMem", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_VIDEO_KEY, "VideoKey", OPTV_INTEGER, {0}, FALSE },
{ OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE },
+ { OPTION_TEXTURED_VIDEO, "TexturedVideo",OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_XAALINES, "XAALines", OPTV_INTEGER, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -298,31 +296,25 @@ static const char *ramdacSymbols[] = {
#ifdef XF86DRI
static const char *drmSymbols[] = {
+ "drmAvailable",
"drmAddBufs",
"drmAddMap",
- "drmAvailable",
- "drmCtlAddCommand",
"drmCtlInstHandler",
"drmGetInterruptFromBusID",
- "drmMapBufs",
- "drmMarkBufs",
- "drmUnmapBufs",
"drmAgpAcquire",
"drmAgpRelease",
"drmAgpEnable",
"drmAgpAlloc",
"drmAgpFree",
"drmAgpBind",
- "drmAgpUnbind",
- "drmAgpVersionMajor",
- "drmAgpVersionMinor",
"drmAgpGetMode",
"drmAgpBase",
"drmAgpSize",
- "drmAgpMemoryUsed",
- "drmAgpMemoryAvail",
- "drmAgpVendorId",
- "drmAgpDeviceId",
+ "drmMgaCleanupDma",
+ "drmMgaLockUpdate",
+ "drmMgaInitDma",
+ "drmFreeVersion",
+ "drmGetVersion",
NULL
};
@@ -339,6 +331,7 @@ static const char *driSymbols[] = {
"DRIUnlock",
"DRIGetSAREAPrivate",
"DRIGetContext",
+ "DRIQueryVersion",
"GlxSetVisualConfigs",
NULL
};
@@ -528,7 +521,7 @@ MGAProbe(DriverPtr drv, int flags)
{
int i;
GDevPtr *devSections = NULL;
- int *usedChips;
+ int *usedChips = NULL;
int numDevSections;
int numUsed;
Bool foundScreen = FALSE;
@@ -598,34 +591,40 @@ MGAProbe(DriverPtr drv, int flags)
#endif
/* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
+ pScrn = NULL;
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = MGA_DRIVER_NAME;
- pScrn->name = MGA_NAME;
- pScrn->Probe = MGAProbe;
- pScrn->PreInit = MGAPreInit;
- pScrn->ScreenInit = MGAScreenInit;
- pScrn->SwitchMode = MGASwitchMode;
- pScrn->AdjustFrame = MGAAdjustFrame;
- pScrn->EnterVT = MGAEnterVT;
- pScrn->LeaveVT = MGALeaveVT;
- pScrn->FreeScreen = MGAFreeScreen;
- pScrn->ValidMode = MGAValidMode;
- foundScreen = TRUE;
#ifndef DISABLE_VGA_IO
- xf86ConfigActivePciEntity(pScrn, usedChips[i], MGAPciChipsets, NULL,
- NULL, NULL, NULL, NULL);
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i],
+ MGAPciChipsets, NULL, NULL,
+ NULL, NULL, NULL)))
#else
- smga = xnfalloc(sizeof(MgaSave));
- smga->pvp = xf86GetPciInfoForEntity(usedChips[i]);
- xf86ConfigActivePciEntity(pScrn, usedChips[i], MGAPciChipsets, NULL,
- VgaIOSave, VgaIOSave, VgaIORestore,
- smga);
+ smga = xnfalloc(sizeof(MgaSave));
+ smga->pvp = xf86GetPciInfoForEntity(usedChips[i]);
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i],
+ MGAPciChipsets, NULL,VgaIOSave,
+ VgaIOSave, VgaIORestore,smga)))
#endif
+ {
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = MGA_VERSION;
+ pScrn->driverName = MGA_DRIVER_NAME;
+ pScrn->name = MGA_NAME;
+ pScrn->Probe = MGAProbe;
+ pScrn->PreInit = MGAPreInit;
+ pScrn->ScreenInit = MGAScreenInit;
+ pScrn->SwitchMode = MGASwitchMode;
+ pScrn->AdjustFrame = MGAAdjustFrame;
+ pScrn->EnterVT = MGAEnterVT;
+ pScrn->LeaveVT = MGALeaveVT;
+ pScrn->FreeScreen = MGAFreeScreen;
+ pScrn->ValidMode = MGAValidMode;
+ foundScreen = TRUE;
+ }
}
- xfree(usedChips);
+ if (usedChips)
+ xfree(usedChips);
+
return foundScreen;
}
@@ -794,7 +793,6 @@ static void
MGASoftReset(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
- int i;
pMga->FbMapSize = 8192 * 1024;
MGAMapMem(pScrn);
@@ -902,26 +900,27 @@ MGACountRam(ScrnInfoPtr pScrn)
pMga->FbMapSize = ProbeSize * 1024;
MGAMapMem(pScrn);
base = pMga->FbBase;
-
+
/* turn MGA mode on - enable linear frame buffer (CRTCEXT3) */
OUTREG8(0x1FDE, 3);
tmp = INREG8(0x1FDF);
OUTREG8(0x1FDF, tmp | 0x80);
-
+
/* write, read and compare method */
for(i = ProbeSize; i > 2048; i -= 2048) {
base[(i * 1024) - 1] = 0xAA;
OUTREG8(MGAREG_CRTC_INDEX, 0); /* flush the cache */
+ usleep(1); /* twart write combination */
if(base[(i * 1024) - 1] == 0xAA) {
SizeFound = i;
break;
}
}
-
+
/* restore CRTCEXT3 state */
OUTREG8(0x1FDE, 3);
OUTREG8(0x1FDF, tmp);
-
+
MGAUnmapMem(pScrn);
}
return SizeFound;
@@ -1063,15 +1062,13 @@ VgaIOEnable(void *arg)
}
#endif /* DISABLE_VGA_IO */
-extern xf86MonPtr ConfiguredMonitor;
-
void
MGAProbeDDC(ScrnInfoPtr pScrn, int index)
{
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
pVbe = VBEInit(NULL,index);
- ConfiguredMonitor = vbeDoEDID(pVbe);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
}
}
@@ -1307,6 +1304,27 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
+ if(xf86GetOptValInteger(MGAOptions, OPTION_XAALINES,
+ &(pMga->numXAALines))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Will Use %d lines for "
+ "offscreen memory if the DRI is enabled.\n",
+ pMga->numXAALines);
+ } else {
+ /* The default is to use 512 lines on a G400, 128 on a G200 */
+ switch (pMga->Chipset) {
+ case PCI_CHIP_MGAG200:
+ case PCI_CHIP_MGAG200_PCI:
+ pMga->numXAALines = 128;
+ break;
+ default:
+ pMga->numXAALines = 512;
+ break;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Offscreen memory usage "
+ "will be limited to %d lines if the DRI is enabled.\n",
+ pMga->numXAALines);
+ }
+
from = X_DEFAULT;
pMga->HWCursor = TRUE;
/*
@@ -1389,6 +1407,9 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
pMga->OverclockMem = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Overclocking memory\n");
}
+ if (xf86ReturnOptValBool(MGAOptions, OPTION_TEXTURED_VIDEO, FALSE)) {
+ pMga->TexturedVideo = TRUE;
+ }
if (pMga->FBDev) {
/* check for linux framebuffer device */
if (!xf86LoadSubModule(pScrn, "fbdevhw"))
@@ -1702,14 +1723,16 @@ MGAPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pMga->MinClock;
clockRanges->maxClock = pMga->MaxClock;
clockRanges->clockIndex = -1; /* programmable */
clockRanges->interlaceAllowed = TRUE;
clockRanges->doubleScanAllowed = TRUE;
-
+ clockRanges->ClockMulFactor = 1;
+ clockRanges->ClockDivFactor = 1;
+
/* Only set MemClk if appropriate for the ramdac */
if (pMga->Dac.SetMemClk) {
if (pMga->MemClk == 0) {
@@ -2142,13 +2165,13 @@ MGAModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
#ifdef XF86DRI
if (pMga->directRenderingEnabled) {
- DRILock(screenInfo.screens[pScrn->scrnIndex]);
- MGASwapContext(screenInfo.screens[pScrn->scrnIndex]);
+ DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
}
#endif
(*pMga->Restore)(pScrn, vgaReg, mgaReg, FALSE);
+ MGAStormSync(pScrn);
MGAStormEngineInit(pScrn);
vgaHWProtect(pScrn, FALSE);
@@ -2180,7 +2203,8 @@ MGARestore(ScrnInfoPtr pScrn)
MGAPtr pMga = MGAPTR(pScrn);
MGARegPtr mgaReg = &pMga->SavedReg;
- MGAStormSync(pScrn);
+ if (pScrn->pScreen != NULL)
+ MGAStormSync(pScrn);
/* Only restore text mode fonts/text for the primary card */
vgaHWProtect(pScrn, TRUE);
@@ -2321,11 +2345,13 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
* Setup DRI after visuals have been established, but before cfbScreenInit
* is called. cfbScreenInit will eventually call into the drivers
* InitGLXVisuals call back.
+ * The DRI does not work when textured video is enabled at this time.
*/
- pMga->directRenderingEnabled = MGADRIScreenInit(pScreen);
- /* Force the initialization of the context */
- MGALostContext(pScreen);
+ if (!pMga->NoAccel && pMga->TexturedVideo != TRUE)
+ pMga->directRenderingEnabled = MGADRIScreenInit(pScreen);
+ else
+ pMga->directRenderingEnabled = FALSE;
#endif
@@ -2458,20 +2484,20 @@ MGAScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#ifdef XF86DRI
/* Initialize the Warp engine */
- if (pMga->directRenderingEnabled) {
- pMga->directRenderingEnabled = mgaConfigureWarp(pScrn);
- }
- if (pMga->directRenderingEnabled) {
- /* Now that mi, cfb, drm and others have done their thing,
- * complete the DRI setup.
- */
- pMga->directRenderingEnabled = MGADRIFinishScreenInit(pScreen);
- }
- if (pMga->directRenderingEnabled) {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n");
- } else {
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n");
- }
+ if (pMga->directRenderingEnabled) {
+ pMga->directRenderingEnabled = mgaConfigureWarp(pScrn);
+ }
+ if (pMga->directRenderingEnabled) {
+ /* Now that mi, cfb, drm and others have done their thing,
+ * complete the DRI setup.
+ */
+ pMga->directRenderingEnabled = MGADRIFinishScreenInit(pScreen);
+ }
+ if (pMga->directRenderingEnabled) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n");
+ }
#endif
pScrn->memPhysBase = pMga->FbAddress;
@@ -2625,7 +2651,7 @@ MGALeaveVT(int scrnIndex, int flags)
pMGA = MGAPTR(pScrn);
if (pMGA->directRenderingEnabled) {
pScreen = screenInfo.screens[scrnIndex];
- DRILock(pScreen);
+ DRILock(pScreen, 0);
}
#endif
@@ -2675,6 +2701,8 @@ MGACloseScreen(int scrnIndex, ScreenPtr pScreen)
xfree(pMga->DGAModes);
if (pMga->adaptor)
xfree(pMga->adaptor);
+ if (pMga->portPrivate)
+ xfree(pMga->portPrivate);
pScrn->vtSema = FALSE;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h
index 535838fe8..3399bac21 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.12 2000/02/11 17:25:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_macros.h,v 1.14 2000/06/17 00:03:20 martin Exp $ */
#ifndef _MGA_MACROS_H_
#define _MGA_MACROS_H_
@@ -20,7 +20,6 @@
#define RGBEQUAL(c) (!((((c) >> 8) ^ (c)) & 0xffff))
#ifdef XF86DRI
-#define MGAREG_DWGSYNC 0x2c4c
#define MGA_SYNC_XTAG 0x275f4200
#define MGABUSYWAIT() do { \
@@ -84,4 +83,17 @@ while(INREG(MGAREG_DWGSYNC) != MGA_SYNC_XTAG) ; \
WAITFIFO(1); \
OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); }
+#ifdef XF86DRI
+extern void mgaGetQuiescence( ScrnInfoPtr pScrn );
+
+#define CHECK_DMA_QUIESCENT(pMGA, pScrn) { \
+ if (!pMGA->have_quiescense) { \
+ mgaGetQuiescence( pScrn ); \
+ } \
+}
+#else
+#define CHECK_DMA_QUIESCENT(pMGA, pScrn)
+#endif
+
+
#endif /* _MGA_MACROS_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h
index f18bd7722..12538fd3c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h
@@ -2,7 +2,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.11 2000/02/11 17:25:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_reg.h,v 1.12 2000/06/09 22:43:38 mvojkovi Exp $ */
@@ -406,5 +406,29 @@
#define MGAREG_BESVCOORD 0x3d2c
#define MGAREG_BESVISCAL 0x3d34
+/* texture engine registers */
+
+#define MGAREG_TMR0 0x2c00
+#define MGAREG_TMR1 0x2c04
+#define MGAREG_TMR2 0x2c08
+#define MGAREG_TMR3 0x2c0c
+#define MGAREG_TMR4 0x2c10
+#define MGAREG_TMR5 0x2c14
+#define MGAREG_TMR6 0x2c18
+#define MGAREG_TMR7 0x2c1c
+#define MGAREG_TMR8 0x2c20
+#define MGAREG_TEXORG 0x2c24
+#define MGAREG_TEXWIDTH 0x2c28
+#define MGAREG_TEXHEIGHT 0x2c2c
+#define MGAREG_TEXCTL 0x2c30
+#define MGAREG_TEXCTL2 0x2c3c
+#define MGAREG_TEXTRANS 0x2c34
+#define MGAREG_TEXTRANSHIGH 0x2c38
+#define MGAREG_TEXFILTER 0x2c58
+#define MGAREG_ALPHACTRL 0x2c7c
+
+#define MGAREG_DWGSYNC 0x2c4c
+
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c
index c6120f923..61f363de5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v 1.64 2000/02/12 20:45:24 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_storm.c,v 1.69 2000/06/29 20:56:59 mvojkovi Exp $ */
/* All drivers should typically include these */
@@ -35,7 +35,6 @@
#ifdef XF86DRI
#include "mga_dri.h"
-#include "mga_dripriv.h"
#endif
static void MGANAME(SubsequentScreenToScreenCopy)(ScrnInfoPtr pScrn,
@@ -141,11 +140,8 @@ MGANAME(AccelInit)(ScreenPtr pScreen)
XAAInfoRecPtr infoPtr;
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
MGAPtr pMga = MGAPTR(pScrn);
- int maxFastBlitMem;
+ int maxFastBlitMem, maxlines;
BoxRec AvailFBArea;
-#ifdef XF86DRI
- RegionRec MemRegion;
-#endif
pMga->AccelInfoRec = infoPtr = XAACreateInfoRec();
if(!infoPtr) return FALSE;
@@ -381,25 +377,31 @@ MGANAME(AccelInit)(ScreenPtr pScreen)
pMga->MaxFastBlitY = maxFastBlitMem / (pScrn->displayWidth * PSZ / 8);
}
+ maxlines = (min(pMga->FbUsableSize, 16*1024*1024)) /
+ (pScrn->displayWidth * PSZ / 8);
+
+#ifdef XF86DRI
+ if (pMga->directRenderingEnabled) {
+ if(maxlines > (pMga->numXAALines + pScrn->virtualY))
+ maxlines = pMga->numXAALines + pScrn->virtualY;
+
+ if(maxlines < (pMga->numXAALines + pScrn->virtualY))
+ pMga->numXAALines = maxlines - pScrn->virtualY;
+
+ /* not like the 3D will even work when there's not
+ even enough memory for a tiny pixmap cache */
+ }
+
+#endif
AvailFBArea.x1 = 0;
AvailFBArea.x2 = pScrn->displayWidth;
-
-#ifndef XF86DRI
AvailFBArea.y1 = 0;
- AvailFBArea.y2 = (min(pMga->FbUsableSize, 16*1024*1024)) /
- (pScrn->displayWidth * PSZ / 8);
-
+ AvailFBArea.y2 = maxlines;
xf86InitFBManager(pScreen, &AvailFBArea);
-#else
- AvailFBArea.y1 = pScrn->virtualY;
- AvailFBArea.y2 = pScrn->virtualY+128;
-
- REGION_INIT(pScreen, &MemRegion, &AvailFBArea, 1);
- xf86InitFBManagerRegion(pScreen, &MemRegion);
- REGION_UNINIT(pScreen, &MemRegion);
-#endif
-
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %d lines for offscreen "
+ "memory.\n",
+ maxlines - pScrn->virtualY);
return(XAAInit(pScreen, infoPtr));
}
@@ -455,7 +457,9 @@ void
MGAStormSync(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
-
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
while(MGAISBUSY());
/* flush cache before a read (mga-1064g 5.1.6) */
OUTREG8(MGAREG_CRTC_INDEX, 0);
@@ -471,6 +475,8 @@ void MGAStormEngineInit(ScrnInfoPtr pScrn)
MGAPtr pMga = MGAPTR(pScrn);
MGAFBLayout *pLayout = &pMga->CurrentLayout;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
if (pMga->Chipset == PCI_CHIP_MGAG100)
maccess = 1 << 14;
@@ -479,8 +485,9 @@ void MGAStormEngineInit(ScrnInfoPtr pScrn)
case 8:
break;
case 16:
- /* set 16 bpp, turn off dithering, turn on 5:5:5 pixels */
- maccess |= 1 + (1 << 30) + (1 << 31);
+ maccess |= 1;
+ if(pLayout->depth == 15)
+ maccess |= (1 << 31);
break;
case 24:
maccess |= 3;
@@ -539,6 +546,8 @@ void MGASetClippingRectangle(
){
MGAPtr pMga = MGAPTR(pScrn);
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
WAITFIFO(3);
OUTREG(MGAREG_CXBNDRY,(x2 << 16) | x1);
OUTREG(MGAREG_YTOP, (y1 * pScrn->displayWidth) + pMga->YDstOrg);
@@ -550,6 +559,8 @@ void MGADisableClipping(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
WAITFIFO(3);
OUTREG(MGAREG_CXBNDRY, 0xFFFF0000); /* (maxX << 16) | minX */
OUTREG(MGAREG_YTOP, 0x00000000); /* minPixelPointer */
@@ -580,6 +591,8 @@ MGANAME(SetupForScreenToScreenCopy)(
CARD32 dwgctl = pMga->AtypeNoBLK[rop] | MGADWG_SHIFTZERO |
MGADWG_BITBLT | MGADWG_BFCOL;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
pMga->AccelInfoRec->SubsequentScreenToScreenCopy =
MGANAME(SubsequentScreenToScreenCopy);
@@ -767,6 +780,8 @@ MGANAME(SetupForSolidFill)(
{
MGAPtr pMga = MGAPTR(pScrn);
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
#if PSZ == 24
if(!RGBEQUAL(color))
pMga->FilledRectCMD = MGADWG_TRAP | MGADWG_SOLID | MGADWG_ARZERO |
@@ -812,7 +827,7 @@ MGANAME(SubsequentSolidFillTrap)(ScrnInfoPtr pScrn, int y, int h,
int ar2 = sdxl? dxL : -dxL;
int sdxr = (dxR < 0);
int ar5 = sdxr? dxR : -dxR;
-
+
WAITFIFO(11);
OUTREG(MGAREG_DWGCTL,
pMga->FilledRectCMD & ~(MGADWG_ARZERO | MGADWG_SGNZERO));
@@ -892,6 +907,8 @@ MGANAME(SetupForMono8x8PatternFill)(
MGAPtr pMga = MGAPTR(pScrn);
XAAInfoRecPtr infoRec = pMga->AccelInfoRec;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
pMga->PatternRectCMD = MGADWG_TRAP | MGADWG_ARZERO | MGADWG_SGNZERO |
MGADWG_BMONOLEF;
@@ -936,7 +953,7 @@ MGANAME(SubsequentMono8x8PatternFillRect)(
int x, int y, int w, int h )
{
MGAPtr pMga = MGAPTR(pScrn);
-
+
WAITFIFO(3);
OUTREG(MGAREG_SHIFT, (paty << 4) | patx);
OUTREG(MGAREG_FXBNDRY, ((x + w) << 16) | (x & 0xffff));
@@ -952,6 +969,7 @@ MGANAME(SubsequentMono8x8PatternFillRect_Additional)(
int x, int y, int w, int h )
{
MGAPtr pMga = MGAPTR(pScrn);
+
WAITFIFO(2);
OUTREG(MGAREG_FXBNDRY, ((x + w) << 16) | (x & 0xffff));
OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC, (y << 16) | h);
@@ -1002,10 +1020,11 @@ MGANAME(SetupForCPUToScreenColorExpandFill)(
unsigned int planemask )
{
MGAPtr pMga = MGAPTR(pScrn);
-
CARD32 mgaCMD = MGADWG_ILOAD | MGADWG_LINEAR | MGADWG_SGNZERO |
MGADWG_SHIFTZERO | MGADWG_BMONOLEF;
-
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
if(bg == -1) {
#if PSZ == 24
if(!RGBEQUAL(fg))
@@ -1066,6 +1085,8 @@ static void MGANAME(SetupForImageWrite)(
){
MGAPtr pMga = MGAPTR(pScrn);
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
WAITFIFO(3);
OUTREG(MGAREG_AR5, 0);
SET_PLANEMASK(planemask);
@@ -1110,6 +1131,8 @@ MGANAME(SetupForDashedLine)(
CARD32 NiceDashPattern = DashPattern[0];
int dwords = (length + 31) >> 5;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
pMga->DashCMD = MGADWG_BFCOL | pMga->AtypeNoBLK[rop];
pMga->StyleLen = length - 1;
@@ -1216,7 +1239,9 @@ MGANAME(SetupForPlanarScreenToScreenColorExpandFill)(
MGAPtr pMga = MGAPTR(pScrn);
CARD32 mgaCMD = pMga->AtypeNoBLK[rop] | MGADWG_BITBLT |
MGADWG_SGNZERO | MGADWG_BPLAN;
-
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
if(bg == -1) {
mgaCMD |= MGADWG_TRANSC;
WAITFIFO(4);
@@ -1267,7 +1292,9 @@ MGANAME(SetupForScreenToScreenColorExpandFill)(
){
MGAPtr pMga = MGAPTR(pScrn);
CARD32 mgaCMD = MGADWG_BITBLT | MGADWG_SGNZERO | MGADWG_SHIFTZERO;
-
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
if(bg == -1) {
#if PSZ == 24
if(!RGBEQUAL(fg))
@@ -1427,6 +1454,8 @@ MGAWriteBitmapColorExpand(
CARD32* maxptr;
int dwords, maxlines, count;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
(*infoRec->SetupForCPUToScreenColorExpandFill)(
pScrn, fg, bg, rop, planemask);
@@ -1570,6 +1599,8 @@ MGAFillSolidRectsDMA(
XAAInfoRecPtr infoRec = pMga->AccelInfoRec;
CARD32 *base = (CARD32*)pMga->ILOADBase;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
SET_SYNC_FLAG(infoRec);
(*infoRec->SetupForSolidFill)(pScrn, fg, rop, planemask);
@@ -1610,6 +1641,7 @@ MGAFillSolidSpansDMA(
XAAInfoRecPtr infoRec = pMga->AccelInfoRec;
CARD32 *base = (CARD32*)pMga->ILOADBase;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
SET_SYNC_FLAG(infoRec);
if(infoRec->ClipBox) {
@@ -1670,6 +1702,8 @@ MGAFillMono8x8PatternRectsTwoPass(
int nBox, SecondPassColor;
BoxPtr pBox;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
if((rop == GXcopy) && (bg != -1)) {
SecondPassColor = bg;
bg = -1;
@@ -1718,6 +1752,7 @@ void MGANonTEGlyphRenderer(
int x1, x2, y1, y2, i, h, skiptop, dwords, maxlines;
unsigned char *src;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
(*infoRec->SetupForCPUToScreenColorExpandFill)(
pScrn, fg, -1, rop, planemask);
WAITFIFO(1);
@@ -1888,6 +1923,8 @@ MGAFillCacheBltRects(
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
int x, y, phaseY, phaseX, skipleft, height, width, w, blit_w, blit_h, start;
+ CHECK_DMA_QUIESCENT(MGAPTR(pScrn), pScrn);
+
(*infoRec->SetupForScreenToScreenCopy)(pScrn, 1, 1, rop, planemask,
pCache->trans_color);
@@ -1980,7 +2017,9 @@ MGATEGlyphRenderer(
CARD32* base;
int dwords;
- (*infoRec->SetupForCPUToScreenColorExpandFill)(
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
+ (*infoRec->SetupForCPUToScreenColorExpandFill)(
pScrn, fg, bg, rop, planemask);
w += skipleft;
@@ -2013,29 +2052,27 @@ MGATEGlyphRenderer(
void
MGANAME(DRIInitBuffers)(WindowPtr pWin, RegionPtr prgn, CARD32 index)
{
- ScreenPtr pScreen = pWin->drawable.pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMGA = MGAPTR(pScrn);
- BoxPtr pbox;
- int nbox;
-
- /* It looks nicer if these start out black */
- pbox = REGION_RECTS(prgn);
- nbox = REGION_NUM_RECTS(prgn);
-
- MGANAME(SetupForSolidFill)(pScrn, 0, GXcopy, -1);
- while (nbox--) {
- MGASelectBuffer(pMGA, MGA_BACK);
- MGANAME(SubsequentSolidFillRect)(pScrn, pbox->x1, pbox->y1,
- pbox->x2-pbox->x1, pbox->y2-pbox->y1);
- MGASelectBuffer(pMGA, MGA_DEPTH);
- MGANAME(SubsequentSolidFillRect)(pScrn, pbox->x1, pbox->y1,
- pbox->x2-pbox->x1, pbox->y2-pbox->y1);
- pbox++;
- }
- MGASelectBuffer(pMGA, MGA_FRONT);
-
- pMGA->AccelInfoRec->NeedToSync = TRUE;
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMGA = MGAPTR(pScrn);
+ BoxPtr pbox = REGION_RECTS(prgn);
+ int nbox = REGION_NUM_RECTS(prgn);
+
+ CHECK_DMA_QUIESCENT(MGAPTR(pScrn), pScrn);
+
+ MGANAME(SetupForSolidFill)(pScrn, 0, GXcopy, -1);
+ while (nbox--) {
+ MGASelectBuffer(pScrn, MGA_BACK);
+ MGANAME(SubsequentSolidFillRect)(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ MGASelectBuffer(pScrn, MGA_DEPTH);
+ MGANAME(SubsequentSolidFillRect)(pScrn, pbox->x1, pbox->y1,
+ pbox->x2-pbox->x1, pbox->y2-pbox->y1);
+ pbox++;
+ }
+ MGASelectBuffer(pScrn, MGA_FRONT);
+
+ pMGA->AccelInfoRec->NeedToSync = TRUE;
}
/*
@@ -2049,127 +2086,142 @@ void
MGANAME(DRIMoveBuffers)(WindowPtr pParent, DDXPointRec ptOldOrg,
RegionPtr prgnSrc, CARD32 index)
{
-#if 0
- ScreenPtr pScreen = pParent->drawable.pScreen;
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- MGAPtr pMGA = MGAPTR(pScrn);
- int nbox;
- BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
- DDXPointPtr pptTmp, pptNew1, pptNew2;
- int xdir, ydir;
- int dx, dy, w, h;
- DDXPointPtr pptSrc;
-
- pbox = REGION_RECTS(prgnSrc);
- nbox = REGION_NUM_RECTS(prgnSrc);
- pboxNew1 = 0;
- pptNew1 = 0;
- pboxNew2 = 0;
- pboxNew2 = 0;
- pptSrc = &ptOldOrg;
-
- dx = pParent->drawable.x - ptOldOrg.x;
- dy = pParent->drawable.y - ptOldOrg.y;
-
- /* If the copy will overlap in Y, reverse the order */
- if (dy>0) {
- ydir = -1;
-
- if (nbox>1) {
- /* Keep ordering in each band, reverse order of bands */
- pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
- if (!pboxNew1) return;
- pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
- if (!pptNew1) {
- DEALLOCATE_LOCAL(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++;
+ ScreenPtr pScreen = pParent->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ MGAPtr pMGA = MGAPTR(pScrn);
+ int nbox;
+ BoxPtr pbox, pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
+ DDXPointPtr pptTmp, pptNew1, pptNew2;
+ int xdir, ydir;
+ int dx, dy;
+ DDXPointPtr pptSrc;
+ int screenwidth = pScrn->virtualX;
+ int screenheight = pScrn->virtualY;
+
+ CHECK_DMA_QUIESCENT(MGAPTR(pScrn), pScrn);
+
+ pbox = REGION_RECTS(prgnSrc);
+ nbox = REGION_NUM_RECTS(prgnSrc);
+ pboxNew1 = 0;
+ pptNew1 = 0;
+ pboxNew2 = 0;
+ pboxNew2 = 0;
+ pptSrc = &ptOldOrg;
+
+ dx = pParent->drawable.x - ptOldOrg.x;
+ dy = pParent->drawable.y - ptOldOrg.y;
+
+ /* If the copy will overlap in Y, reverse the order */
+ if (dy>0) {
+ ydir = -1;
+
+ if (nbox>1) {
+ /* Keep ordering in each band, reverse order of bands */
+ pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ if (!pboxNew1) return;
+ pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pptNew1) {
+ DEALLOCATE_LOCAL(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;
}
- pboxBase = pboxNext;
- }
- pboxNew1 -= nbox;
- pbox = pboxNew1;
- pptNew1 -= nbox;
- pptSrc = pptNew1;
+ } else {
+ /* No changes required */
+ ydir = 1;
}
- } else {
- /* No changes required */
- ydir = 1;
- }
-
- /* If the regions will overlap in X, reverse the order */
- if (dx>0) {
- xdir = -1;
-
- if (nbox > 1) {
- /*reverse orderof rects in each band */
- pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
- pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
- if (!pboxNew2 || !pptNew2) {
- if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
- if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
- if (pboxNew1) {
- DEALLOCATE_LOCAL(pptNew1);
- DEALLOCATE_LOCAL(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;
+
+ /* If the regions will overlap in X, reverse the order */
+ if (dx>0) {
+ xdir = -1;
+
+ if (nbox > 1) {
+ /*reverse orderof rects in each band */
+ pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec)*nbox);
+ pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec)*nbox);
+ if (!pboxNew2 || !pptNew2) {
+ if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+ if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(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;
}
- pboxBase = pboxNext;
- }
- pboxNew2 -= nbox;
- pbox = pboxNew2;
- pptNew2 -= nbox;
- pptSrc = pptNew2;
+ } else {
+ /* No changes are needed */
+ xdir = 1;
}
- } else {
- /* No changes are needed */
- xdir = 1;
- }
- MGANAME(SetupForScreenToScreenCopy)(pScrn, xdir, ydir, GXcopy, -1, -1);
- while (nbox--) {
- w=pbox->x2-pbox->x1+1;
- h=pbox->y2-pbox->y1+1;
- MGASelectBuffer(pMGA, MGA_BACK);
- MGANAME(SubsequentScreenToScreenCopy)(pScrn, pbox->x1, pbox->y1,
- pbox->x1+dx, pbox->y1+dy, w, h);
- MGASelectBuffer(pMGA, MGA_DEPTH);
- MGANAME(SubsequentScreenToScreenCopy)(pScrn, pbox->x1, pbox->y1,
- pbox->x1+dx, pbox->y1+dy, w, h);
- pbox++;
- }
- MGASelectBuffer(pMGA, MGA_FRONT);
-
- if (pboxNew2) {
- DEALLOCATE_LOCAL(pptNew2);
- DEALLOCATE_LOCAL(pboxNew2);
- }
- if (pboxNew1) {
- DEALLOCATE_LOCAL(pptNew1);
- DEALLOCATE_LOCAL(pboxNew1);
- }
-
- pMGA->AccelInfoRec->NeedToSync = TRUE;
-#endif
+ MGANAME(SetupForScreenToScreenCopy)(pScrn, xdir, ydir, GXcopy, -1, -1);
+ for ( ; nbox-- ; pbox++)
+ {
+ int x1 = pbox->x1;
+ int y1 = pbox->y1;
+ int destx = x1 + dx;
+ int desty = y1 + dy;
+ int w = pbox->x2 - x1 + 1;
+ int h = pbox->y2 - y1 + 1;
+
+ if ( destx < 0 ) x1 -= destx, w += destx, destx = 0;
+ if ( desty < 0 ) y1 -= desty, h += desty, desty = 0;
+ if ( destx + w > screenwidth ) w = screenwidth - destx;
+ if ( desty + h > screenheight ) h = screenheight - desty;
+ if ( w <= 0 ) continue;
+ if ( h <= 0 ) continue;
+
+ MGASelectBuffer(pScrn, MGA_BACK);
+ MGANAME(SubsequentScreenToScreenCopy)(pScrn, x1, y1,
+ destx,desty, w, h);
+ MGASelectBuffer(pScrn, MGA_DEPTH);
+ MGANAME(SubsequentScreenToScreenCopy)(pScrn, x1,y1,
+ destx,desty, w, h);
+ }
+ MGASelectBuffer(pScrn, MGA_FRONT);
+
+ if (pboxNew2) {
+ DEALLOCATE_LOCAL(pptNew2);
+ DEALLOCATE_LOCAL(pboxNew2);
+ }
+ if (pboxNew1) {
+ DEALLOCATE_LOCAL(pptNew1);
+ DEALLOCATE_LOCAL(pboxNew1);
+ }
+
+ pMGA->AccelInfoRec->NeedToSync = TRUE;
}
#endif /* XF86DRI */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c
index 26ee6f8dc..444a1fc2b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c,v 1.12 2000/03/08 01:14:27 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_video.c,v 1.15 2000/06/17 00:03:20 martin Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -19,9 +19,10 @@
#include "xaa.h"
#include "xaalocal.h"
#include "dixstruct.h"
+#include "fourcc.h"
-#define OFF_DELAY 200 /* milliseconds */
-#define FREE_DELAY 60000
+#define OFF_DELAY 250 /* milliseconds */
+#define FREE_DELAY 15000
#define OFF_TIMER 0x01
#define FREE_TIMER 0x02
@@ -29,26 +30,36 @@
#define TIMER_MASK (OFF_TIMER | FREE_TIMER)
+#define MGA_MAX_PORTS 16
+
#ifndef XvExtension
void MGAInitVideo(ScreenPtr pScreen) {}
-void MGAResetVideo(ScrnInfoPtr pScrn) {}
#else
-static XF86VideoAdaptorPtr MGASetupImageVideoG(ScreenPtr);
static void MGAInitOffscreenImages(ScreenPtr);
-static void MGAStopVideoG(ScrnInfoPtr, pointer, Bool);
-static int MGASetPortAttributeG(ScrnInfoPtr, Atom, INT32, pointer);
-static int MGAGetPortAttributeG(ScrnInfoPtr, Atom ,INT32 *, pointer);
-static void MGAQueryBestSizeG(ScrnInfoPtr, Bool,
- short, short, short, short, unsigned int *, unsigned int *, pointer);
-static int MGAPutImageG( ScrnInfoPtr,
- short, short, short, short, short, short, short, short,
- int, unsigned char*, short, short, Bool, RegionPtr, pointer);
-static int MGAQueryImageAttributesG(ScrnInfoPtr,
- int, unsigned short *, unsigned short *, int *, int *);
+
+static XF86VideoAdaptorPtr MGASetupImageVideoOverlay(ScreenPtr);
+static int MGASetPortAttributeOverlay(ScrnInfoPtr, Atom, INT32, pointer);
+static int MGAGetPortAttributeOverlay(ScrnInfoPtr, Atom ,INT32 *, pointer);
+
+static XF86VideoAdaptorPtr MGASetupImageVideoTexture(ScreenPtr);
+static int MGASetPortAttributeTexture(ScrnInfoPtr, Atom, INT32, pointer);
+static int MGAGetPortAttributeTexture(ScrnInfoPtr, Atom ,INT32 *, pointer);
+
+static void MGAStopVideo(ScrnInfoPtr, pointer, Bool);
+static void MGAQueryBestSize(ScrnInfoPtr, Bool, short, short, short, short,
+ unsigned int *, unsigned int *, pointer);
+static int MGAPutImage(ScrnInfoPtr, short, short, short, short, short,
+ short, short, short, int, unsigned char*, short,
+ short, Bool, RegionPtr, pointer);
+static int MGAQueryImageAttributes(ScrnInfoPtr, int, unsigned short *,
+ unsigned short *, int *, int *);
static void MGABlockHandler(int, pointer, pointer, pointer);
+static void MGAResetVideoOverlay(ScrnInfoPtr);
+
+
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
static Atom xvBrightness, xvContrast, xvColorKey;
@@ -60,15 +71,32 @@ void MGAInitVideo(ScreenPtr pScreen)
XF86VideoAdaptorPtr newAdaptor = NULL;
MGAPtr pMga = MGAPTR(pScrn);
int num_adaptors;
-
- if((pScrn->bitsPerPixel != 8) && !pMga->Overlay8Plus24 &&
+
+ if((pScrn->bitsPerPixel != 8) && !pMga->NoAccel &&
((pMga->Chipset == PCI_CHIP_MGAG200) ||
(pMga->Chipset == PCI_CHIP_MGAG200_PCI) ||
(pMga->Chipset == PCI_CHIP_MGAG400)))
{
- newAdaptor = MGASetupImageVideoG(pScreen);
- MGAInitOffscreenImages(pScreen);
+
+ if((pMga->Overlay8Plus24 /* || dualhead */ || pMga->TexturedVideo) &&
+ (pScrn->bitsPerPixel != 24))
+ {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using texture video\n");
+ newAdaptor = MGASetupImageVideoTexture(pScreen);
+ pMga->TexturedVideo = TRUE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using overlay video\n");
+ newAdaptor = MGASetupImageVideoOverlay(pScreen);
+ pMga->TexturedVideo = FALSE;
+ }
+
+ if(!pMga->Overlay8Plus24 /* && !dualhead */)
+ MGAInitOffscreenImages(pScreen);
+
+ pMga->BlockHandler = pScreen->BlockHandler;
+ pScreen->BlockHandler = MGABlockHandler;
}
+
num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors);
@@ -97,113 +125,62 @@ void MGAInitVideo(ScreenPtr pScreen)
}
/* client libraries expect an encoding */
-static XF86VideoEncodingRec DummyEncoding[1] =
+static XF86VideoEncodingRec DummyEncoding[2] =
{
- {
+ { /* overlay limit */
0,
"XV_IMAGE",
1024, 1024,
{1, 1}
+ },
+ { /* texture limit */
+ 0,
+ "XV_IMAGE",
+ 2046, 2046,
+ {1, 1}
}
};
-#define NUM_FORMATS_G 3
+#define NUM_FORMATS_OVERLAY 3
+#define NUM_FORMATS_TEXTURE 6
-static XF86VideoFormatRec FormatsG[NUM_FORMATS_G] =
+static XF86VideoFormatRec Formats[NUM_FORMATS_TEXTURE] =
{
- {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor},
+ {15, DirectColor}, {16, DirectColor}, {24, DirectColor}
};
-#define NUM_ATTRIBUTES_G 3
+#define NUM_ATTRIBUTES_OVERLAY 3
-static XF86AttributeRec AttributesG[NUM_ATTRIBUTES_G] =
+static XF86AttributeRec Attributes[NUM_ATTRIBUTES_OVERLAY] =
{
{XvSettable | XvGettable, 0, (1 << 24) - 1, "XV_COLORKEY"},
{XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"},
{XvSettable | XvGettable, 0, 255, "XV_CONTRAST"}
};
-#define NUM_IMAGES_G 3
+#define NUM_IMAGES 4
-static XF86ImageRec ImagesG[NUM_IMAGES_G] =
+static XF86ImageRec Images[NUM_IMAGES] =
{
- {
- 0x32595559,
- 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
- },
- {
- 0x32315659,
- 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
- },
- {
- 0x59565955,
- 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
- }
+ XVIMAGE_YUY2,
+ XVIMAGE_YV12,
+ XVIMAGE_I420,
+ XVIMAGE_UYVY
};
-typedef struct {
- unsigned char brightness;
- unsigned char contrast;
- FBAreaPtr area;
- RegionRec clip;
- CARD32 colorKey;
- CARD32 videoStatus;
- Time offTime;
- Time freeTime;
-} MGAPortPrivRec, *MGAPortPrivPtr;
-
-
-#define GET_PORT_PRIVATE(pScrn) \
- (MGAPortPrivPtr)((MGAPTR(pScrn))->adaptor->pPortPrivates[0].ptr)
-
#define outMGAdreg(reg, val) OUTREG8(RAMDAC_OFFSET + (reg), val)
#define outMGAdac(reg, val) \
(outMGAdreg(MGA1064_INDEX, reg), outMGAdreg(MGA1064_DATA, val))
-void MGAResetVideo(ScrnInfoPtr pScrn)
+static void
+MGAResetVideoOverlay(ScrnInfoPtr pScrn)
{
MGAPtr pMga = MGAPTR(pScrn);
- MGAPortPrivPtr pPriv = pMga->adaptor->pPortPrivates[0].ptr;
+ MGAPortPrivPtr pPriv = pMga->portPrivate;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
outMGAdac(0x51, 0x01); /* keying on */
outMGAdac(0x52, 0xff); /* full mask */
outMGAdac(0x53, 0xff);
@@ -216,79 +193,136 @@ void MGAResetVideo(ScrnInfoPtr pScrn)
outMGAdac(0x57, (pPriv->colorKey & pScrn->mask.blue) >>
pScrn->offset.blue);
-
OUTREG(MGAREG_BESLUMACTL, ((pPriv->brightness & 0xff) << 16) |
(pPriv->contrast & 0xff));
}
+static XF86VideoAdaptorPtr
+MGAAllocAdaptor(ScrnInfoPtr pScrn)
+{
+ XF86VideoAdaptorPtr adapt;
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr pPriv;
+ int i;
+
+ if(!(adapt = xf86XVAllocateVideoAdaptorRec(pScrn)))
+ return NULL;
+
+ if(!(pPriv = xcalloc(1, sizeof(MGAPortPrivRec) +
+ (sizeof(DevUnion) * MGA_MAX_PORTS))))
+ {
+ xfree(adapt);
+ return NULL;
+ }
+
+ adapt->pPortPrivates = (DevUnion*)(&pPriv[1]);
+
+ for(i = 0; i < MGA_MAX_PORTS; i++)
+ adapt->pPortPrivates[i].val = i;
+
+ xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
+ xvContrast = MAKE_ATOM("XV_CONTRAST");
+ xvColorKey = MAKE_ATOM("XV_COLORKEY");
+
+ pPriv->colorKey = pMga->videoKey;
+ pPriv->videoStatus = 0;
+ pPriv->brightness = 0;
+ pPriv->contrast = 128;
+ pPriv->lastPort = -1;
+
+ pMga->adaptor = adapt;
+ pMga->portPrivate = pPriv;
+
+ return adapt;
+}
+
static XF86VideoAdaptorPtr
-MGASetupImageVideoG(ScreenPtr pScreen)
+MGASetupImageVideoOverlay(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
MGAPtr pMga = MGAPTR(pScrn);
XF86VideoAdaptorPtr adapt;
- MGAPortPrivPtr pPriv;
- if(!(adapt = xcalloc(1, sizeof(XF86VideoAdaptorRec) +
- sizeof(MGAPortPrivRec) +
- sizeof(DevUnion))))
- return NULL;
+ adapt = MGAAllocAdaptor(pScrn);
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
adapt->name = "Matrox G-Series Backend Scaler";
adapt->nEncodings = 1;
- adapt->pEncodings = DummyEncoding;
- adapt->nFormats = NUM_FORMATS_G;
- adapt->pFormats = FormatsG;
+ adapt->pEncodings = &DummyEncoding[0];
+ adapt->nFormats = NUM_FORMATS_OVERLAY;
+ adapt->pFormats = Formats;
adapt->nPorts = 1;
- adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
- pPriv = (MGAPortPrivPtr)(&adapt->pPortPrivates[1]);
- adapt->pPortPrivates[0].ptr = (pointer)(pPriv);
- adapt->pAttributes = AttributesG;
+ adapt->pAttributes = Attributes;
if (pMga->Chipset == PCI_CHIP_MGAG400) {
- adapt->nImages = 3;
+ adapt->nImages = 4;
adapt->nAttributes = 3;
} else {
- adapt->nImages = 2;
+ adapt->nImages = 3;
adapt->nAttributes = 1;
}
- adapt->pImages = ImagesG;
+ adapt->pImages = Images;
adapt->PutVideo = NULL;
adapt->PutStill = NULL;
adapt->GetVideo = NULL;
adapt->GetStill = NULL;
- adapt->StopVideo = MGAStopVideoG;
- adapt->SetPortAttribute = MGASetPortAttributeG;
- adapt->GetPortAttribute = MGAGetPortAttributeG;
- adapt->QueryBestSize = MGAQueryBestSizeG;
- adapt->PutImage = MGAPutImageG;
- adapt->QueryImageAttributes = MGAQueryImageAttributesG;
+ adapt->StopVideo = MGAStopVideo;
+ adapt->SetPortAttribute = MGASetPortAttributeOverlay;
+ adapt->GetPortAttribute = MGAGetPortAttributeOverlay;
+ adapt->QueryBestSize = MGAQueryBestSize;
+ adapt->PutImage = MGAPutImage;
+ adapt->QueryImageAttributes = MGAQueryImageAttributes;
- pPriv->colorKey = pMga->videoKey;
- pPriv->videoStatus = 0;
- pPriv->brightness = 0;
- pPriv->contrast = 128;
-
/* gotta uninit this someplace */
- REGION_INIT(pScreen, &pPriv->clip, NullBox, 0);
+ REGION_INIT(pScreen, &(pMga->portPrivate->clip), NullBox, 0);
- pMga->adaptor = adapt;
+ MGAResetVideoOverlay(pScrn);
- pMga->BlockHandler = pScreen->BlockHandler;
- pScreen->BlockHandler = MGABlockHandler;
+ return adapt;
+}
- xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
- xvContrast = MAKE_ATOM("XV_CONTRAST");
- xvColorKey = MAKE_ATOM("XV_COLORKEY");
- MGAResetVideo(pScrn);
+static XF86VideoAdaptorPtr
+MGASetupImageVideoTexture(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XF86VideoAdaptorPtr adapt;
+ MGAPtr pMga = MGAPTR(pScrn);
+
+ adapt = MGAAllocAdaptor(pScrn);
+
+ adapt->type = XvWindowMask | XvInputMask | XvImageMask;
+ adapt->flags = 0;
+ adapt->name = "Matrox G-Series Texture Engine";
+ adapt->nEncodings = 1;
+ adapt->pEncodings = &DummyEncoding[1];
+ adapt->nFormats = NUM_FORMATS_TEXTURE;
+ adapt->pFormats = Formats;
+ adapt->nPorts = MGA_MAX_PORTS;
+ adapt->pAttributes = NULL;
+ adapt->nAttributes = 0;
+ adapt->pImages = Images;
+ if (pMga->Chipset == PCI_CHIP_MGAG400)
+ adapt->nImages = 4;
+ else
+ adapt->nImages = 3;
+ adapt->PutVideo = NULL;
+ adapt->PutStill = NULL;
+ adapt->GetVideo = NULL;
+ adapt->GetStill = NULL;
+ adapt->StopVideo = MGAStopVideo;
+ adapt->SetPortAttribute = MGASetPortAttributeTexture;
+ adapt->GetPortAttribute = MGAGetPortAttributeTexture;
+ adapt->QueryBestSize = MGAQueryBestSize;
+ adapt->PutImage = MGAPutImage;
+ adapt->QueryImageAttributes = MGAQueryImageAttributes;
return adapt;
}
+
static Bool
RegionsEqual(RegionPtr A, RegionPtr B)
{
@@ -328,18 +362,21 @@ RegionsEqual(RegionPtr A, RegionPtr B)
boundaries in 16.16 fixed point.
*/
-static void
+#define DummyScreen screenInfo.screens[0]
+
+static Bool
MGAClipVideo(
BoxPtr dst,
INT32 *x1,
INT32 *x2,
INT32 *y1,
INT32 *y2,
- BoxPtr extents, /* extents of the clip region */
+ RegionPtr reg,
INT32 width,
INT32 height
){
INT32 vscale, hscale, delta;
+ BoxPtr extents = REGION_EXTENTS(DummyScreen, reg);
int diff;
hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
@@ -380,6 +417,8 @@ MGAClipVideo(
dst->x2 -= diff;
*x2 -= diff * hscale;
}
+ if(*x1 >= *x2) return FALSE;
+
if(*y1 < 0) {
diff = (- *y1 + vscale - 1)/ vscale;
dst->y1 += diff;
@@ -391,13 +430,26 @@ MGAClipVideo(
dst->y2 -= diff;
*y2 -= diff * vscale;
}
+ if(*y1 >= *y2) 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;
}
static void
-MGAStopVideoG(ScrnInfoPtr pScrn, pointer data, Bool exit)
+MGAStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)
{
- MGAPortPrivPtr pPriv = (MGAPortPrivPtr)data;
MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr pPriv = pMga->portPrivate;
+
+ if(pMga->TexturedVideo) return;
REGION_EMPTY(pScrn->pScreen, &pPriv->clip);
@@ -418,14 +470,16 @@ MGAStopVideoG(ScrnInfoPtr pScrn, pointer data, Bool exit)
}
static int
-MGASetPortAttributeG(
+MGASetPortAttributeOverlay(
ScrnInfoPtr pScrn,
Atom attribute,
INT32 value,
pointer data
){
- MGAPortPrivPtr pPriv = (MGAPortPrivPtr)data;
MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr pPriv = pMga->portPrivate;
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
if(attribute == xvBrightness) {
if((value < -128) || (value > 127))
@@ -456,13 +510,14 @@ MGASetPortAttributeG(
}
static int
-MGAGetPortAttributeG(
+MGAGetPortAttributeOverlay(
ScrnInfoPtr pScrn,
Atom attribute,
INT32 *value,
pointer data
){
- MGAPortPrivPtr pPriv = (MGAPortPrivPtr)data;
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr pPriv = pMga->portPrivate;
if(attribute == xvBrightness) {
*value = pPriv->brightness;
@@ -477,8 +532,30 @@ MGAGetPortAttributeG(
return Success;
}
+
+static int
+MGASetPortAttributeTexture(
+ ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 value,
+ pointer data
+) {
+ return BadMatch;
+}
+
+
+static int
+MGAGetPortAttributeTexture(
+ ScrnInfoPtr pScrn,
+ Atom attribute,
+ INT32 *value,
+ pointer data
+){
+ return BadMatch;
+}
+
static void
-MGAQueryBestSizeG(
+MGAQueryBestSize(
ScrnInfoPtr pScrn,
Bool motion,
short vid_w, short vid_h,
@@ -488,8 +565,6 @@ MGAQueryBestSizeG(
){
*p_w = drw_w;
*p_h = drw_h;
-
- if(*p_w > 16384) *p_w = 16384;
}
@@ -585,7 +660,7 @@ MGAAllocateMemory(
}
static void
-MGADisplayVideo(
+MGADisplayVideoOverlay(
ScrnInfoPtr pScrn,
int id,
int offset,
@@ -599,16 +674,18 @@ MGADisplayVideo(
MGAPtr pMga = MGAPTR(pScrn);
int tmp;
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
/* got 64 scanlines to do it in */
tmp = INREG(MGAREG_VCOUNT) + 64;
if(tmp > pScrn->currentMode->VDisplay)
tmp -= pScrn->currentMode->VDisplay;
switch(id) {
- case 0x59565955:
+ case FOURCC_UYVY:
OUTREG(MGAREG_BESGLOBCTL, 0x000000c3 | (tmp << 16));
break;
- case 0x32595559:
+ case FOURCC_YUY2:
default:
OUTREG(MGAREG_BESGLOBCTL, 0x00000083 | (tmp << 16));
break;
@@ -645,8 +722,95 @@ MGADisplayVideo(
}
+static void
+MGADisplayVideoTexture(
+ ScrnInfoPtr pScrn,
+ int id, int offset,
+ int nbox, BoxPtr pbox,
+ int width, int height, int pitch,
+ short src_x, short src_y,
+ short src_w, short src_h,
+ short drw_x, short drw_y,
+ short drw_w, short drw_h
+){
+ MGAPtr pMga = MGAPTR(pScrn);
+ int log2w, log2h, i, incx, incy, padw, padh;
+
+ pitch >>= 1;
+
+ i = 12;
+ while(--i) {
+ if(width & (1 << i)) {
+ log2w = i;
+ if(width & ((1 << i) - 1))
+ log2w++;
+ break;
+ }
+ }
+
+ i = 12;
+ while(--i) {
+ if(height & (1 << i)) {
+ log2h = i;
+ if(height & ((1 << i) - 1))
+ log2h++;
+ break;
+ }
+ }
+
+ padw = 1 << log2w;
+ padh = 1 << log2h;
+ incx = (src_w << 20)/(drw_w * padw);
+ incy = (src_h << 20)/(drw_h * padh);
+
+ CHECK_DMA_QUIESCENT(pMga, pScrn);
+
+ if(pMga->Overlay8Plus24) {
+ i = 0x00ffffff;
+ WAITFIFO(1);
+ SET_PLANEMASK(i);
+ }
+
+ WAITFIFO(15);
+ OUTREG(MGAREG_TMR0, incx); /* sx inc */
+ OUTREG(MGAREG_TMR1, 0); /* sy inc */
+ OUTREG(MGAREG_TMR2, 0); /* tx inc */
+ OUTREG(MGAREG_TMR3, incy); /* ty inc */
+ OUTREG(MGAREG_TMR4, 0x00000000);
+ OUTREG(MGAREG_TMR5, 0x00000000);
+ OUTREG(MGAREG_TMR8, 0x00010000);
+ OUTREG(MGAREG_TEXORG, offset);
+ OUTREG(MGAREG_TEXWIDTH, log2w | (((8 - log2w) & 63) << 9) |
+ ((width - 1) << 18));
+ OUTREG(MGAREG_TEXHEIGHT, log2h | (((8 - log2h) & 63) << 9) |
+ ((height - 1) << 18));
+ if(id == FOURCC_UYVY)
+ OUTREG(MGAREG_TEXCTL, 0x1A00010b | ((pitch & 0x07FF) << 9));
+ else
+ OUTREG(MGAREG_TEXCTL, 0x1A00010a | ((pitch & 0x07FF) << 9));
+ OUTREG(MGAREG_TEXCTL2, 0x00000014);
+ OUTREG(MGAREG_DWGCTL, 0x000c7076);
+ OUTREG(MGAREG_TEXFILTER, 0x01e00020);
+ OUTREG(MGAREG_ALPHACTRL, 0x00000001);
+
+ padw = (src_x << 20)/padw;
+ padh = (src_y << 20)/padh;
+
+ while(nbox--) {
+ WAITFIFO(4);
+ OUTREG(MGAREG_TMR6, (incx * (pbox->x1 - drw_x)) + padw);
+ OUTREG(MGAREG_TMR7, (incy * (pbox->y1 - drw_y)) + padh);
+ OUTREG(MGAREG_FXBNDRY, (pbox->x2 << 16) | (pbox->x1 & 0xffff));
+ OUTREG(MGAREG_YDSTLEN + MGAREG_EXEC,
+ (pbox->y1 << 16) | (pbox->y2 - pbox->y1));
+ pbox++;
+ }
+
+ pMga->AccelInfoRec->NeedToSync = TRUE;
+}
+
static int
-MGAPutImageG(
+MGAPutImage(
ScrnInfoPtr pScrn,
short src_x, short src_y,
short drw_x, short drw_y,
@@ -657,8 +821,8 @@ MGAPutImageG(
Bool sync,
RegionPtr clipBoxes, pointer data
){
- MGAPortPrivPtr pPriv = (MGAPortPrivPtr)data;
MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr pPriv = pMga->portPrivate;
INT32 x1, x2, y1, y2;
unsigned char *dst_start;
int pitch, new_h, offset, offset2, offset3;
@@ -667,8 +831,6 @@ MGAPutImageG(
BoxRec dstBox;
CARD32 tmp;
- if(drw_w > 16384) drw_w = 16384;
-
/* Clip */
x1 = src_x;
x2 = src_x + src_w;
@@ -680,16 +842,15 @@ MGAPutImageG(
dstBox.y1 = drw_y;
dstBox.y2 = drw_y + drw_h;
- MGAClipVideo(&dstBox, &x1, &x2, &y1, &y2,
- REGION_EXTENTS(pScreen, clipBoxes), width, height);
-
- if((x1 >= x2) || (y1 >= y2))
- return Success;
+ if(!MGAClipVideo(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, width, height))
+ return Success;
- dstBox.x1 -= pScrn->frameX0;
- dstBox.x2 -= pScrn->frameX0;
- dstBox.y1 -= pScrn->frameY0;
- dstBox.y2 -= pScrn->frameY0;
+ if(!pMga->TexturedVideo) {
+ dstBox.x1 -= pScrn->frameX0;
+ dstBox.x2 -= pScrn->frameX0;
+ dstBox.y1 -= pScrn->frameY0;
+ dstBox.y2 -= pScrn->frameY0;
+ }
pitch = pScrn->bitsPerPixel * pScrn->displayWidth >> 3;
@@ -697,20 +858,20 @@ MGAPutImageG(
new_h = ((dstPitch * height) + pitch - 1) / pitch;
switch(id) {
- case 0x32315659:
+ case FOURCC_YV12:
+ case FOURCC_I420:
srcPitch = (width + 3) & ~3;
offset2 = srcPitch * height;
srcPitch2 = ((width >> 1) + 3) & ~3;
offset3 = (srcPitch2 * (height >> 1)) + offset2;
break;
- case 0x59565955:
- case 0x32595559:
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
default:
srcPitch = (width << 1);
break;
}
-
if(!(pPriv->area = MGAAllocateMemory(pScrn, pPriv->area, new_h)))
return BadAlloc;
@@ -720,22 +881,35 @@ MGAPutImageG(
npixels = ((((x2 + 0xffff) >> 16) + 1) & ~1) - left;
left <<= 1;
- offset = (pPriv->area->box.y1 * pitch) + (top * dstPitch);
- dst_start = pMga->FbStart + offset + left;
+ offset = pPriv->area->box.y1 * pitch;
+ dst_start = pMga->FbStart + offset + left + (top * dstPitch);
+
+ if(pMga->TexturedVideo && pMga->AccelInfoRec->NeedToSync &&
+ ((long)data != pPriv->lastPort))
+ {
+ MGAStormSync(pScrn);
+ pMga->AccelInfoRec->NeedToSync = FALSE;
+ }
switch(id) {
- case 0x32315659:
+ case FOURCC_YV12:
+ case FOURCC_I420:
top &= ~1;
tmp = ((top >> 1) * srcPitch2) + (left >> 2);
offset2 += tmp;
- offset3 += tmp;
+ offset3 += tmp;
+ if(id == FOURCC_I420) {
+ tmp = offset2;
+ offset2 = offset3;
+ offset3 = tmp;
+ }
nlines = ((((y2 + 0xffff) >> 16) + 1) & ~1) - top;
MGACopyMungedData(buf + (top * srcPitch) + (left >> 1),
buf + offset2, buf + offset3, dst_start,
srcPitch, srcPitch2, dstPitch, nlines, npixels);
break;
- case 0x59565955:
- case 0x32595559:
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
default:
buf += (top * srcPitch) + left;
nlines = ((y2 + 0xffff) >> 16) - top;
@@ -743,42 +917,59 @@ MGAPutImageG(
break;
}
+ if(pMga->TexturedVideo) {
+ pPriv->lastPort = (long)data;
+ MGADisplayVideoTexture(pScrn, id, offset,
+ REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes),
+ width, height, dstPitch, src_x, src_y, src_w, src_h,
+ drw_x, drw_y, drw_w, drw_h);
+ pPriv->videoStatus = FREE_TIMER;
+ pPriv->freeTime = currentTime.milliseconds + FREE_DELAY;
+ } else {
/* update cliplist */
- if(!RegionsEqual(&pPriv->clip, clipBoxes)) {
- REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
- /* draw these */
- XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0,
+ if(!RegionsEqual(&pPriv->clip, clipBoxes)) {
+ REGION_COPY(pScreen, &pPriv->clip, clipBoxes);
+ /* draw these */
+ XAAFillSolidRects(pScrn, pPriv->colorKey, GXcopy, ~0,
REGION_NUM_RECTS(clipBoxes),
REGION_RECTS(clipBoxes));
- }
-
+ }
- MGADisplayVideo(pScrn, id, offset, width, height, dstPitch,
+ offset += top * dstPitch;
+ MGADisplayVideoOverlay(pScrn, id, offset, width, height, dstPitch,
x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
- pPriv->videoStatus = CLIENT_VIDEO_ON;
+ pPriv->videoStatus = CLIENT_VIDEO_ON;
+ }
return Success;
}
static int
-MGAQueryImageAttributesG(
- ScrnInfoPtr pScrn,
- int id,
- unsigned short *w, unsigned short *h,
- int *pitches, int *offsets
+MGAQueryImageAttributes(
+ ScrnInfoPtr pScrn,
+ int id,
+ unsigned short *w, unsigned short *h,
+ int *pitches, int *offsets
){
+ MGAPtr pMga = MGAPTR(pScrn);
int size, tmp;
- if(*w > 1024) *w = 1024;
- if(*h > 1024) *h = 1024;
+ if(pMga->TexturedVideo) {
+ if(*w > 2046) *w = 2046;
+ if(*h > 2046) *h = 2046;
+ } else {
+ if(*w > 1024) *w = 1024;
+ if(*h > 1024) *h = 1024;
+ }
*w = (*w + 1) & ~1;
if(offsets) offsets[0] = 0;
switch(id) {
- case 0x32315659:
+ case FOURCC_YV12:
+ case FOURCC_I420:
*h = (*h + 1) & ~1;
size = (*w + 3) & ~3;
if(pitches) pitches[0] = size;
@@ -791,8 +982,8 @@ MGAQueryImageAttributesG(
if(offsets) offsets[2] = size;
size += tmp;
break;
- case 0x59565955:
- case 0x32595559:
+ case FOURCC_UYVY:
+ case FOURCC_YUY2:
default:
size = *w << 1;
if(pitches) pitches[0] = size;
@@ -810,10 +1001,10 @@ MGABlockHandler (
pointer pTimeout,
pointer pReadmask
){
- ScreenPtr pScreen = screenInfo.screens[i];
- ScrnInfoPtr pScrn = xf86Screens[i];
- MGAPtr pMga = MGAPTR(pScrn);
- MGAPortPrivPtr pPriv = GET_PORT_PRIVATE(pScrn);
+ ScreenPtr pScreen = screenInfo.screens[i];
+ ScrnInfoPtr pScrn = xf86Screens[i];
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr pPriv = pMga->portPrivate;
pScreen->BlockHandler = pMga->BlockHandler;
@@ -875,15 +1066,19 @@ MGAAllocateSurface(
surface->width = w;
surface->height = h;
- if(!(surface->pitches = xalloc(sizeof(int))))
+ if(!(surface->pitches = xalloc(sizeof(int)))) {
+ xf86FreeOffscreenArea(area);
return BadAlloc;
+ }
if(!(surface->offsets = xalloc(sizeof(int)))) {
xfree(surface->pitches);
+ xf86FreeOffscreenArea(area);
return BadAlloc;
}
if(!(pPriv = xalloc(sizeof(OffscreenPrivRec)))) {
xfree(surface->pitches);
xfree(surface->offsets);
+ xf86FreeOffscreenArea(area);
return BadAlloc;
}
@@ -933,22 +1128,20 @@ MGAFreeSurface(
static int
MGAGetSurfaceAttribute(
- XF86SurfacePtr surface,
+ ScrnInfoPtr pScrn,
Atom attribute,
INT32 *value
){
- return MGAGetPortAttributeG(surface->pScrn, attribute, value,
- (pointer)(GET_PORT_PRIVATE(surface->pScrn)));
+ return MGAGetPortAttributeOverlay(pScrn, attribute, value, 0);
}
static int
MGASetSurfaceAttribute(
- XF86SurfacePtr surface,
+ ScrnInfoPtr pScrn,
Atom attribute,
INT32 value
){
- return MGASetPortAttributeG(surface->pScrn, attribute, value,
- (pointer)(GET_PORT_PRIVATE(surface->pScrn)));
+ return MGASetPortAttributeOverlay(pScrn, attribute, value, 0);
}
@@ -963,7 +1156,8 @@ MGADisplaySurface(
){
OffscreenPrivPtr pPriv = (OffscreenPrivPtr)surface->devPrivate.ptr;
ScrnInfoPtr pScrn = surface->pScrn;
- MGAPortPrivPtr portPriv = GET_PORT_PRIVATE(pScrn);
+ MGAPtr pMga = MGAPTR(pScrn);
+ MGAPortPrivPtr portPriv = pMga->portPrivate;
INT32 x1, y1, x2, y2;
BoxRec dstBox;
@@ -977,27 +1171,29 @@ MGADisplaySurface(
dstBox.y1 = drw_y;
dstBox.y2 = drw_y + drw_h;
- MGAClipVideo(&dstBox, &x1, &x2, &y1, &y2,
- REGION_EXTENTS(pScreen, clipBoxes),
- surface->width, surface->height);
-
- if((x1 >= x2) || (y1 >= y2))
+ if(!MGAClipVideo(&dstBox, &x1, &x2, &y1, &y2, clipBoxes,
+ surface->width, surface->height))
+ {
return Success;
+ }
dstBox.x1 -= pScrn->frameX0;
dstBox.x2 -= pScrn->frameX0;
dstBox.y1 -= pScrn->frameY0;
dstBox.y2 -= pScrn->frameY0;
- XAAFillSolidRects(pScrn, portPriv->colorKey, GXcopy, ~0,
- REGION_NUM_RECTS(clipBoxes),
- REGION_RECTS(clipBoxes));
+ MGAResetVideoOverlay(pScrn);
- MGADisplayVideo(pScrn, surface->id, surface->offsets[0],
+ MGADisplayVideoOverlay(pScrn, surface->id, surface->offsets[0],
surface->width, surface->height, surface->pitches[0],
x1, y1, x2, y2, &dstBox, src_w, src_h, drw_w, drw_h);
+ XAAFillSolidRects(pScrn, portPriv->colorKey, GXcopy, ~0,
+ REGION_NUM_RECTS(clipBoxes),
+ REGION_RECTS(clipBoxes));
+
pPriv->isOn = TRUE;
+ /* we've prempted the XvImage stream so set its free timer */
if(portPriv->videoStatus & CLIENT_VIDEO_ON) {
REGION_EMPTY(pScrn->pScreen, &portPriv->clip);
UpdateCurrentTime();
@@ -1021,7 +1217,7 @@ MGAInitOffscreenImages(ScreenPtr pScreen)
if(!(offscreenImages = xalloc(num * sizeof(XF86OffscreenImageRec))))
return;
- offscreenImages[0].image = &ImagesG[0];
+ offscreenImages[0].image = &Images[0];
offscreenImages[0].flags = VIDEO_OVERLAID_IMAGES |
VIDEO_CLIP_TO_VIEWPORT;
offscreenImages[0].alloc_surface = MGAAllocateSurface;
@@ -1033,10 +1229,10 @@ MGAInitOffscreenImages(ScreenPtr pScreen)
offscreenImages[0].max_width = 1024;
offscreenImages[0].max_height = 1024;
offscreenImages[0].num_attributes = (num == 1) ? 1 : 3;
- offscreenImages[0].attributes = AttributesG;
+ offscreenImages[0].attributes = Attributes;
if(num == 2) {
- offscreenImages[1].image = &ImagesG[2];
+ offscreenImages[1].image = &Images[3];
offscreenImages[1].flags = VIDEO_OVERLAID_IMAGES |
VIDEO_CLIP_TO_VIEWPORT;
offscreenImages[1].alloc_surface = MGAAllocateSurface;
@@ -1048,7 +1244,7 @@ MGAInitOffscreenImages(ScreenPtr pScreen)
offscreenImages[1].max_width = 1024;
offscreenImages[1].max_height = 1024;
offscreenImages[1].num_attributes = 3;
- offscreenImages[1].attributes = AttributesG;
+ offscreenImages[1].attributes = Attributes;
}
xf86XVRegisterOffscreenImages(pScreen, offscreenImages, num);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c
index 9bd43318a..50b9871b3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c
@@ -1,3 +1,5 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_warp.c,v 1.3 2000/06/17 18:23:23 dawes Exp $ */
+
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86Resources.h"
@@ -18,6 +20,8 @@ Bool mgaConfigureWarp(ScrnInfoPtr pScrn)
MGAPtr pMga = MGAPTR(pScrn);
int wmisc;
+ CHECK_DMA_QUIESCENT( pMga, pScrn );
+
WAITFIFO(3);
switch(pMga->Chipset) {
@@ -108,7 +112,7 @@ static unsigned int mgaG400InstallMicrocode(MGAPtr pMGA, int agp_offset)
unsigned int microcode_size = 0;
memset(pMGADRIServer->WarpIndex, 0,
- sizeof(mgaWarpIndex) * MGA_MAX_WARP_PIPES);
+ sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES);
microcode_size = mgaG400GetMicrocodeSize(pMGA);
mgaWarpInstallCode(tgz, MGA_WARP_TGZ);
@@ -150,7 +154,7 @@ static unsigned int mgaG200InstallMicrocode(MGAPtr pMGA, int agp_offset)
unsigned int microcode_size = 0;
memset(pMGADRIServer->WarpIndex, 0,
- sizeof(mgaWarpIndex) * MGA_MAX_WARP_PIPES);
+ sizeof(drmMgaWarpIndex) * MGA_MAX_WARP_PIPES);
microcode_size = mgaG400GetMicrocodeSize(pMGA);
mgaWarpInstallCode(tgz, MGA_WARP_TGZ);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c
new file mode 100644
index 000000000..06df39d83
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c
@@ -0,0 +1,198 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.c,v 1.1 2000/06/17 00:03:20 martin Exp $ */
+/**************************************************************************
+
+Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
+All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sub license, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice (including the
+next paragraph) shall be included in all copies or substantial portions
+of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Keith Whitwell <keithw@precisioninsight.com>
+ *
+ */
+
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Priv.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb32.h"
+
+#include "miline.h"
+
+#include "GL/glxtokens.h"
+
+#include "mga_bios.h"
+#include "mga_reg.h"
+#include "mga.h"
+#include "mga_macros.h"
+#include "mga_dri.h"
+#include "mga_wrap.h"
+
+
+
+static void MGAWakeupHandler(int screenNum,
+ pointer wakeupData,
+ unsigned long result,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ /*DRIWrappedFuncsRec *pDRIWrap = DRIGetWrappedFuncs(pScreen);*/
+
+ if (0) ErrorF("MGAWakeupHandler (in)\n");
+
+ /* Disabled: Check contention like the 3d clients do before trying
+ * to restore state.
+ */
+ DRILock(pScreen, 0);
+ MGASwapContext( pScreen );
+
+}
+
+static void MGABlockHandler(int screenNum,
+ pointer blockData,
+ pointer pTimeout,
+ pointer pReadmask)
+
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ /*DRIWrappedFuncsRec *pDRIWrap = DRIGetWrappedFuncs(pScreen);*/
+ MGASAREAPtr sa = (MGASAREAPtr)DRIGetSAREAPrivate( pScreen );
+
+ if (0) ErrorF("MGABlockHandler (out)\n");
+
+
+ /* Examine the cliprects for the most recently used 3d drawable.
+ * If they've changed, attempt to push the updated values into the
+ * sarea.
+ *
+ * This avoids the protocol round trip in all single-client
+ * frontbuffer rendering cases providing the cliprects fit into the
+ * sarea, and in all single-client backbuffer rendering with arbitary
+ * numbers of cliprects, for all operations except swapbuffers.
+ *
+ * Thus the number of round trips in the cases where comparison is
+ * possible is reduced to no more (and usually fewer) than the number
+ * Utah requires.
+ */
+
+ if (sa->req_drawable != sa->exported_drawable ||
+ sa->exported_stamp != DRIGetDrawableStamp( pScreen, sa->exported_index ))
+ {
+ int i;
+ XF86DRIClipRectPtr frontboxes, backboxes;
+ XF86DRIClipRectPtr boxes = (XF86DRIClipRectPtr)sa->exported_boxes;
+ WindowPtr window = LookupIDByType( sa->req_drawable, RT_WINDOW );
+
+ if (0)
+ ErrorF("Trying to update req_drawable: %d (exp %d), stamp %d/%d\n",
+ sa->req_drawable, sa->exported_drawable);
+
+ sa->exported_drawable = 0;
+
+ if (!window) {
+ if (0)
+ ErrorF("Couldn't retreive window\n");
+ sa->req_drawable = 0;
+ goto finished;
+ }
+
+ if (!DRIGetDrawableInfo( pScreen, &(window->drawable),
+ &sa->exported_index,
+ &sa->exported_stamp,
+ &sa->exported_front_x,
+ &sa->exported_front_y,
+ &sa->exported_w,
+ &sa->exported_h,
+ &sa->exported_nfront,
+ &frontboxes,
+ &sa->exported_back_x,
+ &sa->exported_back_y,
+ &sa->exported_nback,
+ &backboxes ))
+ {
+ if (0)
+ ErrorF("Couldn't get DRI info\n");
+ sa->req_drawable = 0;
+ goto finished;
+ }
+
+ /* If we can't fit both sets of cliprects into the sarea, try to
+ * fit the current draw buffer. Otherwise return.
+ */
+
+ sa->exported_buffers = MGA_FRONT | MGA_BACK;
+
+ if (sa->exported_nback + sa->exported_nfront >= MGA_NR_SAREA_CLIPRECTS) {
+ if (sa->req_draw_buffer == MGA_FRONT) {
+ sa->exported_buffers = MGA_FRONT;
+ if (sa->exported_nfront >= MGA_NR_SAREA_CLIPRECTS)
+ goto finished;
+ } else {
+ sa->exported_buffers = MGA_BACK;
+ if (sa->exported_nback >= MGA_NR_SAREA_CLIPRECTS)
+ goto finished;
+ }
+ }
+
+ if (sa->exported_buffers & MGA_BACK) {
+ for (i = 0 ; i < sa->exported_nback ; i++)
+ *boxes++ = backboxes[i];
+ }
+
+ if (sa->exported_buffers & MGA_FRONT) {
+ for (i = 0 ; i < sa->exported_nfront ; i++)
+ *boxes++ = frontboxes[i];
+ }
+
+ sa->exported_drawable = sa->req_drawable;
+ }
+
+ finished:
+ DRIUnlock(pScreen);
+}
+
+
+
+
+/* Just wrap validate tree for now to remove the quiescense hack.
+ * This is more of a win for the i810 than the mga, but should be useful
+ * here too.
+ */
+void MGADRIWrapFunctions(ScreenPtr pScreen, DRIInfoPtr pDRIInfo)
+{
+ pDRIInfo->wrap.BlockHandler = MGABlockHandler;
+ pDRIInfo->wrap.WakeupHandler = MGAWakeupHandler;
+/* pDRIInfo->wrap.ValidateTree = NULL; */
+/* pDRIInfo->wrap.PostValidateTree = NULL; */
+}
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.h b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.h
new file mode 100644
index 000000000..e9919b43d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.h
@@ -0,0 +1,8 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/mga/mga_wrap.h,v 1.2 2000/06/17 18:23:23 dawes Exp $ */
+
+#ifndef MGA_WRAP_H
+#define MGA_WRAP_H
+
+void MGADRIWrapFunctions(ScreenPtr pScreen, DRIInfoPtr pDRIInfo);
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile
index fcd378f8a..ff71c1711 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile
@@ -1,13 +1,13 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile,v 1.4 2000/03/03 01:05:39 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/Imakefile,v 1.7 2000/06/30 17:15:12 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
SRCS = neo_driver.c neo_bank.c neo_cursor.c neo_2097.c neo_2070.c \
- neo_2090.c neo_2200.c neo_i2c.c neo_shadow.c
+ neo_2090.c neo_2200.c neo_i2c.c neo_shadow.c neo_dga.c
OBJS = neo_driver.o neo_bank.o neo_cursor.o neo_2097.o neo_2070.o \
- neo_2090.o neo_2200.o neo_i2c.o neo_shadow.o
+ neo_2090.o neo_2200.o neo_i2c.o neo_shadow.o neo_dga.o
DEFINES = -DPSZ=8
@@ -19,7 +19,9 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \
-I$(XINCLUDESRC) -I$(XF86SRC)/xaa -I$(FONTINCSRC) \
-I$(XF86SRC)/ramdac -I$(XF86SRC)/rac -I$(XF86SRC)/ddc \
- -I$(XF86SRC)/i2c -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xf24_32bpp
+ -I$(XF86SRC)/i2c -I$(XF86SRC)/shadowfb -I$(XF86SRC)/xf24_32bpp \
+ -I$(SERVERSRC)/Xext \
+ -I$(XF86SRC)/int10 -I$(XF86OSSRC)/vbe
#endif
#if MakeHasPosixVariableSubstitutions
@@ -48,6 +50,7 @@ InstallDriverSDKNonExecFile(neo_2097.c,$(DRIVERSDKDIR)/drivers/neomagic)
InstallDriverSDKNonExecFile(neo_2200.c,$(DRIVERSDKDIR)/drivers/neomagic)
InstallDriverSDKNonExecFile(neo_bank.c,$(DRIVERSDKDIR)/drivers/neomagic)
InstallDriverSDKNonExecFile(neo_cursor.c,$(DRIVERSDKDIR)/drivers/neomagic)
+InstallDriverSDKNonExecFile(neo_dga.c,$(DRIVERSDKDIR)/drivers/neomagic)
InstallDriverSDKNonExecFile(neo_driver.c,$(DRIVERSDKDIR)/drivers/neomagic)
InstallDriverSDKNonExecFile(neo_i2c.c,$(DRIVERSDKDIR)/drivers/neomagic)
InstallDriverSDKNonExecFile(neo_shadow.c,$(DRIVERSDKDIR)/drivers/neomagic)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h
index 3849d2b07..bbf48a6be 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h
@@ -22,7 +22,7 @@ RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**********************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h,v 1.6 2000/02/08 13:13:18 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo.h,v 1.11 2000/06/30 17:15:12 dawes Exp $ */
/*
* The original Precision Insight driver for
@@ -36,18 +36,20 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* 1998, 1999 by Egbert Eich (Egbert.Eich@Physik.TU-Darmstadt.DE)
*/
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
#include "xaa.h"
#include "xaalocal.h" /* XAA internals as we replace some of XAA */
#include "xf86Cursor.h"
+#include "vbe.h"
+
/* Drivers that need to access the PCI config space directly need this */
#include "xf86Pci.h"
@@ -66,11 +68,16 @@ typedef enum {
NM2093,
NM2097,
NM2160,
- NM2200
+ NM2200,
+ NM2360,
+ NM2380
} NEOType;
/* function prototypes */
+extern Bool NEOSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+extern void NEOAdjustFrame(int scrnIndex, int x, int y, int flags);
+
/* in neo_2070.c */
extern Bool Neo2070AccelInit(ScreenPtr pScreen);
@@ -178,6 +185,10 @@ typedef struct neoRec
unsigned char* NeoFbBase;
long NeoFbMapSize;
unsigned int vgaIOBase;
+ DGAModePtr DGAModes;
+ int numDGAModes;
+ Bool DGAactive;
+ int DGAViewportStatus;
/* ??? */
int NeoFifoCount;
/* cursor */
@@ -214,6 +225,7 @@ typedef struct neoRec
/* proc pointer */
CloseScreenProcPtr CloseScreen;
I2CBusPtr I2C;
+ vbeInfoPtr pVbe;
unsigned char * ShadowPtr;
int ShadowPitch;
void (*PointerMoved)(int index, int x, int y);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c
index 16457100e..35cca1172 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c
@@ -22,7 +22,7 @@ RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**********************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c,v 1.4 1999/12/03 19:17:34 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_2200.c,v 1.6 2000/06/16 01:50:21 dawes Exp $ */
/*
* The original Precision Insight driver for
@@ -180,7 +180,7 @@ Neo2200AccelInit(ScreenPtr pScreen)
* Setup some global variables
*/
- /* Initialize for 8bpp or 15/16bpp support accellerated */
+ /* Initialize for 8bpp or 15/16bpp support accelerated */
switch (pScrn->bitsPerPixel) {
case 8:
nAcl->BltModeFlags = NEO_MODE1_DEPTH8;
@@ -192,6 +192,12 @@ Neo2200AccelInit(ScreenPtr pScreen)
nAcl->PixelWidth = 2;
break;
case 24:
+ if (nPtr->NeoChipset == NM2360) {
+ nAcl->BltModeFlags = NEO_MODE1_DEPTH24;
+ nAcl->PixelWidth = 3;
+ } else
+ return FALSE;
+ break;
default:
return FALSE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c
index c7e1c6237..7376751a1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c
@@ -22,7 +22,7 @@ RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**********************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c,v 1.1 1999/04/17 07:06:22 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_bank.c,v 1.2 2000/04/04 19:25:12 dawes Exp $ */
/*
* The original Precision Insight driver for
@@ -38,14 +38,14 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define PSZ 8
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Driver specific headers */
#include "neo.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c
new file mode 100644
index 000000000..da4f97e89
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
+ *
+ * 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>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c,v 1.1 2000/06/22 18:09:37 alanh Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "neo.h"
+#include "neo_reg.h"
+#include "dgaproc.h"
+
+static Bool NEO_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
+ int *, int *, int *);
+static Bool NEO_SetMode(ScrnInfoPtr, DGAModePtr);
+static void NEO_Sync(ScrnInfoPtr);
+static int NEO_GetViewport(ScrnInfoPtr);
+static void NEO_SetViewport(ScrnInfoPtr, int, int, int);
+static void NEO_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
+static void NEO_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
+static void NEO_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int,
+ unsigned long);
+
+static
+DGAFunctionRec NEODGAFuncs = {
+ NEO_OpenFramebuffer,
+ NULL,
+ NEO_SetMode,
+ NEO_SetViewport,
+ NEO_GetViewport,
+ NEO_Sync,
+ NEO_FillRect,
+ NEO_BlitRect,
+#if 0
+ NEO_BlitTransRect
+#else
+ NULL
+#endif
+};
+
+Bool
+NEODGAInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ NEOPtr pNEO = NEOPTR(pScrn);
+ DGAModePtr modes = NULL, newmodes = NULL, currentMode;
+ DisplayModePtr pMode, firstMode;
+ int Bpp = pScrn->bitsPerPixel >> 3;
+ int num = 0;
+ Bool oneMore;
+
+ pMode = firstMode = pScrn->modes;
+
+ while(pMode) {
+
+ if(0 /*pScrn->displayWidth != pMode->HDisplay*/) {
+ newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+ newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+ xfree(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+
+SECOND_PASS:
+
+ currentMode = modes + num;
+ num++;
+
+ currentMode->mode = pMode;
+ currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
+ currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
+ if(pMode->Flags & V_DBLSCAN)
+ currentMode->flags |= DGA_DOUBLESCAN;
+ if(pMode->Flags & V_INTERLACE)
+ currentMode->flags |= DGA_INTERLACED;
+ currentMode->byteOrder = pScrn->imageByteOrder;
+ currentMode->depth = pScrn->depth;
+ currentMode->bitsPerPixel = pScrn->bitsPerPixel;
+ currentMode->red_mask = pScrn->mask.red;
+ currentMode->green_mask = pScrn->mask.green;
+ currentMode->blue_mask = pScrn->mask.blue;
+ currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
+ currentMode->viewportWidth = pMode->HDisplay;
+ currentMode->viewportHeight = pMode->VDisplay;
+ currentMode->xViewportStep = 1;
+ currentMode->yViewportStep = 1;
+ currentMode->viewportFlags = DGA_FLIP_RETRACE;
+ currentMode->offset = 0;
+ currentMode->address = pNEO->NeoFbBase;
+
+ if(oneMore) { /* first one is narrow width */
+ currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pMode->HDisplay;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ oneMore = FALSE;
+ goto SECOND_PASS;
+ } else {
+ currentMode->bytesPerScanline =
+ ((pScrn->displayWidth * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pScrn->displayWidth;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ }
+
+ pMode = pMode->next;
+ if(pMode == firstMode)
+ break;
+ }
+
+ pNEO->numDGAModes = num;
+ pNEO->DGAModes = modes;
+
+ return DGAInit(pScreen, &NEODGAFuncs, modes, num);
+}
+
+
+static Bool
+NEO_SetMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr pMode
+){
+ static int OldDisplayWidth[MAXSCREENS];
+ int index = pScrn->pScreen->myNum;
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ if(!pMode) { /* restore the original mode */
+ /* put the ScreenParameters back */
+
+ pScrn->displayWidth = OldDisplayWidth[index];
+
+ NEOSwitchMode(index, pScrn->currentMode, 0);
+ pNEO->DGAactive = FALSE;
+ } else {
+ if(!pNEO->DGAactive) { /* save the old parameters */
+ OldDisplayWidth[index] = pScrn->displayWidth;
+
+ pNEO->DGAactive = TRUE;
+ }
+
+ pScrn->displayWidth = pMode->bytesPerScanline /
+ (pMode->bitsPerPixel >> 3);
+
+ NEOSwitchMode(index, pMode->mode, 0);
+ }
+
+ return TRUE;
+}
+
+static int
+NEO_GetViewport(
+ ScrnInfoPtr pScrn
+){
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ return pNEO->DGAViewportStatus;
+}
+
+static void
+NEO_SetViewport(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int flags
+){
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ NEOAdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+ pNEO->DGAViewportStatus = 0; /* NEOAdjustFrame loops until finished */
+}
+
+static void
+NEO_FillRect (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+){
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ if(pNEO->AccelInfoRec) {
+ (*pNEO->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
+ (*pNEO->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
+ SET_SYNC_FLAG(pNEO->AccelInfoRec);
+ }
+}
+
+static void
+NEO_Sync(
+ ScrnInfoPtr pScrn
+){
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ if(pNEO->AccelInfoRec) {
+ (*pNEO->AccelInfoRec->Sync)(pScrn);
+ }
+}
+
+static void
+NEO_BlitRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+){
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ if(pNEO->AccelInfoRec) {
+ int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
+ int ydir = (srcy < dsty) ? -1 : 1;
+
+ (*pNEO->AccelInfoRec->SetupForScreenToScreenCopy)(
+ pScrn, xdir, ydir, GXcopy, ~0, -1);
+ (*pNEO->AccelInfoRec->SubsequentScreenToScreenCopy)(
+ pScrn, srcx, srcy, dstx, dsty, w, h);
+ SET_SYNC_FLAG(pNEO->AccelInfoRec);
+ }
+}
+
+
+static void
+NEO_BlitTransRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+){
+ /* this one should be separate since the XAA function would
+ prohibit usage of ~0 as the key */
+}
+
+
+static Bool
+NEO_OpenFramebuffer(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ NEOPtr pNEO = NEOPTR(pScrn);
+
+ *name = NULL; /* no special device */
+ *mem = (unsigned char*)pNEO->NeoLinearAddr;
+ *size = pNEO->NeoFbMapSize;
+ *offset = 0;
+ *flags = DGA_NEED_ROOT;
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c
index b14a1dc4b..f20fc3aa1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c
@@ -22,7 +22,7 @@ RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**********************************************************************/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c,v 1.18 2000/03/06 23:54:11 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_driver.c,v 1.29 2000/06/30 17:15:12 dawes Exp $ */
/*
* The original Precision Insight driver for
@@ -36,14 +36,14 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
* 1998, 1999 by Egbert Eich (Egbert.Eich@Physik.TU-Darmstadt.DE)
*/
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
#include "xf86Resources.h"
/* Drivers for PCI hardware need this */
@@ -85,6 +85,10 @@ CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* Needed by the Shadow Framebuffer */
#include "shadowfb.h"
+/* int10 */
+#include "xf86int10.h"
+#include "vbe.h"
+
/* Needed for Device Data Channel (DDC) support */
#include "xf86DDC.h"
@@ -114,9 +118,6 @@ static Bool NEOProbe(DriverPtr drv, int flags);
static Bool NEOPreInit(ScrnInfoPtr pScrn, int flags);
static Bool NEOScreenInit(int Index, ScreenPtr pScreen, int argc,
char **argv);
-static Bool NEOSwitchMode(int scrnIndex, DisplayModePtr mode,
- int flags);
-static void NEOAdjustFrame(int scrnIndex, int x, int y, int flags);
static Bool NEOEnterVT(int scrnIndex, int flags);
static void NEOLeaveVT(int scrnIndex, int flags);
static Bool NEOCloseScreen(int scrnIndex, ScreenPtr pScreen);
@@ -183,6 +184,8 @@ static SymTabRec NEOChipsets[] = {
{ NM2097, "neo2097" },
{ NM2160, "neo2160" },
{ NM2200, "neo2200" },
+ { NM2360, "neo2360" },
+ { NM2380, "neo2380" },
{ -1, NULL }
};
@@ -194,6 +197,8 @@ static PciChipsets NEOPCIchipsets[] = {
{ NM2097, PCI_CHIP_NM2097, RES_SHARED_VGA },
{ NM2160, PCI_CHIP_NM2160, RES_SHARED_VGA },
{ NM2200, PCI_CHIP_NM2200, RES_SHARED_VGA },
+ { NM2360, PCI_CHIP_NM2360, RES_SHARED_VGA },
+ { NM2380, PCI_CHIP_NM2380, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED}
};
@@ -322,6 +327,11 @@ static const char *ddcSymbols[] = {
NULL
};
+static const char *vbeSymbols[] = {
+ "VBEInit",
+ NULL
+};
+
static const char *i2cSymbols[] = {
"xf86CreateI2CBusRec",
"xf86I2CBusInit",
@@ -372,7 +382,7 @@ neoSetup(pointer module, pointer opts, int *errmaj, int *errmin)
*/
LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols,
ramdacSymbols, shadowSymbols,
- ddcSymbols, i2cSymbols, NULL);
+ ddcSymbols, vbeSymbols, i2cSymbols, NULL);
/*
* The return value must be non-NULL on success even though there
* is no TearDownProc.
@@ -461,12 +471,46 @@ NEOProbe(DriverPtr drv, int flags)
drv, &usedChips);
if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
- /* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv,0);
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ /* Allocate a ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ NEOPCIchipsets,NULL, NULL,
+ NULL, NULL, NULL))) {
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = NEO_DRIVER_NAME;
+ pScrn->name = NEO_NAME;
+ pScrn->Probe = NEOProbe;
+ pScrn->PreInit = NEOPreInit;
+ pScrn->ScreenInit = NEOScreenInit;
+ pScrn->SwitchMode = NEOSwitchMode;
+ pScrn->AdjustFrame = NEOAdjustFrame;
+ pScrn->EnterVT = NEOEnterVT;
+ pScrn->LeaveVT = NEOLeaveVT;
+ pScrn->FreeScreen = NEOFreeScreen;
+ pScrn->ValidMode = NEOValidMode;
+ foundScreen = TRUE;
+ }
+ }
+ xfree(usedChips);
+ }
+ }
+
+ /* Isa Bus */
+
+ numUsed = xf86MatchIsaInstances(NEO_NAME,NEOChipsets,NEOISAchipsets,
+ drv,neoFindIsaDevice,devSections,
+ numDevSections,&usedChips);
+ if (numUsed > 0) {
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn, 0, usedChips[i],
+ NEOISAchipsets, NULL, NULL,
+ NULL, NULL, NULL))) {
pScrn->driverVersion = VERSION;
pScrn->driverName = NEO_DRIVER_NAME;
pScrn->name = NEO_NAME;
@@ -480,39 +524,7 @@ NEOProbe(DriverPtr drv, int flags)
pScrn->FreeScreen = NEOFreeScreen;
pScrn->ValidMode = NEOValidMode;
foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn, usedChips[i], NEOPCIchipsets,
- NULL, NULL, NULL, NULL, NULL);
- }
- xfree(usedChips);
}
- }
- /* Isa Bus */
-
- numUsed = xf86MatchIsaInstances(NEO_NAME,NEOChipsets,NEOISAchipsets,
- drv,neoFindIsaDevice,devSections,
- numDevSections,&usedChips);
- if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
-
- pScrn = xf86AllocateScreen(drv,0);
- pScrn->driverVersion = VERSION;
- pScrn->driverName = NEO_DRIVER_NAME;
- pScrn->name = NEO_NAME;
- pScrn->Probe = NEOProbe;
- pScrn->PreInit = NEOPreInit;
- pScrn->ScreenInit = NEOScreenInit;
- pScrn->SwitchMode = NEOSwitchMode;
- pScrn->AdjustFrame = NEOAdjustFrame;
- pScrn->EnterVT = NEOEnterVT;
- pScrn->LeaveVT = NEOLeaveVT;
- pScrn->FreeScreen = NEOFreeScreen;
- pScrn->ValidMode = NEOValidMode;
- foundScreen = TRUE;
- xf86ConfigActiveIsaEntity(pScrn, usedChips[i], NEOISAchipsets,
- NULL, NULL, NULL, NULL, NULL);
}
xfree(usedChips);
}
@@ -524,7 +536,7 @@ NEOProbe(DriverPtr drv, int flags)
static int
neoFindIsaDevice(GDevPtr dev)
{
- unsigned char vgaIOBase;
+ unsigned int vgaIOBase;
unsigned char id;
vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
@@ -570,7 +582,8 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
int w;
int apertureSize;
char *s;
-
+ Bool ddc_done = FALSE;
+
if (flags & PROBE_DETECT) return FALSE;
/* The vgahw module should be loaded here when needed */
@@ -622,25 +635,35 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Chipset is a ");
switch(nPtr->NeoChipset){
case NM2070:
- ErrorF("MagicGraph 128 (NM2070)");
+ xf86ErrorF("MagicGraph 128 (NM2070)");
break;
case NM2090 :
- ErrorF("MagicGraph 128V (NM2090)");
+ xf86ErrorF("MagicGraph 128V (NM2090)");
break;
case NM2093 :
- ErrorF("MagicGraph 128ZV (NM2093)");
+ xf86ErrorF("MagicGraph 128ZV (NM2093)");
break;
case NM2097 :
- ErrorF("MagicGraph 128ZV+ (NM2097)");
+ xf86ErrorF("MagicGraph 128ZV+ (NM2097)");
break;
case NM2160 :
- ErrorF("MagicGraph 128XD (NM2160)");
+ xf86ErrorF("MagicGraph 128XD (NM2160)");
break;
case NM2200 :
- ErrorF("MagicMedia 256AV (NM2200)");
+ xf86ErrorF("MagicMedia 256AV (NM2200)");
+ break;
+ case NM2360 :
+ xf86ErrorF("MagicMedia 256ZX (NM2360)");
break;
+ case NM2380 :
+ xf86ErrorF("MagicMedia 256XL+ (NM2380)");
+ break;
+ }
+ xf86ErrorF("\n");
+
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ nPtr->pVbe = VBEInit(NULL,nPtr->pEnt->index);
}
- ErrorF("\n");
vgaHWGetIOBase(hwp);
nPtr->vgaIOBase = hwp->IOBase;
@@ -674,7 +697,8 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
nPtr->NeoPanelHeight = 1024;
break;
#else
- ErrorF("\nOnly 640x480,\n"
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Only 640x480,\n"
" 800x600,\n"
" and 1024x768 panels are currently supported\n");
return FALSE;
@@ -741,6 +765,26 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
linearSize = 4096;
maxWidth = 1280;
break;
+ case NM2360:
+ bppSupport = Support24bppFb | Support32bppFb |
+ SupportConvert32to24 | PreferConvert32to24;
+ videoRam = 4096;
+ maxClock = 110000;
+ CursorMem = 1024;
+ CursorOff = 0x1000;
+ linearSize = 4096;
+ maxWidth = 1280;
+ break;
+ case NM2380:
+ bppSupport = Support24bppFb | Support32bppFb |
+ SupportConvert32to24 | PreferConvert32to24;
+ videoRam = 6144;
+ maxClock = 110000;
+ CursorMem = 1024;
+ CursorOff = 0x1000;
+ linearSize = 4096;
+ maxWidth = 1280;
+ break;
}
pScrn->monitor = pScrn->confScreen->monitor;
@@ -760,8 +804,18 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
VGAwGR(0x09,0x26);
- xf86SetDDCproperties(
- pScrn,xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex,nPtr->I2C)));
+
+ if (nPtr->pVbe) {
+ xf86MonPtr pMon;
+ if ((pMon = xf86PrintEDID(vbeDoEDID(nPtr->pVbe,NULL))) != NULL)
+ ddc_done = TRUE;
+ xf86SetDDCproperties(pScrn,pMon);
+ }
+
+ if (ddc_done)
+ xf86SetDDCproperties(
+ pScrn,xf86PrintEDID(xf86DoEDID_DDC2(pScrn->scrnIndex,nPtr->I2C)));
+
VGAwGR(0x09,0x00);
if (!xf86SetDepthBpp(pScrn, 8, 8, 8, bppSupport ))
@@ -875,11 +929,6 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
}
}
- if (nPtr->shadowFB)
- ErrorF("shadow\n");
- else
- ErrorF("no shadow\n");
-
if (nPtr->internDisp && nPtr->externDisp)
xf86DrvMsg(pScrn->scrnIndex,X_CONFIG,
"Simultaneous LCD/CRT display mode\n");
@@ -981,6 +1030,8 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
case NM2160:
case NM2097:
case NM2200:
+ case NM2360:
+ case NM2380:
nPtr->NeoMMIOAddr = nPtr->PciInfo->memBase[1];
break;
}
@@ -1034,7 +1085,7 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n",
maxClock);
} else {
- xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kByte\n",
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n",
maxClock);
}
@@ -1043,7 +1094,7 @@ NEOPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = (ClockRangePtr)xnfalloc(sizeof(ClockRange));
+ clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->ClockMulFactor = 1;
clockRanges->minClock = 11000; /* guessed §§§ */
@@ -1361,6 +1412,9 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
xf86SetBlackWhitePixels(pScreen);
+
+ if (!nPtr->shadowFB)
+ NEODGAInit(pScreen);
nPtr->NeoHWCursorShown = FALSE;
nPtr->NeoHWCursorInitialized = FALSE;
@@ -1451,6 +1505,8 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
Neo2097AccelInit(pScreen);
break;
case NM2200 :
+ case NM2360 :
+ case NM2380 :
Neo2200AccelInit(pScreen);
break;
}
@@ -1531,14 +1587,14 @@ NEOScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
/* Mandatory */
-static Bool
+Bool
NEOSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
return neoModeInit(xf86Screens[scrnIndex], mode);
}
/* Mandatory */
-static void
+void
NEOAdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScrn;
@@ -1818,21 +1874,24 @@ neoSave(ScrnInfoPtr pScrn)
if (nPtr->NeoChipset == NM2160) {
save->PanelHorizCenterReg4 = VGArGR(0x36);
}
- if (nPtr->NeoChipset == NM2200) {
+ if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360
+ || nPtr->NeoChipset == NM2380) {
save->PanelHorizCenterReg4 = VGArGR(0x36);
save->PanelVertCenterReg5 = VGArGR(0x37);
save->PanelHorizCenterReg5 = VGArGR(0x38);
}
save->ExtColorModeSelect = VGArGR(0x90);
save->VCLK3NumeratorLow = VGArGR(0x9B);
- if (nPtr->NeoChipset == NM2200)
+ if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360
+ || nPtr->NeoChipset == NM2380)
save->VCLK3NumeratorHigh = VGArGR(0x8F);
save->VCLK3Denominator = VGArGR(0x9F);
if (save->reg == NULL)
save->reg = (regSavePtr)xnfcalloc(sizeof(regSaveRec), 1);
else
- ErrorF("WARNING: Non-NULL reg in NeoSave: reg=0x%08X\n", save->reg);
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Non-NULL reg in NeoSave: reg=0x%08X\n", save->reg);
save->reg->CR[0x25] = VGArCR(0x25);
save->reg->CR[0x2F] = VGArCR(0x2F);
@@ -1890,6 +1949,8 @@ neoProgramShadowRegs(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore)
case NM2097:
case NM2160:
case NM2200:
+ case NM2360:
+ case NM2380:
default:
/* Don't program the shadow regs by default */
noProgramShadowRegs = TRUE;
@@ -2055,6 +2116,8 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore,
case NM2097 :
case NM2160 :
case NM2200 :
+ case NM2360 :
+ case NM2380 :
temp &= 0x70; /* Save bits 6:4 */
temp |= (restore->ExtColorModeSelect & ~0x70);
break;
@@ -2104,6 +2167,8 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore,
temp |= (restore->PanelDispCntlReg1 & ~0xDC);
break;
case NM2200 :
+ case NM2360 :
+ case NM2380 :
temp &= 0x98; /* Save bits 7,4:3 */
temp |= (restore->PanelDispCntlReg1 & ~0x98);
break;
@@ -2136,7 +2201,8 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore,
VGAwGR(0x36, restore->PanelHorizCenterReg4);
}
- if (nPtr->NeoChipset == NM2200) {
+ if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360
+ || nPtr->NeoChipset == NM2380) {
VGAwGR(0x36, restore->PanelHorizCenterReg4);
VGAwGR(0x37, restore->PanelVertCenterReg5);
VGAwGR(0x38, restore->PanelHorizCenterReg5);
@@ -2145,7 +2211,8 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore,
/* Program VCLK3 if needed. */
if (restore->ProgramVCLK) {
VGAwGR(0x9B, restore->VCLK3NumeratorLow);
- if (nPtr->NeoChipset == NM2200) {
+ if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360
+ || nPtr->NeoChipset == NM2380) {
temp = VGArGR(0x8F);
temp &= 0x0F; /* Save bits 3:0 */
temp |= (restore->VCLK3NumeratorHigh & ~0x0F);
@@ -2177,7 +2244,8 @@ neoRestore(ScrnInfoPtr pScrn, vgaRegPtr VgaReg, NeoRegPtr restore,
restore->reg = NULL;
}
/* Program vertical extension register */
- if (nPtr->NeoChipset == NM2200) {
+ if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360
+ || nPtr->NeoChipset == NM2380) {
VGAwCR(0x70, restore->VerticalExt);
}
@@ -2444,7 +2512,8 @@ neoModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
* case it isn't, warn us and clear it anyway.
*/
if (NeoNew->reg) {
- ErrorF("WARNING: Non-NULL reg in NeoInit: reg=0x%08X\n", NeoNew->reg);
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Non-NULL reg in NeoInit: reg=0x%08X\n", NeoNew->reg);
xfree(NeoNew->reg);
NeoNew->reg = NULL;
}
@@ -2498,7 +2567,8 @@ neoCalcVCLK(ScrnInfoPtr pScrn, long freq)
}
}
- if (nPtr->NeoChipset == NM2200) {
+ if (nPtr->NeoChipset == NM2200 || nPtr->NeoChipset == NM2360
+ || nPtr->NeoChipset == NM2380) {
/* NOT_DONE: We are trying the full range of the 2200 clock.
We should be able to try n up to 2047 */
nPtr->NeoModeReg.VCLK3NumeratorLow = n_best;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp
index 8e41d5134..fb78c1238 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp,v 1.1 2000/03/03 01:05:40 dawes Exp $
-.TH NEOMAGIC __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neomagic.cpp,v 1.4 2000/06/14 02:13:12 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH NEOMAGIC __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
neomagic \- NeoMagic video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""neomagic"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qneomagic\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B neomagic
is an XFree86 driver for NeoMagic video chips.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile
index f242d6200..03af150d0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile
@@ -1,10 +1,10 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.11 2000/02/25 21:02:54 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.12 2000/03/31 22:55:46 dawes Exp $
XCOMM
XCOMM This is an Imakefile for the NVIDIA driver.
XCOMM
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.11 2000/02/25 21:02:54 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/Imakefile,v 1.12 2000/03/31 22:55:46 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -54,6 +54,7 @@ InstallDriverSDKNonExecFile(nv_dac.c,$(DRIVERSDKDIR)/drivers/nv)
InstallDriverSDKNonExecFile(nv_dga.c,$(DRIVERSDKDIR)/drivers/nv)
InstallDriverSDKNonExecFile(nv_driver.c,$(DRIVERSDKDIR)/drivers/nv)
InstallDriverSDKNonExecFile(nv_include.h,$(DRIVERSDKDIR)/drivers/nv)
+InstallDriverSDKNonExecFile(nv_local.h,$(DRIVERSDKDIR)/drivers/nv)
InstallDriverSDKNonExecFile(nv_proto.h,$(DRIVERSDKDIR)/drivers/nv)
InstallDriverSDKNonExecFile(nv_setup.c,$(DRIVERSDKDIR)/drivers/nv)
InstallDriverSDKNonExecFile(nv_shadow.c,$(DRIVERSDKDIR)/drivers/nv)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp
index 490702f19..7d1872031 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp,v 1.6 2000/03/03 01:05:40 dawes Exp $
-.TH NV __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv.cpp,v 1.10 2000/06/14 02:13:12 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH NV __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
-nv \-NVIDIA video driver
+nv \- NVIDIA video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""nv"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qnv\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B nv
is an XFree86 driver for NVIDIA video cards. The driver is fully
@@ -48,28 +48,28 @@ The following driver
.B Options
are supported:
.TP
-.BI "Option ""HWCursor"" """ boolean """
+.BI "Option \*qHWCursor\*q \*q" boolean \*q
Enable or disable the HW cursor. Default: on.
.TP
-.BI "Option ""NoAccel"" """ boolean """
+.BI "Option \*qNoAccel\*q \*q" boolean \*q
Disable or enable acceleration. Default: acceleration is enabled.
.TP
-.BI "Option ""UseFBDev"" """ boolean """
+.BI "Option \*qUseFBDev\*q \*q" boolean \*q
Enable or disable use of on OS-specific fb interface (and is not supported
on all OSs). See fbdevhw(__drivermansuffix__) for further information.
Default: off.
.TP
-.BI "Option ""Rotate"" ""CW""
+.BI "Option \*qRotate\*q \*qCW\*q"
.TP
-.BI "Option ""Rotate"" ""CCW""
+.BI "Option \*qRotate\*q \*qCCW\*q"
Rotate the display clockwise or counterclockwise. This mode is unaccelerated.
Default: no rotation.
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
Enable or disable use of the shadow framebuffer layer. See
-shadowfb(4) for further information. Default: off.
+shadowfb(__drivermansuffix__) for further information. Default: off.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: David McKay, Jarno Paananen, Chas Inman, Dave Schmenk,
Mark Vojkovich
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
index e45e00f5a..e6b0f1787 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c
@@ -24,7 +24,7 @@
/* Hacked together from mga driver and 3.3.4 NVIDIA driver by Jarno Paananen
<jpaana@s2.org> */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.40 2000/03/05 23:47:51 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_driver.c,v 1.44 2000/06/21 17:28:12 dawes Exp $ */
#include "nv_include.h"
@@ -457,27 +457,28 @@ NVProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
+ ScrnInfoPtr pScrn = NULL;
/* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i],
+ NVPciChipsets, NULL, NULL, NULL,
+ NULL, NULL))) {
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = NV_DRIVER_NAME;
- pScrn->name = NV_NAME;
- pScrn->Probe = NVProbe;
- pScrn->PreInit = NVPreInit;
- pScrn->ScreenInit = NVScreenInit;
- pScrn->SwitchMode = NVSwitchMode;
- pScrn->AdjustFrame = NVAdjustFrame;
- pScrn->EnterVT = NVEnterVT;
- pScrn->LeaveVT = NVLeaveVT;
- pScrn->FreeScreen = NVFreeScreen;
- pScrn->ValidMode = NVValidMode;
- foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn, usedChips[i], NVPciChipsets, NULL,
- NULL, NULL, NULL, NULL);
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = NV_DRIVER_NAME;
+ pScrn->name = NV_NAME;
+ pScrn->Probe = NVProbe;
+ pScrn->PreInit = NVPreInit;
+ pScrn->ScreenInit = NVScreenInit;
+ pScrn->SwitchMode = NVSwitchMode;
+ pScrn->AdjustFrame = NVAdjustFrame;
+ pScrn->EnterVT = NVEnterVT;
+ pScrn->LeaveVT = NVLeaveVT;
+ pScrn->FreeScreen = NVFreeScreen;
+ pScrn->ValidMode = NVValidMode;
+ foundScreen = TRUE;
+ }
}
xfree(usedChips);
return foundScreen;
@@ -729,18 +730,6 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
if (pScrn->numEntities != 1)
return FALSE;
- /* The vgahw module should be loaded here when needed */
- if (!xf86LoadSubModule(pScrn, "vgahw"))
- return FALSE;
-
- xf86LoaderReqSymLists(vgahwSymbols, NULL);
-
- /*
- * Allocate a vgaHWRec
- */
- if (!vgaHWGetHWRec(pScrn))
- return FALSE;
-
/* Allocate the NVRec driverPrivate */
if (!NVGetRec(pScrn)) {
return FALSE;
@@ -892,6 +881,18 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
bytesPerPixel = pScrn->bitsPerPixel / 8;
+ /* The vgahw module should be loaded here when needed */
+ if (!xf86LoadSubModule(pScrn, "vgahw"))
+ return FALSE;
+
+ xf86LoaderReqSymLists(vgahwSymbols, NULL);
+
+ /*
+ * Allocate a vgaHWRec
+ */
+ if (!vgaHWGetHWRec(pScrn))
+ return FALSE;
+
/* We use a programamble clock */
pScrn->progClock = TRUE;
@@ -1150,7 +1151,7 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
pNv->MinClock = 12000;
pNv->MaxClock = pNv->riva.MaxVClockFreqKHz;
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pNv->MinClock;
clockRanges->maxClock = pNv->MaxClock;
@@ -1659,7 +1660,6 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
switch(pScrn->bitsPerPixel) {
case 8: refreshArea = NVRefreshArea8; break;
case 16: refreshArea = NVRefreshArea16; break;
- case 24: refreshArea = NVRefreshArea24; break;
case 32: refreshArea = NVRefreshArea32; break;
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h
index 4c9c5097f..1f995988d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h,v 1.7 2000/02/25 21:02:56 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_include.h,v 1.8 2000/04/04 19:25:13 dawes Exp $ */
#ifndef __NV_INCLUDE_H__
#define __NV_INCLUDE_H__
@@ -7,8 +7,8 @@
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86Resources.h"
-#include "compiler.h"
#include "xf86_ansic.h"
+#include "compiler.h"
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c
index fc6762c4c..be3fa3d0e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c
@@ -2,7 +2,7 @@
Copyright (c) 1999, The XFree86 Project Inc.
Written by Mark Vojkovich <markv@valinux.com>
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c,v 1.4 2000/02/08 17:19:10 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_shadow.c,v 1.5 2000/03/13 18:49:29 mvojkovi Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -154,58 +154,6 @@ NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
}
-/* this one could be faster */
-void
-NVRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
-{
- NVPtr pNv = NVPTR(pScrn);
- int count, width, height, y1, y2, dstPitch, srcPitch;
- CARD8 *dstPtr, *srcPtr, *src;
- CARD32 *dst;
-
- dstPitch = BitmapBytePad(pScrn->displayWidth * 24);
- srcPitch = -pNv->Rotate * pNv->ShadowPitch;
-
- while(num--) {
- width = pbox->x2 - pbox->x1;
- y1 = pbox->y1 & ~3;
- y2 = (pbox->y2 + 3) & ~3;
- height = (y2 - y1) >> 2; /* blocks of 3 dwords */
-
- if(pNv->Rotate == 1) {
- dstPtr = pNv->FbStart +
- (pbox->x1 * dstPitch) + ((pScrn->virtualX - y2) * 3);
- srcPtr = pNv->ShadowPtr + ((1 - y2) * srcPitch) + (pbox->x1 * 3);
- } else {
- dstPtr = pNv->FbStart +
- ((pScrn->virtualY - pbox->x2) * dstPitch) + (y1 * 3);
- srcPtr = pNv->ShadowPtr + (y1 * srcPitch) + (pbox->x2 * 3) - 3;
- }
-
- while(width--) {
- src = srcPtr;
- dst = (CARD32*)dstPtr;
- count = height;
- while(count--) {
- dst[0] = src[0] | (src[1] << 8) | (src[2] << 16) |
- (src[srcPitch] << 24);
- dst[1] = src[srcPitch + 1] | (src[srcPitch + 2] << 8) |
- (src[srcPitch * 2] << 16) |
- (src[(srcPitch * 2) + 1] << 24);
- dst[2] = src[(srcPitch * 2) + 2] | (src[srcPitch * 3] << 8) |
- (src[(srcPitch * 3) + 1] << 16) |
- (src[(srcPitch * 3) + 2] << 24);
- dst += 3;
- src += srcPitch * 4;
- }
- srcPtr += pNv->Rotate * 3;
- dstPtr += dstPitch;
- }
-
- pbox++;
- }
-}
-
void
NVRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
{
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h
index d259babdc..5b249bb4f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.11 2000/02/25 21:02:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/nv/nv_type.h,v 1.12 2000/03/13 18:49:29 mvojkovi Exp $ */
#ifndef __NV_STRUCT_H__
#define __NV_STRUCT_H__
@@ -118,7 +118,6 @@ typedef struct {
void NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void NVRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
-void NVRefreshArea24(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void NVRefreshArea32(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
void NVPointerMoved(int index, int x, int y);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
index e3f7178bf..06dd69865 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.6 2000/03/03 01:05:40 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/Imakefile,v 1.8 2000/06/17 00:03:21 martin Exp $
XCOMM
XCOMM This is the Imakefile for the ATI Rage 128 (r128) driver.
XCOMM
@@ -6,9 +6,16 @@ XCOMM
#define IHaveModules
#include <Server.tmpl>
-SRCS = r128_driver.c r128_cursor.c r128_accel.c # r128_i2c.c
+#if BuildXF86DRI
+DRISRCS = r128_dri.c
+DRIOBJS = r128_dri.o
+DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include
+DRIDEFINES = $(GLX_DEFINES)
+#endif
+
+SRCS = r128_driver.c r128_cursor.c r128_accel.c r128_dga.c $(DRISRCS) # r128_i2c.c
-OBJS = r128_driver.o r128_cursor.o r128_accel.o # r128_i2c.o
+OBJS = r128_driver.o r128_cursor.o r128_accel.o r128_dga.o $(DRIOBJS) # r128_i2c.o
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
@@ -22,9 +29,12 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86OSSRC)/vbe \
-I$(XF86SRC)/int10 -I$(SERVERSRC)/Xext \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
- -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp
+ -I$(EXTINCSRC) -I$(XF86SRC)/xf24_32bpp \
+ $(DRIINCLUDES)
#endif
+DEFINES = $(DRIDEFINES)
+
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
#endif
@@ -47,7 +57,13 @@ InstallDriverSDKNonExecFile(r128.h,$(DRIVERSDKDIR)/drivers/r128)
InstallDriverSDKNonExecFile(r128_accel.c,$(DRIVERSDKDIR)/drivers/r128)
InstallDriverSDKNonExecFile(r128_cursor.c,$(DRIVERSDKDIR)/drivers/r128)
InstallDriverSDKNonExecFile(r128_driver.c,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dga.c,$(DRIVERSDKDIR)/drivers/r128)
InstallDriverSDKNonExecFile(r128_reg.h,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dri.c,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dri.h,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_dripriv.h,$(DRIVERSDKDIR)/drivers/r128)
+InstallDriverSDKNonExecFile(r128_sarea.h,$(DRIVERSDKDIR)/drivers/r128)
+
InstallDriverSDKObjectModule(r128,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/README b/xc/programs/Xserver/hw/xfree86/drivers/r128/README
index 27adcbbbd..95f482c00 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/README
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/README
@@ -69,7 +69,7 @@
7. Known Limitations
- * DGA is not supported yet
+ * None
8. Authors
@@ -111,4 +111,4 @@
http://www.suse.com
-$XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/README,v 1.3 2000/03/08 15:14:50 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/README,v 1.4 2000/06/14 00:16:11 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp
index 6d75efc5e..edc80576d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp,v 1.3 2000/03/06 22:59:26 dawes Exp $
-.TH R128 __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.cpp,v 1.6 2000/06/14 02:13:13 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH R128 __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
r128 \- ATI Rage 128 video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""r128"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qr128\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B r128
is an XFree86 driver for ATI Rage 128 based video cards. It contains
@@ -48,22 +48,22 @@ In addition, the following driver
.B Options
are supported:
.TP
-.BI "Option ""SWcursor"" """ boolean """
+.BI "Option \*qSWcursor\*q \*q" boolean \*q
Selects software cursor. The default is
.B off.
.TP
-.BI "Option ""NoAccel"" """ boolean """
+.BI "Option \*qNoAccel\*q \*q" boolean \*q
Enables or disables all hardware acceleration. The default is to
.B enable
hardware acceleration.
.TP
-.BI "Option ""Dac6Bit"" """ boolean """
+.BI "Option \*qDac6Bit\*q \*q" boolean \*q
Enables or disables the use of 6 bits per color component when in 8 bpp
mode (emulates VGA mode). By default, all 8 bits per color component
are used. The default is
.B off.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
.nf
Rickard E. (Rik) Faith \fIfaith@precisioninsight.com\fP
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
index d5d120153..91676f19f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h
@@ -1,8 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.8 2000/02/23 04:47:18 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128.h,v 1.10 2000/06/17 00:03:22 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -40,10 +40,13 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */
#define R128_MMIOSIZE 0x80000
+ /* R128_NAME is used for the server-side
+ ddx driver, the client-side DRI driver,
+ and the kernel-level DRM driver. */
#define R128_NAME "r128"
#define R128_VERSION_MAJOR 3
-#define R128_VERSION_MINOR 0
-#define R128_VERSION_PATCH 0
+#define R128_VERSION_MINOR 1
+#define R128_VERSION_PATCH 1
#define R128_VERSION ((R128_VERSION_MAJOR << 16) \
| (R128_VERSION_MINOR << 8) \
| R128_VERSION_PATCH)
@@ -100,7 +103,7 @@ typedef struct {
CARD32 amcgpio_en_reg;
CARD32 amcgpio_mask;
- /* Crtc registers */
+ /* CRTC registers */
CARD32 crtc_gen_cntl;
CARD32 crtc_ext_cntl;
CARD32 dac_cntl;
@@ -112,6 +115,21 @@ typedef struct {
CARD32 crtc_offset_cntl;
CARD32 crtc_pitch;
+ /* CRTC2 registers */
+ CARD32 crtc2_gen_cntl;
+
+ /* Flat panel registers */
+ CARD32 fp_crtc_h_total_disp;
+ CARD32 fp_crtc_v_total_disp;
+ CARD32 fp_gen_cntl;
+ CARD32 fp_h_sync_strt_wid;
+ CARD32 fp_horz_stretch;
+ CARD32 fp_panel_cntl;
+ CARD32 fp_v_sync_strt_wid;
+ CARD32 fp_vert_stretch;
+ CARD32 lvds_gen_cntl;
+ CARD32 tmds_crc;
+
/* Computed values for PLL */
int dot_clock_freq;
int pll_output_freq;
@@ -141,6 +159,15 @@ typedef struct {
} R128PLLRec, *R128PLLPtr;
typedef struct {
+ int bitsPerPixel;
+ int depth;
+ int displayWidth;
+ int pixel_code;
+ int pixel_bytes;
+ DisplayModePtr mode;
+} R128FBLayout;
+
+typedef struct {
EntityInfoPtr pEnt;
pciVideoPtr PciInfo;
PCITAG PciTag;
@@ -157,10 +184,24 @@ typedef struct {
unsigned char *FB; /* Map of frame buffer */
CARD32 MemCntl;
- CARD32 BusCntl;
+ CARD32 BusCntl;
unsigned long FbMapSize; /* Size of frame buffer, in bytes */
int Flags; /* Saved copy of mode flags */
+ Bool EnableFP; /* Enable use of FP registers */
+ Bool CRTOnly; /* Only use External CRT instead of FP */
+ Bool HasPanelRegs; /* Current chip can connect to a FP */
+
+ /* Computed values for FPs */
+ int PanelXRes;
+ int PanelYRes;
+ int PanelHNonVis;
+ int PanelHOverPlus;
+ int PanelHSyncWidth;
+ int PanelVNonVis;
+ int PanelVOverPlus;
+ int PanelVSyncWidth;
+
R128PLLRec pll;
R128RAMPtr ram;
@@ -168,6 +209,8 @@ typedef struct {
R128SaveRec ModeReg; /* Current mode */
Bool (*CloseScreen)(int, ScreenPtr);
+ Bool PaletteSavedOnVT; /* Palette saved on last VT switch */
+
I2CBusPtr i2c;
XAAInfoRecPtr accel;
xf86CursorInfoPtr cursor;
@@ -176,8 +219,6 @@ typedef struct {
int fifo_slots; /* Free slots in the FIFO (64 max) */
int pix24bpp; /* Depth of pixmap for 24bpp framebuffer */
- int pixel_code; /* Unified depth/fbbpp value */
- int pixel_bytes;/* Bytes per framebuffer pixel */
Bool dac6bits; /* Use 6 bit DAC? */
/* Computed values for Rage 128 */
@@ -199,13 +240,124 @@ typedef struct {
int scanline_words;
int scanline_direct;
int scanline_bpp; /* Only used for ImageWrite */
+
+ DGAModePtr DGAModes;
+ int numDGAModes;
+ Bool DGAactive;
+ int DGAViewportStatus;
+
+ R128FBLayout CurrentLayout;
+#ifdef XF86DRI
+ Bool directRenderingEnabled;
+ DRIInfoPtr pDRIInfo;
+ int drmFD;
+ int numVisualConfigs;
+ __GLXvisualConfig *pVisualConfigs;
+ R128ConfigPrivPtr pVisualConfigsPriv;
+
+ drmHandle fbHandle;
+
+ drmSize registerSize;
+ drmHandle registerHandle;
+
+ Bool IsPCI; /* Current card is a PCI card */
+
+ drmSize agpSize;
+ drmHandle agpMemHandle; /* Handle from drmAgpAlloc */
+ unsigned long agpOffset;
+ unsigned char *AGP; /* Map */
+ int agpMode;
+
+ Bool CCEInUse; /* CCE is currently active */
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+ Bool CCESecure; /* CCE security enabled */
+ int CCEusecTimeout; /* CCE timeout in usecs */
+ Bool CCE2D; /* CCE is used for X server 2D prims */
+
+ /* CCE ring buffer data */
+ unsigned long ringStart; /* Offset into AGP space */
+ drmHandle ringHandle; /* Handle from drmAddMap */
+ drmSize ringMapSize; /* Size of map */
+ int ringSize; /* Size of ring (in MB) */
+ unsigned char *ring; /* Map */
+ int ringSizeLog2QW;
+
+ unsigned long ringReadOffset; /* Offset into AGP space */
+ drmHandle ringReadPtrHandle; /* Handle from drmAddMap */
+ drmSize ringReadMapSize; /* Size of map */
+ unsigned char *ringReadPtr; /* Map */
+
+ /* CCE vertex buffer data */
+ unsigned long vbStart; /* Offset into AGP space */
+ drmHandle vbHandle; /* Handle from drmAddMap */
+ drmSize vbMapSize; /* Size of map */
+ int vbSize; /* Size of vert bufs (in MB) */
+ unsigned char *vb; /* Map */
+ int vbBufSize; /* Size of individual vert buf */
+ int vbNumBufs; /* Number of vert bufs */
+ drmBufMapPtr vbBufs; /* Buffer map */
+
+ /* CCE indirect buffer data */
+ unsigned long indStart; /* Offset into AGP space */
+ drmHandle indHandle; /* Handle from drmAddMap */
+ drmSize indMapSize; /* Size of map */
+ int indSize; /* Size of indirect bufs (in MB) */
+ unsigned char *ind; /* Map */
+
+ /* CCE AGP Texture data */
+ unsigned long agpTexStart; /* Offset into AGP space */
+ drmHandle agpTexHandle; /* Handle from drmAddMap */
+ drmSize agpTexMapSize; /* Size of map */
+ int agpTexSize; /* Size of AGP tex space (in MB) */
+ unsigned char *agpTex; /* Map */
+ int log2AGPTexGran;
+
+ /* DRI screen private data */
+ int fbX;
+ int fbY;
+ int backX;
+ int backY;
+ int depthX;
+ int depthY;
+ int textureX;
+ int textureY;
+ int textureSize;
+ int log2TexGran;
+#endif
} R128InfoRec, *R128InfoPtr;
+#define R128WaitForFifo(pScrn, entries) \
+do { \
+ if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \
+ info->fifo_slots -= entries; \
+} while (0)
+
+extern void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries);
+extern void R128WaitForIdle(ScrnInfoPtr pScrn);
+extern void R128EngineReset(ScrnInfoPtr pScrn);
+extern void R128EngineFlush(ScrnInfoPtr pScrn);
+
extern int INPLL(ScrnInfoPtr pScrn, int addr);
extern void R128WaitForVerticalSync(ScrnInfoPtr pScrn);
+extern void R128AdjustFrame(int scrnIndex, int x, int y, int flags);
+extern Bool R128SwitchMode(int ScrnIndex, DisplayModePtr mode, int flags);
extern Bool R128AccelInit(ScreenPtr pScreen);
extern void R128EngineInit(ScrnInfoPtr pScrn);
extern Bool R128CursorInit(ScreenPtr pScreen);
+extern Bool R128DGAInit(ScreenPtr pScreen);
+
+extern int R128MinBits(int val);
+
+#ifdef XF86DRI
+extern Bool R128DRIScreenInit(ScreenPtr pScreen);
+extern void R128DRICloseScreen(ScreenPtr pScreen);
+extern Bool R128DRIFinishScreenInit(ScreenPtr pScreen);
+extern void R128CCEStart(ScrnInfoPtr pScrn);
+extern void R128CCEStop(ScrnInfoPtr pScrn);
+extern void R128CCEResetRing(ScrnInfoPtr pScrn);
+extern void R128CCEWaitForIdle(ScrnInfoPtr pScrn);
+#endif
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
index 5b0223661..7a1ce0ed1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c
@@ -1,8 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.7 2000/02/23 04:47:18 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_accel.c,v 1.13 2000/06/26 05:41:32 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -95,6 +95,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* DDC support */
#include "xf86DDC.h"
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
/* Driver data structures */
#include "r128.h"
#include "r128_reg.h"
@@ -122,7 +135,7 @@ static struct {
};
/* Flush all dirty data in the Pixel Cache to memory. */
-static void R128EngineFlush(ScrnInfoPtr pScrn)
+void R128EngineFlush(ScrnInfoPtr pScrn)
{
int i;
R128MMIO_VARS();
@@ -134,11 +147,12 @@ static void R128EngineFlush(ScrnInfoPtr pScrn)
}
/* Reset graphics card to known state. */
-static void R128EngineReset(ScrnInfoPtr pScrn)
+void R128EngineReset(ScrnInfoPtr pScrn)
{
- CARD32 clock_cntl_index;
- CARD32 mclk_cntl;
- CARD32 gen_reset_cntl;
+ R128InfoPtr info = R128PTR(pScrn);
+ CARD32 clock_cntl_index;
+ CARD32 mclk_cntl;
+ CARD32 gen_reset_cntl;
R128MMIO_VARS();
R128EngineFlush(pScrn);
@@ -146,7 +160,7 @@ static void R128EngineReset(ScrnInfoPtr pScrn)
clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX);
mclk_cntl = INPLL(pScrn, R128_MCLK_CNTL);
- OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CPP);
+ OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP);
gen_reset_cntl = INREG(R128_GEN_RESET_CNTL);
@@ -158,17 +172,15 @@ static void R128EngineReset(ScrnInfoPtr pScrn)
OUTPLL(R128_MCLK_CNTL, mclk_cntl);
OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index);
OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl);
-}
-#define R128WaitForFifo(pScrn, entries) \
-do { \
- if (info->fifo_slots < entries) R128WaitForFifoFunction(pScrn, entries); \
- info->fifo_slots -= entries; \
-} while (0)
+#ifdef XF86DRI
+ if (R128CCE_USE_RING_BUFFER(info->CCEMode)) R128CCEResetRing(pScrn);
+#endif
+}
/* The FIFO has 64 slots. This routines waits until at least `entries' of
these slots are empty. */
-static void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
+void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
{
R128InfoPtr info = R128PTR(pScrn);
int i;
@@ -186,15 +198,19 @@ static void R128WaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"FIFO timed out, resetting engine...\n");
R128EngineReset(pScrn);
+#ifdef XF86DRI
+ if (info->CCE2D) R128CCEStart(pScrn);
+#endif
}
}
/* Wait for the graphics engine to be completely idle: the FIFO has
drained, the Pixel Cache is flushed, and the engine is idle. This is a
standard "sync" function that will make the hardware "quiescent". */
-static void R128WaitForIdle(ScrnInfoPtr pScrn)
+void R128WaitForIdle(ScrnInfoPtr pScrn)
{
- int i;
+ R128InfoPtr info = R128PTR(pScrn);
+ int i;
R128MMIO_VARS();
R128WaitForFifoFunction(pScrn, 64);
@@ -213,6 +229,9 @@ static void R128WaitForIdle(ScrnInfoPtr pScrn)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"Idle timed out, resetting engine...\n");
R128EngineReset(pScrn);
+#ifdef XF86DRI
+ if (info->CCE2D) R128CCEStart(pScrn);
+#endif
}
}
@@ -916,12 +935,12 @@ void R128EngineInit(ScrnInfoPtr pScrn)
R128InfoPtr info = R128PTR(pScrn);
R128MMIO_VARS();
- R128TRACE(("EngineInit (%d/%d)\n", info->pixel_code, pScrn->bitsPerPixel));
+ R128TRACE(("EngineInit (%d/%d)\n", info->CurrentLayout.pixel_code, info->CurrentLayout.bitsPerPixel));
OUTREG(R128_SCALE_3D_CNTL, 0);
R128EngineReset(pScrn);
- switch (info->pixel_code) {
+ switch (info->CurrentLayout.pixel_code) {
case 8: info->datatype = 2; break;
case 15: info->datatype = 3; break;
case 16: info->datatype = 4; break;
@@ -929,9 +948,10 @@ void R128EngineInit(ScrnInfoPtr pScrn)
case 32: info->datatype = 6; break;
default:
R128TRACE(("Unknown depth/bpp = %d/%d (code = %d)\n",
- pScrn->depth, pScrn->bitsPerPixel, info->pixel_code));
+ info->CurrentLayout.depth, info->CurrentLayout.bitsPerPixel,
+ info->CurrentLayout.pixel_code));
}
- info->pitch = (pScrn->displayWidth / 8) * (info->pixel_bytes == 3 ? 3 : 1);
+ info->pitch = (info->CurrentLayout.displayWidth / 8) * (info->CurrentLayout.pixel_bytes == 3 ? 3 : 1);
R128TRACE(("Pitch for acceleration = %d\n", info->pitch));
@@ -949,7 +969,7 @@ void R128EngineInit(ScrnInfoPtr pScrn)
info->dp_gui_master_cntl = ((info->datatype << R128_GMC_DST_DATATYPE_SHIFT)
| R128_GMC_CLR_CMP_CNTL_DIS
- | R128_AUX_CLIP_DIS
+ | R128_GMC_AUX_CLIP_DIS
| R128_GMC_DST_CLIPPING);
R128WaitForFifo(pScrn, 1);
OUTREG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl
@@ -966,19 +986,33 @@ void R128EngineInit(ScrnInfoPtr pScrn)
OUTREG(R128_DP_SRC_BKGD_CLR, 0x00000000);
OUTREG(R128_DP_WRITE_MASK, 0xffffffff);
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ OUTREGP(R128_DP_DATATYPE,
+ R128_HOST_BIG_ENDIAN_EN, ~R128_HOST_BIG_ENDIAN_EN);
+#else
+ OUTREGP(R128_DP_DATATYPE, 0, ~R128_HOST_BIG_ENDIAN_EN);
+#endif
+
R128WaitForIdle(pScrn);
}
-/* Initialize XAA for supported acceleration and also initialize the
- graphics hardware for acceleration. */
-Bool R128AccelInit(ScreenPtr pScreen)
+#ifdef XF86DRI
+ /* FIXME: When direct rendering is enabled, we should use the CCE to
+ draw 2D commands */
+static void R128CCEAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- R128InfoPtr info = R128PTR(pScrn);
- XAAInfoRecPtr a;
+ a->Flags = 0;
+
+ /* Sync */
+ a->Sync = R128CCEWaitForIdle;
+
+}
+#endif
+
+static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a)
+{
+ R128InfoPtr info = R128PTR(pScrn);
- if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
-
a->Flags = (PIXMAP_CACHE
| OFFSCREEN_PIXMAPS
| LINEAR_FRAMEBUFFER);
@@ -992,7 +1026,15 @@ Bool R128AccelInit(ScreenPtr pScreen)
a->SubsequentSolidFillRect = R128SubsequentSolidFillRect;
/* Screen-to-screen Copy */
- a->ScreenToScreenCopyFlags = 0;
+ /* Transparency uses the wrong colors for
+ 24 bpp mode -- the transparent part is
+ correct, but the opaque color is wrong.
+ This can be seen with netscape's I-bar
+ cursor when editing in the URL location
+ box. */
+ a->ScreenToScreenCopyFlags = ((pScrn->bitsPerPixel == 24)
+ ? NO_TRANSPARENCY
+ : 0);
a->SetupForScreenToScreenCopy = R128SetupForScreenToScreenCopy;
a->SubsequentScreenToScreenCopy = R128SubsequentScreenToScreenCopy;
@@ -1039,7 +1081,7 @@ Bool R128AccelInit(ScreenPtr pScreen)
| LINE_PATTERN_POWER_OF_2_ONLY);
#if R128_CLIPPING
/* Clipping. */
- if (pScrn->depth != 8 && info->pixel_code != 24) {
+ if (info->CurrentLayout.depth != 8 && info->CurrentLayout.pixel_code != 24) {
/* There is one xtest error in 8bpp and
many xtest errors in 24/24 that do not
appear at other depths. */
@@ -1065,7 +1107,26 @@ Bool R128AccelInit(ScreenPtr pScreen)
| SCANLINE_PAD_DWORD
| SYNC_AFTER_IMAGE_WRITE);
#endif
-
+}
+
+/* Initialize XAA for supported acceleration and also initialize the
+ graphics hardware for acceleration. */
+Bool R128AccelInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr info = R128PTR(pScrn);
+ XAAInfoRecPtr a;
+
+ if (!(a = info->accel = XAACreateInfoRec())) return FALSE;
+
+#ifdef XF86DRI
+ /* FIXME: When direct rendering is enabled, we should use the CCE to
+ draw 2D commands */
+ if (info->CCE2D) R128CCEAccelInit(pScrn, a);
+ else
+#endif
+ R128MMIOAccelInit(pScrn, a);
+
R128EngineInit(pScrn);
return XAAInit(pScreen, a);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c
index a96872702..586a5c36a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c
@@ -1,8 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c,v 1.6 2000/03/06 22:59:26 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_cursor.c,v 1.9 2000/06/17 00:27:32 dawes Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -60,6 +60,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* DDC support */
#include "xf86DDC.h"
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
/* Driver data structures */
#include "r128.h"
#include "r128_reg.h"
@@ -92,16 +105,19 @@ static void R128SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
(xorigin,yorigin). */
static void R128SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
- R128InfoPtr info = R128PTR(pScrn);
- int xorigin = 0;
- int yorigin = 0;
- int total_y = pScrn->frameY1 - pScrn->frameY0;
+ R128InfoPtr info = R128PTR(pScrn);
+ xf86CursorInfoPtr cursor = info->cursor;
+ int xorigin = 0;
+ int yorigin = 0;
+ int total_y = pScrn->frameY1 - pScrn->frameY0;
R128MMIO_VARS();
- if (x < 0) xorigin = -x;
- if (y < 0) yorigin = -y;
- if (y > total_y) y = total_y;
- if (info->Flags & V_DBLSCAN) y *= 2;
+ if (x < 0) xorigin = -x;
+ if (y < 0) yorigin = -y;
+ if (y > total_y) y = total_y;
+ if (info->Flags & V_DBLSCAN) y *= 2;
+ if (xorigin >= cursor->MaxWidth) xorigin = cursor->MaxWidth - 1;
+ if (yorigin >= cursor->MaxHeight) yorigin = cursor->MaxHeight - 1;
OUTREG(R128_CUR_HORZ_VERT_OFF, R128_CUR_LOCK | (xorigin << 16) | yorigin);
OUTREG(R128_CUR_HORZ_VERT_POSN, (R128_CUR_LOCK
@@ -125,48 +141,59 @@ static void R128LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image)
OUTREG(R128_CRTC_GEN_CNTL, save & ~R128_CRTC_CUR_EN);
#if X_BYTE_ORDER == X_BIG_ENDIAN
- switch(info->pixel_bytes) {
- case 4:
- case 3:
- for (y = 0; y < 64; y++) {
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- }
- break;
- case 2:
- for (y = 0; y < 64; y++) {
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- }
- break;
- default:
- for (y = 0; y < 64; y++) {
+ switch(info->CurrentLayout.pixel_bytes) {
+ case 4:
+ case 3:
+ for (y = 0; y < 64; y++) {
+ P_SWAP32(d,s);
+ d++; s++;
+ P_SWAP32(d,s);
+ d++; s++;
+ P_SWAP32(d,s);
+ d++; s++;
+ P_SWAP32(d,s);
+ d++; s++;
+ }
+ break;
+ case 2:
+ for (y = 0; y < 64; y++) {
+ P_SWAP16(d,s);
+ d++; s++;
+ P_SWAP16(d,s);
+ d++; s++;
+ P_SWAP16(d,s);
+ d++; s++;
+ P_SWAP16(d,s);
+ d++; s++;
+ }
+ break;
+ default:
+ for (y = 0; y < 64; y++) {
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
- }
+ }
}
#else
- for (y = 0; y < 64; y++) {
+ for (y = 0; y < 64; y++) {
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
*d++ = *s++;
}
#endif
+
+ /* Set the area after the cursor to be all transparent so that we
+ won't display corrupted cursors on the screen */
+ for (y = 0; y < 64; y++) {
+ *d++ = 0xffffffff; /* The AND bits */
+ *d++ = 0xffffffff;
+ *d++ = 0x00000000; /* The XOR bits */
+ *d++ = 0x00000000;
+ }
+
+
OUTREG(R128_CRTC_GEN_CNTL, save);
}
@@ -204,6 +231,7 @@ Bool R128CursorInit(ScreenPtr pScreen)
FBAreaPtr fbarea;
int width;
int height;
+ int size;
if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE;
@@ -227,8 +255,9 @@ Bool R128CursorInit(ScreenPtr pScreen)
cursor->ShowCursor = R128ShowCursor;
cursor->UseHWCursor = R128UseHWCursor;
+ size = (cursor->MaxWidth/4) * cursor->MaxHeight;
width = pScrn->displayWidth;
- height = (1024 + 1023) / pScrn->displayWidth;
+ height = (size*2 + 1023) / pScrn->displayWidth;
fbarea = xf86AllocateOffscreenArea(pScreen,
width,
height,
@@ -245,8 +274,8 @@ Bool R128CursorInit(ScreenPtr pScreen)
} else {
info->cursor_start = R128_ALIGN((fbarea->box.x1
+ width * fbarea->box.y1)
- * info->pixel_bytes, 16);
- info->cursor_end = info->cursor_start + 1024;
+ * info->CurrentLayout.pixel_bytes, 16);
+ info->cursor_end = info->cursor_start + size;
}
R128TRACE(("R128CursorInit (0x%08x-0x%08x)\n",
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c
new file mode 100644
index 000000000..918928861
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c
@@ -0,0 +1,378 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dga.c,v 1.2 2000/06/17 00:03:22 martin Exp $ */
+/*
+ * Authors:
+ * Ove Kåven <ovek@transgaming.com>,
+ * borrowing some code from the Chips and MGA drivers.
+ */
+
+ /* X and server generic header files */
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+ /* PCI support */
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+
+ /* DDC support */
+#include "xf86DDC.h"
+
+ /* XAA and Cursor Support */
+#include "xaa.h"
+#include "xaalocal.h"
+#include "xf86Cursor.h"
+
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
+ /* Driver data structures */
+#include "r128.h"
+
+ /* DGA support */
+#include "dgaproc.h"
+
+
+static Bool R128_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
+ int *, int *, int *);
+static Bool R128_SetMode(ScrnInfoPtr, DGAModePtr);
+static int R128_GetViewport(ScrnInfoPtr);
+static void R128_SetViewport(ScrnInfoPtr, int, int, int);
+static void R128_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
+static void R128_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
+static void R128_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int,
+ unsigned long);
+
+static
+DGAFunctionRec R128_DGAFuncs = {
+ R128_OpenFramebuffer,
+ NULL,
+ R128_SetMode,
+ R128_SetViewport,
+ R128_GetViewport,
+ R128WaitForIdle,
+ R128_FillRect,
+ R128_BlitRect,
+#if 0
+ R128_BlitTransRect
+#else
+ NULL
+#endif
+};
+
+
+static DGAModePtr
+R128SetupDGAMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr modes,
+ int *num,
+ int bitsPerPixel,
+ int depth,
+ Bool pixmap,
+ int secondPitch,
+ unsigned long red,
+ unsigned long green,
+ unsigned long blue,
+ short visualClass
+){
+ R128InfoPtr info = R128PTR(pScrn);
+ DGAModePtr newmodes = NULL, currentMode;
+ DisplayModePtr pMode, firstMode;
+ int otherPitch, Bpp = bitsPerPixel >> 3;
+ Bool oneMore;
+
+ pMode = firstMode = pScrn->modes;
+
+ while(pMode) {
+
+ otherPitch = secondPitch ? secondPitch : pMode->HDisplay;
+
+ if(pMode->HDisplay != otherPitch) {
+ newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+ newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+ xfree(modes);
+ return NULL;
+ }
+ modes = newmodes;
+
+SECOND_PASS:
+
+ currentMode = modes + *num;
+ (*num)++;
+
+ currentMode->mode = pMode;
+ /* FIXME: is concurrent access really possible? */
+ currentMode->flags = DGA_CONCURRENT_ACCESS;
+ if(pixmap)
+ currentMode->flags |= DGA_PIXMAP_AVAILABLE;
+ if(info->accel)
+ currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
+ if(pMode->Flags & V_DBLSCAN)
+ currentMode->flags |= DGA_DOUBLESCAN;
+ if(pMode->Flags & V_INTERLACE)
+ currentMode->flags |= DGA_INTERLACED;
+ currentMode->byteOrder = pScrn->imageByteOrder;
+ currentMode->depth = depth;
+ currentMode->bitsPerPixel = bitsPerPixel;
+ currentMode->red_mask = red;
+ currentMode->green_mask = green;
+ currentMode->blue_mask = blue;
+ currentMode->visualClass = visualClass;
+ currentMode->viewportWidth = pMode->HDisplay;
+ currentMode->viewportHeight = pMode->VDisplay;
+ currentMode->xViewportStep = 8;
+ currentMode->yViewportStep = 1;
+ currentMode->viewportFlags = DGA_FLIP_RETRACE;
+ currentMode->offset = 0;
+ currentMode->address = (unsigned char*)info->LinearAddr;
+
+ if(oneMore) { /* first one is narrow width */
+ currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pMode->HDisplay;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ oneMore = FALSE;
+ goto SECOND_PASS;
+ } else {
+ currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = otherPitch;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ }
+
+ pMode = pMode->next;
+ if(pMode == firstMode)
+ break;
+ }
+
+ return modes;
+}
+
+
+Bool
+R128DGAInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr info = R128PTR(pScrn);
+ DGAModePtr modes = NULL;
+ int num = 0;
+
+ /* 8 */
+ modes = R128SetupDGAMode (pScrn, modes, &num, 8, 8,
+ (pScrn->bitsPerPixel == 8),
+ (pScrn->bitsPerPixel != 8) ? 0 : pScrn->displayWidth,
+ 0, 0, 0, PseudoColor);
+
+ /* 15 */
+ modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15,
+ (pScrn->bitsPerPixel == 16),
+ (pScrn->depth != 15) ? 0 : pScrn->displayWidth,
+ 0x7c00, 0x03e0, 0x001f, TrueColor);
+
+ modes = R128SetupDGAMode (pScrn, modes, &num, 16, 15,
+ (pScrn->bitsPerPixel == 16),
+ (pScrn->depth != 15) ? 0 : pScrn->displayWidth,
+ 0x7c00, 0x03e0, 0x001f, DirectColor);
+
+ /* 16 */
+ modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16,
+ (pScrn->bitsPerPixel == 16),
+ (pScrn->depth != 16) ? 0 : pScrn->displayWidth,
+ 0xf800, 0x07e0, 0x001f, TrueColor);
+
+ modes = R128SetupDGAMode (pScrn, modes, &num, 16, 16,
+ (pScrn->bitsPerPixel == 16),
+ (pScrn->depth != 16) ? 0 : pScrn->displayWidth,
+ 0xf800, 0x07e0, 0x001f, DirectColor);
+
+ /* 24 */
+ modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24,
+ (pScrn->bitsPerPixel == 24),
+ (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth,
+ 0xff0000, 0x00ff00, 0x0000ff, TrueColor);
+
+ modes = R128SetupDGAMode (pScrn, modes, &num, 24, 24,
+ (pScrn->bitsPerPixel == 24),
+ (pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth,
+ 0xff0000, 0x00ff00, 0x0000ff, DirectColor);
+
+ /* 32 */
+ modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24,
+ (pScrn->bitsPerPixel == 32),
+ (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth,
+ 0xff0000, 0x00ff00, 0x0000ff, TrueColor);
+
+ modes = R128SetupDGAMode (pScrn, modes, &num, 32, 24,
+ (pScrn->bitsPerPixel == 32),
+ (pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth,
+ 0xff0000, 0x00ff00, 0x0000ff, DirectColor);
+
+ info->numDGAModes = num;
+ info->DGAModes = modes;
+
+ return DGAInit(pScreen, &R128_DGAFuncs, modes, num);
+}
+
+
+static Bool
+R128_SetMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr pMode
+){
+ static R128FBLayout SavedLayouts[MAXSCREENS];
+ int index = pScrn->pScreen->myNum;
+ R128InfoPtr info = R128PTR(pScrn);
+
+ if(!pMode) { /* restore the original mode */
+ /* put the ScreenParameters back */
+ if(info->DGAactive)
+ memcpy(&info->CurrentLayout, &SavedLayouts[index], sizeof(R128FBLayout));
+
+ pScrn->currentMode = info->CurrentLayout.mode;
+
+ R128SwitchMode(index, pScrn->currentMode, 0);
+ R128AdjustFrame(index, 0, 0, 0);
+ info->DGAactive = FALSE;
+ } else {
+ if(!info->DGAactive) { /* save the old parameters */
+ memcpy(&SavedLayouts[index], &info->CurrentLayout, sizeof(R128FBLayout));
+ info->DGAactive = TRUE;
+ }
+
+ info->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel;
+ info->CurrentLayout.depth = pMode->depth;
+ info->CurrentLayout.displayWidth = pMode->bytesPerScanline /
+ (pMode->bitsPerPixel >> 3);
+ info->CurrentLayout.pixel_bytes = pMode->bitsPerPixel / 8;
+ info->CurrentLayout.pixel_code = (pMode->bitsPerPixel != 16
+ ? pMode->bitsPerPixel
+ : pMode->depth);
+ /* R128ModeInit() will set the mode field */
+
+ R128SwitchMode(index, pMode->mode, 0);
+ }
+
+ return TRUE;
+}
+
+
+
+static int
+R128_GetViewport(
+ ScrnInfoPtr pScrn
+){
+ R128InfoPtr info = R128PTR(pScrn);
+
+ return info->DGAViewportStatus;
+}
+
+
+static void
+R128_SetViewport(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int flags
+){
+ R128InfoPtr info = R128PTR(pScrn);
+
+ R128AdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+ info->DGAViewportStatus = 0; /* FIXME */
+}
+
+
+static void
+R128_FillRect (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+){
+ R128InfoPtr info = R128PTR(pScrn);
+
+ if(info->accel) {
+ (*info->accel->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
+ (*info->accel->SubsequentSolidFillRect)(pScrn, x, y, w, h);
+ SET_SYNC_FLAG(info->accel);
+ }
+}
+
+static void
+R128_BlitRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+){
+ R128InfoPtr info = R128PTR(pScrn);
+
+ if(info->accel) {
+ int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
+ int ydir = (srcy < dsty) ? -1 : 1;
+
+ (*info->accel->SetupForScreenToScreenCopy)(
+ pScrn, xdir, ydir, GXcopy, ~0, -1);
+ (*info->accel->SubsequentScreenToScreenCopy)(
+ pScrn, srcx, srcy, dstx, dsty, w, h);
+ SET_SYNC_FLAG(info->accel);
+ }
+}
+
+
+static void
+R128_BlitTransRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+){
+ /* this one should be separate since the XAA function would
+ prohibit usage of ~0 as the key */
+}
+
+
+static Bool
+R128_OpenFramebuffer(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ R128InfoPtr info = R128PTR(pScrn);
+
+ *name = NULL; /* no special device */
+ *mem = (unsigned char*)info->LinearAddr;
+ *size = info->FbMapSize;
+ *offset = 0;
+ *flags = /* DGA_NEED_ROOT */ 0; /* don't need root, just /dev/mem access */
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
new file mode 100644
index 000000000..21bf547d2
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c
@@ -0,0 +1,1289 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.c,v 1.4 2000/06/26 05:41:32 martin Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and 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
+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
+ATI, PRECISION INSIGHT 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 <kevin@precisioninsight.com>
+ * Rickard E. Faith <faith@precisioninsight.com>
+ * Daryll Strauss <daryll@precisioninsight.com>
+ *
+ */
+
+
+ /* X and server generic header files */
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Resources.h"
+#include "xf86RAC.h"
+#include "xf86cmap.h"
+#include "xf86fbman.h"
+
+ /* Backing store, software cursor, and
+ colormap initialization */
+#include "mibstore.h"
+#include "mipointer.h"
+#include "micmap.h"
+
+ /* CFB support */
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb24.h"
+#include "cfb32.h"
+#include "cfb24_32.h"
+
+ /* XAA and Cursor Support */
+#include "xaa.h"
+#include "xf86Cursor.h"
+
+ /* PCI support */
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+
+ /* DDC support */
+#include "xf86DDC.h"
+
+ /* DRI support */
+#include "GL/glxint.h"
+#include "GL/glxtokens.h"
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_sarea.h"
+#include "r128_dripriv.h"
+
+ /* Driver data structures */
+#include "r128.h"
+#include "r128_reg.h"
+
+#define R128_WATERMARK_L 16
+#define R128_WATERMARK_M 8
+#define R128_WATERMARK_N 8
+#define R128_WATERMARK_K 128
+
+static int CCEFifoSlots = 0;
+
+#define R128CCEWaitForFifo(pScrn, entries) \
+do { \
+ if (CCEFifoSlots < entries) R128WaitForFifoFunction(pScrn, entries); \
+ CCEFifoSlots -= entries; \
+} while (0)
+
+/* Wait for at least `entries' slots are free. The actual number of
+ slots available is stored in info->CCEFifoSize. */
+static void R128CCEWaitForFifoFunction(ScrnInfoPtr pScrn, int entries)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ int i;
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK;
+ if (CCEFifoSlots >= entries) return;
+ }
+ R128EngineReset(pScrn);
+ if (info->CCE2D) R128CCEStart(pScrn);
+ }
+}
+
+/* Wait until the CCE is completely idle: the FIFO has drained and the
+ CCE is idle. */
+void R128CCEWaitForIdle(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ int i;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ if (R128CCE_USE_RING_BUFFER(info->CCEMode)) {
+ volatile CARD32 *r128RingReadPtr =
+ (volatile CARD32 *)(info->ringReadPtr);
+ R128SAREAPrivPtr pSAREAPriv;
+
+ OUTREGP(R128_PM4_BUFFER_DL_WPTR,
+ R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE);
+
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen);
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (*r128RingReadPtr == pSAREAPriv->ringWrite) {
+ int pm4stat = INREG(R128_PM4_STAT);
+ if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= info->CCEFifoSize
+ && !(pm4stat & (R128_PM4_BUSY|R128_PM4_GUI_ACTIVE))) {
+ R128EngineFlush(pScrn);
+ return;
+ }
+ }
+ }
+ R128EngineReset(pScrn);
+ if (info->CCE2D) R128CCEStart(pScrn);
+ }
+ } else {
+ R128CCEWaitForFifoFunction(pScrn, info->CCEFifoSize);
+
+ for (;;) {
+ for (i = 0; i < R128_TIMEOUT; i++) {
+ if (!(INREG(R128_PM4_STAT)
+ & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
+ R128EngineFlush(pScrn);
+ return;
+ }
+ }
+ R128EngineReset(pScrn);
+ if (info->CCE2D) R128CCEStart(pScrn);
+ }
+ }
+}
+
+/* Reset the ring buffer status, if the engine was reset */
+void R128CCEResetRing(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ R128SAREAPrivPtr pSAREAPriv;
+ volatile CARD32 *r128RingReadPtr;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ r128RingReadPtr = (volatile CARD32 *)(info->ringReadPtr);
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScrn->pScreen);
+
+ OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
+ OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
+ pSAREAPriv->ringWrite = 0;
+ *r128RingReadPtr = 0;
+
+ /* Resetting the ring turns off the CCE */
+ info->CCEInUse = FALSE;
+}
+
+/* Start the CCE, but only if it is not already in use and the requested
+ mode is a CCE mode. The mode is stored in info->CCEMode. */
+void R128CCEStart(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ if (info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ R128WaitForIdle(pScrn);
+ OUTREG(R128_PM4_BUFFER_CNTL, info->CCEMode | info->ringSizeLog2QW);
+ (void)INREG(R128_PM4_BUFFER_ADDR); /* as per the sample code */
+ OUTREG(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+ info->CCEInUse = TRUE;
+}
+
+/* Stop the CCE, but only if it is in use and the requested mode is not
+ the non-CCE mode. This function also flushes any outstanding
+ requests before switching modes.*/
+void R128CCEStop(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ if (!info->CCEInUse || info->CCEMode == R128_PM4_NONPM4) return;
+
+ R128CCEWaitForIdle(pScrn);
+ OUTREG(R128_PM4_MICRO_CNTL, 0);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+ R128EngineReset(pScrn);
+ info->CCEInUse = FALSE;
+}
+
+/* Initialize the visual configs that are supported by the hardware.
+ These are combined with the visual configs that the indirect
+ rendering core supports, and the intersection is exported to the
+ client. */
+static Bool R128InitVisualConfigs(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ int numConfigs = 0;
+ __GLXvisualConfig *pConfigs = 0;
+ R128ConfigPrivPtr pR128Configs = 0;
+ R128ConfigPrivPtr *pR128ConfigPtrs = 0;
+ int i, accum, stencil;
+
+ switch (pR128->CurrentLayout.pixel_code) {
+ case 8: /* 8bpp mode is not support */
+ case 15: /* FIXME?? */
+ case 24: /* FIXME?? */
+ return FALSE;
+
+#define R128_USE_ACCUM 1
+#define R128_USE_STENCIL 1
+
+ case 16:
+ numConfigs = 1;
+ if (R128_USE_ACCUM) numConfigs *= 2;
+ if (R128_USE_STENCIL) numConfigs *= 2;
+
+ if (!(pConfigs
+ = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+ if (!(pR128Configs
+ = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec),
+ numConfigs))) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+ if (!(pR128ConfigPtrs
+ = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr),
+ numConfigs))) {
+ xfree(pConfigs);
+ xfree(pR128Configs);
+ return FALSE;
+ }
+
+ i = 0;
+ for (accum = 0; accum <= R128_USE_ACCUM; accum++) {
+ for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) {
+ pR128ConfigPtrs[i] = &pR128Configs[i];
+
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].alphaSize = 0;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+ pConfigs[i].alphaMask = 0x00000000;
+ if (accum) { /* Simulated in software */
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ pConfigs[i].doubleBuffer = TRUE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ pConfigs[i].depthSize = 16;
+ if (stencil)
+ pConfigs[i].stencilSize = 8; /* Simulated in software */
+ else
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = GLX_NONE;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ break;
+ case 32:
+ numConfigs = 1;
+ if (R128_USE_ACCUM) numConfigs *= 2;
+ if (R128_USE_STENCIL) numConfigs *= 2;
+
+ if (!(pConfigs
+ = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
+ numConfigs))) {
+ return FALSE;
+ }
+ if (!(pR128Configs
+ = (R128ConfigPrivPtr)xnfcalloc(sizeof(R128ConfigPrivRec),
+ numConfigs))) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+ if (!(pR128ConfigPtrs
+ = (R128ConfigPrivPtr*)xnfcalloc(sizeof(R128ConfigPrivPtr),
+ numConfigs))) {
+ xfree(pConfigs);
+ xfree(pR128Configs);
+ return FALSE;
+ }
+
+ i = 0;
+ for (accum = 0; accum <= R128_USE_ACCUM; accum++) {
+ for (stencil = 0; stencil <= R128_USE_STENCIL; stencil++) {
+ pR128ConfigPtrs[i] = &pR128Configs[i];
+
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 8;
+ pConfigs[i].greenSize = 8;
+ pConfigs[i].blueSize = 8;
+ pConfigs[i].alphaSize = 8;
+ pConfigs[i].redMask = 0x00FF0000;
+ pConfigs[i].greenMask = 0x0000FF00;
+ pConfigs[i].blueMask = 0x000000FF;
+ pConfigs[i].alphaMask = 0xFF000000;
+ if (accum) { /* Simulated in software */
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 16;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ pConfigs[i].doubleBuffer = TRUE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 24;
+ if (stencil) {
+ pConfigs[i].depthSize = 24;
+ pConfigs[i].stencilSize = 8;
+ } else {
+ pConfigs[i].depthSize = 32;
+ pConfigs[i].stencilSize = 0;
+ }
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = GLX_NONE;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ break;
+ }
+
+ pR128->numVisualConfigs = numConfigs;
+ pR128->pVisualConfigs = pConfigs;
+ pR128->pVisualConfigsPriv = pR128Configs;
+ GlxSetVisualConfigs(numConfigs, pConfigs, (void**)pR128ConfigPtrs);
+ return TRUE;
+}
+
+/* Create the Rage 128-specific context information */
+static Bool R128CreateContext(ScreenPtr pScreen, VisualPtr visual,
+ drmContext hwContext, void *pVisualConfigPriv,
+ DRIContextType contextStore)
+{
+ /* Nothing yet */
+ return TRUE;
+}
+
+/* Destroy the Rage 128-specific context information */
+static void R128DestroyContext(ScreenPtr pScreen, drmContext hwContext,
+ DRIContextType contextStore)
+{
+ /* Nothing yet */
+}
+
+/* Called when the X server is woken up to allow the last client's
+ context to be saved and the X server's context to be loaded. This is
+ not necessary for the Rage 128 since the client detects when it's
+ context is not currently loaded and then load's it itself. Since the
+ registers to start and stop the CCE are privileged, only the X server
+ can start/stop the engine. */
+static void R128EnterServer(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ if (pR128->accel) pR128->accel->NeedToSync = TRUE;
+
+#if 1
+ if (!pR128->CCE2D) R128CCEStop(pScrn);
+#else
+ if (pR128->CCE2D) R128CCEWaitForIdle(pScrn);
+ else R128CCEStop(pScrn);
+#endif
+}
+
+/* Called when the X server goes to sleep to allow the X server's
+ context to be saved and the last client's context to be loaded. This
+ is not necessary for the Rage 128 since the client detects when it's
+ context is not currently loaded and then load's it itself. Since the
+ registers to start and stop the CCE are privileged, only the X server
+ can start/stop the engine. */
+static void R128LeaveServer(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+#if 1
+ if (!pR128->CCE2D) R128CCEStart(pScrn);
+#else
+ if (pR128->CCE2D) R128CCEWaitForIdle(pScrn);
+ else R128CCEStart(pScrn);
+#endif
+}
+
+/* Contexts can be swapped by the X server if necessary. This callback
+ is currently only used to perform any functions necessary when
+ entering or leaving the X server, and in the future might not be
+ necessary. */
+static void R128DRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
+ DRIContextType oldContextType, void *oldContext,
+ DRIContextType newContextType, void *newContext)
+{
+ if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
+ R128EnterServer(pScreen);
+ }
+ if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
+ R128LeaveServer(pScreen);
+ }
+}
+
+/* Initialize the state of the back and depth buffers. */
+static void R128DRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
+{
+ /* FIXME: This routine needs to have acceleration turned on */
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ BoxPtr pbox;
+ int nbox;
+ int depth;
+
+ /* FIXME: Use accel when CCE 2D code is written */
+ if (pR128->CCE2D) return;
+
+ /* FIXME: This should be based on the __GLXvisualConfig info */
+ switch (pScrn->bitsPerPixel) {
+ case 8: depth = 0x000000ff; break;
+ case 16: depth = 0x0000ffff; break;
+ case 24: depth = 0x00ffffff; break;
+ case 32: depth = 0xffffffff; break;
+ default: depth = 0x00000000; break;
+ }
+
+ /* FIXME: Copy XAAPaintWindow() and use REGION_TRANSLATE() */
+ /* FIXME: Only initialize the back and depth buffers for contexts
+ that request them */
+
+ pbox = REGION_RECTS(prgn);
+ nbox = REGION_NUM_RECTS(prgn);
+
+ (*pR128->accel->SetupForSolidFill)(pScrn, 0, GXcopy, -1);
+ for (; nbox; nbox--, pbox++) {
+ (*pR128->accel->SubsequentSolidFillRect)(pScrn,
+ pbox->x1 + pR128->fbX,
+ pbox->y1 + pR128->fbY,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ (*pR128->accel->SubsequentSolidFillRect)(pScrn,
+ pbox->x1 + pR128->backX,
+ pbox->y1 + pR128->backY,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+ }
+
+ (*pR128->accel->SetupForSolidFill)(pScrn, depth, GXcopy, -1);
+ for (; nbox; nbox--, pbox++)
+ (*pR128->accel->SubsequentSolidFillRect)(pScrn,
+ pbox->x1 + pR128->depthX,
+ pbox->y1 + pR128->depthY,
+ pbox->x2 - pbox->x1,
+ pbox->y2 - pbox->y1);
+
+ pR128->accel->NeedToSync = TRUE;
+}
+
+/* Copy the back and depth buffers when the X server moves a window. */
+static void R128DRIMoveBuffers(WindowPtr pWin, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ /* FIXME: This routine needs to have acceleration turned on */
+ /* FIXME: Copy XAACopyWindow() and use REGION_TRANSLATE() */
+ /* FIXME: Only initialize the back and depth buffers for contexts
+ that request them */
+
+ /* FIXME: Use accel when CCE 2D code is written */
+ if (pR128->CCE2D) return;
+}
+
+/* Initialize the AGP state. Request memory for use in AGP space, and
+ initialize the Rage 128 registers to point to that memory. */
+static Bool R128DRIAgpInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ unsigned char *R128MMIO = pR128->MMIO;
+ unsigned long mode;
+ unsigned int vendor, device;
+ int ret;
+ unsigned long cntl;
+ int s, l;
+ int flags;
+
+ if (drmAgpAcquire(pR128->drmFD) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not available\n");
+ return FALSE;
+ }
+
+ /* Modify the mode if the default mode is
+ not appropriate for this particular
+ combination of graphics card and AGP
+ chipset. */
+
+ mode = drmAgpGetMode(pR128->drmFD); /* Default mode */
+ vendor = drmAgpVendorId(pR128->drmFD);
+ device = drmAgpDeviceId(pR128->drmFD);
+
+ mode &= ~R128_AGP_MODE_MASK;
+ switch (pR128->agpMode) {
+ case 2: mode |= R128_AGP_2X_MODE;
+ case 1: default: mode |= R128_AGP_1X_MODE;
+ }
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Mode 0x%08lx [AGP 0x%04x/0x%04x; Card 0x%04x/0x%04x]\n",
+ mode, vendor, device,
+ pR128->PciInfo->vendor,
+ pR128->PciInfo->chipType);
+
+ if (drmAgpEnable(pR128->drmFD, mode) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] AGP not enabled\n");
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+
+ pR128->agpOffset = 0;
+
+ if ((ret = drmAgpAlloc(pR128->drmFD, pR128->agpSize*1024*1024, 0, NULL,
+ &pR128->agpMemHandle)) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Out of memory (%d)\n", ret);
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] %d kB allocated with handle 0x%08x\n",
+ pR128->agpSize*1024, pR128->agpMemHandle);
+
+ if (drmAgpBind(pR128->drmFD, pR128->agpMemHandle, pR128->agpOffset) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not bind\n");
+ drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
+ drmAgpRelease(pR128->drmFD);
+ return FALSE;
+ }
+
+ /* Initialize the CCE ring buffer data */
+ pR128->ringStart = pR128->agpOffset;
+ pR128->ringMapSize = pR128->ringSize*1024*1024 + 4096;
+ pR128->ringSizeLog2QW = R128MinBits(pR128->ringSize*1024*1024/8) - 1;
+
+ pR128->ringReadOffset = pR128->ringStart + pR128->ringMapSize;
+ pR128->ringReadMapSize = 4096;
+
+ /* Reserve space for the vertex buffer */
+ pR128->vbStart = pR128->ringReadOffset + pR128->ringReadMapSize;
+ pR128->vbMapSize = pR128->vbSize*1024*1024;
+
+ /* Reserve space for the indirect buffer */
+ pR128->indStart = pR128->vbStart + pR128->vbMapSize;
+ pR128->indMapSize = pR128->indSize*1024*1024;
+
+ /* Reserve the rest for AGP textures */
+ pR128->agpTexStart = pR128->indStart + pR128->indMapSize;
+ s = (pR128->agpSize*1024*1024 - pR128->agpTexStart);
+ l = R128MinBits((s-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+ pR128->agpTexMapSize = (s >> l) << l;
+ pR128->log2AGPTexGran = l;
+
+ if (pR128->CCESecure) flags = DRM_READ_ONLY;
+ else flags = 0;
+
+ if (drmAddMap(pR128->drmFD, pR128->ringStart, pR128->ringMapSize,
+ DRM_AGP, flags, &pR128->ringHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add ring mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] ring handle = 0x%08lx\n", pR128->ringHandle);
+
+ if (drmMap(pR128->drmFD, pR128->ringHandle, pR128->ringMapSize,
+ (drmAddressPtr)&pR128->ring) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "[agp] Could not map ring\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Ring mapped at 0x%08lx\n",
+ (unsigned long)pR128->ring);
+
+ if (drmAddMap(pR128->drmFD, pR128->ringReadOffset, pR128->ringReadMapSize,
+ DRM_AGP, flags, &pR128->ringReadPtrHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add ring read ptr mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] ring read ptr handle = 0x%08lx\n",
+ pR128->ringReadPtrHandle);
+
+ if (drmMap(pR128->drmFD, pR128->ringReadPtrHandle, pR128->ringReadMapSize,
+ (drmAddressPtr)&pR128->ringReadPtr) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map ring read ptr\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Ring read ptr mapped at 0x%08lx\n",
+ (unsigned long)pR128->ringReadPtr);
+
+ if (drmAddMap(pR128->drmFD, pR128->vbStart, pR128->vbMapSize,
+ DRM_AGP, 0, &pR128->vbHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add vertex buffers mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] vertex buffers handle = 0x%08lx\n", pR128->vbHandle);
+
+ if (drmMap(pR128->drmFD, pR128->vbHandle, pR128->vbMapSize,
+ (drmAddressPtr)&pR128->vb) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map vertex buffers\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Vertex buffers mapped at 0x%08lx\n",
+ (unsigned long)pR128->vb);
+
+ if (drmAddMap(pR128->drmFD, pR128->indStart, pR128->indMapSize,
+ DRM_AGP, flags, &pR128->indHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add indirect buffers mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] indirect buffers handle = 0x%08lx\n", pR128->indHandle);
+
+ if (drmMap(pR128->drmFD, pR128->indHandle, pR128->indMapSize,
+ (drmAddressPtr)&pR128->ind) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map indirect buffers\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] Indirect buffers mapped at 0x%08lx\n",
+ (unsigned long)pR128->ind);
+
+ if (drmAddMap(pR128->drmFD, pR128->agpTexStart, pR128->agpTexMapSize,
+ DRM_AGP, 0, &pR128->agpTexHandle) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not add AGP texture map mapping\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] AGP texture map handle = 0x%08lx\n",
+ pR128->agpTexHandle);
+
+ if (drmMap(pR128->drmFD, pR128->agpTexHandle, pR128->agpTexMapSize,
+ (drmAddressPtr)&pR128->agpTex) < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Could not map AGP texture map\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[agp] AGP Texture map mapped at 0x%08lx\n",
+ (unsigned long)pR128->agpTex);
+
+ /* Initialize Rage 128's AGP registers */
+ cntl = INREG(R128_AGP_CNTL);
+ cntl &= ~R128_AGP_APER_SIZE_MASK;
+ switch (pR128->agpSize) {
+ case 256: cntl |= R128_AGP_APER_SIZE_256MB; break;
+ case 128: cntl |= R128_AGP_APER_SIZE_128MB; break;
+ case 64: cntl |= R128_AGP_APER_SIZE_64MB; break;
+ case 32: cntl |= R128_AGP_APER_SIZE_32MB; break;
+ case 16: cntl |= R128_AGP_APER_SIZE_16MB; break;
+ case 8: cntl |= R128_AGP_APER_SIZE_8MB; break;
+ case 4: cntl |= R128_AGP_APER_SIZE_4MB; break;
+ default:
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[agp] Illegal aperture size %d kB\n",
+ pR128->agpSize*1024);
+ return FALSE;
+ }
+ OUTREG(R128_AGP_BASE, pR128->ringHandle); /* Ring buf is at AGP offset 0 */
+ OUTREG(R128_AGP_CNTL, cntl);
+
+ return TRUE;
+}
+
+/* Add a map for the MMIO registers that will be accessed by any
+ DRI-based clients. */
+static Bool R128DRIMapInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ int flags;
+
+ if (pR128->CCESecure) flags = DRM_READ_ONLY;
+ else flags = 0;
+
+ /* Map registers */
+ pR128->registerSize = R128_MMIOSIZE;
+ if (drmAddMap(pR128->drmFD, pR128->MMIOAddr, pR128->registerSize,
+ DRM_REGISTERS, flags, &pR128->registerHandle) < 0) {
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] register handle = 0x%08lx\n", pR128->registerHandle);
+
+ return TRUE;
+}
+
+/* Initialize the ring buffer state for use in the X server and any
+ DRI-based clients. */
+static void R128DRICCEInitRingBuffer(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+ unsigned long addr;
+
+ /* FIXME: When we use the CCE for the X server, we should move this
+ function (and the support functions above) to r128_accel.c */
+
+ /* The manual (p. 2) says this address is
+ in "VM space". This means it's an
+ offset from the start of AGP space. */
+ OUTREG(R128_PM4_BUFFER_OFFSET, info->ringStart | 0x02000000);
+
+ OUTREG(R128_PM4_BUFFER_DL_WPTR, 0);
+ OUTREG(R128_PM4_BUFFER_DL_RPTR, 0);
+
+ /* DL_RPTR_ADDR is a physical address.
+ This should be in the SAREA. */
+ *(volatile long unsigned *)(info->ringReadPtr) = 0;
+ OUTREG(R128_PM4_BUFFER_DL_RPTR_ADDR, (info->ringReadPtrHandle));
+
+ /* Set watermark control */
+ OUTREG(R128_PM4_BUFFER_WM_CNTL,
+ ((R128_WATERMARK_L/4) << R128_WMA_SHIFT)
+ | ((R128_WATERMARK_M/4) << R128_WMB_SHIFT)
+ | ((R128_WATERMARK_N/4) << R128_WMC_SHIFT)
+ | ((R128_WATERMARK_K/64) << R128_WB_WM_SHIFT));
+
+ addr = INREG(R128_PM4_BUFFER_ADDR); /* Force read. Why? Because it's
+ in the examples... */
+
+#if 0
+ R128CCEWaitForIdle(pScrn);
+#endif
+
+ /* Turn on bus mastering */
+ info->BusCntl &= ~R128_BUS_MASTER_DIS;
+ OUTREGP(R128_BUS_CNTL, 0, ~R128_BUS_MASTER_DIS);
+}
+
+/* Initialize the kernel data structures. */
+static int R128DRIKernelInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ drmR128Init drmInfo;
+
+ drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec);
+ drmInfo.is_pci = pR128->IsPCI;
+ drmInfo.cce_mode = pR128->CCEMode;
+ drmInfo.cce_fifo_size = pR128->CCEFifoSize;
+ drmInfo.cce_secure = pR128->CCESecure;
+ drmInfo.ring_size = pR128->ringSize*1024*1024;
+ drmInfo.usec_timeout = pR128->CCEusecTimeout;
+
+ drmInfo.fb_offset = pR128->LinearAddr;
+ drmInfo.agp_ring_offset = pR128->ringHandle;
+ drmInfo.agp_read_ptr_offset = pR128->ringReadPtrHandle;
+ drmInfo.agp_vertbufs_offset = pR128->vbHandle;
+ drmInfo.agp_indbufs_offset = pR128->indHandle;
+ drmInfo.agp_textures_offset = pR128->agpTexHandle;
+ drmInfo.mmio_offset = pR128->registerHandle;
+
+ if (drmR128InitCCE(pR128->drmFD, &drmInfo) < 0) return FALSE;
+
+ return TRUE;
+}
+
+/* Add a map for the vertex buffers that will be accessed by any
+ DRI-based clients. */
+static Bool R128DRIBufInit(R128InfoPtr pR128, ScreenPtr pScreen)
+{
+ /* Initialize vertex buffers */
+ if ((pR128->vbNumBufs = drmAddBufs(pR128->drmFD,
+ pR128->vbMapSize / pR128->vbBufSize,
+ pR128->vbBufSize,
+ DRM_AGP_BUFFER,
+ pR128->vbStart)) <= 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Could not create vertex buffers list\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Added %d %d byte vertex buffers\n",
+ pR128->vbNumBufs, pR128->vbBufSize);
+
+ if (drmMarkBufs(pR128->drmFD, 0.133333, 0.266666)) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to mark vertex buffers list\n");
+ return FALSE;
+ }
+
+ if (!(pR128->vbBufs = drmMapBufs(pR128->drmFD))) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "[drm] Failed to map vertex buffers list\n");
+ return FALSE;
+ }
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] Mapped %d vertex buffers\n",
+ pR128->vbBufs->count);
+
+ return TRUE;
+}
+
+/* Load the microcode for the CCE */
+static void R128DRILoadMicrocode(ScrnInfoPtr pScrn)
+{
+ unsigned char *R128MMIO = R128PTR(pScrn)->MMIO;
+ int i;
+ unsigned long R128Microcode[] = {
+ /* CCE microcode (from ATI) */
+ 0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0, 1617039951,
+ 0, 774592877, 0, 1987540286, 0, 2307490946U, 0, 599558925, 0, 589505315, 0,
+ 596487092, 0, 589505315, 1, 11544576, 1, 206848, 1, 311296, 1, 198656, 2,
+ 912273422, 11, 262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12,
+ 28, 1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9, 30, 1,
+ 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656, 1, 15630, 1, 51200,
+ 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1, 15717, 1, 15718, 2, 43, 1,
+ 15936948, 1, 570480831, 1, 14715071, 12, 322123831, 1, 33953125, 12, 55, 1,
+ 33559908, 1, 15718, 2, 46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1,
+ 509952, 1, 459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1,
+ 18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1, 15975928, 1,
+ 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2, 268449859, 2, 10307, 12,
+ 176, 1, 15734, 1, 15735, 1, 15630, 1, 15631, 1, 5253120, 6, 3145810, 16,
+ 2150645232U, 1, 15864, 2, 82, 1, 343310, 1, 1064207, 2, 3145813, 1, 15728,
+ 1, 7817, 1, 15729, 3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002,
+ 1, 16008, 1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0,
+ 15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1, 180224, 1,
+ 103824738, 2, 112, 2, 3145839, 0, 536885440, 1, 114880, 14, 125, 12,
+ 206975, 1, 33559995, 12, 198784, 0, 33570236, 1, 15803, 0, 15804, 3,
+ 294912, 1, 294912, 3, 442370, 1, 11544576, 0, 811612160, 1, 12593152, 1,
+ 11536384, 1, 14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1,
+ 14793, 1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1,
+ 198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1, 114880, 14,
+ 159, 12, 198784, 1, 1109409213, 12, 198783, 1, 1107312059, 12, 198784, 1,
+ 1109409212, 2, 162, 1, 1075854781, 1, 1073757627, 1, 1075854780, 1, 540672,
+ 1, 10485760, 6, 3145894, 16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0,
+ 0, 0, 256, 14, 174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858,
+ 1, 33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1, 33560360, 1,
+ 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1, 409611, 9, 188, 0,
+ 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0
+ };
+
+ R128WaitForIdle(pScrn);
+
+ OUTREG(R128_PM4_MICROCODE_ADDR, 0);
+ for (i = 0; i < 256; i += 1) {
+ OUTREG(R128_PM4_MICROCODE_DATAH, R128Microcode[i*2]);
+ OUTREG(R128_PM4_MICROCODE_DATAL, R128Microcode[i*2 + 1]);
+ }
+}
+
+/* Initialize the CCE state, and start the CCE (if used by the X server) */
+static void R128DRICCEInit(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+ unsigned char *R128MMIO = info->MMIO;
+
+ /* CCEMode is initialized in r128_driver.c */
+ switch (info->CCEMode) {
+ case R128_PM4_NONPM4: info->CCEFifoSize = 0; break;
+ case R128_PM4_192PIO: info->CCEFifoSize = 192; break;
+ case R128_PM4_192BM: info->CCEFifoSize = 192; break;
+ case R128_PM4_128PIO_64INDBM: info->CCEFifoSize = 128; break;
+ case R128_PM4_128BM_64INDBM: info->CCEFifoSize = 128; break;
+ case R128_PM4_64PIO_128INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64BM_128INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64PIO_64VCBM_64INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64BM_64VCBM_64INDBM: info->CCEFifoSize = 64; break;
+ case R128_PM4_64PIO_64VCPIO_64INDPIO: info->CCEFifoSize = 64; break;
+ }
+
+ if (info->CCE2D) {
+ /* Make sure the CCE is on for the X server */
+ R128CCEStart(pScrn);
+ } else {
+ /* Make sure the CCE is off for the X server */
+ OUTREG(R128_PM4_MICRO_CNTL, 0);
+ OUTREG(R128_PM4_BUFFER_CNTL, R128_PM4_NONPM4);
+ }
+}
+
+/* Initialize the screen-specific data structures for the DRI and the
+ Rage 128. This is the main entry point to the device-specific
+ initialization code. It calls device-independent DRI functions to
+ create the DRI data structures and initialize the DRI state. */
+Bool R128DRIScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ DRIInfoPtr pDRIInfo;
+ R128DRIPtr pR128DRI;
+ int major, minor, patch;
+ drmVersionPtr version;
+
+ /* Check that the GLX, DRI, and DRM modules have been loaded by testing
+ * for known symbols in each module. */
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "R128DRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+
+ /* Check the DRI version */
+ DRIQueryVersion(&major, &minor, &patch);
+ if (major != 3 || minor != 0 || patch < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "R128DRIScreenInit failed "
+ "(DRI version = %d.%d.%d, expected 3.0.x). "
+ "Disabling DRI.\n",
+ major, minor, patch);
+ return FALSE;
+ }
+
+ switch (pR128->CurrentLayout.pixel_code) {
+ case 8:
+ /* These modes are not supported (yet). */
+ case 15:
+ case 24:
+ return FALSE;
+
+ /* Only 16 and 32 color depths are supports currently. */
+ case 16:
+ case 32:
+ break;
+ }
+
+ /* Create the DRI data structure, and fill it in before calling the
+ DRIScreenInit(). */
+ if (!(pDRIInfo = DRICreateInfoRec())) return FALSE;
+
+ pR128->pDRIInfo = pDRIInfo;
+ pDRIInfo->drmDriverName = R128_NAME;
+ pDRIInfo->clientDriverName = R128_NAME;
+ pDRIInfo->busIdString = xalloc(64);
+ sprintf(pDRIInfo->busIdString,
+ "PCI:%d:%d:%d",
+ pR128->PciInfo->bus,
+ pR128->PciInfo->device,
+ pR128->PciInfo->func);
+ pDRIInfo->ddxDriverMajorVersion = R128_VERSION_MAJOR;
+ pDRIInfo->ddxDriverMinorVersion = R128_VERSION_MINOR;
+ pDRIInfo->ddxDriverPatchVersion = R128_VERSION_PATCH;
+ pDRIInfo->frameBufferPhysicalAddress = pR128->LinearAddr;
+ pDRIInfo->frameBufferSize = pR128->FbMapSize;
+ pDRIInfo->frameBufferStride = (pScrn->displayWidth *
+ pR128->CurrentLayout.pixel_bytes);
+ pDRIInfo->ddxDrawableTableEntry = R128_MAX_DRAWABLES;
+ pDRIInfo->maxDrawableTableEntry = (SAREA_MAX_DRAWABLES
+ < R128_MAX_DRAWABLES
+ ? SAREA_MAX_DRAWABLES
+ : R128_MAX_DRAWABLES);
+
+#ifdef NOT_DONE
+ /* FIXME: Need to extend DRI protocol to pass this size back to
+ * client for SAREA mapping that includes a device private record
+ */
+ pDRIInfo->SAREASize =
+ ((sizeof(XF86DRISAREARec) + 0xfff) & 0x1000); /* round to page */
+ /* + shared memory device private rec */
+#else
+ /* For now the mapping works by using a fixed size defined
+ * in the SAREA header
+ */
+ if (sizeof(XF86DRISAREARec)+sizeof(R128SAREAPriv)>SAREA_MAX) {
+ ErrorF("Data does not fit in SAREA\n");
+ return FALSE;
+ }
+ pDRIInfo->SAREASize = SAREA_MAX;
+#endif
+
+ if (!(pR128DRI = (R128DRIPtr)xnfcalloc(sizeof(R128DRIRec),1))) {
+ DRIDestroyInfoRec(pR128->pDRIInfo);
+ pR128->pDRIInfo = NULL;
+ return FALSE;
+ }
+ pDRIInfo->devPrivate = pR128DRI;
+ pDRIInfo->devPrivateSize = sizeof(R128DRIRec);
+ pDRIInfo->contextSize = sizeof(R128DRIContextRec);
+
+ pDRIInfo->CreateContext = R128CreateContext;
+ pDRIInfo->DestroyContext = R128DestroyContext;
+ pDRIInfo->SwapContext = R128DRISwapContext;
+ pDRIInfo->InitBuffers = R128DRIInitBuffers;
+ pDRIInfo->MoveBuffers = R128DRIMoveBuffers;
+ pDRIInfo->bufferRequests = DRI_ALL_WINDOWS;
+
+ if (!DRIScreenInit(pScreen, pDRIInfo, &pR128->drmFD)) {
+ xfree(pDRIInfo->devPrivate);
+ pDRIInfo->devPrivate = NULL;
+ DRIDestroyInfoRec(pDRIInfo);
+ pDRIInfo = NULL;
+ return FALSE;
+ }
+
+ /* Check the r128 DRM version */
+ version = drmGetVersion(pR128->drmFD);
+ if (version) {
+ if (version->version_major != 1 ||
+ version->version_minor != 0 ||
+ version->version_patchlevel < 0) {
+ /* incompatible drm version */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "R128DRIScreenInit failed "
+ "(DRM version = %d.%d.%d, expected 1.0.x). "
+ "Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ drmFreeVersion(version);
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ drmFreeVersion(version);
+ }
+
+ /* Initialize AGP */
+ if (!pR128->IsPCI && !R128DRIAgpInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* DRIScreenInit doesn't add all the
+ common mappings. Add additional
+ mappings here. */
+ if (!R128DRIMapInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Initialize the ring buffer */
+ if (!pR128->IsPCI) R128DRICCEInitRingBuffer(pScrn);
+
+ /* Initialize the kernel data structures */
+ if (!R128DRIKernelInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* Initialize vertex buffers list */
+ if (!pR128->IsPCI && !R128DRIBufInit(pR128, pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ /* FIXME: When are these mappings unmapped? */
+
+ if (!R128InitVisualConfigs(pScreen)) {
+ R128DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Visual configs initialized\n");
+
+ /* Load the CCE Microcode */
+ R128DRILoadMicrocode(pScrn);
+
+ /* Reset the Graphics Engine */
+ R128EngineReset(pScrn);
+
+ return TRUE;
+}
+
+/* Finish initializing the device-dependent DRI state, and call
+ DRIFinishScreenInit() to complete the device-independent DRI
+ initialization. */
+Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+ R128SAREAPrivPtr pSAREAPriv;
+ R128DRIPtr pR128DRI;
+
+ /* Init and start the CCE */
+ R128DRICCEInit(pScrn);
+
+ pSAREAPriv = (R128SAREAPrivPtr)DRIGetSAREAPrivate(pScreen);
+ memset(pSAREAPriv, 0, sizeof(*pSAREAPriv));
+
+ pR128->pDRIInfo->driverSwapMethod = DRI_HIDE_X_CONTEXT;
+ /* pR128->pDRIInfo->driverSwapMethod = DRI_SERVER_SWAP; */
+
+ pR128DRI = (R128DRIPtr)pR128->pDRIInfo->devPrivate;
+ pR128DRI->registerHandle = pR128->registerHandle;
+ pR128DRI->registerSize = pR128->registerSize;
+
+ pR128DRI->ringHandle = pR128->ringHandle;
+ pR128DRI->ringMapSize = pR128->ringMapSize;
+ pR128DRI->ringSize = pR128->ringSize*1024*1024;
+
+ pR128DRI->ringReadPtrHandle = pR128->ringReadPtrHandle;
+ pR128DRI->ringReadMapSize = pR128->ringReadMapSize;
+
+ pR128DRI->vbHandle = pR128->vbHandle;
+ pR128DRI->vbMapSize = pR128->vbMapSize;
+ pR128DRI->vbOffset = pR128->vbStart;
+ pR128DRI->vbBufSize = pR128->vbBufSize;
+
+ pR128DRI->indHandle = pR128->indHandle;
+ pR128DRI->indMapSize = pR128->indMapSize;
+
+ pR128DRI->agpTexHandle = pR128->agpTexHandle;
+ pR128DRI->agpTexMapSize = pR128->agpTexMapSize;
+ pR128DRI->log2AGPTexGran = pR128->log2AGPTexGran;
+ pR128DRI->agpTexOffset = pR128->agpTexStart;
+
+ pR128DRI->deviceID = pR128->Chipset;
+ pR128DRI->width = pScrn->virtualX;
+ pR128DRI->height = pScrn->virtualY;
+ pR128DRI->depth = pScrn->depth;
+ pR128DRI->bpp = pScrn->bitsPerPixel;
+
+ pR128DRI->fbX = pR128->fbX;
+ pR128DRI->fbY = pR128->fbY;
+ pR128DRI->backX = pR128->backX;
+ pR128DRI->backY = pR128->backY;
+ pR128DRI->depthX = pR128->depthX;
+ pR128DRI->depthY = pR128->depthY;
+ pR128DRI->textureX = pR128->textureX;
+ pR128DRI->textureY = pR128->textureY;
+ pR128DRI->textureSize = pR128->textureSize;
+ pR128DRI->log2TexGran = pR128->log2TexGran;
+
+ pR128DRI->IsPCI = pR128->IsPCI;
+
+ pR128DRI->CCEMode = pR128->CCEMode;
+ pR128DRI->CCEFifoSize = pR128->CCEFifoSize;
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "0x%08lx %d\n",
+ pR128DRI->registerHandle, pR128DRI->registerSize);
+ return DRIFinishScreenInit(pScreen);
+}
+
+/* The screen is being closed, so clean up any state and free any
+ resources used by the DRI. */
+void R128DRICloseScreen(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ R128InfoPtr pR128 = R128PTR(pScrn);
+
+ /* Stop the CCE if it is still in use */
+ if (pR128->CCE2D) R128CCEStop(pScrn);
+
+ /* De-allocate vertex buffers */
+ if (pR128->vbBufs) {
+ drmUnmapBufs(pR128->vbBufs);
+ pR128->vbBufs = NULL;
+ }
+
+ /* De-allocate all kernel resources */
+ drmR128CleanupCCE(pR128->drmFD);
+
+ /* De-allocate all AGP resources */
+ if (pR128->agpTex) {
+ drmUnmap(pR128->agpTex, pR128->agpTexMapSize);
+ pR128->agpTex = NULL;
+ }
+ if (pR128->ind) {
+ drmUnmap(pR128->ind, pR128->indMapSize);
+ pR128->ind = NULL;
+ }
+ if (pR128->vb) {
+ drmUnmap(pR128->vb, pR128->vbMapSize);
+ pR128->vb = NULL;
+ }
+ if (pR128->ringReadPtr) {
+ drmUnmap(pR128->ringReadPtr, pR128->ringReadMapSize);
+ pR128->ringReadPtr = NULL;
+ }
+ if (pR128->ring) {
+ drmUnmap(pR128->ring, pR128->ringMapSize);
+ pR128->ring = NULL;
+ }
+ if (pR128->agpMemHandle) {
+ drmAgpUnbind(pR128->drmFD, pR128->agpMemHandle);
+ drmAgpFree(pR128->drmFD, pR128->agpMemHandle);
+ pR128->agpMemHandle = 0;
+ drmAgpRelease(pR128->drmFD);
+ }
+
+ /* De-allocate all DRI resources */
+ DRICloseScreen(pScreen);
+
+ /* De-allocate all DRI data structures */
+ if (pR128->pDRIInfo) {
+ if (pR128->pDRIInfo->devPrivate) {
+ xfree(pR128->pDRIInfo->devPrivate);
+ pR128->pDRIInfo->devPrivate = NULL;
+ }
+ DRIDestroyInfoRec(pR128->pDRIInfo);
+ pR128->pDRIInfo = NULL;
+ }
+ if (pR128->pVisualConfigs) {
+ xfree(pR128->pVisualConfigs);
+ pR128->pVisualConfigs = NULL;
+ }
+ if (pR128->pVisualConfigsPriv) {
+ xfree(pR128->pVisualConfigsPriv);
+ pR128->pVisualConfigsPriv = NULL;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
new file mode 100644
index 000000000..6e2fb4517
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h
@@ -0,0 +1,116 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dri.h,v 1.1 2000/06/17 00:03:22 martin Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and 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
+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
+ATI, PRECISION INSIGHT 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 <kevin@precisioninsight.com>
+ * Rickard E. Faith <faith@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_DRI_
+#define _R128_DRI_
+
+#include <xf86drm.h>
+
+/* DRI Driver defaults */
+#define R128_DEFAULT_CCE_PIO_MODE R128_PM4_64PIO_64VCBM_64INDBM
+#define R128_DEFAULT_CCE_BM_MODE R128_PM4_64BM_64VCBM_64INDBM
+#define R128_DEFAULT_AGP_MODE 2
+#define R128_DEFAULT_AGP_SIZE 8 /* MB (must be a power of 2 and > 4MB) */
+#define R128_DEFAULT_RING_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_VB_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_IND_SIZE 1 /* MB (must be page aligned) */
+#define R128_DEFAULT_AGP_TEX_SIZE 1 /* MB (must be page aligned) */
+
+#define R128_DEFAULT_VB_BUF_SIZE 16384 /* bytes */
+#define R128_DEFAULT_CCE_TIMEOUT 10000 /* usecs */
+
+#define R128_AGP_MAX_MODE 2
+
+#define R128CCE_USE_RING_BUFFER(m) \
+(((m) == R128_PM4_192BM) || \
+ ((m) == R128_PM4_128BM_64INDBM) || \
+ ((m) == R128_PM4_64BM_128INDBM) || \
+ ((m) == R128_PM4_64BM_64VCBM_64INDBM))
+
+typedef struct {
+ /* MMIO register data */
+ drmHandle registerHandle;
+ drmSize registerSize;
+
+ /* CCE ring buffer data */
+ drmHandle ringHandle;
+ drmSize ringMapSize;
+ int ringSize;
+
+ /* CCE ring read pointer data */
+ drmHandle ringReadPtrHandle;
+ drmSize ringReadMapSize;
+
+ /* CCE vertex buffer data */
+ drmHandle vbHandle;
+ drmSize vbMapSize;
+ int vbOffset;
+ int vbBufSize;
+
+ /* CCE indirect buffer data */
+ drmHandle indHandle;
+ drmSize indMapSize;
+
+ /* CCE AGP Texture data */
+ drmHandle agpTexHandle;
+ drmSize agpTexMapSize;
+ int log2AGPTexGran;
+ int agpTexOffset;
+
+ /* DRI screen private data */
+ int deviceID; /* PCI device ID */
+ int width; /* Width in pixels of display */
+ int height; /* Height in scanlines of display */
+ int depth; /* Depth of display (8, 15, 16, 24) */
+ int bpp; /* Bit depth of display (8, 16, 24, 32) */
+
+ int fbX; /* Start of frame buffer */
+ int fbY;
+ int backX; /* Start of shared back buffer */
+ int backY;
+ int depthX; /* Start of shared depth buffer */
+ int depthY;
+ int textureX; /* Start of texture data in frame buffer */
+ int textureY;
+ int textureSize;
+ int log2TexGran;
+
+ int IsPCI; /* Current card is a PCI card */
+
+ int CCEMode; /* CCE mode that server/clients use */
+ int CCEFifoSize; /* Size of the CCE command FIFO */
+} R128DRIRec, *R128DRIPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
new file mode 100644
index 000000000..726656cc3
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h
@@ -0,0 +1,54 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_dripriv.h,v 1.1 2000/06/17 00:03:22 martin Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and 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
+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
+ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+**************************************************************************/
+
+/*
+ * Authors:
+ * Rickard E. Faith <faith@precisioninsight.com>
+ * Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_DRIPRIV_H_
+#define _R128_DRIPRIV_H_
+
+#define R128_MAX_DRAWABLES 256
+
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **configprivs);
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} R128ConfigPrivRec, *R128ConfigPrivPtr;
+
+typedef struct {
+ /* Nothing here yet */
+ int dummy;
+} R128DRIContextRec, *R128DRIContextPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
index b5da4cb6e..bef8a4329 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c
@@ -1,8 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.26 2000/03/06 23:17:44 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_driver.c,v 1.38 2000/07/01 01:40:45 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -70,7 +70,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "mipointer.h"
#include "micmap.h"
-#undef USE_FB /* not until overlays and 24->32 code added */
+#define USE_FB /* not until overlays and 24->32 code added */
#ifdef USE_FB
#include "fb.h"
#else
@@ -107,6 +107,19 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
/* VESA support */
#include "vbe.h"
+ /* DRI support */
+#ifdef XF86DRI
+#include "GL/glxint.h"
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "r128_dri.h"
+#include "r128_dripriv.h"
+#include "r128_sarea.h"
+#endif
+
/* Driver data structures */
#include "r128.h"
#include "r128_reg.h"
@@ -126,7 +139,6 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
static int R128ValidMode(int scrnIndex, DisplayModePtr mode,
Bool verbose, int flag);
-static void R128AdjustFrame(int scrnIndex, int x, int y, int flags);
static Bool R128EnterVT(int scrnIndex, int flags);
static void R128LeaveVT(int scrnIndex, int flags);
static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen);
@@ -135,7 +147,6 @@ static Bool R128SaveScreen(ScreenPtr pScreen, int mode);
static void R128Save(ScrnInfoPtr pScrn);
static void R128Restore(ScrnInfoPtr pScrn);
static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static Bool R128SwitchMode(int ScrnIndex, DisplayModePtr mode, int flags);
static void R128DisplayPowerManagementSet(ScrnInfoPtr pScrn,
int PowerManagementMode, int flags);
static Bool R128EnterVTFBDev(int scrnIndex, int flags);
@@ -158,6 +169,8 @@ static SymTabRec R128Chipsets[] = {
{ PCI_CHIP_RAGE128RK, "ATI Rage 128 RK (PCI)" },
{ PCI_CHIP_RAGE128RL, "ATI Rage 128 RL (AGP)" },
{ PCI_CHIP_RAGE128PF, "ATI Rage 128 Pro PF (AGP)" },
+ { PCI_CHIP_RAGE128LE, "ATI Rage 128 Mobility LE (PCI)" },
+ { PCI_CHIP_RAGE128LF, "ATI Rage 128 Mobility LF (AGP)" },
{ -1, NULL }
};
@@ -167,6 +180,8 @@ static PciChipsets R128PciChipsets[] = {
{ PCI_CHIP_RAGE128RK, PCI_CHIP_RAGE128RK, RES_SHARED_VGA },
{ PCI_CHIP_RAGE128RL, PCI_CHIP_RAGE128RL, RES_SHARED_VGA },
{ PCI_CHIP_RAGE128PF, PCI_CHIP_RAGE128PF, RES_SHARED_VGA },
+ { PCI_CHIP_RAGE128LE, PCI_CHIP_RAGE128LE, RES_SHARED_VGA },
+ { PCI_CHIP_RAGE128LF, PCI_CHIP_RAGE128LF, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED }
};
@@ -176,17 +191,45 @@ typedef enum {
OPTION_HW_CURSOR,
OPTION_DAC_6BIT,
OPTION_DAC_8BIT,
+#ifdef XF86DRI
+ OPTION_IS_PCI,
+ OPTION_CCE_PIO,
+ OPTION_NO_SECURITY,
+ OPTION_USEC_TIMEOUT,
+ OPTION_AGP_MODE,
+ OPTION_AGP_SIZE,
+ OPTION_RING_SIZE,
+ OPTION_VERT_SIZE,
+ OPTION_VBUF_SIZE,
+ OPTION_USE_CCE_2D,
+#endif
+ OPTION_ENABLE_FP,
+ OPTION_CRT,
OPTION_FBDEV
} R128Opts;
static OptionInfoRec R128Options[] = {
- { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE },
- { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE },
- { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE },
- { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE },
- { -1, NULL, OPTV_NONE, {0}, FALSE }
+ { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, TRUE },
+ { OPTION_DAC_6BIT, "Dac6Bit", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_DAC_8BIT, "Dac8Bit", OPTV_BOOLEAN, {0}, TRUE },
+#ifdef XF86DRI
+ { OPTION_IS_PCI, "ForcePCIMode", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_CCE_PIO, "CCEPIOMode", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_NO_SECURITY, "CCENoSecurity", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_USEC_TIMEOUT, "CCEusecTimeout", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_AGP_MODE, "AGPMode", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_AGP_SIZE, "AGPSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_RING_SIZE, "RingSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_VERT_SIZE, "VBListSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_VBUF_SIZE, "VBSize", OPTV_INTEGER, {0}, FALSE },
+ { OPTION_USE_CCE_2D, "UseCCEfor2D", OPTV_BOOLEAN, {0}, FALSE },
+#endif
+ { OPTION_ENABLE_FP, "EnableFP", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_CRT, "CRTOnly", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_FBDEV, "UseFBDev", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
};
R128RAMRec R128RAM[] = { /* Memory Specifications
@@ -299,6 +342,41 @@ static const char *ramdacSymbols[] = {
NULL
};
+#ifdef XF86DRI
+static const char *drmSymbols[] = {
+ "drmAddBufs",
+ "drmAddMap",
+ "drmAvailable",
+ "drmCtlAddCommand",
+ "drmCtlInstHandler",
+ "drmGetInterruptFromBusID",
+ "drmMapBufs",
+ "drmMarkBufs",
+ "drmUnmapBufs",
+ "drmFreeVersion",
+ "drmGetVersion",
+ NULL
+};
+
+static const char *driSymbols[] = {
+ "DRIGetDrawableIndex",
+ "DRIFinishScreenInit",
+ "DRIDestroyInfoRec",
+ "DRICloseScreen",
+ "DRIDestroyInfoRec",
+ "DRIScreenInit",
+ "DRIDestroyInfoRec",
+ "DRICreateInfoRec",
+ "DRILock",
+ "DRIUnlock",
+ "DRIGetSAREAPrivate",
+ "DRIGetContext",
+ "DRIQueryVersion",
+ "GlxSetVisualConfigs",
+ NULL
+};
+#endif
+
static MODULESETUPPROTO(R128Setup);
static XF86ModuleVersionInfo R128VersRec =
@@ -347,6 +425,10 @@ static pointer R128Setup(pointer module, pointer opts, int *errmaj,
xaaSymbols,
xf8_32bppSymbols,
ramdacSymbols,
+#ifdef XF86DRI
+ drmSymbols,
+ driSymbols,
+#endif
fbdevHWSymbols,
vbeSymbols,
0 /* ddcsymbols */,
@@ -518,7 +600,7 @@ static void R128Unblank(ScrnInfoPtr pScrn)
}
/* Compute log base 2 of val. */
-static int R128MinBits(int val)
+int R128MinBits(int val)
{
int bits;
@@ -714,16 +796,18 @@ static Bool R128PreInitVisual(ScrnInfoPtr pScrn)
info->fifo_slots = 0;
info->pix24bpp = xf86GetBppFromDepth(pScrn, pScrn->depth);
- info->pixel_bytes = pScrn->bitsPerPixel / 8;
- info->pixel_code = (pScrn->bitsPerPixel != 16
- ? pScrn->bitsPerPixel
- : pScrn->depth);
+ info->CurrentLayout.bitsPerPixel = pScrn->bitsPerPixel;
+ info->CurrentLayout.depth = pScrn->depth;
+ info->CurrentLayout.pixel_bytes = pScrn->bitsPerPixel / 8;
+ info->CurrentLayout.pixel_code = (pScrn->bitsPerPixel != 16
+ ? pScrn->bitsPerPixel
+ : pScrn->depth);
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Pixel depth = %d bits stored in %d byte%s (%d bpp pixmaps)\n",
pScrn->depth,
- info->pixel_bytes,
- info->pixel_bytes > 1 ? "s" : "",
+ info->CurrentLayout.pixel_bytes,
+ info->CurrentLayout.pixel_bytes > 1 ? "s" : "",
info->pix24bpp);
@@ -779,6 +863,10 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
int offset = 0; /* RAM Type */
MessageType from;
unsigned char *R128MMIO;
+ CARD32 fp_horz_stretch = 0, fp_vert_stretch = 0;
+ CARD32 crtc_h_total_disp = 0, crtc_v_total_disp = 0;
+ CARD32 crtc_h_sync_strt_wid = 0, crtc_v_sync_strt_wid = 0;
+
/* Chipset */
from = X_PROBED;
if (dev->chipset && *dev->chipset) {
@@ -861,27 +949,53 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
"BIOS at 0x%08lx\n", info->BIOSAddr);
}
- /* RAM */
- from = X_PROBED;
+ /* Flat panel (part 1) */
+ /* FIXME: Make this an option */
+ switch (info->Chipset) {
+ case PCI_CHIP_RAGE128LE:
+ case PCI_CHIP_RAGE128LF: info->HasPanelRegs = TRUE; break;
+ case PCI_CHIP_RAGE128RE:
+ case PCI_CHIP_RAGE128RF:
+ case PCI_CHIP_RAGE128RK:
+ case PCI_CHIP_RAGE128RL:
+ case PCI_CHIP_RAGE128PF:
+ default: info->HasPanelRegs = FALSE; break;
+ }
+
+ /* Read registers used to determine options */
+ from = X_PROBED;
R128MapMMIO(pScrn);
- R128MMIO = info->MMIO;
+ R128MMIO = info->MMIO;
if (info->FBDev)
- pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024;
+ pScrn->videoRam = fbdevHWGetVidmem(pScrn) / 1024;
else
- pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024;
- info->MemCntl = INREG(R128_MEM_CNTL);
- info->BusCntl = INREG(R128_BUS_CNTL);
- R128MMIO = NULL;
+ pScrn->videoRam = INREG(R128_CONFIG_MEMSIZE) / 1024;
+ info->MemCntl = INREG(R128_MEM_CNTL);
+ info->BusCntl = INREG(R128_BUS_CNTL);
+ if (info->HasPanelRegs) {
+ fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH);
+ fp_vert_stretch = INREG(R128_FP_VERT_STRETCH);
+ crtc_h_total_disp = INREG(R128_CRTC_H_TOTAL_DISP);
+ crtc_v_total_disp = INREG(R128_CRTC_V_TOTAL_DISP);
+ crtc_h_sync_strt_wid = INREG(R128_CRTC_H_SYNC_STRT_WID);
+ crtc_v_sync_strt_wid = INREG(R128_CRTC_V_SYNC_STRT_WID);
+ }
+ R128MMIO = NULL;
R128UnmapMMIO(pScrn);
+
+ /* RAM */
switch (info->MemCntl & 0x3) {
case 0: /* SDR SGRAM 1:1 */
switch (info->Chipset) {
- case PCI_CHIP_RAGE128RE:
+ case PCI_CHIP_RAGE128LE:
+ case PCI_CHIP_RAGE128LF:
+ case PCI_CHIP_RAGE128RE:
case PCI_CHIP_RAGE128RF: offset = 0; break; /* 128-bit SDR SGRAM 1:1 */
case PCI_CHIP_RAGE128RK:
case PCI_CHIP_RAGE128RL:
default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */
}
+ break;
case 1: offset = 2; break; /* 64-bit SDR SGRAM 2:1 */
case 2: offset = 3; break; /* 64-bit DDR SGRAM */
default: offset = 1; break; /* 64-bit SDR SGRAM 1:1 */
@@ -895,12 +1009,98 @@ static Bool R128PreInitConfig(ScrnInfoPtr pScrn)
pScrn->videoRam);
from = X_CONFIG;
pScrn->videoRam = dev->videoRam;
- }
+ }
pScrn->videoRam &= ~1023;
info->FbMapSize = pScrn->videoRam * 1024;
xf86DrvMsg(pScrn->scrnIndex, from,
"VideoRAM: %d kByte (%s)\n", pScrn->videoRam, info->ram->name);
+ /* Flat panel (part 2) */
+ if ((info->EnableFP = xf86ReturnOptValBool(R128Options,
+ OPTION_ENABLE_FP, FALSE))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Enabling use of flat panel registers\n");
+ if ((info->CRTOnly = xf86ReturnOptValBool(R128Options,
+ OPTION_CRT, FALSE))) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using external CRT instead of "
+ "flat panel for display\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Using flat panel for display\n");
+ }
+ }
+
+ if (info->HasPanelRegs) {
+ int tmp;
+
+ info->PanelXRes =
+ (fp_horz_stretch & R128_HORZ_PANEL_SIZE) >> R128_HORZ_PANEL_SHIFT;
+ info->PanelXRes = (info->PanelXRes + 1) * 8;
+ info->PanelYRes =
+ (fp_vert_stretch & R128_VERT_PANEL_SIZE) >> R128_VERT_PANEL_SHIFT;
+ info->PanelYRes += 1;
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Panel dimensions: %dx%d\n",
+ info->PanelXRes, info->PanelYRes);
+
+ info->PanelHNonVis =
+ (crtc_h_total_disp & R128_CRTC_H_TOTAL) >> R128_CRTC_H_TOTAL_SHIFT;
+ info->PanelHNonVis += 4; /* Add 4 since we are in VGA mode */
+ tmp =
+ (crtc_h_total_disp & R128_CRTC_H_DISP) >> R128_CRTC_H_DISP_SHIFT;
+ info->PanelHNonVis -= tmp;
+ info->PanelHOverPlus =
+ (crtc_h_sync_strt_wid & R128_CRTC_H_SYNC_STRT_CHAR)
+ >> R128_CRTC_H_SYNC_STRT_CHAR_SHIFT;
+ info->PanelHOverPlus -= tmp;
+ switch (info->CurrentLayout.pixel_code) {
+ /* Adjustments are from ATI */
+ case 8: info->PanelHOverPlus += 2; break;
+ case 15:
+ case 16: info->PanelHOverPlus += 1; break;
+ case 24:
+ case 32: info->PanelHOverPlus += 0; break;
+ }
+ info->PanelHSyncWidth =
+ (crtc_h_sync_strt_wid & R128_CRTC_H_SYNC_WID)
+ >> R128_CRTC_H_SYNC_WID_SHIFT;
+ info->PanelHSyncWidth += 14; /* ??? */
+
+ info->PanelVNonVis =
+ (crtc_v_total_disp & R128_CRTC_V_TOTAL) >> R128_CRTC_V_TOTAL_SHIFT;
+ info->PanelVNonVis += 1; /* Add 1 since we are in VGA mode */
+ tmp =
+ (crtc_v_total_disp & R128_CRTC_V_DISP) >> R128_CRTC_V_DISP_SHIFT;
+ info->PanelVNonVis -= tmp;
+ info->PanelVOverPlus =
+ (crtc_v_sync_strt_wid & R128_CRTC_V_SYNC_STRT)
+ >> R128_CRTC_V_SYNC_STRT_SHIFT;
+ info->PanelVOverPlus -= tmp + 1;
+ info->PanelVSyncWidth =
+ (crtc_v_sync_strt_wid & R128_CRTC_V_SYNC_WID)
+ >> R128_CRTC_V_SYNC_WID_SHIFT;
+ info->PanelVSyncWidth -= 2; /* ??? */
+ }
+
+#ifdef XF86DRI
+ /* AGP/PCI */
+ if (xf86ReturnOptValBool(R128Options, OPTION_IS_PCI, FALSE)) {
+ info->IsPCI = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Forced into PCI-only mode\n");
+ } else {
+ switch (info->Chipset) {
+ case PCI_CHIP_RAGE128LE:
+ case PCI_CHIP_RAGE128RE:
+ case PCI_CHIP_RAGE128RK: info->IsPCI = TRUE; break;
+ case PCI_CHIP_RAGE128LF:
+ case PCI_CHIP_RAGE128RF:
+ case PCI_CHIP_RAGE128RL:
+ case PCI_CHIP_RAGE128PF:
+ default: info->IsPCI = FALSE; break;
+ }
+ }
+#endif
+
return TRUE;
}
@@ -956,7 +1156,7 @@ static Bool R128PreInitModes(ScrnInfoPtr pScrn)
/* Get mode information */
pScrn->progClock = TRUE;
- clockRanges = xnfalloc(sizeof(*clockRanges));
+ clockRanges = xnfcalloc(sizeof(*clockRanges), 1);
clockRanges->next = NULL;
clockRanges->minClock = info->pll.min_pll_freq;
clockRanges->maxClock = info->pll.max_pll_freq * 10;
@@ -1000,7 +1200,8 @@ static Bool R128PreInitModes(ScrnInfoPtr pScrn)
/* Get ScreenInit function */
#ifdef USE_FB
- mod = "fb"; Sym = "fbScreenInit";
+ mod = "fb";
+ Sym = "fbScreenInit";
#else
switch (pScrn->bitsPerPixel) {
case 8: mod = "cfb"; Sym = "cfbScreenInit"; break;
@@ -1017,6 +1218,9 @@ static Bool R128PreInitModes(ScrnInfoPtr pScrn)
#endif
if (mod && !xf86LoadSubModule(pScrn, mod)) return FALSE;
xf86LoaderReqSymbols(Sym, NULL);
+
+ info->CurrentLayout.displayWidth = pScrn->displayWidth;
+ info->CurrentLayout.mode = pScrn->currentMode;
return TRUE;
}
@@ -1053,7 +1257,142 @@ static Bool R128PreInitInt10(ScrnInfoPtr pScrn)
return TRUE;
}
-extern xf86MonPtr ConfiguredMonitor;
+#ifdef XF86DRI
+static Bool R128PreInitDRI(ScrnInfoPtr pScrn)
+{
+ R128InfoPtr info = R128PTR(pScrn);
+
+ if (info->IsPCI) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n");
+ info->CCEMode = R128_DEFAULT_CCE_PIO_MODE;
+ } else if (xf86ReturnOptValBool(R128Options, OPTION_CCE_PIO, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in PIO mode\n");
+ info->CCEMode = R128_DEFAULT_CCE_PIO_MODE;
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "CCE in BM mode\n");
+ info->CCEMode = R128_DEFAULT_CCE_BM_MODE;
+ }
+
+ if (xf86ReturnOptValBool(R128Options, OPTION_USE_CCE_2D, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using CCE for 2D\n");
+ info->CCE2D = TRUE;
+ } else {
+ info->CCE2D = FALSE;
+ }
+
+ if (xf86ReturnOptValBool(R128Options, OPTION_NO_SECURITY, FALSE)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "WARNING!!! CCE Security checks disabled!!! **********\n");
+ info->CCESecure = FALSE;
+ } else {
+ info->CCESecure = TRUE;
+ }
+
+ info->agpMode = R128_DEFAULT_AGP_MODE;
+ info->agpSize = R128_DEFAULT_AGP_SIZE;
+ info->ringSize = R128_DEFAULT_RING_SIZE;
+ info->vbSize = R128_DEFAULT_VB_SIZE;
+ info->indSize = R128_DEFAULT_IND_SIZE;
+ info->agpTexSize = R128_DEFAULT_AGP_TEX_SIZE;
+
+ info->vbBufSize = R128_DEFAULT_VB_BUF_SIZE;
+
+ info->CCEusecTimeout = R128_DEFAULT_CCE_TIMEOUT;
+
+ if (!info->IsPCI) {
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_AGP_MODE, &(info->agpMode))) {
+ if (info->agpMode < 1 || info->agpMode > R128_AGP_MAX_MODE) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal AGP Mode: %d\n", info->agpMode);
+ return FALSE;
+ }
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using AGP %dx mode\n", info->agpMode);
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_AGP_SIZE, (int *)&(info->agpSize))) {
+ switch (info->agpSize) {
+ case 4:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ case 256:
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal AGP size: %d MB\n", info->agpSize);
+ return FALSE;
+ }
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_RING_SIZE, &(info->ringSize))) {
+ if (info->ringSize < 1 || info->ringSize >= info->agpSize) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal ring buffer size: %d MB\n",
+ info->ringSize);
+ return FALSE;
+ }
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_VERT_SIZE, &(info->vbSize))) {
+ if (info->vbSize < 1 || info->vbSize >= info->agpSize) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal vertex buffers list size: %d MB\n",
+ info->vbSize);
+ return FALSE;
+ }
+ }
+
+ if (xf86GetOptValInteger(R128Options,
+ OPTION_VBUF_SIZE, &(info->vbBufSize))) {
+ int numBufs = info->vbSize*1024*1024/info->vbBufSize;
+ if (numBufs < 2 || numBufs > 512) { /* FIXME: 512 is arbitrary */
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Illegal individual vertex buffer size: %d bytes\n",
+ info->vbBufSize);
+ return FALSE;
+ }
+ }
+
+ if (info->ringSize + info->vbSize + info->indSize + info->agpTexSize >
+ info->agpSize) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Buffers are too big for requested AGP space\n");
+ return FALSE;
+ }
+
+ info->agpTexSize = info->agpSize - (info->ringSize +
+ info->vbSize +
+ info->indSize);
+
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB AGP aperture\n", info->agpSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for the ring buffer\n", info->ringSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for vertex buffers\n", info->vbSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for indirect buffers\n", info->indSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d MB for AGP textures\n", info->agpTexSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG,
+ "Using %d byte vertex buffers\n", info->vbBufSize);
+ }
+
+ if (xf86GetOptValInteger(R128Options, OPTION_USEC_TIMEOUT,
+ &(info->CCEusecTimeout))) {
+ /* This option checked by the R128 DRM kernel module */
+ }
+
+ return TRUE;
+}
+#endif
static void
R128ProbeDDC(ScrnInfoPtr pScrn, int index)
@@ -1061,7 +1400,7 @@ R128ProbeDDC(ScrnInfoPtr pScrn, int index)
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
pVbe = VBEInit(NULL,index);
- ConfiguredMonitor = vbeDoEDID(pVbe);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
}
}
@@ -1152,6 +1491,10 @@ static Bool R128PreInit(ScrnInfoPtr pScrn, int flags)
if (!R128PreInitAccel(pScrn)) goto fail;
+#ifdef XF86DRI
+ if (!R128PreInitDRI(pScrn)) goto fail;
+#endif
+
return TRUE;
fail:
@@ -1161,62 +1504,53 @@ static Bool R128PreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
-/* Load a palette for 15bpp mode. This sends 32 values. */
-static void R128LoadPalette15(ScrnInfoPtr pScrn, int numColors,
- int *indices, LOCO *colors, VisualPtr pVisual)
+/* Load a palette. */
+static void R128LoadPalette(ScrnInfoPtr pScrn, int numColors,
+ int *indices, LOCO *colors, VisualPtr pVisual)
{
+ R128InfoPtr info = R128PTR(pScrn);
int i;
int idx;
unsigned char r, g, b;
R128MMIO_VARS();
- for (i = 0; i < numColors; i++) {
- idx = indices[i];
- r = colors[idx].red;
- g = colors[idx].green;
- b = colors[idx].blue;
- OUTPAL(idx * 8, r, g, b);
+ /* Select palette 0 (main CRTC) if using FP-enabled chip */
+ if (info->HasPanelRegs) PAL_SELECT(0);
+
+ if (info->CurrentLayout.depth == 15) {
+ /* 15bpp mode. This sends 32 values. */
+ for (i = 0; i < numColors; i++) {
+ idx = indices[i];
+ r = colors[idx].red;
+ g = colors[idx].green;
+ b = colors[idx].blue;
+ OUTPAL(idx * 8, r, g, b);
+ }
}
-}
-
-/* Load a palette for 16bpp mode. This sends 64 values. */
-static void R128LoadPalette16(ScrnInfoPtr pScrn, int numColors,
- int *indices, LOCO *colors, VisualPtr pVisual)
-{
- int i;
- int idx;
- unsigned char r, g, b;
- R128MMIO_VARS();
-
+ else if (info->CurrentLayout.depth == 16) {
+ /* 16bpp mode. This sends 64 values. */
/* There are twice as many green values as
there are values for red and blue. So,
we take each red and blue pair, and
combine it with each of the two green
values. */
- for (i = 0; i < numColors; i++) {
- idx = indices[i];
- r = colors[idx / 2].red;
- g = colors[idx].green;
- b = colors[idx / 2].blue;
- OUTPAL(idx * 4, r, g, b);
+ for (i = 0; i < numColors; i++) {
+ idx = indices[i];
+ r = colors[idx / 2].red;
+ g = colors[idx].green;
+ b = colors[idx / 2].blue;
+ OUTPAL(idx * 4, r, g, b);
+ }
}
-}
-
-/* Load a palette for 8bpp mode. This sends 256 values. */
-static void R128LoadPalette(ScrnInfoPtr pScrn, int numColors,
- int *indices, LOCO *colors, VisualPtr pVisual)
-{
- int i;
- int idx;
- unsigned char r, g, b;
- R128MMIO_VARS();
-
- for (i = 0; i < numColors; i++) {
- idx = indices[i];
- r = colors[idx].red;
- b = colors[idx].blue;
- g = colors[idx].green;
- OUTPAL(idx, r, g, b);
+ else {
+ /* 8bpp mode. This sends 256 values. */
+ for (i = 0; i < numColors; i++) {
+ idx = indices[i];
+ r = colors[idx].red;
+ b = colors[idx].blue;
+ g = colors[idx].green;
+ OUTPAL(idx, r, g, b);
+ }
}
}
@@ -1231,9 +1565,20 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset));
+#ifdef XF86DRI
+ /* Turn off the CCE for now. */
+ info->CCEInUse = FALSE;
+#endif
+
if (!R128MapMem(pScrn)) return FALSE;
pScrn->fbOffset = 0;
-
+#ifdef XF86DRI
+ info->fbX = 0;
+ info->fbY = 0;
+#endif
+
+ info->PaletteSavedOnVT = FALSE;
+
R128Save(pScrn);
if (info->FBDev) {
if (!fbdevHWModeInit(pScrn, pScrn->currentMode)) return FALSE;
@@ -1251,6 +1596,18 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
pScrn->rgbBits,
pScrn->defaultVisual)) return FALSE;
+#ifdef XF86DRI
+ /* Setup DRI after visuals have been
+ established, but before cfbScreenInit is
+ called. cfbScreenInit will eventually
+ call the driver's InitGLXVisuals call
+ back. */
+ if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE))
+ info->directRenderingEnabled = R128DRIScreenInit(pScreen);
+ else
+ info->directRenderingEnabled = FALSE;
+#endif
+
#ifdef USE_FB
if (!fbScreenInit (pScreen, info->FB,
pScrn->virtualX, pScrn->virtualY,
@@ -1317,11 +1674,13 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
}
}
+ R128DGAInit(pScreen);
+
/* Memory manager setup */
MemBox.x1 = 0;
MemBox.y1 = 0;
MemBox.x2 = pScrn->displayWidth;
- y2 = info->FbMapSize / (pScrn->displayWidth * info->pixel_bytes);
+ y2 = info->FbMapSize / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes);
if (y2 >= 32768) y2 = 32767; /* because MemBox.y2 is signed short */
MemBox.y2 = y2;
@@ -1358,6 +1717,103 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
}
}
+#ifdef XF86DRI
+ /* Allocate frame buffer space for the
+ shared back and depth buffers as well
+ as for local textures. */
+ if (info->directRenderingEnabled) {
+ FBAreaPtr fbarea;
+ int width_bytes = (pScrn->displayWidth *
+ info->CurrentLayout.pixel_bytes);
+ int maxy = info->FbMapSize / width_bytes;
+ int l;
+
+ /* Allocate the shared back buffer */
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ 32, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved back buffer from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+
+ info->backX = fbarea->box.x1;
+ info->backY = fbarea->box.y1;
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n");
+ info->backX = -1;
+ info->backY = -1;
+ }
+
+ /* Allocate the shared depth buffer */
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ 32, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved depth buffer from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+
+ info->depthX = fbarea->box.x1;
+ info->depthY = fbarea->box.y1;
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n");
+ info->depthX = -1;
+ info->depthY = -1;
+ }
+
+ /* Allocate local texture space */
+ if (((maxy - MemBox.y2 - 1) * width_bytes) >
+ (pScrn->virtualX * pScrn->virtualY * 2 *
+ info->CurrentLayout.pixel_bytes)) {
+ info->textureX = 0;
+ info->textureY = MemBox.y2 + 1;
+ info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes;
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
+ info->textureSize/1024,
+ info->textureX, info->textureY,
+ pScrn->displayWidth, maxy);
+ } else if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY * 2,
+ 32,
+ NULL, NULL, NULL))) {
+ info->textureX = fbarea->box.x1;
+ info->textureY = fbarea->box.y1;
+ info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) *
+ (fbarea->box.x2 - fbarea->box.x1) *
+ info->CurrentLayout.pixel_bytes);
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ info->log2TexGran = l;
+ info->textureSize = (info->textureSize >> l) << l;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
+ info->textureSize/1024,
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Unable to reserve texture space in frame buffer\n");
+ info->textureX = -1;
+ info->textureY = -1;
+ }
+ }
+#endif
+
/* Backing store setup */
miInitializeBackingStore(pScreen);
xf86SetBackingStore(pScreen);
@@ -1403,28 +1859,12 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
/* Colormap setup */
if (!miCreateDefColormap(pScreen)) return FALSE;
- if (pScrn->depth == 15) {
- if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8,
- (info->FBDev ? fbdevHWLoadPalette :
- R128LoadPalette15), NULL,
- CMAP_PALETTED_TRUECOLOR
- | CMAP_RELOAD_ON_MODE_SWITCH
- | CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE;
- } else if (pScrn->depth == 16) {
- if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8,
- (info->FBDev ? fbdevHWLoadPalette :
- R128LoadPalette16), NULL,
- CMAP_PALETTED_TRUECOLOR
- | CMAP_RELOAD_ON_MODE_SWITCH
- | CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE;
- } else {
- if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8,
- (info->FBDev ? fbdevHWLoadPalette :
- R128LoadPalette), NULL,
- CMAP_PALETTED_TRUECOLOR
- | CMAP_RELOAD_ON_MODE_SWITCH
- | CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE;
- }
+ if (!xf86HandleColormaps(pScreen, 256, info->dac6bits ? 6 : 8,
+ (info->FBDev ? fbdevHWLoadPalette :
+ R128LoadPalette), NULL,
+ CMAP_PALETTED_TRUECOLOR
+ | CMAP_RELOAD_ON_MODE_SWITCH
+ | CMAP_LOAD_EVEN_IF_OFFSCREEN)) return FALSE;
/* DPMS setup */
#ifdef DPMSExtension
@@ -1453,6 +1893,21 @@ static Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen,
if (serverGeneration == 1)
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+#ifdef XF86DRI
+ /* DRI finalization */
+ if (info->directRenderingEnabled) {
+ /* Now that mi, cfb, drm and others have
+ done their thing, complete the DRI
+ setup. */
+ info->directRenderingEnabled = R128DRIFinishScreenInit(pScreen);
+ }
+ if (info->directRenderingEnabled) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering enabled\n");
+ } else {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Direct rendering disabled\n");
+ }
+#endif
+
return TRUE;
}
@@ -1473,7 +1928,7 @@ static void R128RestoreCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr restore)
OUTREG(R128_GEN_INT_CNTL, restore->gen_int_cntl);
OUTREG(R128_CAP0_TRIG_CNTL, restore->cap0_trig_cntl);
OUTREG(R128_CAP1_TRIG_CNTL, restore->cap1_trig_cntl);
- OUTREG(R128_BUS_CNTL, restore->bus_cntl);
+ OUTREG(R128_BUS_CNTL, restore->bus_cntl);
}
/* Write CRTC registers. */
@@ -1498,6 +1953,24 @@ static void R128RestoreCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr restore)
OUTREG(R128_CRTC_PITCH, restore->crtc_pitch);
}
+/* Write flat panel registers */
+static void R128RestoreFPRegisters(ScrnInfoPtr pScrn, R128SavePtr restore)
+{
+ R128MMIO_VARS();
+
+ OUTREG(R128_CRTC2_GEN_CNTL, restore->crtc2_gen_cntl);
+ OUTREG(R128_FP_CRTC_H_TOTAL_DISP, restore->fp_crtc_h_total_disp);
+ OUTREG(R128_FP_CRTC_V_TOTAL_DISP, restore->fp_crtc_v_total_disp);
+ OUTREG(R128_FP_GEN_CNTL, restore->fp_gen_cntl);
+ OUTREG(R128_FP_H_SYNC_STRT_WID, restore->fp_h_sync_strt_wid);
+ OUTREG(R128_FP_HORZ_STRETCH, restore->fp_horz_stretch);
+ OUTREG(R128_FP_PANEL_CNTL, restore->fp_panel_cntl);
+ OUTREG(R128_FP_V_SYNC_STRT_WID, restore->fp_v_sync_strt_wid);
+ OUTREG(R128_FP_VERT_STRETCH, restore->fp_vert_stretch);
+ OUTREG(R128_LVDS_GEN_CNTL, restore->lvds_gen_cntl);
+ OUTREG(R128_TMDS_CRC, restore->tmds_crc);
+}
+
static void R128PLLWaitForReadUpdateComplete(ScrnInfoPtr pScrn)
{
while (INPLL(pScrn, R128_PPLL_REF_DIV) & R128_PPLL_ATOMIC_UPDATE_R);
@@ -1566,11 +2039,15 @@ static void R128RestoreDDARegisters(ScrnInfoPtr pScrn, R128SavePtr restore)
/* Write palette data. */
static void R128RestorePalette(ScrnInfoPtr pScrn, R128SavePtr restore)
{
- int i;
+ R128InfoPtr info = R128PTR(pScrn);
+ int i;
R128MMIO_VARS();
if (!restore->palette_valid) return;
+ /* Select palette 0 (main CRTC) if using FP-enabled chip */
+ if (info->HasPanelRegs) PAL_SELECT(0);
+
OUTPAL_START(0);
for (i = 0; i < 256; i++) OUTPAL_NEXT_CARD32(restore->palette[i]);
}
@@ -1581,6 +2058,8 @@ static void R128RestoreMode(ScrnInfoPtr pScrn, R128SavePtr restore)
R128TRACE(("R128RestoreMode(%p)\n", restore));
R128RestoreCommonRegisters(pScrn, restore);
R128RestoreCrtcRegisters(pScrn, restore);
+ if (R128PTR(pScrn)->HasPanelRegs && R128PTR(pScrn)->EnableFP)
+ R128RestoreFPRegisters(pScrn, restore);
R128RestorePLLRegisters(pScrn, restore);
R128RestoreDDARegisters(pScrn, restore);
R128RestorePalette(pScrn, restore);
@@ -1603,7 +2082,7 @@ static void R128SaveCommonRegisters(ScrnInfoPtr pScrn, R128SavePtr save)
save->gen_int_cntl = INREG(R128_GEN_INT_CNTL);
save->cap0_trig_cntl = INREG(R128_CAP0_TRIG_CNTL);
save->cap1_trig_cntl = INREG(R128_CAP1_TRIG_CNTL);
- save->bus_cntl = INREG(R128_BUS_CNTL);
+ save->bus_cntl = INREG(R128_BUS_CNTL);
}
/* Read CRTC registers. */
@@ -1623,6 +2102,24 @@ static void R128SaveCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save)
save->crtc_pitch = INREG(R128_CRTC_PITCH);
}
+/* Read flat panel registers */
+static void R128SaveFPRegisters(ScrnInfoPtr pScrn, R128SavePtr save)
+{
+ R128MMIO_VARS();
+
+ save->crtc2_gen_cntl = INREG(R128_CRTC2_GEN_CNTL);
+ save->fp_crtc_h_total_disp = INREG(R128_FP_CRTC_H_TOTAL_DISP);
+ save->fp_crtc_v_total_disp = INREG(R128_FP_CRTC_V_TOTAL_DISP);
+ save->fp_gen_cntl = INREG(R128_FP_GEN_CNTL);
+ save->fp_h_sync_strt_wid = INREG(R128_FP_H_SYNC_STRT_WID);
+ save->fp_horz_stretch = INREG(R128_FP_HORZ_STRETCH);
+ save->fp_panel_cntl = INREG(R128_FP_PANEL_CNTL);
+ save->fp_v_sync_strt_wid = INREG(R128_FP_V_SYNC_STRT_WID);
+ save->fp_vert_stretch = INREG(R128_FP_VERT_STRETCH);
+ save->lvds_gen_cntl = INREG(R128_LVDS_GEN_CNTL);
+ save->tmds_crc = INREG(R128_TMDS_CRC);
+}
+
/* Read PLL registers. */
static void R128SavePLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save)
{
@@ -1652,9 +2149,13 @@ static void R128SaveDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save)
/* Read palette data. */
static void R128SavePalette(ScrnInfoPtr pScrn, R128SavePtr save)
{
- int i;
+ R128InfoPtr info = R128PTR(pScrn);
+ int i;
R128MMIO_VARS();
+ /* Select palette 0 (main CRTC) if using FP-enabled chip */
+ if (info->HasPanelRegs) PAL_SELECT(0);
+
INPAL_START(0);
for (i = 0; i < 256; i++) save->palette[i] = INPAL_NEXT();
save->palette_valid = TRUE;
@@ -1667,6 +2168,8 @@ static void R128SaveMode(ScrnInfoPtr pScrn, R128SavePtr save)
R128SaveCommonRegisters(pScrn, save);
R128SaveCrtcRegisters(pScrn, save);
+ if (R128PTR(pScrn)->HasPanelRegs && R128PTR(pScrn)->EnableFP)
+ R128SaveFPRegisters(pScrn, save);
R128SavePLLRegisters(pScrn, save);
R128SaveDDARegisters(pScrn, save);
R128SavePalette(pScrn, save);
@@ -1765,7 +2268,7 @@ static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save,
int vsync_wid;
int bytpp;
- switch (info->pixel_code) {
+ switch (info->CurrentLayout.pixel_code) {
case 4: format = 1; bytpp = 0; hsync_fudge = 0; break;
case 8: format = 2; bytpp = 1; hsync_fudge = 18; break;
case 15: format = 3; bytpp = 2; hsync_fudge = 9; break; /* 555 */
@@ -1774,7 +2277,7 @@ static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save,
case 32: format = 6; bytpp = 4; hsync_fudge = 5; break; /* xRGB */
default:
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Unsupported pixel depth (%d)\n", pScrn->bitsPerPixel);
+ "Unsupported pixel depth (%d)\n", info->CurrentLayout.bitsPerPixel);
return FALSE;
}
R128TRACE(("Format = %d (%d bytes per pixel)\n", format, bytpp));
@@ -1834,13 +2337,135 @@ static Bool R128InitCrtcRegisters(ScrnInfoPtr pScrn, R128SavePtr save,
: 0));
save->crtc_offset = 0;
save->crtc_offset_cntl = 0;
- save->crtc_pitch = pScrn->displayWidth / 8;
+ save->crtc_pitch = info->CurrentLayout.displayWidth / 8;
R128TRACE(("Pitch = %d bytes (virtualX = %d, displayWidth = %d)\n",
- save->crtc_pitch, pScrn->virtualX, pScrn->displayWidth));
+ save->crtc_pitch, pScrn->virtualX, info->CurrentLayout.displayWidth));
return TRUE;
}
+/* Define CRTC registers for requested video mode. */
+static void R128InitFPRegisters(ScrnInfoPtr pScrn, R128SavePtr orig,
+ R128SavePtr save, DisplayModePtr mode,
+ R128InfoPtr info)
+{
+ int xres = mode->CrtcHDisplay;
+ int yres = mode->CrtcVDisplay;
+ float Hratio, Vratio;
+ int disp_end;
+
+ if (info->CRTOnly) {
+ save->crtc_ext_cntl |= R128_CRTC_CRT_ON;
+ save->crtc2_gen_cntl = 0;
+ save->fp_gen_cntl = orig->fp_gen_cntl;
+ save->fp_gen_cntl &= ~(R128_FP_FPON |
+ R128_FP_CRTC_USE_SHADOW_VEND |
+ R128_FP_CRTC_HORZ_DIV2_EN |
+ R128_FP_CRTC_HOR_CRT_DIV2_DIS |
+ R128_FP_USE_SHADOW_EN);
+ save->fp_gen_cntl |= (R128_FP_SEL_CRTC2 |
+ R128_FP_CRTC_DONT_SHADOW_VPAR);
+ save->fp_panel_cntl = orig->fp_panel_cntl & ~R128_FP_DIGON;
+ save->lvds_gen_cntl = orig->lvds_gen_cntl & ~R128_LVDS_ON;
+ return;
+ }
+
+ if (xres > info->PanelXRes) xres = info->PanelXRes;
+ if (yres > info->PanelYRes) yres = info->PanelYRes;
+
+ Hratio = (float)xres/(float)info->PanelXRes;
+ Vratio = (float)yres/(float)info->PanelYRes;
+
+ save->fp_horz_stretch =
+ (((((int)(Hratio * R128_HORZ_STRETCH_RATIO_MAX))
+ & R128_HORZ_STRETCH_RATIO_MASK) << R128_HORZ_STRETCH_RATIO_SHIFT) |
+ (orig->fp_horz_stretch & (R128_HORZ_PANEL_SIZE |
+ R128_HORZ_FP_LOOP_STRETCH |
+ R128_HORZ_STRETCH_RESERVED)));
+ if (Hratio != 1.0) save->fp_horz_stretch |= (R128_HORZ_STRETCH_BLEND |
+ R128_HORZ_STRETCH_ENABLE);
+
+ save->fp_vert_stretch =
+ (((((int)(Vratio * R128_VERT_STRETCH_RATIO_MAX))
+ & R128_VERT_STRETCH_RATIO_MASK) << R128_VERT_STRETCH_RATIO_SHIFT) |
+ (orig->fp_vert_stretch & (R128_VERT_PANEL_SIZE |
+ R128_VERT_STRETCH_RESERVED |
+ R128_VERT_STRETCH_BLEND)));
+ if (Vratio == 1.0) save->fp_vert_stretch &= ~R128_VERT_STRETCH_ENABLE;
+ else save->fp_vert_stretch |= R128_VERT_STRETCH_ENABLE;
+
+ save->fp_gen_cntl = ((orig->fp_gen_cntl & ~(R128_FP_SEL_CRTC2 |
+ R128_FP_CRTC_USE_SHADOW_VEND |
+ R128_FP_CRTC_HORZ_DIV2_EN |
+ R128_FP_CRTC_HOR_CRT_DIV2_DIS |
+ R128_FP_USE_SHADOW_EN)) |
+ R128_FP_CRTC_DONT_SHADOW_VPAR |
+ R128_FP_TDMS_EN);
+ save->fp_panel_cntl = orig->fp_panel_cntl;
+ save->fp_crtc_h_total_disp = orig->fp_crtc_h_total_disp;
+ save->fp_crtc_v_total_disp = orig->fp_crtc_v_total_disp;
+ save->fp_h_sync_strt_wid = orig->fp_h_sync_strt_wid;
+ save->fp_v_sync_strt_wid = orig->fp_v_sync_strt_wid;
+ save->lvds_gen_cntl = orig->lvds_gen_cntl;
+
+ save->tmds_crc = orig->tmds_crc;
+
+ /* Disable CRT output by disabling CRT output and setting the CRT
+ DAC to use CRTC2, which we set to 0's. In the future, we will
+ want to use the dual CRTC capabilities of the R128 to allow both
+ the flat panel and external CRT to either simultaneously display
+ the same image or display two different images. */
+ save->crtc_ext_cntl &= ~R128_CRTC_CRT_ON;
+ save->dac_cntl |= R128_DAC_CRT_SEL_CRTC2;
+ save->crtc2_gen_cntl = 0;
+
+ save->fp_panel_cntl |= (R128_FP_DIGON | R128_FP_BLON);
+ save->fp_gen_cntl |= (R128_FP_FPON);
+
+ save->crtc_gen_cntl &= ~(R128_CRTC_DBL_SCAN_EN |
+ R128_CRTC_INTERLACE_EN |
+ R128_CRTC_CSYNC_EN |
+ R128_CRTC_CUR_EN |
+ R128_CRTC_CUR_MODE_MASK |
+ R128_CRTC_ICON_EN |
+ R128_CRTC_EXT_DISP_EN |
+ R128_CRTC_EN |
+ R128_CRTC_DISP_REQ_EN_B);
+ save->crtc_gen_cntl |= R128_CRTC_EXT_DISP_EN | R128_CRTC_EN;
+
+ disp_end = xres/8 - 1;
+ save->crtc_h_total_disp = ((disp_end << R128_CRTC_H_DISP_SHIFT) |
+ (disp_end + info->PanelHNonVis));
+
+ save->crtc_h_sync_strt_wid &= ~(R128_CRTC_H_SYNC_STRT_PIX |
+ R128_CRTC_H_SYNC_STRT_CHAR |
+ R128_CRTC_H_SYNC_WID);
+ save->crtc_h_sync_strt_wid |=
+ (disp_end + info->PanelHOverPlus) << R128_CRTC_H_SYNC_STRT_CHAR_SHIFT;
+ switch (info->CurrentLayout.pixel_code) {
+ /* Adjustments are from ATI */
+ case 8: save->crtc_h_sync_strt_wid |= 2; break;
+ case 15:
+ case 16: save->crtc_h_sync_strt_wid |= 1; break;
+ case 24: save->crtc_h_sync_strt_wid |= 6; break;
+ case 32: save->crtc_h_sync_strt_wid |= 5; break;
+ }
+ save->crtc_h_sync_strt_wid |=
+ info->PanelHSyncWidth << R128_CRTC_H_SYNC_WID_SHIFT;
+ save->crtc_h_sync_strt_wid |= R128_CRTC_H_SYNC_POL;
+
+ disp_end = yres - 1;
+ save->crtc_v_total_disp = ((disp_end << R128_CRTC_V_DISP_SHIFT) |
+ (disp_end + info->PanelVNonVis));
+
+ save->crtc_v_sync_strt_wid &= ~(R128_CRTC_V_SYNC_STRT |
+ R128_CRTC_V_SYNC_WID);
+ save->crtc_v_sync_strt_wid |= (disp_end + info->PanelVOverPlus);
+ save->crtc_v_sync_strt_wid |=
+ info->PanelVSyncWidth << R128_CRTC_V_SYNC_WID_SHIFT;
+ save->crtc_v_sync_strt_wid |= R128_CRTC_V_SYNC_POL;
+}
+
/* Define PLL registers for requested video mode. */
static void R128InitPLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save,
DisplayModePtr mode, R128PLLPtr pll,
@@ -1914,13 +2539,13 @@ static Bool R128InitDDARegisters(ScrnInfoPtr pScrn, R128SavePtr save,
pll->reference_div * save->post_div);
XclksPerTransfer = R128Div(XclkFreq * DisplayFifoWidth,
- VclkFreq * (info->pixel_bytes * 8));
+ VclkFreq * (info->CurrentLayout.pixel_bytes * 8));
UseablePrecision = R128MinBits(XclksPerTransfer) + 1;
XclksPerTransferPrecise = R128Div((XclkFreq * DisplayFifoWidth)
<< (11 - UseablePrecision),
- VclkFreq * (info->pixel_bytes * 8));
+ VclkFreq * (info->CurrentLayout.pixel_bytes * 8));
Roff = XclksPerTransferPrecise * (DisplayFifoDepth - 4);
@@ -2022,11 +2647,13 @@ static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save)
R128InitCommonRegisters(save, mode, info);
if (!R128InitCrtcRegisters(pScrn, save, mode, info)) return FALSE;
+ if (info->HasPanelRegs && info->EnableFP)
+ R128InitFPRegisters(pScrn, &info->SavedReg, save, mode, info);
R128InitPLLRegisters(pScrn, save, mode, &info->pll, dot_clock);
if (!R128InitDDARegisters(pScrn, save, mode, &info->pll, info))
return FALSE;
- R128InitPalette(save, info);
-
+ if (!info->PaletteSavedOnVT) R128InitPalette(save, info);
+
R128TRACE(("R128Init returns %p\n", save));
return TRUE;
}
@@ -2037,9 +2664,13 @@ static Bool R128ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
R128InfoPtr info = R128PTR(pScrn);
if (!R128Init(pScrn, mode, &info->ModeReg)) return FALSE;
+ /* FIXME? DRILock/DRIUnlock here? */
R128Blank(pScrn);
R128RestoreMode(pScrn, &info->ModeReg);
R128Unblank(pScrn);
+
+ info->CurrentLayout.mode = mode;
+
return TRUE;
}
@@ -2054,7 +2685,7 @@ static Bool R128SaveScreen(ScreenPtr pScreen, int mode)
return TRUE;
}
-static Bool R128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+Bool R128SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
return R128ModeInit(xf86Screens[scrnIndex], mode);
}
@@ -2068,16 +2699,16 @@ static int R128ValidMode(int scrnIndex, DisplayModePtr mode,
/* Adjust viewport into virtual desktop such that (0,0) in viewport space
is (x,y) in virtual space. */
-static void R128AdjustFrame(int scrnIndex, int x, int y, int flags)
+void R128AdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
R128InfoPtr info = R128PTR(pScrn);
int Base;
R128MMIO_VARS();
- Base = y * pScrn->displayWidth + x;
+ Base = y * info->CurrentLayout.displayWidth + x;
- switch (info->pixel_code) {
+ switch (info->CurrentLayout.pixel_code) {
case 15:
case 16: Base *= 2; break;
case 24: Base *= 3; break;
@@ -2086,7 +2717,7 @@ static void R128AdjustFrame(int scrnIndex, int x, int y, int flags)
Base &= ~7; /* 3 lower bits are always 0 */
- if (info->pixel_code == 24)
+ if (info->CurrentLayout.pixel_code == 24)
Base += 8 * (Base % 3); /* Must be multiple of 8 and 3 */
OUTREG(R128_CRTC_OFFSET, Base);
@@ -2096,14 +2727,43 @@ static void R128AdjustFrame(int scrnIndex, int x, int y, int flags)
mode. */
static Bool R128EnterVT(int scrnIndex, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ R128InfoPtr info = R128PTR(pScrn);
R128TRACE(("R128EnterVT\n"));
+#ifdef XF86DRI
+ if (R128PTR(pScrn)->directRenderingEnabled) {
+ R128CCEStart(pScrn);
+ DRIUnlock(pScrn->pScreen);
+ }
+#endif
if (!R128ModeInit(pScrn, pScrn->currentMode)) return FALSE;
+ info->PaletteSavedOnVT = FALSE;
R128AdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
+
return TRUE;
}
+/* Called when VT switching away from the X server. Restore the original
+ text mode. */
+static void R128LeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ R128InfoPtr info = R128PTR(pScrn);
+ R128SavePtr save = &info->ModeReg;
+
+ R128TRACE(("R128LeaveVT\n"));
+#ifdef XF86DRI
+ if (R128PTR(pScrn)->directRenderingEnabled) {
+ DRILock(pScrn->pScreen, 0);
+ R128CCEStop(pScrn);
+ }
+#endif
+ R128SavePalette(pScrn, save);
+ info->PaletteSavedOnVT = TRUE;
+ R128Restore(pScrn);
+}
+
static Bool
R128EnterVTFBDev(int scrnIndex, int flags)
{
@@ -2116,8 +2776,6 @@ R128EnterVTFBDev(int scrnIndex, int flags)
return TRUE;
}
-/* Called when VT switching away from the X server. Restore the original
- text mode. */
static void R128LeaveVTFBDev(int scrnIndex, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
@@ -2127,14 +2785,6 @@ static void R128LeaveVTFBDev(int scrnIndex, int flags)
fbdevHWLeaveVT(scrnIndex,flags);
}
-static void R128LeaveVT(int scrnIndex, int flags)
-{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- R128TRACE(("R128LeaveVT\n"));
- R128Restore(pScrn);
-}
-
/* Called at the end of each server generation. Restore the original text
mode, unmap video memory, and unwrap and call the saved CloseScreen
function. */
@@ -2144,6 +2794,15 @@ static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen)
R128InfoPtr info = R128PTR(pScrn);
R128TRACE(("R128CloseScreen\n"));
+
+#ifdef XF86DRI
+ /* Disable direct rendering */
+ if (info->directRenderingEnabled) {
+ R128DRICloseScreen(pScreen);
+ info->directRenderingEnabled = FALSE;
+ }
+#endif
+
if (pScrn->vtSema) {
R128Restore(pScrn);
R128UnmapMem(pScrn);
@@ -2157,6 +2816,9 @@ static Bool R128CloseScreen(int scrnIndex, ScreenPtr pScreen)
if (info->cursor) xf86DestroyCursorInfoRec(info->cursor);
info->cursor = NULL;
+
+ if (info->DGAModes) xfree(info->DGAModes);
+ info->DGAModes = NULL;
pScrn->vtSema = FALSE;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
index 86652affa..9b920eb98 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h
@@ -1,8 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.6 2000/02/23 04:47:19 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_reg.h,v 1.11 2000/07/01 01:40:46 martin Exp $ */
/**************************************************************************
-Copyright 1999 ATI Technologies Inc. and Precision Insight, Inc.,
- Cedar Park, Texas.
+Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc.,
+ Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
@@ -46,50 +46,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define _R128_REG_H_
#include <compiler.h>
-#if defined(__powerpc__)
-
-static inline void regw(volatile unsigned long base_addr, unsigned long regindex, unsigned long regdata)
-{
- asm volatile ("stwbrx %1,%2,%3; eieio"
- : "=m" (*(volatile unsigned *)(base_addr+regindex))
- : "r" (regdata), "b" (regindex), "r" (base_addr));
-}
-
-static inline void regw16(volatile unsigned long base_addr, unsigned long regindex, unsigned short regdata)
-{
- asm volatile ("sthbrx %0,%1,%2; eieio": : "r"(regdata), "b"(regindex), "r"(base_addr));
-}
-
-static inline unsigned long regr(volatile unsigned long base_addr, unsigned long regindex)
-{
- register unsigned long val;
- asm volatile ("lwbrx %0,%1,%2; eieio"
- : "=r"(val)
- : "b"(regindex), "r"(base_addr),
- "m" (*(volatile unsigned *)(base_addr+regindex)));
- return(val);
-}
-
-static inline unsigned short regr16(volatile unsigned long base_addr, unsigned long regindex)
-{
- register unsigned short val;
- asm volatile ("lhbrx %0,%1,%2; eieio": "=r"(val):"b"(regindex), "r"(base_addr));
- return(val);
-}
-
- /* Memory mapped register access macros */
-#define INREG(addr) regr(((unsigned long)R128MMIO),(addr))
-#define INREG8(addr) *(volatile CARD8 *)(R128MMIO + (addr))
-#define INREG16(addr) regr16(((unsigned long)R128MMIO), (addr))
-#define OUTREG(addr, val) regw(((unsigned long)R128MMIO), (addr), (val))
-#define OUTREG8(addr, val) *(volatile CARD8 *)(R128MMIO + (addr)) = (val)
-#define OUTREG16(addr, val) regw16(((unsigned long)R128MMIO), (addr), (val))
-#define ADDRREG(addr) ((volatile CARD32 *)(R128MMIO + (addr)))
-
-#define R128MMIO_VARS() \
- unsigned char *R128MMIO = R128PTR(pScrn)->MMIO
-
-#else
/* Memory mapped register access macros */
#define INREG8(addr) MMIO_IN8(R128MMIO, addr)
#define INREG16(addr) MMIO_IN16(R128MMIO, addr)
@@ -103,7 +59,6 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128MMIO_VARS() \
unsigned char *R128MMIO = R128PTR(pScrn)->MMIO
-#endif
#define OUTREGP(addr, val, mask) \
do { \
@@ -155,13 +110,37 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define INPAL_NEXT() INREG(R128_PALETTE_DATA)
+#define PAL_SELECT(idx) \
+ do { \
+ if (idx) { \
+ OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) | \
+ R128_DAC_PALETTE_ACC_CTL); \
+ } else { \
+ OUTREG(R128_DAC_CNTL, INREG(R128_DAC_CNTL) & \
+ ~R128_DAC_PALETTE_ACC_CTL); \
+ } \
+ } while (0)
+
#define R128_ADAPTER_ID 0x0f2c /* PCI */
#define R128_AGP_APER_OFFSET 0x0178
#define R128_AGP_BASE 0x0170
#define R128_AGP_CNTL 0x0174
+# define R128_AGP_APER_SIZE_256MB (0x00 << 0)
+# define R128_AGP_APER_SIZE_128MB (0x20 << 0)
+# define R128_AGP_APER_SIZE_64MB (0x30 << 0)
+# define R128_AGP_APER_SIZE_32MB (0x38 << 0)
+# define R128_AGP_APER_SIZE_16MB (0x3c << 0)
+# define R128_AGP_APER_SIZE_8MB (0x3e << 0)
+# define R128_AGP_APER_SIZE_4MB (0x3f << 0)
+# define R128_AGP_APER_SIZE_MASK (0x3f << 0)
+#define R128_AGP_CNTL_B 0x0b44
#define R128_AGP_COMMAND 0x0f58 /* PCI */
#define R128_AGP_PLL_CNTL 0x0010 /* PLL */
#define R128_AGP_STATUS 0x0f54 /* PCI */
+# define R128_AGP_1X_MODE 0x01
+# define R128_AGP_2X_MODE 0x02
+# define R128_AGP_4X_MODE 0x04
+# define R128_AGP_MODE_MASK 0x07
#define R128_AMCGPIO_A_REG 0x01a0
#define R128_AMCGPIO_EN_REG 0x01a8
#define R128_AMCGPIO_MASK 0x0194
@@ -169,6 +148,15 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_ATTRDR 0x03c1 /* VGA */
#define R128_ATTRDW 0x03c0 /* VGA */
#define R128_ATTRX 0x03c0 /* VGA */
+# define R128_AUX1_SC_EN (1 << 0)
+# define R128_AUX1_SC_MODE_OR (0 << 1)
+# define R128_AUX1_SC_MODE_NAND (1 << 1)
+# define R128_AUX2_SC_EN (1 << 2)
+# define R128_AUX2_SC_MODE_OR (0 << 3)
+# define R128_AUX2_SC_MODE_NAND (1 << 3)
+# define R128_AUX3_SC_EN (1 << 4)
+# define R128_AUX3_SC_MODE_OR (0 << 5)
+# define R128_AUX3_SC_MODE_NAND (1 << 5)
#define R128_AUX_SC_CNTL 0x1660
#define R128_AUX1_SC_BOTTOM 0x1670
#define R128_AUX1_SC_LEFT 0x1664
@@ -182,6 +170,8 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_AUX3_SC_LEFT 0x1684
#define R128_AUX3_SC_RIGHT 0x1688
#define R128_AUX3_SC_TOP 0x168c
+#define R128_AUX_WINDOW_HORZ_CNTL 0x02d8
+#define R128_AUX_WINDOW_VERT_CNTL 0x02dc
#define R128_BASE_CODE 0x0f0b
#define R128_BIOS_0_SCRATCH 0x0010
@@ -257,12 +247,14 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_BRUSH_SCALE 0x1470
#define R128_BRUSH_Y_X 0x1474
#define R128_BUS_CNTL 0x0030
-# define R128_BUS_RD_DISCARD_EN (1 << 24)
-# define R128_BUS_RD_ABORT_EN (1 << 25)
-# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28)
-# define R128_BUS_WRT_BURST (1 << 29)
-# define R128_BUS_READ_BURST (1 << 30)
+# define R128_BUS_MASTER_DIS (1 << 6)
+# define R128_BUS_RD_DISCARD_EN (1 << 24)
+# define R128_BUS_RD_ABORT_EN (1 << 25)
+# define R128_BUS_MSTR_DISCONNECT_EN (1 << 28)
+# define R128_BUS_WRT_BURST (1 << 29)
+# define R128_BUS_READ_BURST (1 << 30)
#define R128_BUS_CNTL1 0x0034
+# define R128_BUS_WAIT_ON_LOCK_EN (1 << 4)
#define R128_CACHE_CNTL 0x1724
#define R128_CACHE_LINE 0x0f0c /* PCI */
@@ -297,6 +289,9 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_CONFIG_REG_APER_SIZE 0x0110
#define R128_CONFIG_XSTRAP 0x00e4
#define R128_CONSTANT_COLOR_C 0x1d34
+# define R128_CONSTANT_COLOR_MASK 0x00ffffff
+# define R128_CONSTANT_COLOR_ONE 0x00ffffff
+# define R128_CONSTANT_COLOR_ZERO 0x00000000
#define R128_CRC_CMDFIFO_ADDR 0x0740
#define R128_CRC_CMDFIFO_DOUT 0x0744
#define R128_CRTC_CRNT_FRAME 0x0214
@@ -308,6 +303,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_CRTC_HSYNC_DIS (1 << 8)
# define R128_CRTC_VSYNC_DIS (1 << 9)
# define R128_CRTC_DISPLAY_DIS (1 << 10)
+# define R128_CRTC_CRT_ON (1 << 15)
#define R128_CRTC_EXT_CNTL_DPMS_BYTE 0x0055
# define R128_CRTC_HSYNC_DIS_BYTE (1 << 0)
# define R128_CRTC_VSYNC_DIS_BYTE (1 << 1)
@@ -315,24 +311,57 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_CRTC_GEN_CNTL 0x0050
# define R128_CRTC_DBL_SCAN_EN (1 << 0)
# define R128_CRTC_INTERLACE_EN (1 << 1)
+# define R128_CRTC_CSYNC_EN (1 << 4)
# define R128_CRTC_CUR_EN (1 << 16)
# define R128_CRTC_CUR_MODE_MASK (7 << 17)
+# define R128_CRTC_ICON_EN (1 << 20)
# define R128_CRTC_EXT_DISP_EN (1 << 24)
# define R128_CRTC_EN (1 << 25)
+# define R128_CRTC_DISP_REQ_EN_B (1 << 26)
#define R128_CRTC_GUI_TRIG_VLINE 0x0218
#define R128_CRTC_H_SYNC_STRT_WID 0x0204
-# define R128_CRTC_H_SYNC_POL (1 << 23)
+# define R128_CRTC_H_SYNC_STRT_PIX (0x07 << 0)
+# define R128_CRTC_H_SYNC_STRT_CHAR (0x1ff << 3)
+# define R128_CRTC_H_SYNC_STRT_CHAR_SHIFT 3
+# define R128_CRTC_H_SYNC_WID (0x3f << 16)
+# define R128_CRTC_H_SYNC_WID_SHIFT 16
+# define R128_CRTC_H_SYNC_POL (1 << 23)
#define R128_CRTC_H_TOTAL_DISP 0x0200
+# define R128_CRTC_H_TOTAL (0x01ff << 0)
+# define R128_CRTC_H_TOTAL_SHIFT 0
+# define R128_CRTC_H_DISP (0x00ff << 16)
+# define R128_CRTC_H_DISP_SHIFT 16
#define R128_CRTC_OFFSET 0x0224
#define R128_CRTC_OFFSET_CNTL 0x0228
#define R128_CRTC_PITCH 0x022c
#define R128_CRTC_STATUS 0x005c
# define R128_CRTC_VBLANK_SAVE (1 << 1)
#define R128_CRTC_V_SYNC_STRT_WID 0x020c
-# define R128_CRTC_V_SYNC_POL (1 << 23)
+# define R128_CRTC_V_SYNC_STRT (0x7ff << 0)
+# define R128_CRTC_V_SYNC_STRT_SHIFT 0
+# define R128_CRTC_V_SYNC_WID (0x1f << 16)
+# define R128_CRTC_V_SYNC_WID_SHIFT 16
+# define R128_CRTC_V_SYNC_POL (1 << 23)
#define R128_CRTC_V_TOTAL_DISP 0x0208
+# define R128_CRTC_V_TOTAL (0x07ff << 0)
+# define R128_CRTC_V_TOTAL_SHIFT 0
+# define R128_CRTC_V_DISP (0x07ff << 16)
+# define R128_CRTC_V_DISP_SHIFT 16
#define R128_CRTC_VLINE_CRNT_VLINE 0x0210
# define R128_CRTC_CRNT_VLINE_MASK (0x7ff << 16)
+#define R128_CRTC2_CRNT_FRAME 0x0314
+#define R128_CRTC2_DEBUG 0x031c
+#define R128_CRTC2_GEN_CNTL 0x03f8
+#define R128_CRTC2_GUI_TRIG_VLINE 0x0318
+#define R128_CRTC2_H_SYNC_STRT_WID 0x0304
+#define R128_CRTC2_H_TOTAL_DISP 0x0300
+#define R128_CRTC2_OFFSET 0x0324
+#define R128_CRTC2_OFFSET_CNTL 0x0328
+#define R128_CRTC2_PITCH 0x032c
+#define R128_CRTC2_STATUS 0x03fc
+#define R128_CRTC2_V_SYNC_STRT_WID 0x030c
+#define R128_CRTC2_V_TOTAL_DISP 0x0308
+#define R128_CRTC2_VLINE_CRNT_VLINE 0x0310
#define R128_CRTC8_DATA 0x03d5 /* VGA, 0x3b5 */
#define R128_CRTC8_IDX 0x03d4 /* VGA, 0x3b4 */
#define R128_CUR_CLR0 0x026c
@@ -345,6 +374,8 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_DAC_CNTL 0x0058
# define R128_DAC_RANGE_CNTL (3 << 0)
# define R128_DAC_BLANKING (1 << 2)
+# define R128_DAC_CRT_SEL_CRTC2 (1 << 4)
+# define R128_DAC_PALETTE_ACC_CTL (1 << 5)
# define R128_DAC_8BIT_EN (1 << 8)
# define R128_DAC_VGA_ADR_EN (1 << 13)
# define R128_DAC_MASK_ALL (0xff << 24)
@@ -360,8 +391,8 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_DEFAULT_SC_BOTTOM_RIGHT 0x16e8
# define R128_DEFAULT_SC_RIGHT_MAX (0x1fff << 0)
# define R128_DEFAULT_SC_BOTTOM_MAX (0x1fff << 16)
-#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824
#define R128_DESTINATION_3D_CLR_CMP_VAL 0x1820
+#define R128_DESTINATION_3D_CLR_CMP_MSK 0x1824
#define R128_DEVICE_ID 0x0f02 /* PCI */
#define R128_DP_BRUSH_BKGD_CLR 0x1478
#define R128_DP_BRUSH_FRGD_CLR 0x147c
@@ -373,6 +404,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_DST_Y_DIR_TOP_TO_BOTTOM (1 << 15)
# define R128_DST_X_DIR_LEFT_TO_RIGHT (1 << 31)
#define R128_DP_DATATYPE 0x16c4
+# define R128_HOST_BIG_ENDIAN_EN (1 << 29)
#define R128_DP_GUI_MASTER_CNTL 0x146c
# define R128_GMC_SRC_PITCH_OFFSET_CNTL (1 << 0)
# define R128_GMC_DST_PITCH_OFFSET_CNTL (1 << 1)
@@ -388,6 +420,19 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_GMC_BRUSH_8x8_COLOR (10 << 4)
# define R128_GMC_BRUSH_1X8_COLOR (12 << 4)
# define R128_GMC_BRUSH_SOLID_COLOR (13 << 4)
+# define R128_GMC_BRUSH_NONE (15 << 4)
+# define R128_GMC_DST_8BPP_CI (2 << 8)
+# define R128_GMC_DST_15BPP (3 << 8)
+# define R128_GMC_DST_16BPP (4 << 8)
+# define R128_GMC_DST_24BPP (5 << 8)
+# define R128_GMC_DST_32BPP (6 << 8)
+# define R128_GMC_DST_8BPP_RGB (7 << 8)
+# define R128_GMC_DST_Y8 (8 << 8)
+# define R128_GMC_DST_RGB8 (9 << 8)
+# define R128_GMC_DST_VYUY (11 << 8)
+# define R128_GMC_DST_YVYU (12 << 8)
+# define R128_GMC_DST_AYUV444 (14 << 8)
+# define R128_GMC_DST_ARGB4444 (15 << 8)
# define R128_GMC_DST_DATATYPE_MASK (0x0f << 8)
# define R128_GMC_DST_DATATYPE_SHIFT 8
# define R128_GMC_SRC_DATATYPE_MASK (3 << 12)
@@ -395,16 +440,19 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
# define R128_GMC_SRC_DATATYPE_MONO_FG_LA (1 << 12)
# define R128_GMC_SRC_DATATYPE_COLOR (3 << 12)
# define R128_GMC_BYTE_PIX_ORDER (1 << 14)
+# define R128_GMC_BYTE_MSB_TO_LSB (0 << 14)
# define R128_GMC_BYTE_LSB_TO_MSB (1 << 14)
# define R128_GMC_CONVERSION_TEMP (1 << 15)
+# define R128_GMC_CONVERSION_TEMP_6500 (0 << 15)
+# define R128_GMC_CONVERSION_TEMP_9300 (1 << 15)
# define R128_GMC_ROP3_MASK (0xff << 16)
# define R128_DP_SRC_SOURCE_MASK (7 << 24)
# define R128_DP_SRC_SOURCE_MEMORY (2 << 24)
# define R128_DP_SRC_SOURCE_HOST_DATA (3 << 24)
# define R128_GMC_3D_FCN_EN (1 << 27)
# define R128_GMC_CLR_CMP_CNTL_DIS (1 << 28)
-# define R128_AUX_CLIP_DIS (1 << 29)
-# define R128_GMC_WR_MSK_DS (1 << 30)
+# define R128_GMC_AUX_CLIP_DIS (1 << 29)
+# define R128_GMC_WR_MSK_DIS (1 << 30)
# define R128_GMC_LD_BRUSH_Y_X (1 << 31)
# define R128_ROP3_ZERO 0x00000000
# define R128_ROP3_DSa 0x00880000
@@ -456,6 +504,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_DST_PITCH 0x1408
#define R128_DST_PITCH_OFFSET 0x142c
#define R128_DST_PITCH_OFFSET_C 0x1c80
+# define R128_PITCH_SHIFT 21
#define R128_DST_WIDTH 0x140c
#define R128_DST_WIDTH_HEIGHT 0x1598
#define R128_DST_WIDTH_X 0x1588
@@ -477,13 +526,60 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_FLUSH_5 0x1714
#define R128_FLUSH_6 0x1718
#define R128_FLUSH_7 0x171c
+#define R128_FOG_3D_TABLE_START 0x1810
+#define R128_FOG_3D_TABLE_END 0x1814
+#define R128_FOG_3D_TABLE_DENSITY 0x181c
+#define R128_FOG_TABLE_INDEX 0x1a14
+#define R128_FOG_TABLE_DATA 0x1a18
+#define R128_FP_CRTC_H_TOTAL_DISP 0x0250
+#define R128_FP_CRTC_V_TOTAL_DISP 0x0254
+#define R128_FP_GEN_CNTL 0x0284
+# define R128_FP_FPON (1 << 0)
+# define R128_FP_TDMS_EN (1 << 2)
+# define R128_FP_SEL_CRTC2 (1 << 13)
+# define R128_FP_CRTC_DONT_SHADOW_VPAR (1 << 16)
+# define R128_FP_CRTC_USE_SHADOW_VEND (1 << 18)
+# define R128_FP_CRTC_HORZ_DIV2_EN (1 << 20)
+# define R128_FP_CRTC_HOR_CRT_DIV2_DIS (1 << 21)
+# define R128_FP_USE_SHADOW_EN (1 << 24)
+#define R128_FP_H_SYNC_STRT_WID 0x02c4
+#define R128_FP_HORZ_STRETCH 0x028c
+# define R128_HORZ_STRETCH_RATIO_MASK 0xffff
+# define R128_HORZ_STRETCH_RATIO_SHIFT 0
+# define R128_HORZ_STRETCH_RATIO_MAX 4096
+# define R128_HORZ_PANEL_SIZE (0xff << 16)
+# define R128_HORZ_PANEL_SHIFT 16
+# define R128_HORZ_STRETCH_PIXREP (0 << 25)
+# define R128_HORZ_STRETCH_BLEND (1 << 25)
+# define R128_HORZ_STRETCH_ENABLE (1 << 26)
+# define R128_HORZ_FP_LOOP_STRETCH (0x7 << 27)
+# define R128_HORZ_STRETCH_RESERVED 0xc0000000
+
+#define R128_FP_PANEL_CNTL 0x0288
+# define R128_FP_DIGON (1 << 0)
+# define R128_FP_BLON (1 << 1)
+#define R128_FP_V_SYNC_STRT_WID 0x02c8
+#define R128_FP_VERT_STRETCH 0x0290
+# define R128_VERT_PANEL_SIZE (0x7ff << 0)
+# define R128_VERT_PANEL_SHIFT 0
+# define R128_VERT_STRETCH_RATIO_MASK 0x3ff
+# define R128_VERT_STRETCH_RATIO_SHIFT 11
+# define R128_VERT_STRETCH_RATIO_MAX 1024
+# define R128_VERT_STRETCH_ENABLE (1 << 24)
+# define R128_VERT_STRETCH_LINEREP (0 << 25)
+# define R128_VERT_STRETCH_BLEND (1 << 25)
+# define R128_VERT_STRETCH_RESERVED 0xf8e00000
#define R128_GEN_INT_CNTL 0x0040
#define R128_GEN_INT_STATUS 0x0044
# define R128_VSYNC_INT_AK (1 << 2)
# define R128_VSYNC_INT (1 << 2)
#define R128_GEN_RESET_CNTL 0x00f0
-# define R128_SOFT_RESET_GUI (1 << 0)
+# define R128_SOFT_RESET_GUI (1 << 0)
+# define R128_SOFT_RESET_VCLK (1 << 8)
+# define R128_SOFT_RESET_PCLK (1 << 9)
+# define R128_SOFT_RESET_DISPENG_XCLK (1 << 11)
+# define R128_SOFT_RESET_MEMCTLR_XCLK (1 << 12)
#define R128_GENENB 0x03c3 /* VGA */
#define R128_GENFC_RD 0x03ca /* VGA */
#define R128_GENFC_WT 0x03da /* VGA, 0x03ba */
@@ -542,6 +638,7 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_HOST_PATH_CNTL 0x0130
#define R128_HTOTAL_CNTL 0x0009 /* PLL */
#define R128_HW_DEBUG 0x0128
+#define R128_HW_DEBUG2 0x011c
#define R128_I2C_CNTL_1 0x0094 /* ? */
#define R128_INTERRUPT_LINE 0x0f3c /* PCI */
@@ -554,11 +651,15 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_LEAD_BRES_INC 0x1604
#define R128_LEAD_BRES_LNTH 0x161c
#define R128_LEAD_BRES_LNTH_SUB 0x1624
+#define R128_LVDS_GEN_CNTL 0x02d0
+# define R128_LVDS_ON (1 << 0)
+# define R128_LVDS_SEL_CRTC2 (1 << 23)
#define R128_MAX_LATENCY 0x0f3f /* PCI */
#define R128_MCLK_CNTL 0x000f /* PLL */
# define R128_FORCE_GCP (1 << 16)
-# define R128_FORCE_PIPE3D_CPP (1 << 17)
+# define R128_FORCE_PIPE3D_CP (1 << 17)
+# define R128_FORCE_RCP (1 << 18)
#define R128_MDGPIO_A_REG 0x01ac
#define R128_MDGPIO_EN_REG 0x01b0
#define R128_MDGPIO_MASK 0x0198
@@ -573,7 +674,6 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_MEM_VGA_RP_SEL 0x003c
#define R128_MEM_VGA_WP_SEL 0x0038
#define R128_MIN_GRANT 0x0f3e /* PCI */
-#define R128_MISC_3D_STATE_CNTL_REG 0x1CA0
#define R128_MM_DATA 0x0004
#define R128_MM_INDEX 0x0000
#define R128_MPLL_CNTL 0x000e /* PLL */
@@ -592,7 +692,11 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_PC_DEBUG_MODE 0x1760
#define R128_PC_GUI_CTLSTAT 0x1748
#define R128_PC_GUI_MODE 0x1744
+# define R128_PC_IGNORE_UNIFY (1 << 5)
+#define R128_PC_MISC_CNTL 0x0188
#define R128_PC_NGUI_CTLSTAT 0x0184
+# define R128_PC_FLUSH_GUI (3 << 0)
+# define R128_PC_RI_GUI (1 << 2)
# define R128_PC_FLUSH_ALL 0x00ff
# define R128_PC_BUSY (1 << 31)
#define R128_PC_NGUI_MODE 0x0180
@@ -669,11 +773,13 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_TEST_DEBUG_CNTL 0x0120
#define R128_TEST_DEBUG_MUX 0x0124
#define R128_TEST_DEBUG_OUT 0x012c
+#define R128_TMDS_CRC 0x02a0
#define R128_TRAIL_BRES_DEC 0x1614
#define R128_TRAIL_BRES_ERR 0x160c
#define R128_TRAIL_BRES_INC 0x1610
#define R128_TRAIL_X 0x1618
#define R128_TRAIL_X_SUB 0x1620
+
#define R128_VCLK_ECP_CNTL 0x0008 /* PLL */
#define R128_VENDOR_ID 0x0f00 /* PCI */
#define R128_VGA_DDA_CONFIG 0x02e8
@@ -689,6 +795,547 @@ static inline unsigned short regr16(volatile unsigned long base_addr, unsigned l
#define R128_XDLL_CNTL 0x000c /* PLL */
#define R128_XPLL_CNTL 0x000b /* PLL */
+ /* Registers for CCE and Microcode Engine */
+#define R128_PM4_MICROCODE_ADDR 0x07d4
+#define R128_PM4_MICROCODE_RADDR 0x07d8
+#define R128_PM4_MICROCODE_DATAH 0x07dc
+#define R128_PM4_MICROCODE_DATAL 0x07e0
+
+#define R128_PM4_BUFFER_OFFSET 0x0700
+#define R128_PM4_BUFFER_CNTL 0x0704
+# define R128_PM4_NONPM4 (0 << 28)
+# define R128_PM4_192PIO (1 << 28)
+# define R128_PM4_192BM (2 << 28)
+# define R128_PM4_128PIO_64INDBM (3 << 28)
+# define R128_PM4_128BM_64INDBM (4 << 28)
+# define R128_PM4_64PIO_128INDBM (5 << 28)
+# define R128_PM4_64BM_128INDBM (6 << 28)
+# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
+# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
+# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
+#define R128_PM4_BUFFER_WM_CNTL 0x0708
+# define R128_WMA_SHIFT 0
+# define R128_WMB_SHIFT 8
+# define R128_WMC_SHIFT 16
+# define R128_WB_WM_SHIFT 24
+#define R128_PM4_BUFFER_DL_RPTR_ADDR 0x070c
+#define R128_PM4_BUFFER_DL_RPTR 0x0710
+#define R128_PM4_BUFFER_DL_WPTR 0x0714
+# define R128_PM4_BUFFER_DL_DONE (1 << 31)
+#define R128_PM4_BUFFER_DL_WPTR_DELAY 0x0718
+# define R128_PRE_WRITE_TIMER_SHIFT 0
+# define R128_PRE_WRITE_LIMIT_SHIFT 23
+#define R128_PM4_VC_FPU_SETUP 0x071c
+# define R128_FRONT_DIR_CW (0 << 0)
+# define R128_FRONT_DIR_CCW (1 << 0)
+# define R128_FRONT_DIR_MASK (1 << 0)
+# define R128_BACKFACE_CULL (0 << 1)
+# define R128_BACKFACE_POINTS (1 << 1)
+# define R128_BACKFACE_LINES (2 << 1)
+# define R128_BACKFACE_SOLID (3 << 1)
+# define R128_BACKFACE_MASK (3 << 1)
+# define R128_FRONTFACE_CULL (0 << 3)
+# define R128_FRONTFACE_POINTS (1 << 3)
+# define R128_FRONTFACE_LINES (2 << 3)
+# define R128_FRONTFACE_SOLID (3 << 3)
+# define R128_FRONTFACE_MASK (3 << 3)
+# define R128_FPU_COLOR_SOLID (0 << 5)
+# define R128_FPU_COLOR_FLAT (1 << 5)
+# define R128_FPU_COLOR_GOURAUD (2 << 5)
+# define R128_FPU_COLOR_GOURAUD2 (3 << 5)
+# define R128_FPU_SUB_PIX_2BITS (0 << 7)
+# define R128_FPU_SUB_PIX_4BITS (1 << 7)
+# define R128_FPU_MODE_2D (0 << 8)
+# define R128_FPU_MODE_3D (1 << 8)
+# define R128_TRAP_BITS_DISABLE (1 << 9)
+# define R128_EDGE_ANTIALIAS (1 << 10)
+# define R128_SUPERSAMPLE (1 << 11)
+# define R128_XFACTOR_2 (0 << 12)
+# define R128_XFACTOR_4 (1 << 12)
+# define R128_YFACTOR_2 (0 << 13)
+# define R128_YFACTOR_4 (1 << 13)
+# define R128_FLAT_SHADE_VERTEX_D3D (0 << 14)
+# define R128_FLAT_SHADE_VERTEX_OGL (1 << 14)
+# define R128_FPU_ROUND_TRUNCATE (0 << 15)
+# define R128_FPU_ROUND_NEAREST (1 << 15)
+# define R128_WM_SEL_8DW (0 << 16)
+# define R128_WM_SEL_16DW (1 << 16)
+# define R128_WM_SEL_32DW (2 << 16)
+#define R128_PM4_VC_DEBUG_CONFIG 0x07a4
+#define R128_PM4_VC_STAT 0x07a8
+#define R128_PM4_VC_TIMESTAMP0 0x07b0
+#define R128_PM4_VC_TIMESTAMP1 0x07b4
+#define R128_PM4_STAT 0x07b8
+# define R128_PM4_FIFOCNT_MASK 0x0fff
+# define R128_PM4_BUSY (1 << 16)
+# define R128_PM4_GUI_ACTIVE (1 << 31)
+#define R128_PM4_BUFFER_ADDR 0x07f0
+#define R128_PM4_MICRO_CNTL 0x07fc
+# define R128_PM4_MICRO_FREERUN (1 << 30)
+#define R128_PM4_FIFO_DATA_EVEN 0x1000
+#define R128_PM4_FIFO_DATA_ODD 0x1004
+
#define R128_SCALE_3D_CNTL 0x1a00
+# define R128_SCALE_DITHER_ERR_DIFF (0 << 1)
+# define R128_SCALE_DITHER_TABLE (1 << 1)
+# define R128_TEX_CACHE_SIZE_FULL (0 << 2)
+# define R128_TEX_CACHE_SIZE_HALF (1 << 2)
+# define R128_DITHER_INIT_CURR (0 << 3)
+# define R128_DITHER_INIT_RESET (1 << 3)
+# define R128_ROUND_24BIT (1 << 4)
+# define R128_TEX_CACHE_DISABLE (1 << 5)
+# define R128_SCALE_3D_NOOP (0 << 6)
+# define R128_SCALE_3D_SCALE (1 << 6)
+# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6)
+# define R128_SCALE_PIX_BLEND (0 << 8)
+# define R128_SCALE_PIX_REPLICATE (1 << 8)
+# define R128_TEX_CACHE_SPLIT (1 << 9)
+# define R128_APPLE_YUV_MODE (1 << 10)
+# define R128_TEX_CACHE_PALLETE_MODE (1 << 11)
+# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12)
+# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_SIGNED_DST_CLAMP (1 << 15)
+# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16)
+# define R128_ALPHA_BLEND_SRC_ONE (1 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16)
+# define R128_ALPHA_BLEND_SRC_DSTALPHA (6 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDSTALPHA (7 << 16)
+# define R128_ALPHA_BLEND_SRC_DSTCOLOR (8 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDSTCOLOR (9 << 16)
+# define R128_ALPHA_BLEND_SRC_SAT (10 << 16)
+# define R128_ALPHA_BLEND_SRC_BLEND (11 << 16)
+# define R128_ALPHA_BLEND_SRC_INVBLEND (12 << 16)
+# define R128_ALPHA_BLEND_DST_ZERO (0 << 20)
+# define R128_ALPHA_BLEND_DST_ONE (1 << 20)
+# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20)
+# define R128_ALPHA_BLEND_DST_DSTALPHA (6 << 20)
+# define R128_ALPHA_BLEND_DST_INVDSTALPHA (7 << 20)
+# define R128_ALPHA_BLEND_DST_DSTCOLOR (8 << 20)
+# define R128_ALPHA_BLEND_DST_INVDSTCOLOR (9 << 20)
+# define R128_ALPHA_TEST_NEVER (0 << 24)
+# define R128_ALPHA_TEST_LESS (1 << 24)
+# define R128_ALPHA_TEST_LESSEQUAL (2 << 24)
+# define R128_ALPHA_TEST_EQUAL (3 << 24)
+# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24)
+# define R128_ALPHA_TEST_GREATER (5 << 24)
+# define R128_ALPHA_TEST_NEQUAL (6 << 24)
+# define R128_ALPHA_TEST_ALWAYS (7 << 24)
+# define R128_COMPOSITE_SHADOW_CMP_EQUAL (0 << 28)
+# define R128_COMPOSITE_SHADOW_CMP_NEQUAL (1 << 28)
+# define R128_COMPOSITE_SHADOW (1 << 29)
+# define R128_TEX_MAP_ALPHA_IN_TEXTURE (1 << 30)
+# define R128_TEX_CACHE_LINE_SIZE_8QW (0 << 31)
+# define R128_TEX_CACHE_LINE_SIZE_4QW (1 << 31)
+#define R128_SCALE_3D_DATATYPE 0x1a20
+
+#define R128_SETUP_CNTL 0x1bc4
+# define R128_DONT_START_TRIANGLE (1 << 0)
+# define R128_Z_BIAS (0 << 1)
+# define R128_DONT_START_ANY_ON (1 << 2)
+# define R128_COLOR_SOLID_COLOR (0 << 3)
+# define R128_COLOR_FLAT_VERT_1 (1 << 3)
+# define R128_COLOR_FLAT_VERT_2 (2 << 3)
+# define R128_COLOR_FLAT_VERT_3 (3 << 3)
+# define R128_COLOR_GOURAUD (4 << 3)
+# define R128_PRIM_TYPE_TRI (0 << 7)
+# define R128_PRIM_TYPE_LINE (1 << 7)
+# define R128_PRIM_TYPE_POINT (2 << 7)
+# define R128_PRIM_TYPE_POLY_EDGE (3 << 7)
+# define R128_TEXTURE_ST_MULT_W (0 << 9)
+# define R128_TEXTURE_ST_DIRECT (1 << 9)
+# define R128_STARTING_VERTEX_1 (1 << 14)
+# define R128_STARTING_VERTEX_2 (2 << 14)
+# define R128_STARTING_VERTEX_3 (3 << 14)
+# define R128_ENDING_VERTEX_1 (1 << 16)
+# define R128_ENDING_VERTEX_2 (2 << 16)
+# define R128_ENDING_VERTEX_3 (3 << 16)
+# define R128_SU_POLY_LINE_LAST (0 << 18)
+# define R128_SU_POLY_LINE_NOT_LAST (1 << 18)
+# define R128_SUB_PIX_2BITS (0 << 19)
+# define R128_SUB_PIX_4BITS (1 << 19)
+# define R128_SET_UP_CONTINUE (1 << 31)
+
+#define R128_WINDOW_XY_OFFSET 0x1bcc
+# define R128_WINDOW_Y_SHIFT 4
+# define R128_WINDOW_X_SHIFT 20
+
+#define R128_Z_OFFSET_C 0x1c90
+#define R128_Z_PITCH_C 0x1c94
+#define R128_Z_STEN_CNTL_C 0x1c98
+# define R128_Z_PIX_WIDTH_16 (0 << 1)
+# define R128_Z_PIX_WIDTH_24 (1 << 1)
+# define R128_Z_PIX_WIDTH_32 (2 << 1)
+# define R128_Z_PIX_WIDTH_MASK (3 << 1)
+# define R128_Z_TEST_NEVER (0 << 4)
+# define R128_Z_TEST_LESS (1 << 4)
+# define R128_Z_TEST_LESSEQUAL (2 << 4)
+# define R128_Z_TEST_EQUAL (3 << 4)
+# define R128_Z_TEST_GREATEREQUAL (4 << 4)
+# define R128_Z_TEST_GREATER (5 << 4)
+# define R128_Z_TEST_NEQUAL (6 << 4)
+# define R128_Z_TEST_ALWAYS (7 << 4)
+# define R128_Z_TEST_MASK (7 << 4)
+# define R128_STENCIL_TEST_NEVER (0 << 12)
+# define R128_STENCIL_TEST_LESS (1 << 12)
+# define R128_STENCIL_TEST_LESSEQUAL (2 << 12)
+# define R128_STENCIL_TEST_EQUAL (3 << 12)
+# define R128_STENCIL_TEST_GREATEREQUAL (4 << 12)
+# define R128_STENCIL_TEST_GREATER (5 << 12)
+# define R128_STENCIL_TEST_NEQUAL (6 << 12)
+# define R128_STENCIL_TEST_ALWAYS (7 << 12)
+# define R128_STENCIL_S_FAIL_KEEP (0 << 16)
+# define R128_STENCIL_S_FAIL_ZERO (1 << 16)
+# define R128_STENCIL_S_FAIL_REPLACE (2 << 16)
+# define R128_STENCIL_S_FAIL_INC (3 << 16)
+# define R128_STENCIL_S_FAIL_DEC (4 << 16)
+# define R128_STENCIL_S_FAIL_INV (5 << 16)
+# define R128_STENCIL_ZPASS_KEEP (0 << 20)
+# define R128_STENCIL_ZPASS_ZERO (1 << 20)
+# define R128_STENCIL_ZPASS_REPLACE (2 << 20)
+# define R128_STENCIL_ZPASS_INC (3 << 20)
+# define R128_STENCIL_ZPASS_DEC (4 << 20)
+# define R128_STENCIL_ZPASS_INV (5 << 20)
+# define R128_STENCIL_ZFAIL_KEEP (0 << 24)
+# define R128_STENCIL_ZFAIL_ZERO (1 << 24)
+# define R128_STENCIL_ZFAIL_REPLACE (2 << 24)
+# define R128_STENCIL_ZFAIL_INC (3 << 24)
+# define R128_STENCIL_ZFAIL_DEC (4 << 24)
+# define R128_STENCIL_ZFAIL_INV (5 << 24)
+#define R128_TEX_CNTL_C 0x1c9c
+# define R128_Z_ENABLE (1 << 0)
+# define R128_Z_WRITE_ENABLE (1 << 1)
+# define R128_STENCIL_ENABLE (1 << 3)
+# define R128_SHADE_ENABLE (0 << 4)
+# define R128_TEXMAP_ENABLE (1 << 4)
+# define R128_SEC_TEXMAP_ENABLE (1 << 5)
+# define R128_FOG_ENABLE (1 << 7)
+# define R128_DITHER_ENABLE (1 << 8)
+# define R128_ALPHA_ENABLE (1 << 9)
+# define R128_ALPHA_TEST_ENABLE (1 << 10)
+# define R128_SPEC_LIGHT_ENABLE (1 << 11)
+# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12)
+# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13)
+# define R128_ALPHA_IN_TEX_LSB_A (1 << 13)
+# define R128_LIGHT_DIS (0 << 14)
+# define R128_LIGHT_COPY (1 << 14)
+# define R128_LIGHT_MODULATE (2 << 14)
+# define R128_LIGHT_ADD (3 << 14)
+# define R128_LIGHT_BLEND_CONSTANT (4 << 14)
+# define R128_LIGHT_BLEND_TEXTURE (5 << 14)
+# define R128_LIGHT_BLEND_VERTEX (6 << 14)
+# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14)
+# define R128_ALPHA_LIGHT_DIS (0 << 18)
+# define R128_ALPHA_LIGHT_COPY (1 << 18)
+# define R128_ALPHA_LIGHT_MODULATE (2 << 18)
+# define R128_ALPHA_LIGHT_ADD (3 << 18)
+# define R128_ANTI_ALIAS (1 << 21)
+# define R128_TEX_CACHE_FLUSH (1 << 23)
+# define R128_LOD_BIAS_SHIFT 24
+#define R128_MISC_3D_STATE_CNTL_REG 0x1ca0
+# define R128_REF_ALPHA_MASK 0xff
+# define R128_MISC_SCALE_3D_NOOP (0 << 8)
+# define R128_MISC_SCALE_3D_SCALE (1 << 8)
+# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8)
+# define R128_MISC_SCALE_PIX_BLEND (0 << 10)
+# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10)
+# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12)
+# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12)
+# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12)
+# define R128_FOG_VERTEX (0 << 14)
+# define R128_FOG_TABLE (1 << 14)
+# define R128_ALPHA_BLEND_SRC_ZERO (0 << 16)
+# define R128_ALPHA_BLEND_SRC_ONE (1 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCCOLOR (2 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCCOLOR (3 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHA (4 << 16)
+# define R128_ALPHA_BLEND_SRC_INVSRCALPHA (5 << 16)
+# define R128_ALPHA_BLEND_SRC_DESTALPHA (6 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDESTALPHA (7 << 16)
+# define R128_ALPHA_BLEND_SRC_DESTCOLOR (8 << 16)
+# define R128_ALPHA_BLEND_SRC_INVDESTCOLOR (9 << 16)
+# define R128_ALPHA_BLEND_SRC_SRCALPHASAT (10 << 16)
+# define R128_ALPHA_BLEND_SRC_BOTHSRCALPHA (11 << 16)
+# define R128_ALPHA_BLEND_SRC_BOTHINVSRCALPHA (12 << 16)
+# define R128_ALPHA_BLEND_SRC_MASK (15 << 16)
+# define R128_ALPHA_BLEND_DST_ZERO (0 << 20)
+# define R128_ALPHA_BLEND_DST_ONE (1 << 20)
+# define R128_ALPHA_BLEND_DST_SRCCOLOR (2 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCCOLOR (3 << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHA (4 << 20)
+# define R128_ALPHA_BLEND_DST_INVSRCALPHA (5 << 20)
+# define R128_ALPHA_BLEND_DST_DESTALPHA (6 << 20)
+# define R128_ALPHA_BLEND_DST_INVDESTALPHA (7 << 20)
+# define R128_ALPHA_BLEND_DST_DESTCOLOR (8 << 20)
+# define R128_ALPHA_BLEND_DST_INVDESTCOLOR (9 << 20)
+# define R128_ALPHA_BLEND_DST_SRCALPHASAT (10 << 20)
+# define R128_ALPHA_BLEND_DST_MASK (15 << 20)
+# define R128_ALPHA_TEST_NEVER (0 << 24)
+# define R128_ALPHA_TEST_LESS (1 << 24)
+# define R128_ALPHA_TEST_LESSEQUAL (2 << 24)
+# define R128_ALPHA_TEST_EQUAL (3 << 24)
+# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24)
+# define R128_ALPHA_TEST_GREATER (5 << 24)
+# define R128_ALPHA_TEST_NEQUAL (6 << 24)
+# define R128_ALPHA_TEST_ALWAYS (7 << 24)
+# define R128_ALPHA_TEST_MASK (7 << 24)
+#define R128_TEXTURE_CLR_CMP_CLR_C 0x1ca4
+#define R128_TEXTURE_CLR_CMP_MSK_C 0x1ca8
+#define R128_FOG_COLOR_C 0x1cac
+# define R128_FOG_BLUE_SHIFT 0
+# define R128_FOG_GREEN_SHIFT 8
+# define R128_FOG_RED_SHIFT 16
+#define R128_PRIM_TEX_CNTL_C 0x1cb0
+# define R128_MIN_BLEND_NEAREST (0 << 1)
+# define R128_MIN_BLEND_LINEAR (1 << 1)
+# define R128_MIN_BLEND_MIPNEAREST (2 << 1)
+# define R128_MIN_BLEND_MIPLINEAR (3 << 1)
+# define R128_MIN_BLEND_LINEARMIPNEAREST (4 << 1)
+# define R128_MIN_BLEND_LINEARMIPLINEAR (5 << 1)
+# define R128_MIN_BLEND_MASK (7 << 1)
+# define R128_MAG_BLEND_NEAREST (0 << 4)
+# define R128_MAG_BLEND_LINEAR (1 << 4)
+# define R128_MAG_BLEND_MASK (7 << 4)
+# define R128_MIP_MAP_DISABLE (1 << 7)
+# define R128_TEX_CLAMP_S_WRAP (0 << 8)
+# define R128_TEX_CLAMP_S_MIRROR (1 << 8)
+# define R128_TEX_CLAMP_S_CLAMP (2 << 8)
+# define R128_TEX_CLAMP_S_BORDER_COLOR (3 << 8)
+# define R128_TEX_CLAMP_S_MASK (3 << 8)
+# define R128_TEX_WRAP_S (1 << 10)
+# define R128_TEX_CLAMP_T_WRAP (0 << 11)
+# define R128_TEX_CLAMP_T_MIRROR (1 << 11)
+# define R128_TEX_CLAMP_T_CLAMP (2 << 11)
+# define R128_TEX_CLAMP_T_BORDER_COLOR (3 << 11)
+# define R128_TEX_CLAMP_T_MASK (3 << 11)
+# define R128_TEX_WRAP_T (1 << 13)
+# define R128_TEX_PERSPECTIVE_DISABLE (1 << 14)
+# define R128_DATATYPE_VQ (0 << 16)
+# define R128_DATATYPE_CI4 (1 << 16)
+# define R128_DATATYPE_CI8 (2 << 16)
+# define R128_DATATYPE_ARGB1555 (3 << 16)
+# define R128_DATATYPE_RGB565 (4 << 16)
+# define R128_DATATYPE_RGB888 (5 << 16)
+# define R128_DATATYPE_ARGB8888 (6 << 16)
+# define R128_DATATYPE_RGB332 (7 << 16)
+# define R128_DATATYPE_Y8 (8 << 16)
+# define R128_DATATYPE_RGB8 (9 << 16)
+# define R128_DATATYPE_CI16 (10 << 16)
+# define R128_DATATYPE_YUV422 (11 << 16)
+# define R128_DATATYPE_YUV422_2 (12 << 16)
+# define R128_DATATYPE_AYUV444 (14 << 16)
+# define R128_DATATYPE_ARGB4444 (15 << 16)
+# define R128_PALLETE_EITHER (0 << 20)
+# define R128_PALLETE_1 (1 << 20)
+# define R128_PALLETE_2 (2 << 20)
+# define R128_PSEUDOCOLOR_DT_RGB565 (0 << 24)
+# define R128_PSEUDOCOLOR_DT_ARGB1555 (1 << 24)
+# define R128_PSEUDOCOLOR_DT_ARGB4444 (2 << 24)
+#define R128_PRIM_TEXTURE_COMBINE_CNTL_C 0x1cb4
+# define R128_COMB_DIS (0 << 0)
+# define R128_COMB_COPY (1 << 0)
+# define R128_COMB_COPY_INP (2 << 0)
+# define R128_COMB_MODULATE (3 << 0)
+# define R128_COMB_MODULATE2X (4 << 0)
+# define R128_COMB_MODULATE4X (5 << 0)
+# define R128_COMB_ADD (6 << 0)
+# define R128_COMB_ADD_SIGNED (7 << 0)
+# define R128_COMB_BLEND_VERTEX (8 << 0)
+# define R128_COMB_BLEND_TEXTURE (9 << 0)
+# define R128_COMB_BLEND_CONST (10 << 0)
+# define R128_COMB_BLEND_PREMULT (11 << 0)
+# define R128_COMB_BLEND_PREV (12 << 0)
+# define R128_COMB_BLEND_PREMULT_INV (13 << 0)
+# define R128_COMB_ADD_SIGNED2X (14 << 0)
+# define R128_COMB_BLEND_CONST_COLOR (15 << 0)
+# define R128_COMB_MASK (15 << 0)
+# define R128_COLOR_FACTOR_TEX (4 << 4)
+# define R128_COLOR_FACTOR_NTEX (5 << 4)
+# define R128_COLOR_FACTOR_ALPHA (6 << 4)
+# define R128_COLOR_FACTOR_NALPHA (7 << 4)
+# define R128_COLOR_FACTOR_MASK (15 << 4)
+# define R128_INPUT_FACTOR_CONST_COLOR (2 << 10)
+# define R128_INPUT_FACTOR_CONST_ALPHA (3 << 10)
+# define R128_INPUT_FACTOR_INT_COLOR (4 << 10)
+# define R128_INPUT_FACTOR_INT_ALPHA (5 << 10)
+# define R128_INPUT_FACTOR_MASK (15 << 10)
+# define R128_COMB_ALPHA_DIS (0 << 14)
+# define R128_COMB_ALPHA_COPY (1 << 14)
+# define R128_COMB_ALPHA_COPY_INP (2 << 14)
+# define R128_COMB_ALPHA_MODULATE (3 << 14)
+# define R128_COMB_ALPHA_MODULATE2X (4 << 14)
+# define R128_COMB_ALPHA_MODULATE4X (5 << 14)
+# define R128_COMB_ALPHA_ADD (6 << 14)
+# define R128_COMB_ALPHA_ADD_SIGNED (7 << 14)
+# define R128_COMB_ALPHA_ADD_SIGNED2X (14 << 14)
+# define R128_COMB_ALPHA_MASK (15 << 14)
+# define R128_ALPHA_FACTOR_TEX_ALPHA (6 << 18)
+# define R128_ALPHA_FACTOR_NTEX_ALPHA (7 << 18)
+# define R128_ALPHA_FACTOR_MASK (15 << 18)
+# define R128_INP_FACTOR_A_CONST_ALPHA (1 << 25)
+# define R128_INP_FACTOR_A_INT_ALPHA (2 << 25)
+# define R128_INP_FACTOR_A_MASK (7 << 25)
+#define R128_TEX_SIZE_PITCH_C 0x1cb8
+# define R128_TEX_PITCH_SHIFT 0
+# define R128_TEX_SIZE_SHIFT 4
+# define R128_TEX_HEIGHT_SHIFT 8
+# define R128_TEX_MIN_SIZE_SHIFT 12
+# define R128_SEC_TEX_PITCH_SHIFT 16
+# define R128_SEC_TEX_SIZE_SHIFT 20
+# define R128_SEC_TEX_HEIGHT_SHIFT 24
+# define R128_SEC_TEX_MIN_SIZE_SHIFT 28
+# define R128_TEX_PITCH_MASK (0x0f << 0)
+# define R128_TEX_SIZE_MASK (0x0f << 4)
+# define R128_TEX_HEIGHT_MASK (0x0f << 8)
+# define R128_TEX_MIN_SIZE_MASK (0x0f << 12)
+# define R128_SEC_TEX_PITCH_MASK (0x0f << 16)
+# define R128_SEC_TEX_SIZE_MASK (0x0f << 20)
+# define R128_SEC_TEX_HEIGHT_MASK (0x0f << 24)
+# define R128_SEC_TEX_MIN_SIZE_MASK (0x0f << 28)
+# define R128_TEX_SIZE_PITCH_SHIFT 0
+# define R128_SEC_TEX_SIZE_PITCH_SHIFT 16
+# define R128_TEX_SIZE_PITCH_MASK (0xffff << 0)
+# define R128_SEC_TEX_SIZE_PITCH_MASK (0xffff << 16)
+#define R128_PRIM_TEX_0_OFFSET_C 0x1cbc
+#define R128_PRIM_TEX_1_OFFSET_C 0x1cc0
+#define R128_PRIM_TEX_2_OFFSET_C 0x1cc4
+#define R128_PRIM_TEX_3_OFFSET_C 0x1cc8
+#define R128_PRIM_TEX_4_OFFSET_C 0x1ccc
+#define R128_PRIM_TEX_5_OFFSET_C 0x1cd0
+#define R128_PRIM_TEX_6_OFFSET_C 0x1cd4
+#define R128_PRIM_TEX_7_OFFSET_C 0x1cd8
+#define R128_PRIM_TEX_8_OFFSET_C 0x1cdc
+#define R128_PRIM_TEX_9_OFFSET_C 0x1ce0
+#define R128_PRIM_TEX_10_OFFSET_C 0x1ce4
+# define R128_TEX_NO_TILE (0 << 30)
+# define R128_TEX_TILED_BY_HOST (1 << 30)
+# define R128_TEX_TILED_BY_STORAGE (2 << 30)
+# define R128_TEX_TILED_BY_STORAGE2 (3 << 30)
+
+#define R128_SEC_TEX_CNTL_C 0x1d00
+# define R128_SEC_SELECT_PRIM_ST (0 << 0)
+# define R128_SEC_SELECT_SEC_ST (1 << 0)
+#define R128_SEC_TEX_COMBINE_CNTL_C 0x1d04
+# define R128_INPUT_FACTOR_PREV_COLOR (8 << 10)
+# define R128_INPUT_FACTOR_PREV_ALPHA (9 << 10)
+# define R128_INP_FACTOR_A_PREV_ALPHA (4 << 25)
+#define R128_SEC_TEX_0_OFFSET_C 0x1d08
+#define R128_SEC_TEX_1_OFFSET_C 0x1d0c
+#define R128_SEC_TEX_2_OFFSET_C 0x1d10
+#define R128_SEC_TEX_3_OFFSET_C 0x1d14
+#define R128_SEC_TEX_4_OFFSET_C 0x1d18
+#define R128_SEC_TEX_5_OFFSET_C 0x1d1c
+#define R128_SEC_TEX_6_OFFSET_C 0x1d20
+#define R128_SEC_TEX_7_OFFSET_C 0x1d24
+#define R128_SEC_TEX_8_OFFSET_C 0x1d28
+#define R128_SEC_TEX_9_OFFSET_C 0x1d2c
+#define R128_SEC_TEX_10_OFFSET_C 0x1d30
+#define R128_CONSTANT_COLOR_C 0x1d34
+# define R128_CONSTANT_BLUE_SHIFT 0
+# define R128_CONSTANT_GREEN_SHIFT 8
+# define R128_CONSTANT_RED_SHIFT 16
+# define R128_CONSTANT_ALPHA_SHIFT 24
+#define R128_PRIM_TEXTURE_BORDER_COLOR_C 0x1d38
+# define R128_PRIM_TEX_BORDER_BLUE_SHIFT 0
+# define R128_PRIM_TEX_BORDER_GREEN_SHIFT 8
+# define R128_PRIM_TEX_BORDER_RED_SHIFT 16
+# define R128_PRIM_TEX_BORDER_ALPHA_SHIFT 24
+#define R128_SEC_TEXTURE_BORDER_COLOR_C 0x1d3c
+# define R128_SEC_TEX_BORDER_BLUE_SHIFT 0
+# define R128_SEC_TEX_BORDER_GREEN_SHIFT 8
+# define R128_SEC_TEX_BORDER_RED_SHIFT 16
+# define R128_SEC_TEX_BORDER_ALPHA_SHIFT 24
+#define R128_STEN_REF_MASK_C 0x1d40
+# define R128_STEN_REFERENCE_SHIFT 0
+# define R128_STEN_MASK_SHIFT 16
+# define R128_STEN_WRITE_MASK_SHIFT 24
+#define R128_PLANE_3D_MASK_C 0x1d44
+#define R128_TEX_CACHE_STAT_COUNT 0x1974
+
+
+ /* Constants */
+#define R128_AGP_TEX_OFFSET 0x02000000
+
+#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0
+#define R128_SWAP_AGE_REG R128_GUI_SCRATCH_REG1
+
+ /* CCE packet types */
+#define R128_CCE_PACKET0 0x00000000
+#define R128_CCE_PACKET0_ONE_REG_WR 0x00008000
+#define R128_CCE_PACKET1 0x40000000
+#define R128_CCE_PACKET2 0x80000000
+#define R128_CCE_PACKET3_NOP 0xC0001000
+#define R128_CCE_PACKET3_PAINT 0xC0001100
+#define R128_CCE_PACKET3_BITBLT 0xC0001200
+#define R128_CCE_PACKET3_SMALLTEXT 0xC0001300
+#define R128_CCE_PACKET3_HOSTDATA_BLT 0xC0001400
+#define R128_CCE_PACKET3_POLYLINE 0xC0001500
+#define R128_CCE_PACKET3_SCALING 0xC0001600
+#define R128_CCE_PACKET3_TRANS_SCALING 0xC0001700
+#define R128_CCE_PACKET3_POLYSCANLINES 0xC0001800
+#define R128_CCE_PACKET3_NEXT_CHAR 0xC0001900
+#define R128_CCE_PACKET3_PAINT_MULTI 0xC0001A00
+#define R128_CCE_PACKET3_BITBLT_MULTI 0xC0001B00
+#define R128_CCE_PACKET3_PLY_NEXTSCAN 0xC0001D00
+#define R128_CCE_PACKET3_SET_SCISSORS 0xC0001E00
+#define R128_CCE_PACKET3_SET_MODE24BPP 0xC0001F00
+#define R128_CCE_PACKET3_CNTL_PAINT 0xC0009100
+#define R128_CCE_PACKET3_CNTL_BITBLT 0xC0009200
+#define R128_CCE_PACKET3_CNTL_SMALLTEXT 0xC0009300
+#define R128_CCE_PACKET3_CNTL_HOSTDATA_BLT 0xC0009400
+#define R128_CCE_PACKET3_CNTL_POLYLINE 0xC0009500
+#define R128_CCE_PACKET3_CNTL_SCALING 0xC0009600
+#define R128_CCE_PACKET3_CNTL_TRANS_SCALING 0xC0009700
+#define R128_CCE_PACKET3_CNTL_POLYSCANLINES 0xC0009800
+#define R128_CCE_PACKET3_CNTL_NEXT_CHAR 0xC0009900
+#define R128_CCE_PACKET3_CNTL_PAINT_MULTI 0xC0009A00
+#define R128_CCE_PACKET3_CNTL_BITBLT_MULTI 0xC0009B00
+#define R128_CCE_PACKET3_CNTL_TRANS_BITBLT 0xC0009C00
+#define R128_CCE_PACKET3_3D_SAVE_CONTEXT 0xC0002000
+#define R128_CCE_PACKET3_3D_PLAY_CONTEXT 0xC0002100
+#define R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM 0xC0002300
+#define R128_CCE_PACKET3_3D_RNDR_GEN_PRIM 0xC0002500
+#define R128_CCE_PACKET3_LOAD_PALETTE 0xC0002C00
+#define R128_CCE_PACKET3_PURGE 0xC0002D00
+#define R128_CCE_PACKET3_NEXT_VERTEX_BUNDLE 0xC0002E00
+# define R128_CCE_PACKET_MASK 0xC0000000
+# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000
+# define R128_CCE_PACKET_MAX_DWORDS (1 << 14)
+# define R128_CCE_PACKET0_REG_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG0_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG1_MASK 0x003ff800
+
+#define R128_CCE_VC_FRMT_RHW 0x00000001
+#define R128_CCE_VC_FRMT_DIFFUSE_BGR 0x00000002
+#define R128_CCE_VC_FRMT_DIFFUSE_A 0x00000004
+#define R128_CCE_VC_FRMT_DIFFUSE_ARGB 0x00000008
+#define R128_CCE_VC_FRMT_SPEC_BGR 0x00000010
+#define R128_CCE_VC_FRMT_SPEC_F 0x00000020
+#define R128_CCE_VC_FRMT_SPEC_FRGB 0x00000040
+#define R128_CCE_VC_FRMT_S_T 0x00000080
+#define R128_CCE_VC_FRMT_S2_T2 0x00000100
+#define R128_CCE_VC_FRMT_RHW2 0x00000200
+
+#define R128_CCE_VC_CNTL_PRIM_TYPE_NONE 0x00000000
+#define R128_CCE_VC_CNTL_PRIM_TYPE_POINT 0x00000001
+#define R128_CCE_VC_CNTL_PRIM_TYPE_LINE 0x00000002
+#define R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE 0x00000003
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST 0x00000004
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN 0x00000005
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP 0x00000006
+#define R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 0x00000007
+#define R128_CCE_VC_CNTL_PRIM_WALK_IND 0x00000010
+#define R128_CCE_VC_CNTL_PRIM_WALK_LIST 0x00000020
+#define R128_CCE_VC_CNTL_PRIM_WALK_RING 0x00000030
+#define R128_CCE_VC_CNTL_NUM_SHIFT 16
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h
new file mode 100644
index 000000000..2af80d140
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h
@@ -0,0 +1,77 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/r128/r128_sarea.h,v 1.1 2000/06/17 00:03:23 martin Exp $ */
+/**************************************************************************
+
+Copyright 1999, 2000 ATI Technologies Inc. and 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
+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
+ATI, PRECISION INSIGHT 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 <kevin@precisioninsight.com>
+ *
+ */
+
+#ifndef _R128_SAREA_H_
+#define _R128_SAREA_H_
+
+/* There are 2 heaps (local/AGP). Each region within a heap is a
+ minimum of 64k, and there are at most 64 of them per heap. */
+#define R128_LOCAL_TEX_HEAP 0
+#define R128_AGP_TEX_HEAP 1
+#define R128_NR_TEX_HEAPS 2
+#define R128_NR_TEX_REGIONS 64
+#define R128_LOG_TEX_GRANULARITY 16
+
+typedef struct {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} R128TexRegion;
+
+typedef struct {
+ /* Maintain an LRU of contiguous regions of texture space. If you
+ * think you own a region of texture memory, and it has an age
+ * different to the one you set, then you are mistaken and it has
+ * been stolen by another client. If global texAge hasn't changed,
+ * there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained texture
+ * information of other clients - by maintaining them in the same
+ * lru which is used to age their own textures, clients have an
+ * approximate lru for the whole of global texture space, and can
+ * make informed decisions as to which areas to kick out. There is
+ * no need to choose whether to kick out your own texture or someone
+ * else's - simply eject them all in LRU order.
+ */
+ /* Last elt is sentinal */
+ R128TexRegion texList[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
+ /* last time texture was uploaded */
+ int texAge[R128_NR_TEX_HEAPS];
+
+ int ctxOwner; /* last context to upload state */
+
+ int ringWrite; /* current ring buffer write index */
+} R128SAREAPriv, *R128SAREAPrivPtr;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile
index 1e9ddad3e..6cf524e39 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile,v 1.15 2000/03/03 01:05:41 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/Imakefile,v 1.16 2000/03/31 20:13:24 dawes Exp $
XCOMM
XCOMM This is an Imakefile for the Rendition driver.
@@ -20,7 +20,7 @@ INCLUDES = -I. -I$(XF86SRC)/xf4bpp -I$(XF86SRC)/xf1bpp \
-I$(SERVERSRC)/cfb -I$(SERVERSRC)/mfb \
-I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb\
-I$(XF86SRC)/ddc -I$(XF86SRC)/i2c -I$(XF86SRC)/vgahw \
- -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \
+ -I$(XF86SRC)/rac -I$(XF86SRC)/int10 -I$(XF86OSSRC)/vbe \
-I$(XF86COMSRC) -I$(XF86OSSRC) -I$(FONTINCSRC) -I$(XINCLUDESRC) \
-I$(SERVERSRC)/include -I$(XF86SRC)/xaa \
-I$(XF86SRC)/xf24_32bpp -I$(XF86SRC)/xf8_32bpp \
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c
index 4678c192c..aad4fb8a7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c
@@ -3,7 +3,7 @@
*
* accelerator functions for X
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c,v 1.6 2000/02/25 21:02:59 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/accelX.c,v 1.8 2000/06/13 02:28:33 dawes Exp $ */
@@ -29,24 +29,19 @@
/*
* defines
*/
-#if 1
-/* Global imported during compile-time */
-char MICROCODE_DIR [PATH_MAX] = MODULEDIR;
-#endif
-
#define waitfifo(size) do { int c=0; \
- while ((c++<0xfffff)&&((v_in8(iob+FIFOINFREE)&0x1f)<size)) /* if(!(c%0xffff))ErrorF("#1# !0x%x! -- ",v_in8(iob+FIFOINFREE)) */; \
+ while ((c++<0xfffff)&&((verite_in8(iob+FIFOINFREE)&0x1f)<size)) /* if(!(c%0xffff))ErrorF("#1# !0x%x! -- ",verite_in8(iob+FIFOINFREE)) */; \
if (c >= 0xfffff) { \
- ErrorF("RENDITION: Input fifo full (1) FIFO in == %d\n",v_in8(iob+FIFOINFREE)&0x1f); \
+ ErrorF("RENDITION: Input fifo full (1) FIFO in == %d\n",verite_in8(iob+FIFOINFREE)&0x1f); \
return; \
} \
} while (0)
#define waitfifo2(size, rv) do { int c=0; \
- while ((c++<0xfffff)&&((v_in8(iob+FIFOINFREE)&0x1f)<size)) /* if(!(c%0xffff))ErrorF("#2# !0x%x! -- ",v_in8(iob+FIFOINFREE)) */; \
+ while ((c++<0xfffff)&&((verite_in8(iob+FIFOINFREE)&0x1f)<size)) /* if(!(c%0xffff))ErrorF("#2# !0x%x! -- ",verite_in8(iob+FIFOINFREE)) */; \
if (c >= 0xfffff) { \
- ErrorF("RENDITION: Input fifo full (2) FIFO in ==%d\n",v_in8(iob+FIFOINFREE)&0x1f); \
+ ErrorF("RENDITION: Input fifo full (2) FIFO in ==%d\n",verite_in8(iob+FIFOINFREE)&0x1f); \
RENDITIONAccelNone(pScreenInfo); \
pRendition->board.accel=0; \
return rv; \
@@ -124,38 +119,13 @@ RENDITIONAccelPreInit(ScrnInfoPtr pScreenInfo)
sleep(1);
#endif
-#ifdef DEBUG
- v1k_stop(pScreenInfo);
- memset (pRendition->board.vmem_base,0,MC_SIZE);
-#endif
-
-#if 0
if (RENDITIONLoadUcode(pScreenInfo)){
ErrorF ("RENDITION: AccelPreInit - Warning. Loading of microcode failed!!\n");
}
-#endif
-
-#if 1 /* Test */
- if (V1000_DEVICE == pRendition->board.chip){
- c=v_load_ucfile(pScreenInfo, strcat ((char *)MICROCODE_DIR,"v10002d.uc"));
- }
- else {
- /* V2x00 chip */
- c=v_load_ucfile(pScreenInfo, strcat ((char *)MICROCODE_DIR,"v20002d.uc"));
- }
-
- if (c == -1) {
- ErrorF( "RENDITION: Microcode loading failed !!!\n");
- return;
- }
-
- pRendition->board.ucode_entry=c;
- ErrorF("UCode_Entry == 0x%x\n",pRendition->board.ucode_entry);
-#endif
+ pRendition->board.fbOffset += MC_SIZE;
#ifdef DEBUG
- pRendition->board.fbOffset += MC_SIZE;
ErrorF("RENDITION: Offset is now %d\n",pRendition->board.fbOffset);
sleep(2);
#endif
@@ -180,7 +150,8 @@ RENDITIONAccelXAAInit(ScreenPtr pScreen)
pRendition->AccelInfoRec = pXAAinfo = XAACreateInfoRec();
if(!pXAAinfo){
- ErrorF("RENDITION; Failed to set up XAA structure!\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex,X_ERROR,
+ ("Failed to set up XAA structure!\n"));
return;
}
@@ -216,28 +187,14 @@ RENDITIONAccelXAAInit(ScreenPtr pScreen)
RENDITIONSubsequentTwoPointLine;
#endif /* #if 0 */
- if (RENDITIONLoadUcode(pScreenInfo)) return;
+ verite_check_csucode(pScreenInfo);
-#if 1 /* Testingcode */
- if (V1000_DEVICE == pRendition->board.chip){
- c=v_load_ucfile(pScreenInfo, MICROCODE_DIR);
- }
- else {
- /* V2x00 chip */
- c=v_load_ucfile(pScreenInfo, MICROCODE_DIR);
- }
-
- if (c == -1) {
- ErrorF( "RENDITION: Microcode loading failed !!!\n");
- return;
- }
-
- pRendition->board.ucode_entry=c;
-#endif
+ if (RENDITIONLoadUcode(pScreenInfo)) return;
if (RENDITIONInitUcode(pScreenInfo)) return;
- v_check_csucode(pScreenInfo);
- /* the remaining code was copied from s3v_accel.c.
+ verite_check_csucode(pScreenInfo);
+
+ /* the remaining code was copied from s3verite_accel.c.
* we need to check it if it is suitable <ml> */
/* make sure offscreen pixmaps aren't bigger than our address space */
@@ -313,7 +270,7 @@ RENDITIONLoadUcode(ScrnInfoPtr pScreenInfo)
/* load or restore ucode */
if (!ucode_loaded) {
- if (0 != v_initboard(pScreenInfo)) {
+ if (0 != verite_initboard(pScreenInfo)) {
RENDITIONAccelNone(pScreenInfo);
pRendition->board.accel=0;
return 1;
@@ -323,8 +280,8 @@ RENDITIONLoadUcode(ScrnInfoPtr pScreenInfo)
else
RENDITIONRestoreUcode(pScreenInfo);
- ErrorF("RENDITION: Ucode successfully %s\n",
- (ucode_loaded ? "restored" : "loaded"));
+ ErrorF ("Rendition: Ucode successfully %s\n",
+ (ucode_loaded ? "restored" : "loaded"));
ucode_loaded=1;
return 0;
@@ -337,25 +294,28 @@ RENDITIONInitUcode(ScrnInfoPtr pScreenInfo)
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
vu16 iob = pRendition->board.io_base;
- if (0 == v_getstride(pScreenInfo, NULL,
+ if (0 == verite_getstride(pScreenInfo, NULL,
&pRendition->board.mode.stride0,
&pRendition->board.mode.stride1)) {
- ErrorF("RENDITION: Acceleration for this resolution not available\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex,X_ERROR,
+ ("Acceleration for this resolution not available\n"));
RENDITIONAccelNone(pScreenInfo);
pRendition->board.accel=0;
return 1;
}
else
- ErrorF("RENDITION: Stride 0: %d, stride 1: %d\n",
- pRendition->board.mode.stride0,
- pRendition->board.mode.stride1);
+ ErrorF ("Rendition: Stride 0: %d, stride 1: %d\n",
+ pRendition->board.mode.stride0,
+ pRendition->board.mode.stride1);
/* NOTE: for 1152x864 only!
stride0=6;
stride1=1;
*/
- ErrorF("#InitUcode(1)# FIFOIN_FREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
+#ifdef DEBUG
+ ErrorF("#InitUcode(1)# FIFOIN_FREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+#endif
/* init the ucode */
@@ -363,36 +323,44 @@ RENDITIONInitUcode(ScrnInfoPtr pScreenInfo)
v1k_flushicache(pScreenInfo);
v1k_start(pScreenInfo, pRendition->board.csucode_base);
- ErrorF("#InitUcode(2)# FIFOIN_FREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
+#ifdef DEBUG
+ ErrorF("#InitUcode(2)# FIFOIN_FREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+#endif
- v_out32(iob, 0); /* a0 - ucode init command */
- v_out32(iob, 0); /* a1 - 1024 byte context store area */
- v_out32(iob, 0); /* a2 */
- v_out32(iob, pRendition->board.ucode_entry);
+ verite_out32(iob, 0); /* a0 - ucode init command */
+ verite_out32(iob, 0); /* a1 - 1024 byte context store area */
+ verite_out32(iob, 0); /* a2 */
+ verite_out32(iob, pRendition->board.ucode_entry);
- ErrorF("#InitUcode(3)# FIFOIN_FREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
+#ifdef DEBUG
+ ErrorF("#InitUcode(3)# FIFOIN_FREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+#endif
waitfifo2(6, 1);
- ErrorF("#InitUcode(4)# FIFOIN_FREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
+#ifdef DEBUG
+ ErrorF("#InitUcode(4)# FIFOIN_FREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+#endif
- v_out32(iob, CMD_SETUP);
- v_out32(iob, P2(pRendition->board.mode.virtualwidth,
+ verite_out32(iob, CMD_SETUP);
+ verite_out32(iob, P2(pRendition->board.mode.virtualwidth,
pRendition->board.mode.virtualheight));
- v_out32(iob, P2(pRendition->board.mode.bitsperpixel,
+ verite_out32(iob, P2(pRendition->board.mode.bitsperpixel,
pRendition->board.mode.pixelformat));
- v_out32(iob, MC_SIZE);
+ verite_out32(iob, MC_SIZE);
- v_out32(iob, (pRendition->board.mode.virtualwidth)*
+ verite_out32(iob, (pRendition->board.mode.virtualwidth)*
(pRendition->board.mode.bitsperpixel>>3));
- v_out32(iob, (pRendition->board.mode.stride1<<12)|
+ verite_out32(iob, (pRendition->board.mode.stride1<<12)|
(pRendition->board.mode.stride0<<8));
- ErrorF("#InitUcode(5)# FIFOIN_FREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
+#ifdef DEBUG
+ ErrorF("#InitUcode(5)# FIFOIN_FREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+#endif
#if 0
- v_out32(iob+0x60, 129);
- ErrorF("RENDITION: PC at %x\n", v_in32(iob+0x64));
+ verite_out32(iob+0x60, 129);
+ ErrorF("RENDITION: PC at %x\n", verite_in32(iob+0x64));
#endif
return 0;
@@ -416,26 +384,26 @@ RENDITIONRestoreUcode(ScrnInfoPtr pScreenInfo)
#endif
v1k_stop(pScreenInfo);
- memend=v_in8(iob+MEMENDIAN);
- v_out8(iob+MEMENDIAN, MEMENDIAN_NO);
+ memend=verite_in8(iob+MEMENDIAN);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
#if 1
memcpy(pRendition->board.vmem_base, pRendition->board.ucode_buffer, MC_SIZE);
#else
/* SlowBcopy has inverted src and dst */
xf86SlowBcopy(pRendition->board.ucode_buffer,pRendition->board.vmem_base,MC_SIZE);
#endif
- v_out8(iob+MEMENDIAN, memend);
+ verite_out8(iob+MEMENDIAN, memend);
v1k_flushicache(pScreenInfo);
v1k_start(pScreenInfo, pRendition->board.csucode_base);
- v_out32(iob, 0); /* a0 - ucode init command */
- v_out32(iob, 0); /* a1 - 1024 byte context store area */
- v_out32(iob, 0); /* a2 */
- v_out32(iob, pRendition->board.ucode_entry);
+ verite_out32(iob, 0); /* a0 - ucode init command */
+ verite_out32(iob, 0); /* a1 - 1024 byte context store area */
+ verite_out32(iob, 0); /* a2 */
+ verite_out32(iob, pRendition->board.ucode_entry);
#if 0
- v_out32(iob+0x60, 129);
- ErrorF("RENDITION: PC at %x\n", v_in32(iob+0x64));
+ verite_out32(iob+0x60, 129);
+ ErrorF("RENDITION: PC at %x\n", verite_in32(iob+0x64));
#endif
}
@@ -454,8 +422,8 @@ RENDITIONSaveUcode(ScrnInfoPtr pScreenInfo)
#endif
v1k_stop(pScreenInfo);
- memend=v_in8(iob+MEMENDIAN);
- v_out8(iob+MEMENDIAN, MEMENDIAN_NO);
+ memend=verite_in8(iob+MEMENDIAN);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
#if 1
memcpy(pRendition->board.ucode_buffer, pRendition->board.vmem_base, MC_SIZE);
@@ -463,7 +431,7 @@ RENDITIONSaveUcode(ScrnInfoPtr pScreenInfo)
/* SlowBcopy has inverted src and dst */
xf86SlowBcopy(pRendition->board.vmem_base,pRendition->board.ucode_buffer,MC_SIZE);
#endif
- v_out8(iob+MEMENDIAN, memend);
+ verite_out8(iob+MEMENDIAN, memend);
v1k_continue(pScreenInfo);
}
@@ -486,80 +454,79 @@ RENDITIONSyncV1000(ScrnInfoPtr pScreenInfo)
#ifdef DEBUG
ErrorF("RENDITION: RENDITIONSyncV1000 called\n");
-#endif
-#ifdef DEBUG
- ErrorF("#Sync (1)# FIFO_INFREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
- ErrorF("#Sync (1)# FIFO_OUTVALID 0x%x -- \n",v_in8(iob+FIFOOUTVALID));
+
+ ErrorF("#Sync (1)# FIFO_INFREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+ ErrorF("#Sync (1)# FIFO_OUTVALID 0x%x -- \n",verite_in8(iob+FIFOOUTVALID));
#endif
c=0;
/* empty output fifo,
i.e. if there is any valid data in the output fifo then read it */
- while ((c++<0xfffff) && ((v_in8(iob+FIFOOUTVALID)&0x7)>0))
- (void)v_in32(iob);
+ while ((c++<0xfffff) && ((verite_in8(iob+FIFOOUTVALID)&0x7)>0))
+ (void)verite_in32(iob);
-/* if(!(c%0xffff))ErrorF("#F1# !0x%x! -- ",v_in8(iob+FIFOOUTVALID)); */
+/* if(!(c%0xffff))ErrorF("#F1# !0x%x! -- ",verite_in8(iob+FIFOOUTVALID)); */
if (c >= 0xfffff) {
ErrorF("RENDITION: RISC synchronization failed (1) FIFO out == %d!\n",
- v_in8(iob+FIFOOUTVALID)&0x1f);
+ verite_in8(iob+FIFOOUTVALID)&0x1f);
return;
}
/* sync RISC */
waitfifo(2);
- v_out32(iob, CMD_GET_PIXEL);
- v_out32(iob, 0);
+ verite_out32(iob, CMD_GET_PIXEL);
+ verite_out32(iob, 0);
c=0;
- while ((c++<0xfffff) && ((v_in8(iob+FIFOOUTVALID)&0x7)>0))
- (void)v_in32(iob);
+ while ((c++<0xfffff) && ((verite_in8(iob+FIFOOUTVALID)&0x7)>0))
+ (void)verite_in32(iob);
-/* if(!(c%0xffff))ErrorF("#F2# !0x%x! -- ",v_in8(iob+FIFOOUTVALID)); */
+/* if(!(c%0xffff))ErrorF("#F2# !0x%x! -- ",verite_in8(iob+FIFOOUTVALID)); */
if (c >= 0xfffff) {
- ErrorF("RENDITION: RISC synchronization failed (2) FIFO out == %d!\n",
- v_in8(iob+FIFOOUTVALID)&0x1f);
+ ErrorF ("Rendition: RISC synchronization failed (2) FIFO out == %d!\n",
+ verite_in8(iob+FIFOOUTVALID)&0x1f);
return;
}
/* sync pixel engine using csucode -- I suppose this is quite slow <ml> */
v1k_stop(pScreenInfo);
v1k_start(pScreenInfo, pRendition->board.csucode_base);
- v_out32(iob, 2); /* a0 - sync command */
+ verite_out32(iob, 2); /* a0 - sync command */
c=0;
- while ((c++<0xfffff) && ((v_in8(iob+FIFOOUTVALID)&0x7)>0))
- (void)v_in32(iob);
+ while ((c++<0xfffff) && ((verite_in8(iob+FIFOOUTVALID)&0x7)>0))
+ (void)verite_in32(iob);
-/* if(!(c%0xffff))ErrorF("#F3# !0x%x! -- ",v_in8(iob+FIFOOUTVALID)); */
+/* if(!(c%0xffff))ErrorF("#F3# !0x%x! -- ",verite_in8(iob+FIFOOUTVALID)); */
if (c == 0xfffff) {
- ErrorF("RENDITION: Pixel engine synchronization failed FIFO out == %d!\n",
- v_in8(iob+FIFOOUTVALID)&0x1f);
- return;
+ ErrorF ("Rendition: Pixel engine synchronization failed FIFO out == %d!\n",
+ verite_in8(iob+FIFOOUTVALID)&0x1f);
+ return;
}
/* restart the ucode */
- v_out32(iob, 0); /* a0 - ucode init command */
- v_out32(iob, 0); /* a1 - 1024 byte context store area */
- v_out32(iob, 0); /* a2 */
- v_out32(iob, pRendition->board.ucode_entry);
+ verite_out32(iob, 0); /* a0 - ucode init command */
+ verite_out32(iob, 0); /* a1 - 1024 byte context store area */
+ verite_out32(iob, 0); /* a2 */
+ verite_out32(iob, pRendition->board.ucode_entry);
/* init the ucode */
waitfifo(6);
- v_out32(iob, CMD_SETUP);
- v_out32(iob, P2(pRendition->board.mode.virtualwidth,
+ verite_out32(iob, CMD_SETUP);
+ verite_out32(iob, P2(pRendition->board.mode.virtualwidth,
pRendition->board.mode.virtualheight));
- v_out32(iob, P2(pRendition->board.mode.bitsperpixel,
+ verite_out32(iob, P2(pRendition->board.mode.bitsperpixel,
pRendition->board.mode.pixelformat));
- v_out32(iob, MC_SIZE);
+ verite_out32(iob, MC_SIZE);
- v_out32(iob, pRendition->board.mode.virtualwidth *
+ verite_out32(iob, pRendition->board.mode.virtualwidth *
(pRendition->board.mode.bitsperpixel>>3));
- v_out32(iob, (pRendition->board.mode.stride1<<12) |
+ verite_out32(iob, (pRendition->board.mode.stride1<<12) |
(pRendition->board.mode.stride0<<8));
}
@@ -601,16 +568,16 @@ RENDITIONSubsequentScreenToScreenCopy(ScrnInfoPtr pScreenInfo,
#if 1 /* def DEBUG */
- ErrorF("#ScreentoScreen# FIFO_INFREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
- ErrorF("#ScreentoScreen# FIFO_OUTVALID 0x%x -- \n",v_in8(iob+FIFOOUTVALID));
+ ErrorF("#ScreentoScreen# FIFO_INFREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+ ErrorF("#ScreentoScreen# FIFO_OUTVALID 0x%x -- \n",verite_in8(iob+FIFOOUTVALID));
#endif
waitfifo(5);
- v_out32(iob, CMD_SCREEN_BLT);
- v_out32(iob, pRendition->board.Rop);
- v_out32(iob, P2(srcX, srcY));
- v_out32(iob, P2(w, h));
- v_out32(iob, P2(dstX, dstY));
+ verite_out32(iob, CMD_SCREEN_BLT);
+ verite_out32(iob, pRendition->board.Rop);
+ verite_out32(iob, P2(srcX, srcY));
+ verite_out32(iob, P2(w, h));
+ verite_out32(iob, P2(dstX, dstY));
}
@@ -652,14 +619,14 @@ RENDITIONSubsequentSolidFillRect(ScrnInfoPtr pScreenInfo,
waitfifo(4);
#ifdef DEBUG
- ErrorF("#SubsequentSolidFill# FIFO_INFREE 0x%x -- \n",v_in8(iob+FIFOINFREE));
- ErrorF("#SubsequentSolidFill# FIFO_OUTVALID 0x%x -- \n",v_in8(iob+FIFOOUTVALID));
+ ErrorF("#SubsequentSolidFill# FIFO_INFREE 0x%x -- \n",verite_in8(iob+FIFOINFREE));
+ ErrorF("#SubsequentSolidFill# FIFO_OUTVALID 0x%x -- \n",verite_in8(iob+FIFOOUTVALID));
sleep(1);
#endif
- v_out32(iob, P2(pRendition->board.Rop, CMD_RECT_SOLID_ROP));
- v_out32(iob, pRendition->board.Color);
- v_out32(iob, P2(x, y));
- v_out32(iob, P2(w, h));
+ verite_out32(iob, P2(pRendition->board.Rop, CMD_RECT_SOLID_ROP));
+ verite_out32(iob, pRendition->board.Color);
+ verite_out32(iob, P2(x, y));
+ verite_out32(iob, P2(w, h));
}
@@ -684,11 +651,11 @@ RENDITIONSubsequentTwoPointLine(ScrnInfoPtr pScreenInfo,
#endif
waitfifo(5);
- v_out32(iob, P2(1, CMD_LINE_SOLID));
- v_out32(iob, pRendition->board.Rop);
- v_out32(iob, pRendition->board.Color);
- v_out32(iob, P2(x1, y1));
- v_out32(iob, P2(x2, y2));
+ verite_out32(iob, P2(1, CMD_LINE_SOLID));
+ verite_out32(iob, pRendition->board.Rop);
+ verite_out32(iob, pRendition->board.Color);
+ verite_out32(iob, P2(x1, y1));
+ verite_out32(iob, P2(x2, y2));
}
/*
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c
index 808e393cc..e7b5ca926 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c,v 1.6 2000/02/25 21:03:00 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/hwcursor.c,v 1.7 2000/03/31 20:13:25 dawes Exp $ */
/*
* includes
*/
@@ -138,11 +138,11 @@ RENDITIONShowCursor(ScrnInfoPtr pScreenInfo)
#endif
/* enable cursor - X11 mode */
- v_enablecursor(pScreenInfo, V_3COLORS,
+ verite_enablecursor(pScreenInfo, VERITE_3COLORS,
#ifdef BIGCURSOR
- V_CURSOR64
+ VERITE_CURSOR64
#else
- V_CURSOR32
+ VERITE_CURSOR32
#endif
);
}
@@ -157,7 +157,7 @@ RENDITIONHideCursor(ScrnInfoPtr pScreenInfo)
#endif
/* Disable cursor */
- v_enablecursor(pScreenInfo, V_NOCURSOR, 0);
+ verite_enablecursor(pScreenInfo, VERITE_NOCURSOR, 0);
}
@@ -169,7 +169,7 @@ RENDITIONSetCursorPosition(ScrnInfoPtr pScreenInfo, int x, int y)
ErrorF( "RENDITION: SetCursorPosition(%d, %d) called\n", x, y);
#endif
- v_movecursor(pScreenInfo, x, y, 1 /* xorigin */, 1 /* yorigin */);
+ verite_movecursor(pScreenInfo, x, y, 1 /* xorigin */, 1 /* yorigin */);
}
@@ -181,7 +181,7 @@ RENDITIONSetCursorColors(ScrnInfoPtr pScreenInfo, int bg, int fg)
ErrorF( "RENDITION: SetCursorColors(%x, %x) called\n", fg, bg);
#endif
- v_setcursorcolor(pScreenInfo, bg, fg);
+ verite_setcursorcolor(pScreenInfo, bg, fg);
}
@@ -192,11 +192,11 @@ RENDITIONLoadCursorImage(ScrnInfoPtr pScreenInfo, unsigned char* src)
#ifdef DEBUG
ErrorF( "RENDITION: loadcursor called\n");
#endif
- v_loadcursor(pScreenInfo,
+ verite_loadcursor(pScreenInfo,
#ifdef BIGCURSOR
- V_CURSOR64,
+ VERITE_CURSOR64,
#else
- V_CURSOR32,
+ VERITE_CURSOR32,
#endif
(vu8 *)src);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c
index 95122b137..c2daa6254 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c,v 1.30 2000/03/06 23:54:12 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.c,v 1.34 2000/06/13 02:28:33 dawes Exp $ */
/*
* Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
*
@@ -61,6 +61,7 @@
#include "accel.h"
#include "vramdac.h"
#include "rendition_shadow.h"
+#include "vbe.h"
/*
* defines
@@ -98,9 +99,11 @@ static Bool renditionUnmapMem(ScrnInfoPtr pScreenInfo);
static xf86MonPtr renditionDDC(ScrnInfoPtr pScreenInfo);
static unsigned int renditionDDC1Read (ScrnInfoPtr pScreenInfo);
+static void renditionProbeDDC(ScrnInfoPtr pScrn, int index);
static void renditionLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
+
/*
* global data
*/
@@ -195,6 +198,12 @@ static const char *shadowfbSymbols[] = {
NULL
};
+static const char *vbeSymbols[] = {
+ "VBEInit",
+ "vbeDoEDID",
+ NULL
+};
+
#ifdef XFree86LOADER
@@ -230,7 +239,7 @@ renditionSetup(pointer Module, pointer Options, int *ErrorMajor,
xf86AddDriver(&RENDITION, Module, 0);
LoaderRefSymLists(vgahwSymbols, ramdacSymbols, fbSymbols,
xaaSymbols, ddcSymbols, int10Symbols,
- shadowfbSymbols, NULL);
+ shadowfbSymbols, vbeSymbols, NULL);
return (pointer)TRUE;
}
@@ -316,22 +325,25 @@ renditionProbe(DriverPtr drv, int flags)
else for (c=0; c<numUsed; c++) {
ScrnInfoPtr pScrn;
/* Allocate a ScrnInfoRec and claim the slot */
- pScrn=xf86AllocateScreen(drv, 0);
- pScrn->driverVersion=RENDITION_VERSION_CURRENT;
- pScrn->driverName =RENDITION_DRIVER_NAME;
- pScrn->name =RENDITION_NAME;
- pScrn->Probe =renditionProbe;
- pScrn->PreInit =renditionPreInit;
- pScrn->ScreenInit =renditionScreenInit;
- pScrn->SwitchMode =renditionSwitchMode;
- pScrn->AdjustFrame =renditionAdjustFrame;
- pScrn->EnterVT =renditionEnterVT;
- pScrn->LeaveVT =renditionLeaveVT;
- pScrn->FreeScreen =renditionFreeScreen;
- pScrn->ValidMode =renditionValidMode;
- foundScreen=TRUE;
- xf86ConfigActivePciEntity(pScrn, usedChips[c],
- renditionPCIchipsets, NULL, NULL, NULL, NULL, NULL);
+ pScrn=NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[c],
+ renditionPCIchipsets, NULL,
+ NULL, NULL, NULL, NULL))) {
+
+ pScrn->driverVersion=RENDITION_VERSION_CURRENT;
+ pScrn->driverName =RENDITION_DRIVER_NAME;
+ pScrn->name =RENDITION_NAME;
+ pScrn->Probe =renditionProbe;
+ pScrn->PreInit =renditionPreInit;
+ pScrn->ScreenInit =renditionScreenInit;
+ pScrn->SwitchMode =renditionSwitchMode;
+ pScrn->AdjustFrame =renditionAdjustFrame;
+ pScrn->EnterVT =renditionEnterVT;
+ pScrn->LeaveVT =renditionLeaveVT;
+ pScrn->FreeScreen =renditionFreeScreen;
+ pScrn->ValidMode =renditionValidMode;
+ foundScreen=TRUE;
+ }
}
}
xfree(usedChips);
@@ -391,7 +403,6 @@ renditionFreeRec(ScrnInfoPtr pScreenInfo)
ErrorF("FreeRec...!!!!\n");
sleep(1);
#endif
-
if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
vgaHWFreeHWRec(pScreenInfo);
xfree(pScreenInfo->driverPrivate);
@@ -464,8 +475,6 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
renditionPtr pRendition;
char *in_string;
- if (flags & PROBE_DETECT) return FALSE;
-
#ifdef DEBUG
ErrorF("Rendition: renditionPreInit() called\n");
#endif
@@ -474,12 +483,10 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
if (pScreenInfo->numEntities != 1)
return FALSE;
- /* set the monitor */
- pScreenInfo->monitor=pScreenInfo->confScreen->monitor;
-
/* allocate driver private structure */
if (!renditionGetRec(pScreenInfo))
return FALSE;
+
pRendition=RENDITIONPTR(pScreenInfo);
/* Get the entity, and make sure it is PCI. */
@@ -487,6 +494,14 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
if (pRendition->pEnt->location.type != BUS_PCI)
return FALSE;
+ if (flags & PROBE_DETECT) {
+ renditionProbeDDC(pScreenInfo, pRendition->pEnt->index);
+ return TRUE;
+ }
+
+ /* set the monitor */
+ pScreenInfo->monitor=pScreenInfo->confScreen->monitor;
+
/* Initialize the card through int10 interface if needed */
if (xf86LoadSubModule(pScreenInfo, "int10")){
xf86Int10InfoPtr pInt=NULL;
@@ -580,7 +595,7 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
/* determine default visual */
if (!xf86SetDefaultVisual(pScreenInfo, -1))
- return FALSE;
+ return FALSE;
/* the gamma fields must be initialised when using the new cmap code */
if (pScreenInfo->depth > 1) {
@@ -624,20 +639,21 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
/* I do not get the IO base addres <ml> */
/* XXX Is this still true? If so, the wrong base is being checked */
- ErrorF("Rendition %s @ %x/%x\n",renditionChipsets[
- pRendition->board.chip==V1000_DEVICE ? 0:1].name,
- pRendition->board.io_base,
- pRendition->board.mem_base);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_PROBED,
+ "Rendition %s @ %x/%x\n",
+ renditionChipsets[pRendition->board.chip==V1000_DEVICE ? 0:1].name,
+ pRendition->board.io_base,
+ pRendition->board.mem_base);
/* First of all get a "clean" starting state */
- v_resetboard(pScreenInfo);
+ verite_resetboard(pScreenInfo);
/* determine video ram -- to do so, we assume a full size memory of 16M,
- * then map it and use v_getmemorysize() to determine the real amount of
+ * then map it and use verite_getmemorysize() to determine the real amount of
* memory */
pScreenInfo->videoRam=pRendition->board.mem_size=16<<20;
renditionMapMem(pScreenInfo);
- videoRam=v_getmemorysize(pScreenInfo)>>10;
+ videoRam=verite_getmemorysize(pScreenInfo)>>10;
/* Unmaping delayed until after micrcode loading */
/****************************************/
@@ -647,9 +663,12 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
if (!xf86ReturnOptValBool(renditionOptions, OPTION_NOACCEL,0)) {
RENDITIONAccelPreInit (pScreenInfo);
}
- else ErrorF("RENDITION: Skipping acceleration on users request\n");
+ else
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
+ ("Skipping acceleration on users request\n"));
#else
- ErrorF("RENDITION: Skipping acceleration\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_WARNING,
+ ("Skipping acceleration\n"));
#endif
xf86MarkOptionUsedByName(renditionOptions,"NoAccel");
@@ -667,7 +686,6 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
}
xf86LoaderReqSymLists(vgahwSymbols, NULL);
-
pRendition->board.shadowfb=TRUE;
if ((in_string = xf86GetOptValString(renditionOptions, OPTION_ROTATE))) {
@@ -733,10 +751,12 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
}
#endif
+#if 0
/* Load DDC module if needed */
if (!xf86ReturnOptValBool(renditionOptions, OPTION_NO_DDC,0)){
if (!xf86LoadSubModule(pScreenInfo, "ddc")) {
- ErrorF ("RENDITION: Loading of DDC library failed, skipping DDC-probe\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ ("Loading of DDC library failed, skipping DDC-probe\n"));
}
else {
xf86LoaderReqSymLists(ddcSymbols, NULL);
@@ -744,8 +764,26 @@ renditionPreInit(ScrnInfoPtr pScreenInfo, int flags)
}
}
else {
- ErrorF ("RENDITION: Skipping DDC probe on users request\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
+ ("Skipping DDC probe on users request\n"));
}
+#else
+ /* Load DDC module if needed */
+ if (!xf86ReturnOptValBool(renditionOptions, OPTION_NO_DDC,0)){
+ if (!xf86LoadSubModule(pScreenInfo, "vbe")) {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ ("Loading of DDC library failed, skipping DDC-probe\n"));
+ }
+ else {
+ xf86LoaderReqSymLists(vbeSymbols, NULL);
+ renditionProbeDDC(pScreenInfo, pRendition->pEnt->index);
+ }
+ }
+ else {
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
+ ("Skipping DDC probe on users request\n"));
+ }
+#endif
/***********************************************/
/* ensure vgahw private structure is allocated */
@@ -878,7 +916,7 @@ renditionRestore(ScrnInfoPtr pScreenInfo)
vgaHWRestore(pScreenInfo, &VGAHWPTR(pScreenInfo)->SavedReg, VGA_SR_ALL);
vgaHWProtect(pScreenInfo, FALSE);
- v_setmode(pScreenInfo, &RENDITIONPTR(pScreenInfo)->mode);
+ verite_setmode(pScreenInfo, &RENDITIONPTR(pScreenInfo)->mode);
#ifdef DEBUG
ErrorF("Restore OK...!!!!\n");
sleep(1);
@@ -890,7 +928,7 @@ renditionRestore(ScrnInfoPtr pScreenInfo)
static Bool
renditionSetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode)
{
- struct v_modeinfo_t *modeinfo=&RENDITIONPTR(pScreenInfo)->mode;
+ struct verite_modeinfo_t *modeinfo=&RENDITIONPTR(pScreenInfo)->mode;
vgaHWPtr pvgaHW;
#ifdef DEBUG
@@ -900,7 +938,7 @@ renditionSetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode)
#endif
pvgaHW = VGAHWPTR(pScreenInfo);
- /* construct a modeinfo for the v_setmode function */
+ /* construct a modeinfo for the verite_setmode function */
modeinfo->clock=pMode->SynthClock;
modeinfo->hdisplay=pMode->HDisplay;
modeinfo->hsyncstart=pMode->HSyncStart;
@@ -955,12 +993,10 @@ renditionSetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode)
break;
case 16:
modeinfo->bitsperpixel=16;
-#if 0
- if (vga256InfoRec.weight.green == 5)
+ if (pScreenInfo->weight.green == 5)
/* on a V1000, this looks too 'red/magenta' <ml> */
modeinfo->pixelformat=V_PIXFMT_1555;
else
-#endif
modeinfo->pixelformat=V_PIXFMT_565;
break;
case 32:
@@ -971,7 +1007,7 @@ renditionSetMode(ScrnInfoPtr pScreenInfo, DisplayModePtr pMode)
modeinfo->fifosize=128;
modeinfo->flags=pMode->Flags;
- v_setmode(pScreenInfo,&RENDITIONPTR(pScreenInfo)->mode);
+ verite_setmode(pScreenInfo,&RENDITIONPTR(pScreenInfo)->mode);
#ifdef DEBUG
ErrorF("Setmode OK...!!!!\n");
@@ -1033,7 +1069,7 @@ renditionLeaveGraphics(ScrnInfoPtr pScreenInfo)
renditionRestore(pScreenInfo);
vgaHWLock(VGAHWPTR(pScreenInfo));
- v_textmode(&RENDITIONPTR(pScreenInfo)->board);
+ verite_textmode(&RENDITIONPTR(pScreenInfo)->board);
#ifdef DEBUG
ErrorF("Leavegraphics OK...!!!!\n");
sleep(1);
@@ -1180,42 +1216,63 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!Inited)
return FALSE;
- miInitializeBackingStore(pScreen);
if (pScreenInfo->bitsPerPixel > 8) {
/* Fixup RGB ordering */
visual=pScreen->visuals+pScreen->numVisuals;
while (--visual >= pScreen->visuals) {
- if (0 && (visual->class | DynamicClass) == DirectColor) {
- visual->offsetRed = pScreenInfo->offset.red;
- visual->offsetGreen = pScreenInfo->offset.green;
- visual->offsetBlue = pScreenInfo->offset.blue;
- visual->redMask = pScreenInfo->mask.red;
- visual->greenMask = pScreenInfo->mask.green;
- visual->blueMask = pScreenInfo->mask.blue;
- }
- else {
- ErrorF("Changing masks!!!\n");
- if (pScreenInfo->bitsPerPixel == 32) {
- visual->offsetRed=16;
- visual->offsetGreen=8;
- visual->offsetBlue=0;
- visual->redMask=0xff0000;
- visual->greenMask=0xff00;
- visual->blueMask=0xff;
- } else {
- visual->offsetRed=11;
- visual->offsetGreen=5;
- visual->offsetBlue=0;
- visual->redMask=0xf800;
- visual->greenMask=0x7e0;
- visual->blueMask=0x1f;
+ if ((visual->class | DynamicClass) == DirectColor){
+ visual->offsetRed = pScreenInfo->offset.red;
+ visual->offsetGreen = pScreenInfo->offset.green;
+ visual->offsetBlue = pScreenInfo->offset.blue;
+ visual->redMask = pScreenInfo->mask.red;
+ visual->greenMask = pScreenInfo->mask.green;
+ visual->blueMask = pScreenInfo->mask.blue;
+ }
+
+#if 0 /* This code is never called ? <DI> */
+ else {
+ switch (pScreenInfo->bitsPerPixel)
+ {
+ case 16:
+ if (pScreenInfo->weight.green == 5){
+ /* weight 555 mode */
+ ErrorF("RENDITION: 15bit mode\n");
+ visual->offsetRed=10;
+ visual->offsetGreen=5;
+ visual->offsetBlue=0;
+ visual->redMask=0x7c00;
+ visual->greenMask=0x3e0;
+ visual->blueMask=0x1f;
+ }
+ else{
+ ErrorF("RENDITION: 16bit mode\n");
+ visual->offsetRed=11;
+ visual->offsetGreen=5;
+ visual->offsetBlue=0;
+ visual->redMask=0xf800;
+ visual->greenMask=0x7e0;
+ visual->blueMask=0x1f;
}
+ break;
+
+ case 32:
+ ErrorF("RENDITION: 32bit mode\n");
+ visual->offsetRed=16;
+ visual->offsetGreen=8;
+ visual->offsetBlue=0;
+ visual->redMask=0xff0000;
+ visual->greenMask=0xff00;
+ visual->blueMask=0xff;
+ break;
+ }
}
+#endif /* Never used fixup code */
}
}
xf86SetBlackWhitePixels(pScreen);
+ miInitializeBackingStore(pScreen);
/*********************************************************/
/* The actual setup of the driver-specific code */
@@ -1227,6 +1284,7 @@ renditionScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#endif
/* Initialise cursor functions */
+ xf86SetSilkenMouse(pScreen);
miDCInitialize(pScreen, xf86GetPointerScreenFuncs());
if(!xf86ReturnOptValBool(renditionOptions, OPTION_SW_CURSOR,0)&&
@@ -1332,7 +1390,7 @@ renditionAdjustFrame(int scrnIndex, int x, int y, int flags)
#ifdef DEBUG
ErrorF ("MOVING SCREEN %d bytes!!\n",offset);
#endif
- v_setframebase(pScreenInfo, offset);
+ verite_setframebase(pScreenInfo, offset);
}
@@ -1385,7 +1443,7 @@ renditionMapMem(ScrnInfoPtr pScreenInfo)
RENDITIONPTR(pScreenInfo)->board.mem_base, pScreenInfo->videoRam);
#endif
- if (1 /* RENDITIONPTR(pScreenInfo)->board.chip==V1000_DEVICE */){
+ if (RENDITIONPTR(pScreenInfo)->board.chip==V1000_DEVICE){
/* Some V1000 boards are known to have problems with Write-Combining */
/* V2x00 also found to have similar problems with memcpy & WC ! */
WriteCombine = 0;
@@ -1397,11 +1455,13 @@ renditionMapMem(ScrnInfoPtr pScreenInfo)
/* Override on users request */
WriteCombine=xf86ReturnOptValBool(renditionOptions, OPTION_FBWC, WriteCombine);
if (WriteCombine){
- ErrorF("RENDITION: Requesting write-combined memory access\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
+ ("Requesting Write-Combined memory access\n"));
mapOption = VIDMEM_FRAMEBUFFER;
}
else {
- ErrorF("RENDITION: Requesting MMIO-style memory access\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
+ ("Requesting MMIO-style memory access\n"));
mapOption = VIDMEM_MMIO;
}
@@ -1438,7 +1498,7 @@ renditionLoadPalette(ScrnInfoPtr pScreenInfo, int numColors,
int *indices, LOCO *colors,
VisualPtr pVisual)
{
- v_setpalette(pScreenInfo, numColors, indices, colors, pVisual);
+ verite_setpalette(pScreenInfo, numColors, indices, colors, pVisual);
}
@@ -1450,10 +1510,10 @@ renditionDDC (ScrnInfoPtr pScreenInfo)
vu32 temp;
xf86MonPtr MonInfo = NULL;
- temp = v_in32(iob+CRTCCTL); /* Remember original value */
+ temp = verite_in32(iob+CRTCCTL); /* Remember original value */
/* Enable DDC1 */
- v_out32(iob+CRTCCTL,(temp|
+ verite_out32(iob+CRTCCTL,(temp|
CRTCCTL_ENABLEDDC|
CRTCCTL_VSYNCENABLE|
CRTCCTL_VIDEOENABLE));
@@ -1462,7 +1522,7 @@ renditionDDC (ScrnInfoPtr pScreenInfo)
vgaHWddc1SetSpeed,
renditionDDC1Read );
- v_out32(iob+CRTCCTL,temp); /* return the original values */
+ verite_out32(iob+CRTCCTL,temp); /* return the original values */
xf86DrvMsg(pScreenInfo->scrnIndex, X_INFO,
"DDC Monitor info: %p\n", MonInfo);
@@ -1483,10 +1543,22 @@ renditionDDC1Read (ScrnInfoPtr pScreenInfo)
vu32 value = 0;
/* wait for Vsync */
- while (!(v_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC));
- while (v_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC);
+ while (!(verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC));
+ while (verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_SYNC);
/* Read the value */
- value = v_in32(iob+CRTCCTL) & CRTCCTL_DDCDATA;
+ value = verite_in32(iob+CRTCCTL) & CRTCCTL_DDCDATA;
return value;
}
+
+void
+renditionProbeDDC(ScrnInfoPtr pScreenInfo, int index)
+{
+ vbeInfoPtr pVbe;
+ if (xf86LoadSubModule(pScreenInfo, "vbe")) {
+ xf86LoaderReqSymLists(vbeSymbols, NULL);
+
+ pVbe = VBEInit(NULL,index);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp b/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp
index 644cbc732..6e9572ba4 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp,v 1.2 2000/03/05 16:59:14 dawes Exp $
-.TH RENDITION __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.cpp,v 1.5 2000/06/14 02:13:13 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH RENDITION __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
rendition \- Rendition video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""rendition"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qrendition\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B rendition
is an XFree86 driver for Rendition/Micron based video cards. The driver
@@ -39,7 +39,7 @@ driver.
The driver auto-detects the chipset type, but the following
.B ChipSet
names may optionally be specified in the config file
-.B """Device"""
+.B \*qDevice\*q
section, and will override the auto-detection:
.PP
.RS 4
@@ -51,40 +51,40 @@ chips. If the amount of memory is detected incorrectly, the actual amount
of video memory should be specified with a
.B VideoRam
entry in the config file
-.B """Device"""
+.B \*qDevice\*q
section.
.PP
The following driver
.B Options
are supported:
.TP
-.BI "Option ""SWCursor"" """ boolean """
+.BI "Option \*qSWCursor\*q \*q" boolean \*q
Disables use of the hardware cursor. Default: use HW-cursor.
.TP
-.BI "Option ""OverclockMem"" """ boolean """
+.BI "Option \*qOverclockMem\*q \*q" boolean \*q
Increases the Mem/Sys clock to 125MHz/60MHz from standard 110MHz/50MHz.
Default: Not overclocked.
.TP
-.BI "Option ""DacSpeed"" """ MHz """
+.BI "Option \*qDacSpeed\*q \*q" MHz \*q
Run the memory at a higher clock. Useful on some cards with display glitches
at higher resolutions. But adds the risk to damage the hardware. Use with
caution.
.TP
-.BI "Option ""FramebufferWC"" """ boolean """
+.BI "Option \*qFramebufferWC\*q \*q" boolean \*q
If writecombine is disabled in BIOS, and you add this option in configuration
file, then the driver will try to request writecombined access to the
framebuffer. This can drastically increase the performance on unaccelerated
server. Requires that "MTRR"-support is compiled into the OS-kernel.
Default: Disabled for V1000, enabled for V2100/V2200.
.TP
-.BI "Option ""NoDDC"" """ boolean """
+.BI "Option \*qNoDDC\*q \*q" boolean \*q
Disable probing of DDC-information from your monitor. This information is not
used yet and is only there for informational purposes. This might change
before final XFree86 4.0 release. Safe to disable if you experience problems
during startup of X-server.
Default: Probe DDC.
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
If this option is enabled, the driver will cause the CPU to do each drawing
operation first into a shadow frame buffer in system virtual memory and then
copy the result into video memory. If this option is not active, the CPU will
@@ -95,18 +95,18 @@ normally the case for PCI or AGP adapters, and, so, this option is enabled by
default unless acceleration is enabled.
Default: Enabled unless acceleration is used.
.TP
-.BI "Option ""Rotate"" ""CW""
+.BI "Option \*qRotate\*q \*qCW\*q"
.TP
-.BI "Option ""Rotate"" ""CCW""
+.BI "Option \*qRotate\*q \*qCCW\*q"
Rotate the display clockwise or counterclockwise. This mode is unaccelerated.
Default: no rotation.
.TP
.SH "Notes"
For the moment the driver defaults to not request write-combine for any chipset
as there has been indications of problems with it. Use
-.B "Option ""MTRR"""
+.B "Option \*qMTRR\*q"
to let the driver request write-combining of memory access on the videoboard.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: Marc Langenbach, Dejan Ilic
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h
index a9f73bb01..6a5a6e81b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h
@@ -1,11 +1,8 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h,v 1.5 2000/02/25 21:03:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/rendition.h,v 1.6 2000/04/04 19:25:15 dawes Exp $ */
#ifndef __RENDITION_H__
#define __RENDITION_H__
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -13,6 +10,9 @@
/* All drivers need this */
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* This is used for module versioning */
#include "xf86Version.h"
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c
index 516268691..609f20d4f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c,v 1.5 2000/02/25 21:03:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/v1krisc.c,v 1.6 2000/03/31 20:13:25 dawes Exp $ */
/*
*
*/
@@ -72,7 +72,7 @@
#define WRITE_SHORT 1
#define WRITE_WORD 2
-#define V_MAX_POLLS 100
+#define VERITE_MAX_POLLS 100
@@ -80,8 +80,8 @@
* local function prototypes
*/
-static void v_iopoll(vu16 port, vu32 data, vu32 mask);
-static void v_iopoll8(vu16 port, vu8 data, vu8 mask);
+static void verite_iopoll(vu16 port, vu32 data, vu32 mask);
+static void verite_iopoll8(vu16 port, vu8 data, vu8 mask);
static vu32 readRF(vu16 io_base, vu8 index);
static void writeRF(vu16 io_base, vu8 index, vu32 data);
@@ -151,39 +151,41 @@ v1k_stop(ScrnInfoPtr pScreenInfo)
vu16 STATUS = 0x4A; /* v2x00 io register offset */
int c;
- debugreg=v_in8(io_base+DEBUGREG);
+ debugreg=verite_in8(io_base+DEBUGREG);
if (pRendition->board.chip == V2000_DEVICE){
c=0;
do {
-/* if(!(c%10000))ErrorF("#S1# !0x%x! -- ",v_in8((vu16)(io_base+STATUS))); */
- statusreg = v_in8((vu16)(io_base+STATUS));
+/* if(!(c%10000))ErrorF("#S1# !0x%x! -- ",verite_in8((vu16)(io_base+STATUS))); */
+ statusreg = verite_in8((vu16)(io_base+STATUS));
if ((statusreg & 0x8C) == 0x8C)
break;
} while (c++<0xfffff);
if (c >= 0xfffff)
- ErrorF ("RENDITION: Status timeout (1)\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ ("Status timeout (1)\n"));
- v_out8(io_base+DEBUGREG, debugreg|HOLDRISC);
+ verite_out8(io_base+DEBUGREG, debugreg|HOLDRISC);
if (pRendition->board.chip == V2000_DEVICE){
c=0;
do {
-/* if(!(c%10000))ErrorF("#S2# !0x%x! -- ",v_in8((vu16)(io_base+STATUS))); */
- statusreg = v_in8((vu16)(io_base+STATUS));
+/* if(!(c%10000))ErrorF("#S2# !0x%x! -- ",verite_in8((vu16)(io_base+STATUS))); */
+ statusreg = verite_in8((vu16)(io_base+STATUS));
if (statusreg & HOLDRISC) break;
} while (c++<0xfffff);
if (c >= 0xfffff)
- ErrorF ("RENDITION: Status timeout (2)\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ ("Status timeout (2)\n"));
}
}
else {
/* V1000 stop */
- v_out8(io_base+DEBUGREG, debugreg|HOLDRISC);
+ verite_out8(io_base+DEBUGREG, debugreg|HOLDRISC);
- v_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
- v_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
- v_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
+ verite_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
+ verite_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
+ verite_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
}
}
@@ -250,32 +252,32 @@ v1k_softreset(ScrnInfoPtr pScreenInfo)
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
vu16 io_base=pRendition->board.io_base;
- v_out8(io_base+DEBUGREG, SOFTRESET|HOLDRISC);
- v_out8(io_base+STATEINDEX, STATEINDEX_PC);
- v_iopoll(io_base+STATEDATA, 0, 0xffffffff);
- v_iopoll(io_base+STATEDATA, 0, 0xffffffff);
- v_iopoll(io_base+STATEDATA, 0, 0xffffffff);
+ verite_out8(io_base+DEBUGREG, SOFTRESET|HOLDRISC);
+ verite_out8(io_base+STATEINDEX, STATEINDEX_PC);
+ verite_iopoll(io_base+STATEDATA, 0, 0xffffffff);
+ verite_iopoll(io_base+STATEDATA, 0, 0xffffffff);
+ verite_iopoll(io_base+STATEDATA, 0, 0xffffffff);
- v_out8(io_base+DEBUGREG, HOLDRISC);
- v_iopoll(io_base+STATEDATA, 0, 0);
- v_iopoll(io_base+STATEDATA, 0, 0);
- v_iopoll(io_base+STATEDATA, 0, 0);
+ verite_out8(io_base+DEBUGREG, HOLDRISC);
+ verite_iopoll(io_base+STATEDATA, 0, 0);
+ verite_iopoll(io_base+STATEDATA, 0, 0);
+ verite_iopoll(io_base+STATEDATA, 0, 0);
/* turn icache on */
risc_forcestep(io_base, LI_INSTR(LI_OP, RISC_RA, ICACHE_ONOFF_MASK&0xffff));
risc_forcestep(io_base, INT_INSTR(ADDIFI_OP, RISC_FLAG, RISC_RA,
ICACHE_ONOFF_MASK>>16));
/* clear any interrupts */
- v_out8(io_base+INTR, 0xff);
+ verite_out8(io_base+INTR, 0xff);
/* byte swap mode=word */
- v_out8(io_base+MEMENDIAN, MEMENDIAN_NO);
+ verite_out8(io_base+MEMENDIAN, MEMENDIAN_NO);
}
/*
void
-v1k_getriscprocs(v_board_desc *boardDesc)
+v1k_getriscprocs(verite_board_desc *boardDesc)
{
boardDesc->risc_procs.risc_softreset = v1krisc_softreset;
boardDesc->risc_procs.risc_flushicache = v1krisc_flushicache;
@@ -293,32 +295,32 @@ v1k_getriscprocs(v_board_desc *boardDesc)
*/
/*
- * static void v_iopoll(vu16 port, vu32 data, vu32 mask)
+ * static void verite_iopoll(vu16 port, vu32 data, vu32 mask)
*
- * Loop on IO read until expected data is read or V_MAX_POLLS is reached.
+ * Loop on IO read until expected data is read or VERITE_MAX_POLLS is reached.
*/
static void
-v_iopoll(vu16 port, vu32 data, vu32 mask)
+verite_iopoll(vu16 port, vu32 data, vu32 mask)
{
vu32 c, d;
c=0;
do {
c++;
- if (((d=v_in32(port))&mask) == (data&mask))
+ if (((d=verite_in32(port))&mask) == (data&mask))
break;
- } while (c <= V_MAX_POLLS);
+ } while (c <= VERITE_MAX_POLLS);
}
/*
- * static void v_iopoll8(vu16 port, vu8 data, vu8 mask)
+ * static void verite_iopoll8(vu16 port, vu8 data, vu8 mask)
*
- * Loop on IO read until expected data is read or V_MAX_POLLS is reached.
+ * Loop on IO read until expected data is read or VERITE_MAX_POLLS is reached.
*/
static void
-v_iopoll8(vu16 port, vu8 data, vu8 mask)
+verite_iopoll8(vu16 port, vu8 data, vu8 mask)
{
vu32 c;
vu8 d;
@@ -326,9 +328,9 @@ v_iopoll8(vu16 port, vu8 data, vu8 mask)
c=0;
do {
c++;
- if (((d=v_in8(port))&mask) == (data&mask))
+ if (((d=verite_in8(port))&mask) == (data&mask))
break;
- } while (c <= V_MAX_POLLS);
+ } while (c <= VERITE_MAX_POLLS);
}
@@ -344,27 +346,27 @@ readRF(vu16 io_base, vu8 index)
vu32 data, instr;
vu8 debug, stateindex;
- debug=v_in8(io_base+DEBUGREG);
- stateindex=v_in8(io_base+STATEINDEX);
+ debug=verite_in8(io_base+DEBUGREG);
+ stateindex=verite_in8(io_base+STATEINDEX);
/* force RISC instruction: add zero,zero,index
* S1 reg address = reg index to read
* write to the DEC_IR, but no need to step it! */
- v_out8(io_base+DEBUGREG, debug|HOLDRISC);
+ verite_out8(io_base+DEBUGREG, debug|HOLDRISC);
instr=INT_INSTR(ADD_OP, 0, 0, index);
- v_out32(io_base+STATEDATA, instr);
+ verite_out32(io_base+STATEDATA, instr);
/* wait for instruction to get to RISC IR. */
- v_out8(io_base+STATEINDEX, STATEINDEX_IR); /* point at DEC_IR */
- v_iopoll(io_base+STATEDATA, instr, 0xffffffff);
+ verite_out8(io_base+STATEINDEX, STATEINDEX_IR); /* point at DEC_IR */
+ verite_iopoll(io_base+STATEDATA, instr, 0xffffffff);
- v_out8(io_base+STATEINDEX, STATEINDEX_S1); /* point at RISCS1 */
- v_iopoll(io_base+STATEINDEX, 0, 0); /* short pause */
- data=v_in32(io_base+STATEDATA); /* read RF */
+ verite_out8(io_base+STATEINDEX, STATEINDEX_S1); /* point at RISCS1 */
+ verite_iopoll(io_base+STATEINDEX, 0, 0); /* short pause */
+ data=verite_in32(io_base+STATEDATA); /* read RF */
- v_out8(io_base+STATEINDEX, stateindex); /* restore state_index */
- v_out8(io_base+DEBUGREG, debug); /* restore debug */
+ verite_out8(io_base+STATEINDEX, stateindex); /* restore state_index */
+ verite_out8(io_base+DEBUGREG, debug); /* restore debug */
return data;
}
@@ -472,11 +474,11 @@ risc_step(vu16 io_base, vu32 count)
/* RISC is already held; just single step it */
for (c=0; c<count; c++) {
- debugreg=v_in8(io_base+DEBUGREG);
- v_out8(io_base+DEBUGREG, debugreg|STEPRISC);
+ debugreg=verite_in8(io_base+DEBUGREG);
+ verite_out8(io_base+DEBUGREG, debugreg|STEPRISC);
for (d=0; d<1000; d++)
- if(0 == (v_in8(io_base+DEBUGREG)&STEPRISC))
+ if(0 == (verite_in8(io_base+DEBUGREG)&STEPRISC))
break;
if (1000 == d)
@@ -498,21 +500,21 @@ risc_forcestep(vu16 io_base, vu32 instruction)
vu8 debugreg, stateindex;
- debugreg=v_in8(io_base+DEBUGREG);
- stateindex=v_in8(io_base+STATEINDEX);
- v_out8(io_base+STATEINDEX, STATEINDEX_IR);
- v_iopoll8(io_base+STATEINDEX, STATEINDEX_IR, 0xff); /* wait */
- v_out32(io_base+STATEDATA, instruction); /* load instruction */
- v_iopoll(io_base+STATEDATA, instruction, 0xffffffff); /* wait */
- v_out8(io_base+DEBUGREG, debugreg|HOLDRISC|STEPRISC); /* step */
- v_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
+ debugreg=verite_in8(io_base+DEBUGREG);
+ stateindex=verite_in8(io_base+STATEINDEX);
+ verite_out8(io_base+STATEINDEX, STATEINDEX_IR);
+ verite_iopoll8(io_base+STATEINDEX, STATEINDEX_IR, 0xff); /* wait */
+ verite_out32(io_base+STATEDATA, instruction); /* load instruction */
+ verite_iopoll(io_base+STATEDATA, instruction, 0xffffffff); /* wait */
+ verite_out8(io_base+DEBUGREG, debugreg|HOLDRISC|STEPRISC); /* step */
+ verite_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
- for (c=0; c<V_MAX_POLLS; c++)
- if (HOLDRISC == (v_in8(io_base+DEBUGREG) & (HOLDRISC|STEPRISC)))
+ for (c=0; c<VERITE_MAX_POLLS; c++)
+ if (HOLDRISC == (verite_in8(io_base+DEBUGREG) & (HOLDRISC|STEPRISC)))
break;
/* restore */
- v_out8(io_base+STATEINDEX, stateindex);
+ verite_out8(io_base+STATEINDEX, stateindex);
}
@@ -527,9 +529,9 @@ risc_continue(vu16 io_base)
{
vu8 debugreg;
- debugreg=v_in8(io_base+DEBUGREG);
- v_out8(io_base+DEBUGREG, debugreg&(~HOLDRISC));
- v_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
+ debugreg=verite_in8(io_base+DEBUGREG);
+ verite_out8(io_base+DEBUGREG, debugreg&(~HOLDRISC));
+ verite_iopoll(io_base+STATEDATA, 0, 0); /* short pause */
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c
index 94676049f..6bea7ba16 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c,v 1.9 2000/02/25 21:03:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.c,v 1.12 2000/06/19 15:01:02 tsi Exp $ */
/*
* includes
*/
@@ -17,11 +17,8 @@
#include "cscode.h"
-#if 0
/* Global imported during compile-time */
char MICROCODE_DIR [PATH_MAX] = MODULEDIR;
-#endif
-
/*
* local function prototypes
@@ -32,7 +29,7 @@ char MICROCODE_DIR [PATH_MAX] = MODULEDIR;
* functions
*/
int
-v_initboard(ScrnInfoPtr pScreenInfo)
+verite_initboard(ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -45,8 +42,8 @@ v_initboard(ScrnInfoPtr pScreenInfo)
/* write "monitor" program to memory */
v1k_stop(pScreenInfo);
pRendition->board.csucode_base=0x800;
- memendian=v_in8(iob+MEMENDIAN);
- v_out8(iob+MEMENDIAN, MEMENDIAN_NO);
+ memendian=verite_in8(iob+MEMENDIAN);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
/* Note that CS ucode must wait on address in csucode_base
* when initialized for later context switch code to work. */
@@ -55,63 +52,67 @@ v_initboard(ScrnInfoPtr pScreenInfo)
vmb=pRendition->board.vmem_base;
offset=pRendition->board.csucode_base;
for (c=0; c<sizeof(csrisc)/sizeof(vu32); c++, offset+=sizeof(vu32))
- v_write_memory32(vmb, offset, csrisc[c]);
+ verite_write_memory32(vmb, offset, csrisc[c]);
/* Initialize the CS flip semaphore */
- v_write_memory32(vmb, 0x7f8, 0);
- v_write_memory32(vmb, 0x7fc, 0);
+ verite_write_memory32(vmb, 0x7f8, 0);
+ verite_write_memory32(vmb, 0x7fc, 0);
/* Run the code we just transfered to the boards memory */
/* ... and start accelerator */
v1k_flushicache(pScreenInfo);
- v_out8(iob + STATEINDEX, STATEINDEX_PC);
- pc = v_in32(iob + STATEDATA);
+ verite_out8(iob + STATEINDEX, STATEINDEX_PC);
+ pc = verite_in32(iob + STATEDATA);
v1k_start(pScreenInfo, pRendition->board.csucode_base);
/* Get on loading the ucode */
- v_out8(iob + STATEINDEX, STATEINDEX_PC);
+ verite_out8(iob + STATEINDEX, STATEINDEX_PC);
for (c = 0; c < 0xffffffL; c++){
v1k_stop(pScreenInfo);
- pc = v_in32(iob + STATEDATA);
+ pc = verite_in32(iob + STATEDATA);
v1k_continue(pScreenInfo);
if (pc == pRendition->board.csucode_base)
break;
}
if (pc != pRendition->board.csucode_base){
- ErrorF ("RENDITION: V_INITBOARD -- PC != CSUCODEBASE\n");
- ErrorF ("RENDITION: PC == 0x%x -- CSU == 0x%x\n",pc,pRendition->board.csucode_base);
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ ("VERITE_INITBOARD -- PC != CSUCODEBASE\n"));
+ ErrorF ("RENDITION: PC == 0x%x -- CSU == 0x%x\n",
+ pc,pRendition->board.csucode_base);
}
/* reset memory endian */
- v_out8(iob+MEMENDIAN, memendian);
+ verite_out8(iob+MEMENDIAN, memendian);
-#if 0
if (V1000_DEVICE == pRendition->board.chip){
- c=v_load_ucfile(pScreenInfo, xf86strcat ((char *)MICROCODE_DIR,"v10002d.uc"));
+ c=verite_load_ucfile(pScreenInfo, strcat ((char *)MICROCODE_DIR,"v10002d.uc"));
}
else {
/* V2x00 chip */
- c=v_load_ucfile(pScreenInfo, xf86strcat ((char *)MICROCODE_DIR,"v20002d.uc"));
+ c=verite_load_ucfile(pScreenInfo, strcat ((char *)MICROCODE_DIR,"v20002d.uc"));
}
if (c == -1) {
- ErrorF( "RENDITION: Microcode loading failed !!!\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_ERROR,
+ ("Microcode loading failed !!!\n"));
return 1;
}
pRendition->board.ucode_entry=c;
- ErrorF("UCode_Entry == 0x%x\n",pRendition->board.ucode_entry);
+#ifdef DEBUG
+ ErrorF("UCode_Entry == 0x%x\n",pRendition->board.ucode_entry); */
#endif
+
/* Everything's OK */
return 0;
}
int
-v_resetboard(ScrnInfoPtr pScreenInfo)
+verite_resetboard(ScrnInfoPtr pScreenInfo)
{
/*
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -123,7 +124,7 @@ v_resetboard(ScrnInfoPtr pScreenInfo)
int
-v_getmemorysize(ScrnInfoPtr pScreenInfo)
+verite_getmemorysize(ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -137,23 +138,23 @@ v_getmemorysize(ScrnInfoPtr pScreenInfo)
#ifdef XSERVER
vu8 modereg;
- modereg=v_in8(pRendition->board.io_base+MODEREG);
- v_out8(pRendition->board.io_base+MODEREG, NATIVE_MODE);
+ modereg=verite_in8(pRendition->board.io_base+MODEREG);
+ verite_out8(pRendition->board.io_base+MODEREG, NATIVE_MODE);
#endif
/* no byte swapping */
- memendian=v_in8(pRendition->board.io_base+MEMENDIAN);
- v_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_NO);
+ memendian=verite_in8(pRendition->board.io_base+MEMENDIAN);
+ verite_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_NO);
/* it looks like the v1000 wraps the memory; but for I'm not sure,
* let's test also for non-writable offsets */
- start=v_read_memory32(pRendition->board.vmem_base, 0);
- v_write_memory32(pRendition->board.vmem_base, 0, START);
+ start=verite_read_memory32(pRendition->board.vmem_base, 0);
+ verite_write_memory32(pRendition->board.vmem_base, 0, START);
for (offset=ONEMEG; offset<16*ONEMEG; offset+=ONEMEG) {
#ifdef DEBUG
ErrorF( "Testing %d MB: ", offset/ONEMEG);
#endif
- pattern=v_read_memory32(pRendition->board.vmem_base, offset);
+ pattern=verite_read_memory32(pRendition->board.vmem_base, offset);
if (START == pattern) {
#ifdef DEBUG
ErrorF( "Back at the beginning\n");
@@ -162,20 +163,20 @@ v_getmemorysize(ScrnInfoPtr pScreenInfo)
}
pattern^=PATTERN;
- v_write_memory32(pRendition->board.vmem_base, offset, pattern);
+ verite_write_memory32(pRendition->board.vmem_base, offset, pattern);
#ifdef DEBUG
ErrorF( "%x <-> %x\n", (int)pattern,
- (int)v_read_memory32(pRendition->board.vmem_base, offset));
+ (int)verite_read_memory32(pRendition->board.vmem_base, offset));
#endif
- if (pattern != v_read_memory32(pRendition->board.vmem_base, offset)) {
+ if (pattern != verite_read_memory32(pRendition->board.vmem_base, offset)) {
offset-=ONEMEG;
break;
}
- v_write_memory32(pRendition->board.vmem_base, offset, pattern^PATTERN);
+ verite_write_memory32(pRendition->board.vmem_base, offset, pattern^PATTERN);
}
- v_write_memory32(pRendition->board.vmem_base, 0, start);
+ verite_write_memory32(pRendition->board.vmem_base, 0, start);
if (16*ONEMEG <= offset)
pRendition->board.mem_size=4*ONEMEG;
@@ -183,10 +184,10 @@ v_getmemorysize(ScrnInfoPtr pScreenInfo)
pRendition->board.mem_size=offset;
/* restore default byte swapping */
- v_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_NO);
+ verite_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_NO);
#ifdef XSERVER
- v_out8(pRendition->board.io_base+MODEREG, modereg);
+ verite_out8(pRendition->board.io_base+MODEREG, modereg);
#endif
return pRendition->board.mem_size;
@@ -195,7 +196,7 @@ v_getmemorysize(ScrnInfoPtr pScreenInfo)
}
void
-v_check_csucode(ScrnInfoPtr pScreenInfo)
+verite_check_csucode(ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
vu16 iob=pRendition->board.io_base;
@@ -205,32 +206,36 @@ v_check_csucode(ScrnInfoPtr pScreenInfo)
int memend;
int mismatches=0;
- memend=v_in8(iob+MEMENDIAN);
- v_out8(iob+MEMENDIAN, MEMENDIAN_NO);
+ memend=verite_in8(iob+MEMENDIAN);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
+#ifdef DEBUG
ErrorF("Checking presence of csucode @ 0x%x + 0x800\n",
pRendition->board.vmem_base);
if (0x800 != pRendition->board.csucode_base)
ErrorF("pRendition->board.csucode_base == 0x%x\n",
pRendition->board.csucode_base);
+#endif
/* compare word by word */
vmb=pRendition->board.vmem_base;
offset=pRendition->board.csucode_base;
for (c=0; c<sizeof(csrisc)/sizeof(vu32); c++, offset+=sizeof(vu32))
- if (csrisc[c] != v_read_memory32(vmb, offset)) {
+ if (csrisc[c] != verite_read_memory32(vmb, offset)) {
ErrorF("csucode mismatch in word %02d: 0x%08x should be 0x%08x\n",
c,
- v_read_memory32(vmb, offset),
+ verite_read_memory32(vmb, offset),
csrisc[c]);
mismatches++;
}
+#ifdef DEBUG
ErrorF("Encountered %d out of %d possible mismatches\n",
mismatches,
sizeof(csrisc)/sizeof(vu32));
+#endif
- v_out8(iob+MEMENDIAN, memend);
+ verite_out8(iob+MEMENDIAN, memend);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h
index ea880fe6b..ddda20621 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h,v 1.5 2000/02/25 21:03:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vboard.h,v 1.6 2000/03/31 20:13:26 dawes Exp $ */
/*
* vboard.h
@@ -21,11 +21,11 @@
* function prototypes
*/
-int v_initboard(ScrnInfoPtr pScreenInfo);
-int v_resetboard(ScrnInfoPtr pScreenInfo);
-int v_getmemorysize(ScrnInfoPtr pScreenInfo);
+int verite_initboard(ScrnInfoPtr pScreenInfo);
+int verite_resetboard(ScrnInfoPtr pScreenInfo);
+int verite_getmemorysize(ScrnInfoPtr pScreenInfo);
-void v_check_csucode(ScrnInfoPtr pScreenInfo);
+void verite_check_csucode(ScrnInfoPtr pScreenInfo);
#endif /* __VBOARD_H__ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c
index ec03fa1d0..cc2c6e66e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c,v 1.10 2000/02/25 21:03:04 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.c,v 1.12 2000/04/07 03:57:51 tsi Exp $ */
/*
* includes
*/
@@ -45,7 +45,7 @@ static void mmve(ScrnInfoPtr pScreenInfo, vu32 size, vu8 *data, vu32 phys_addr);
*/
/*
- * int v_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
+ * int verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
*
* Loads verite elf file microcode file in |name| onto the board.
* NOTE: Assumes the ucode loader is already running on the board!
@@ -53,7 +53,7 @@ static void mmve(ScrnInfoPtr pScreenInfo, vu32 size, vu8 *data, vu32 phys_addr);
* Returns the program's entry point, on error -1;
*/
int
-v_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
+verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
{
/* renditionPtr pRendition = RENDITIONPTR(pScreenInfo); */
@@ -64,7 +64,7 @@ v_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name)
Elf32_Shdr *pshdr, *orig_pshdr=NULL;
Elf32_Ehdr ehdr ;
-#if 1 /* DEBUG */
+#ifdef DEBUG
ErrorF("RENDITION: Loading microcode %s\n", file_name);
#endif
@@ -188,7 +188,7 @@ loadSegment2board(ScrnInfoPtr pScreenInfo, int fd, Elf32_Phdr *phdr)
}
if (read(fd, data, size) != size){
- ErrorF("RENDITION: v_readfile Failure, couldn't read %x bytes ", size);
+ ErrorF("RENDITION: verite_readfile Failure, couldn't read %x bytes ", size);
return;
}
@@ -223,8 +223,8 @@ mmve(ScrnInfoPtr pScreenInfo, vu32 size, vu8 *data, vu32 phys_addr)
vu8 *vmb=pRendition->board.vmem_base;
/* swap bytes 3<>0, 2<>1 */
- memend=v_in8(pRendition->board.io_base+MEMENDIAN);
- v_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_END);
+ memend=verite_in8(pRendition->board.io_base+MEMENDIAN);
+ verite_out8(pRendition->board.io_base+MEMENDIAN, MEMENDIAN_END);
dataout=(vu32 *)data;
@@ -232,13 +232,13 @@ mmve(ScrnInfoPtr pScreenInfo, vu32 size, vu8 *data, vu32 phys_addr)
v1k_stop(pScreenInfo);
while (size > 0) {
- v_write_memory32(vmb, phys_addr, *dataout);
+ verite_write_memory32(vmb, phys_addr, *dataout);
phys_addr+=4;
dataout++;
size-=4;
}
- v_out8(pRendition->board.io_base+MEMENDIAN, memend);
+ verite_out8(pRendition->board.io_base+MEMENDIAN, memend);
}
/*
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h
index 2ef904b0a..0c127d144 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h,v 1.3 1999/10/13 04:21:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vloaduc.h,v 1.4 2000/03/31 20:13:27 dawes Exp $ */
/*
* file vloaduc.h
@@ -30,7 +30,7 @@
* function prototypes
*/
-int v_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name);
+int verite_load_ucfile(ScrnInfoPtr pScreenInfo, char *file_name);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c
index ffc3861e7..fec54ed7d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c
@@ -1,5 +1,5 @@
/* Misc routines used elsewhere in driver */
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c,v 1.3 2000/02/25 21:03:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.c,v 1.4 2000/03/31 20:13:27 dawes Exp $ */
#include "rendition.h"
#include "vtypes.h"
@@ -10,26 +10,26 @@
/* block copy from and to the card */
void
-v_bustomem_cpy(vu8 *dst, vu8 *src, vu32 num)
+verite_bustomem_cpy(vu8 *dst, vu8 *src, vu32 num)
{
int i;
#ifdef DEBUG
- ErrorF ("Rendition: DEBUG v_bustomem_cpy called\n");
+ ErrorF ("Rendition: DEBUG verite_bustomem_cpy called\n");
#endif
for (i=0; i<num; i++)
- dst[i] = v_read_memory8(src, i);
+ dst[i] = verite_read_memory8(src, i);
}
void
-v_memtobus_cpy(vu8 *dst, vu8 *src, vu32 num)
+verite_memtobus_cpy(vu8 *dst, vu8 *src, vu32 num)
{
int i;
#ifdef DEBUG
- ErrorF ("Rendition: DEBUG v_memtobus_cpy called\n");
+ ErrorF ("Rendition: DEBUG verite_memtobus_cpy called\n");
#endif
for (i=0; i<num; i++)
- v_write_memory8(dst, i, src[i]);
+ verite_write_memory8(dst, i, src[i]);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h
index 8813e82ec..c104147e0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h,v 1.2 1999/11/19 14:59:18 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmisc.h,v 1.3 2000/03/31 20:13:27 dawes Exp $ */
#ifndef __VMISC_H__
#define __VMISC_H__
@@ -7,7 +7,7 @@
#include "vtypes.h"
#include "vos.h"
-void v_bustomem_cpy (vu8 *, vu8 *, vu32);
-void v_memtobus_cpy (vu8 *, vu8 *, vu32);
+void verite_bustomem_cpy (vu8 *, vu8 *, vu32);
+void verite_memtobus_cpy (vu8 *, vu8 *, vu32);
#endif /* __VMISC_H__ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c
index 2e4e8dded..13237f4d3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c,v 1.7 2000/02/25 21:03:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.c,v 1.8 2000/03/31 20:13:27 dawes Exp $ */
/*
* file vmodes.c
*
@@ -205,7 +205,7 @@ static double V2200CalcClock(double target, int *m, int *n, int *p);
*/
int
-v_setmodefixed(ScrnInfoPtr pScreenInfo)
+verite_setmodefixed(ScrnInfoPtr pScreenInfo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -213,40 +213,40 @@ v_setmodefixed(ScrnInfoPtr pScreenInfo)
int tmp;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_setmodefixed called\n");
+ ErrorF ("Rendition: Debug verite_setmodefixed called\n");
#endif
#ifdef SAVEVGA
- v_savetextmode(pRendition->board);
+ verite_savetextmode(pRendition->board);
#endif
v1k_softreset(pScreenInfo);
/* switching to native mode */
- v_out8(iob+MODEREG, NATIVE_MODE);
+ verite_out8(iob+MODEREG, NATIVE_MODE);
/* flipping some bytes */
- v_out8(iob+MEMENDIAN, MEMENDIAN_HW);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_HW);
/* try programming 1024x768@70 in highcolor */
- tmp=v_in32(iob+DRAMCTL)&0xdfff; /* reset bit 13 */
- v_out32(iob+DRAMCTL, tmp|DEFAULT_WREFRESH);
+ tmp=verite_in32(iob+DRAMCTL)&0xdfff; /* reset bit 13 */
+ verite_out32(iob+DRAMCTL, tmp|DEFAULT_WREFRESH);
/* program pixel clock */
if (pRendition->board.chip == V1000_DEVICE) {
set_PLL(iob, combineNMP(21, 55, 0));
}
else {
- tmp = (~0x1800) & v_in32(iob+DRAMCTL);
- v_out32(iob+DRAMCTL, tmp);
- v_out32(iob+PCLKPLL, v2kcombineNMP(2, 21, 2));
+ tmp = (~0x1800) & verite_in32(iob+DRAMCTL);
+ verite_out32(iob+DRAMCTL, tmp);
+ verite_out32(iob+PCLKPLL, v2kcombineNMP(2, 21, 2));
}
usleep(500);
- v_initdac(pScreenInfo, 16, 0);
+ verite_initdac(pScreenInfo, 16, 0);
- v_out32(iob+CRTCHORZ, HORZ(24, 136, 144, 1024));
- v_out32(iob+CRTCVERT, VERT(3, 6, 29, 768));
+ verite_out32(iob+CRTCHORZ, HORZ(24, 136, 144, 1024));
+ verite_out32(iob+CRTCVERT, VERT(3, 6, 29, 768));
pRendition->board.mode.screenwidth=1024;
pRendition->board.mode.virtualwidth=1024;
@@ -257,7 +257,7 @@ v_setmodefixed(ScrnInfoPtr pScreenInfo)
(*pScreenInfo->AdjustFrame)(pScreenInfo->scrnIndex,
pScreenInfo->frameX0, pScreenInfo->frameY0, 0);
- v_out32(iob+CRTCCTL, CTL(0, 0, 0)
+ verite_out32(iob+CRTCCTL, CTL(0, 0, 0)
|V_PIXFMT_565
|CRTCCTL_VIDEOFIFOSIZE128
|CRTCCTL_HSYNCENABLE
@@ -270,7 +270,7 @@ v_setmodefixed(ScrnInfoPtr pScreenInfo)
int
-v_setmode(ScrnInfoPtr pScreenInfo, struct v_modeinfo_t *mode)
+verite_setmode(ScrnInfoPtr pScreenInfo, struct verite_modeinfo_t *mode)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -280,43 +280,44 @@ v_setmode(ScrnInfoPtr pScreenInfo, struct v_modeinfo_t *mode)
int iob=pRendition->board.io_base;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_setmode called\n");
+ ErrorF ("Rendition: Debug verite_setmode called\n");
#endif
/* switching to native mode */
- v_out8(iob+MODEREG, NATIVE_MODE|VESA_MODE);
+ verite_out8(iob+MODEREG, NATIVE_MODE|VESA_MODE);
/* flipping some bytes */
/* Must be something better to do than this -- FIX */
switch (mode->bitsperpixel) {
case 32:
- v_out8(iob+MEMENDIAN, MEMENDIAN_NO);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_NO);
break;
case 16:
- v_out8(iob+MEMENDIAN, MEMENDIAN_HW);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_HW);
break;
case 8:
- v_out8(iob+MEMENDIAN, MEMENDIAN_END);
+ verite_out8(iob+MEMENDIAN, MEMENDIAN_END);
break;
}
if (pRendition->board.chip != V1000_DEVICE) {
if(!pRendition->board.overclock_mem){
- v_out32(iob+SCLKPLL, 0xa484d); /* mclk=110 sclk=50 */
+ verite_out32(iob+SCLKPLL, 0xa484d); /* mclk=110 sclk=50 */
/* M/N/P/P = 77/5/2/4 */
}
else{
- ErrorF ("RENDITION: *** OVERCLOCKING MEM/CLK mclk=125 sclk=60 ***\n");
+ xf86DrvMsg(pScreenInfo->scrnIndex, X_CONFIG,
+ (" *** OVERCLOCKING MEM/CLK mclk=125 sclk=60 ***\n"));
/* increase Mem/Sys clock on request */
- v_out32(iob+SCLKPLL, 0xa4854); /* mclk=125 sclk=60 */
+ verite_out32(iob+SCLKPLL, 0xa4854); /* mclk=125 sclk=60 */
/* M/N/P/P = 84/5/2/4 */
}
usleep(500);
}
/* this has something to do with memory */
- tmp=v_in32(iob+DRAMCTL)&0xdfff; /* reset bit 13 */
- v_out32(iob+DRAMCTL, tmp|0x330000);
+ tmp=verite_in32(iob+DRAMCTL)&0xdfff; /* reset bit 13 */
+ verite_out32(iob+DRAMCTL, tmp|0x330000);
/* program pixel clock */
if (pRendition->board.chip == V1000_DEVICE) {
@@ -327,27 +328,27 @@ v_setmode(ScrnInfoPtr pScreenInfo, struct v_modeinfo_t *mode)
set_PLL(iob, combineNMP(N, M, P));
}
else {
- tmp = (~0x1800) & v_in32(iob+DRAMCTL);
- v_out32(iob+DRAMCTL, tmp);
+ tmp = (~0x1800) & verite_in32(iob+DRAMCTL);
+ verite_out32(iob+DRAMCTL, tmp);
V2200CalcClock(mode->clock/1000.0, &M, &N, &P);
- v_out32(iob+PCLKPLL, v2kcombineNMP(N, M, P));
+ verite_out32(iob+PCLKPLL, v2kcombineNMP(N, M, P));
}
usleep(500);
/* init the ramdac */
- v_initdac(pScreenInfo, mode->bitsperpixel, doubleclock);
+ verite_initdac(pScreenInfo, mode->bitsperpixel, doubleclock);
- v_out32(iob+CRTCHORZ, HORZ(mode->hsyncstart-mode->hdisplay,
+ verite_out32(iob+CRTCHORZ, HORZ(mode->hsyncstart-mode->hdisplay,
mode->hsyncend-mode->hsyncstart,
mode->htotal-mode->hsyncend,
mode->hdisplay));
- v_out32(iob+CRTCVERT, VERT(mode->vsyncstart-mode->vdisplay,
+ verite_out32(iob+CRTCVERT, VERT(mode->vsyncstart-mode->vdisplay,
mode->vsyncend-mode->vsyncstart,
mode->vtotal-mode->vsyncend,
mode->vdisplay));
/* fill in the mode parameters */
- memcpy(&(pRendition->board.mode), mode, sizeof(struct v_modeinfo_t));
+ memcpy(&(pRendition->board.mode), mode, sizeof(struct verite_modeinfo_t));
pRendition->board.mode.fifosize=128;
pRendition->board.mode.pll_m=M;
pRendition->board.mode.pll_n=N;
@@ -363,7 +364,7 @@ v_setmode(ScrnInfoPtr pScreenInfo, struct v_modeinfo_t *mode)
/* Need to fix up syncs */
/* enable the display */
- v_out32(iob+CRTCCTL, CTL(0, mode->hsynchi, mode->vsynchi)
+ verite_out32(iob+CRTCCTL, CTL(0, mode->hsynchi, mode->vsynchi)
|mode->pixelformat
|CRTCCTL_VIDEOFIFOSIZE128
|CRTCCTL_HSYNCENABLE
@@ -381,7 +382,7 @@ v_setmode(ScrnInfoPtr pScreenInfo, struct v_modeinfo_t *mode)
void
-v_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase)
+verite_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -394,7 +395,7 @@ v_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase)
int fifo_size=pRendition->board.mode.fifosize;
#ifdef DEBUG
- ErrorF( "Rendition: Debug v_setframebase w=%d v=%d b=%d f=%d\n",
+ ErrorF( "Rendition: Debug verite_setframebase w=%d v=%d b=%d f=%d\n",
swidth, vwidth, bytespp, fifo_size);
#endif
@@ -411,9 +412,9 @@ v_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase)
/* wait for vertical retrace */
#ifndef DEBUG
if (!pRendition->board.init) {
- while ((v_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_MASK) !=
+ while ((verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_MASK) !=
CRTCSTATUS_VERT_ACTIVE) ;
- while ((v_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_MASK) ==
+ while ((verite_in32(iob+CRTCSTATUS) & CRTCSTATUS_VERT_MASK) ==
CRTCSTATUS_VERT_ACTIVE) ;
}
else
@@ -421,17 +422,17 @@ v_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase)
#endif
/* framebase */
- v_out32(iob+FRAMEBASEA, framebase);
+ verite_out32(iob+FRAMEBASEA, framebase);
/* crtc offset */
- v_out32(iob+CRTCOFFSET, offset&0xffff);
+ verite_out32(iob+CRTCOFFSET, offset&0xffff);
}
int
-v_getstride(ScrnInfoPtr pScreenInfo, int *width, vu16 *stride0, vu16 *stride1)
+verite_getstride(ScrnInfoPtr pScreenInfo, int *width, vu16 *stride0, vu16 *stride1)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
int bytesperline;
@@ -477,12 +478,12 @@ set_PLL(vu16 iob, vu32 value)
/* shift out the 20 serial bits */
for (b=19; b>=0; b--) {
ulD=(value>>b)&1;
- v_out8(iob+PLLDEV, (vu8)ulD);
+ verite_out8(iob+PLLDEV, (vu8)ulD);
}
/* read PLL device so the latch is filled with the previously
* written value */
- (void)v_in8(iob+PLLDEV);
+ (void)verite_in8(iob+PLLDEV);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h
index a7a804185..f2db04875 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h,v 1.3 1999/10/13 04:21:24 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vmodes.h,v 1.4 2000/03/31 20:13:27 dawes Exp $ */
/*
* file vmodes.h
*
@@ -22,10 +22,10 @@
* function prototypes
*/
-int v_setmodefixed(ScrnInfoPtr pScreenInfo);
-int v_setmode(ScrnInfoPtr pScreenInfo, struct v_modeinfo_t *mode);
-void v_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase);
-int v_getstride(ScrnInfoPtr pScreenInfo, int *width, vu16 *stride0, vu16 *stride1);
+int verite_setmodefixed(ScrnInfoPtr pScreenInfo);
+int verite_setmode(ScrnInfoPtr pScreenInfo, struct verite_modeinfo_t *mode);
+void verite_setframebase(ScrnInfoPtr pScreenInfo, vu32 framebase);
+int verite_getstride(ScrnInfoPtr pScreenInfo, int *width, vu16 *stride0, vu16 *stride1);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h
index 54ecfc12f..43c320d47 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h,v 1.7 2000/02/25 21:03:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vos.h,v 1.8 2000/03/31 20:13:28 dawes Exp $ */
/*
* file vos.h
*
@@ -24,32 +24,32 @@
/*
* function prototypes
*/
-#define /*void*/ v_out8(/*vu16*/ port, /*vu8*/ data) \
+#define /*void*/ verite_out8(/*vu16*/ port, /*vu8*/ data) \
outb(port, data)
-#define /*void*/ v_out16(/*vu16*/ port, /*vu16*/ data) \
+#define /*void*/ verite_out16(/*vu16*/ port, /*vu16*/ data) \
outw(port, data)
-#define /*void*/ v_out32(/*vu16*/ port, /*vu32*/ data) \
+#define /*void*/ verite_out32(/*vu16*/ port, /*vu32*/ data) \
outl(port, data)
-#define /*vu8*/ v_in8(/*vu16*/ io_base) ((vu8)inb(io_base))
-#define /*vu16*/ v_in16(/*vu16*/ io_base) ((vu16)inw(io_base))
-#define /*vu32*/ v_in32(/*vu16*/ io_base) ((vu32)inl(io_base))
+#define /*vu8*/ verite_in8(/*vu16*/ io_base) ((vu8)inb(io_base))
+#define /*vu16*/ verite_in16(/*vu16*/ io_base) ((vu16)inw(io_base))
+#define /*vu32*/ verite_in32(/*vu16*/ io_base) ((vu32)inl(io_base))
/* memory accesses */
-#define v_read_memory32(base, offset) MMIO_IN32(base, offset)
-#define v_read_memory16(base, offset) MMIO_IN16(base, offset)
-#define v_read_memory8(base, offset) MMIO_IN8(base, offset)
-#define v_write_memory32(base, offset, data) MMIO_OUT32(base, offset, data)
-#define v_write_memory16(base, offset, data) MMIO_OUT16(base, offset, data)
-#define v_write_memory8(base, offset, data) MMIO_OUT8(base, offset, data)
+#define verite_read_memory32(base, offset) MMIO_IN32(base, offset)
+#define verite_read_memory16(base, offset) MMIO_IN16(base, offset)
+#define verite_read_memory8(base, offset) MMIO_IN8(base, offset)
+#define verite_write_memory32(base, offset, data) MMIO_OUT32(base, offset, data)
+#define verite_write_memory16(base, offset, data) MMIO_OUT16(base, offset, data)
+#define verite_write_memory8(base, offset, data) MMIO_OUT8(base, offset, data)
/* the rest of it */
-void v_enableio(void);
-void v_disableio(void);
-vu8 *v_mapmemory(vu8 *membase, vu32 size);
-void v_unmapmemory(vu8 *vmembase, vu32 size);
+void verite_enableio(void);
+void verite_disableio(void);
+vu8 *verite_mapmemory(vu8 *membase, vu32 size);
+void verite_unmapmemory(vu8 *vmembase, vu32 size);
#endif /* #ifndef _VOS_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c
index 57016e5f6..61ed10738 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c,v 1.9 2000/02/25 21:03:06 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.c,v 1.11 2000/06/13 02:28:33 dawes Exp $ */
/*
* includes
*/
@@ -110,22 +110,23 @@ int Cursor_size=0;
*/
/*
- * int v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
+ * int verite_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
*
* Used to initialize the ramdac. Palette-bypass is dis-/enabled with respect
* to the color depth, the cursor is disabled by default. If needed (i.e. if
- * the corresponding field in the v_board_t struct is set), the clock doubling
+ * the corresponding field in the verite_board_t struct is set), the clock doubling
* is turned on.
*/
int
-v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
+verite_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
vu16 iob=pRendition->board.io_base+RAMDACBASEADDR;
+ vu8 cmd0,cmd1,cmd2;
vu8 cmd3_data=0;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_initdac called\n");
+ ErrorF ("Rendition: Debug verite_initdac called\n");
#endif
if (doubleclock)
@@ -139,46 +140,60 @@ v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
return -1;
case 8:
- v_out8(iob+BT485_COMMAND_REG_0, BT485_CR0_EXTENDED_REG_ACCESS |
- BT485_CR0_8_BIT_DAC);
- v_out8(iob+BT485_COMMAND_REG_1, BT485_CR1_8BPP |
- BT485_CR1_PIXEL_PORT_AB);
- v_out8(iob+BT485_COMMAND_REG_2, BT485_PIXEL_INPUT_GATE |
- BT485_DISABLE_CURSOR);
- break;
+ cmd0 = BT485_CR0_EXTENDED_REG_ACCESS |
+ BT485_CR0_8_BIT_DAC;
+
+ cmd1 = BT485_CR1_8BPP |
+ BT485_CR1_PIXEL_PORT_AB;
+
+ cmd2 = BT485_PIXEL_INPUT_GATE |
+ BT485_DISABLE_CURSOR;
- case 15:
- v_out8(iob+BT485_COMMAND_REG_0, BT485_CR0_EXTENDED_REG_ACCESS |
- BT485_CR0_8_BIT_DAC);
- v_out8(iob+BT485_COMMAND_REG_1, BT485_CR1_16BPP |
- BT485_CR1_BYPASS_CLUT |
- BT485_CR1_555_16BPP |
- BT485_CR1_2_TO_1_16BPP |
- BT485_CR1_PIXEL_PORT_AB);
- v_out8(iob+BT485_COMMAND_REG_2, BT485_PIXEL_INPUT_GATE |
- BT485_DISABLE_CURSOR);
+ verite_out8(iob+BT485_COMMAND_REG_0, cmd0);
+ verite_out8(iob+BT485_COMMAND_REG_1, cmd1);
+ verite_out8(iob+BT485_COMMAND_REG_2, cmd2);
break;
case 16:
- v_out8(iob+BT485_COMMAND_REG_0, BT485_CR0_EXTENDED_REG_ACCESS |
- BT485_CR0_8_BIT_DAC);
- v_out8(iob+BT485_COMMAND_REG_1, BT485_CR1_16BPP |
- BT485_CR1_BYPASS_CLUT |
- BT485_CR1_565_16BPP |
- BT485_CR1_2_TO_1_16BPP |
- BT485_CR1_PIXEL_PORT_AB);
- v_out8(iob+BT485_COMMAND_REG_2, BT485_PIXEL_INPUT_GATE |
- BT485_DISABLE_CURSOR);
+ cmd0 = BT485_CR0_EXTENDED_REG_ACCESS |
+ BT485_CR0_8_BIT_DAC;
+
+ cmd1 = BT485_CR1_16BPP |
+ BT485_CR1_2_TO_1_16BPP |
+ BT485_CR1_PIXEL_PORT_AB;
+
+ cmd2 = BT485_PIXEL_INPUT_GATE |
+ BT485_DISABLE_CURSOR;
+
+ if (pScreenInfo->defaultVisual == TrueColor)
+ cmd1 |= BT485_CR1_BYPASS_CLUT;
+
+ if (pScreenInfo->weight.green == 5)
+ cmd1 |= BT485_CR1_555_16BPP;
+ else
+ cmd1 |= BT485_CR1_565_16BPP;
+
+ verite_out8(iob+BT485_COMMAND_REG_0,cmd0);
+ verite_out8(iob+BT485_COMMAND_REG_1,cmd1);
+ verite_out8(iob+BT485_COMMAND_REG_2,cmd2);
break;
case 32:
- v_out8(iob+BT485_COMMAND_REG_0, BT485_CR0_EXTENDED_REG_ACCESS |
- BT485_CR0_8_BIT_DAC);
- v_out8(iob+BT485_COMMAND_REG_1, BT485_CR1_24BPP |
- BT485_CR1_BYPASS_CLUT |
- BT485_CR1_PIXEL_PORT_AB);
- v_out8(iob+BT485_COMMAND_REG_2, BT485_PIXEL_INPUT_GATE |
- BT485_DISABLE_CURSOR);
+ cmd0 = BT485_CR0_EXTENDED_REG_ACCESS |
+ BT485_CR0_8_BIT_DAC;
+
+ cmd1 = BT485_CR1_24BPP |
+ BT485_CR1_PIXEL_PORT_AB;
+
+ cmd2 = BT485_PIXEL_INPUT_GATE |
+ BT485_DISABLE_CURSOR;
+
+ if (pScreenInfo->defaultVisual == TrueColor)
+ cmd1 |= BT485_CR1_BYPASS_CLUT;
+
+ verite_out8(iob+BT485_COMMAND_REG_0,cmd0);
+ verite_out8(iob+BT485_COMMAND_REG_1,cmd1);
+ verite_out8(iob+BT485_COMMAND_REG_2,cmd2);
break;
default:
@@ -188,12 +203,12 @@ v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
break;
}
- v_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
- v_out8(iob+BT485_STATUS_REG, cmd3_data);
+ verite_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
+ verite_out8(iob+BT485_STATUS_REG, cmd3_data);
/*
Bt485_write_masked(iob, BT485_COMMAND_REG_0, 0x7f, 0x00);
*/
- v_out8(iob+BT485_PIXEL_MASK, 0xff);
+ verite_out8(iob+BT485_PIXEL_MASK, 0xff);
return 0;
}
@@ -201,7 +216,7 @@ v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
/*
- * void v_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
+ * void verite_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
*
* Used to enable the hardware cursor. Size indicates, whether to use no cursor
* at all, a 32x32 or a 64x64 cursor. The type selects a two-color, three-color
@@ -209,7 +224,7 @@ v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock)
*
*/
void
-v_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
+verite_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -220,7 +235,7 @@ v_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
vu16 iob=pRendition->board.io_base+RAMDACBASEADDR;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_enablecursor called type=0x%x\n",type);
+ ErrorF ("Rendition: Debug verite_enablecursor called type=0x%x\n",type);
#endif
#if 0
@@ -239,7 +254,7 @@ v_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
Cursor_size=(size ? 64 : 32);
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_enablecursor Exit\n");
+ ErrorF ("Rendition: Debug verite_enablecursor Exit\n");
#endif
}
@@ -248,14 +263,14 @@ v_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size)
/*
- * void v_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
+ * void verite_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
*
* Moves the cursor to the specified location. To hide the cursor, call
* this routine with x=0x0 and y=0x0.
*
*/
void
-v_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
+verite_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
vu16 iob=pRendition->board.io_base+RAMDACBASEADDR;
@@ -263,52 +278,52 @@ v_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo)
x+=Cursor_size-xo;
y+=Cursor_size-yo;
- v_out8(iob+BT485_CURS_X_LOW, x&0xff);
- v_out8(iob+BT485_CURS_X_HIGH, (x>>8)&0x0f);
- v_out8(iob+BT485_CURS_Y_LOW, y&0xff);
- v_out8(iob+BT485_CURS_Y_HIGH, (y>>8)&0x0f);
+ verite_out8(iob+BT485_CURS_X_LOW, x&0xff);
+ verite_out8(iob+BT485_CURS_X_HIGH, (x>>8)&0x0f);
+ verite_out8(iob+BT485_CURS_Y_LOW, y&0xff);
+ verite_out8(iob+BT485_CURS_Y_HIGH, (y>>8)&0x0f);
}
/*
- * void v_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 bg, vu32 fg)
+ * void verite_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 bg, vu32 fg)
*
* Sets the color of the cursor -- should be revised for use with 3 colors!
*
*/
void
-v_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 fg, vu32 bg)
+verite_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 fg, vu32 bg)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
vu16 iob=pRendition->board.io_base+RAMDACBASEADDR;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_setcursorcolor called FG=0x%x BG=0x%x\n",
+ ErrorF ("Rendition: Debug verite_setcursorcolor called FG=0x%x BG=0x%x\n",
fg,bg);
#endif
- v_out8(iob+BT485_CURS_WR_ADDR, 0x00);
+ verite_out8(iob+BT485_CURS_WR_ADDR, 0x00);
/* load the cursor color 0 */
- v_out8(iob+BT485_CURS_DATA, 0x00);
- v_out8(iob+BT485_CURS_DATA, 0x00);
- v_out8(iob+BT485_CURS_DATA, 0x00);
+ verite_out8(iob+BT485_CURS_DATA, 0x00);
+ verite_out8(iob+BT485_CURS_DATA, 0x00);
+ verite_out8(iob+BT485_CURS_DATA, 0x00);
/* load the cursor color 1 */
- v_out8(iob+BT485_CURS_DATA, (fg>>16)&0xff);
- v_out8(iob+BT485_CURS_DATA, (fg>>8)&0xff);
- v_out8(iob+BT485_CURS_DATA, fg&0xff);
+ verite_out8(iob+BT485_CURS_DATA, (fg>>16)&0xff);
+ verite_out8(iob+BT485_CURS_DATA, (fg>>8)&0xff);
+ verite_out8(iob+BT485_CURS_DATA, fg&0xff);
/* load the cursor color 2 */
- v_out8(iob+BT485_CURS_DATA, 0x00);
- v_out8(iob+BT485_CURS_DATA, 0x00);
- v_out8(iob+BT485_CURS_DATA, 0x00);
+ verite_out8(iob+BT485_CURS_DATA, 0x00);
+ verite_out8(iob+BT485_CURS_DATA, 0x00);
+ verite_out8(iob+BT485_CURS_DATA, 0x00);
/* load the cursor color 3 */
- v_out8(iob+BT485_CURS_DATA, (bg>>16)&0xff);
- v_out8(iob+BT485_CURS_DATA, (bg>>8)&0xff);
- v_out8(iob+BT485_CURS_DATA, bg&0xff);
+ verite_out8(iob+BT485_CURS_DATA, (bg>>16)&0xff);
+ verite_out8(iob+BT485_CURS_DATA, (bg>>8)&0xff);
+ verite_out8(iob+BT485_CURS_DATA, bg&0xff);
}
@@ -319,7 +334,7 @@ v_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 fg, vu32 bg)
*
*/
void
-v_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
+verite_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
{
int c, bytes, row;
vu8 *src = cursorimage;
@@ -329,15 +344,15 @@ v_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
vu8 memend; /* Added for byte-swap fix */
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_loadcursor called\n");
+ ErrorF ("Rendition: Debug verite_loadcursor called\n");
#endif
if (NULL == cursorimage)
return;
/* Following two lines added for the byte-swap fix */
- memend = v_in8(pRendition->board.io_base + MEMENDIAN);
- v_out8(pRendition->board.io_base + MEMENDIAN, MEMENDIAN_HW);
+ memend = verite_in8(pRendition->board.io_base + MEMENDIAN);
+ verite_out8(pRendition->board.io_base + MEMENDIAN, MEMENDIAN_HW);
size&=1;
if (size)
@@ -349,50 +364,50 @@ v_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
if (pRendition->board.chip == V1000_DEVICE) {
/* now load the cursor data into the cursor ram */
- tmp=v_in8(iob+BT485_COMMAND_REG_0)&0x7f;
- v_out8(iob+BT485_COMMAND_REG_0, tmp|0x80);
+ tmp=verite_in8(iob+BT485_COMMAND_REG_0)&0x7f;
+ verite_out8(iob+BT485_COMMAND_REG_0, tmp|0x80);
- v_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
+ verite_out8(iob+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
- tmp=v_in8(iob+BT485_STATUS_REG)&0xf8;
- v_out8(iob+BT485_STATUS_REG, tmp|(size<<2));
- v_out8(iob+BT485_WRITE_ADDR, 0x00);
+ tmp=verite_in8(iob+BT485_STATUS_REG)&0xf8;
+ verite_out8(iob+BT485_STATUS_REG, tmp|(size<<2));
+ verite_out8(iob+BT485_WRITE_ADDR, 0x00);
/* output cursor image */
src=cursorimage;
/* First plane data */
for (c=0; c<bytes; c++) {
- v_out8(iob+BT485_CURS_RAM_DATA, *src);
+ verite_out8(iob+BT485_CURS_RAM_DATA, *src);
src+=2;
}
/* Second plane data */
src=cursorimage+1;
for (c=0; c<bytes; c++) {
- v_out8(iob+BT485_CURS_RAM_DATA, *src);
+ verite_out8(iob+BT485_CURS_RAM_DATA, *src);
src+=2;
}
}
else {
/* V2x00 HW-Cursor, supports only 64x64x2 size */
- v_out32(iob+CURSORBASE, pRendition->board.hwcursor_membase);
+ verite_out32(iob+CURSORBASE, pRendition->board.hwcursor_membase);
/* First plane data */
for (row=0; row<64; row++)
for (c=0, src=cursorimage+1+16*row; c<8; c++, src+=2)
- v_write_memory8(pRendition->board.vmem_base, 16*(63-row)+c,
+ verite_write_memory8(pRendition->board.vmem_base, 16*(63-row)+c,
(c&1)?(*(src-2)):(*(src+2)));
/* Second plane data */
for (row=0; row<64; row++)
for (c=0, src=cursorimage+16*row; c<8; c++, src+=2)
- v_write_memory8(pRendition->board.vmem_base, 8+16*(63-row)+c,
+ verite_write_memory8(pRendition->board.vmem_base, 8+16*(63-row)+c,
(c&1)?(*(src-2)):(*(src+2)));
}
/* Following line added for the byte-swap fix */
- v_out8(pRendition->board.io_base + MEMENDIAN, memend);
+ verite_out8(pRendition->board.io_base + MEMENDIAN, memend);
}
@@ -400,7 +415,7 @@ v_loadcursor(ScrnInfoPtr pScreenInfo, vu8 size, vu8 *cursorimage)
/* NOTE: count is the actual number of colors decremented by 1 */
void
-v_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
+verite_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
LOCO *colors, VisualPtr pVisual)
{
renditionPtr pRendition = RENDITIONPTR(pScreenInfo);
@@ -410,11 +425,11 @@ v_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
int c;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_setpalette called\n");
+ ErrorF ("Rendition: Debug verite_setpalette called\n");
#endif
while (1) {
- crtc_status=v_in32(iob+CRTCSTATUS);
+ crtc_status=verite_in32(iob+CRTCSTATUS);
if (crtc_status & CRTCSTATUS_VERT_SYNC)
break;
};
@@ -423,11 +438,11 @@ v_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
for (i = 0; i < numColors; i++) {
index = indices[i];
- v_out8(iob+BT485_WRITE_ADDR, index);
+ verite_out8(iob+BT485_WRITE_ADDR, index);
- v_out8(iob+BT485_RAMDAC_DATA, colors[index].red);
- v_out8(iob+BT485_RAMDAC_DATA, colors[index].green);
- v_out8(iob+BT485_RAMDAC_DATA, colors[index].blue);
+ verite_out8(iob+BT485_RAMDAC_DATA, colors[index].red);
+ verite_out8(iob+BT485_RAMDAC_DATA, colors[index].green);
+ verite_out8(iob+BT485_RAMDAC_DATA, colors[index].blue);
}
@@ -451,8 +466,8 @@ Bt485_write_masked(vu16 port, vu8 reg, vu8 mask, vu8 data)
{
vu8 tmp;
- tmp=v_in8(port+reg)&mask;
- v_out8(port+reg, tmp|data);
+ tmp=verite_in8(port+reg)&mask;
+ verite_out8(port+reg, tmp|data);
}
@@ -468,7 +483,7 @@ Bt485_write_cmd3_masked(vu16 port, vu8 mask, vu8 data)
/*
Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x80);
*/
- v_out8(port+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
+ verite_out8(port+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
Bt485_write_masked(port, BT485_STATUS_REG, mask, data);
/*
Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x00);
@@ -485,7 +500,7 @@ Bt485_write_cmd3_masked(vu16 port, vu8 mask, vu8 data)
static vu8
Bt485_read_masked(vu16 port, vu8 reg, vu8 mask)
{
- return v_in8(port+reg)&mask;
+ return verite_in8(port+reg)&mask;
}
@@ -501,7 +516,7 @@ Bt485_read_cmd3_masked(vu16 port, vu8 mask)
vu8 value;
Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x80);
- v_out8(port+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
+ verite_out8(port+BT485_WRITE_ADDR, BT485_COMMAND_REG_3);
value=Bt485_read_masked(port, BT485_STATUS_REG, mask);
Bt485_write_masked(port, BT485_COMMAND_REG_0, 0x7f, 0x00);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h
index 2bcc91d91..c1b8a896a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h,v 1.4 2000/02/25 21:03:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vramdac.h,v 1.5 2000/03/31 20:13:28 dawes Exp $ */
/*
* file vramdac.h
*
@@ -22,13 +22,13 @@
* defines
*/
-#define V_NOCURSOR 0
-#define V_2COLORS 1
-#define V_3COLORS 2
-#define V_XCURSOR 3
+#define VERITE_NOCURSOR 0
+#define VERITE_2COLORS 1
+#define VERITE_3COLORS 2
+#define VERITE_XCURSOR 3
-#define V_CURSOR32 0
-#define V_CURSOR64 1
+#define VERITE_CURSOR32 0
+#define VERITE_CURSOR64 1
@@ -36,12 +36,12 @@
* function prototypes
*/
-int v_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock);
-void v_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size);
-void v_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo);
-void v_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 bg, vu32 fg);
-void v_loadcursor(ScrnInfoPtr pScreenInfo, vu8 type, vu8 *cursorimage);
-void v_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
+int verite_initdac(ScrnInfoPtr pScreenInfo, vu8 bpp, vu8 doubleclock);
+void verite_enablecursor(ScrnInfoPtr pScreenInfo, int type, int size);
+void verite_movecursor(ScrnInfoPtr pScreenInfo, vu16 x, vu16 y, vu8 xo, vu8 yo);
+void verite_setcursorcolor(ScrnInfoPtr pScreenInfo, vu32 bg, vu32 fg);
+void verite_loadcursor(ScrnInfoPtr pScreenInfo, vu8 type, vu8 *cursorimage);
+void verite_setpalette(ScrnInfoPtr pScreenInfo, int numColors, int *indices,
LOCO *colors, VisualPtr pVisual);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h
index ec47a4a27..8fd62e5e5 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h,v 1.5 2000/03/01 00:25:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vtypes.h,v 1.6 2000/03/31 20:13:28 dawes Exp $ */
#ifndef _VTYPES_H_
#define _VTYPES_H_
@@ -66,7 +66,7 @@ typedef enum {
* structs
*/
-struct v_modeinfo_t {
+struct verite_modeinfo_t {
int clock; /* pixel clock */
int hdisplay; /* horizontal timing */
int hsyncstart;
@@ -99,7 +99,7 @@ struct v_modeinfo_t {
/* structure describing the Verite board and its functionality */
-struct v_board_t {
+struct verite_board_t {
/* type of chip */
vu16 chip;
@@ -125,7 +125,7 @@ struct v_board_t {
int Color;
/* mode information */
- struct v_modeinfo_t mode;
+ struct verite_modeinfo_t mode;
/* saved text mode settings */
vu8 cursor_hi;
@@ -158,8 +158,8 @@ struct v_board_t {
*/
typedef struct _renditionRec
{
- struct v_board_t board; /* information on the board */
- struct v_modeinfo_t mode; /* information on the mode */
+ struct verite_board_t board; /* information on the board */
+ struct verite_modeinfo_t mode; /* information on the mode */
int pcitag; /* tag for the PCI config space */
pciVideoPtr PciInfo; /* PCI config data */
EntityInfoPtr pEnt; /* entity information */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c
index b3368c158..701fe7a58 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c,v 1.8 2000/02/25 21:03:07 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.c,v 1.9 2000/03/31 20:13:29 dawes Exp $ */
/*
* file vvga.c
*
@@ -46,7 +46,7 @@ static void updattr(vu8 index, vu8 value);
*/
void
-v_resetvga(void)
+verite_resetvga(void)
{
static struct VIDEO_REGS {
vu8 seq[8]; /* sequencer regs */
@@ -74,7 +74,7 @@ v_resetvga(void)
int c;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_resetvga called\n");
+ ErrorF ("Rendition: Debug verite_resetvga called\n");
#endif
/* set attribute controller */
@@ -98,7 +98,7 @@ v_resetvga(void)
void
-v_loadvgafont(void)
+verite_loadvgafont(void)
{
int c;
vu8 b;
@@ -108,12 +108,12 @@ v_loadvgafont(void)
int fbFlags;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_loadvgafont called\n");
+ ErrorF ("Rendition: Debug verite_loadvgafont called\n");
#endif
/* Assert synchroneous reset while setting the clock mode */
setvgareg(0x3c4, 0, 1); /* assert synchronous reset */
- v_out8(0x3c2, 0x67); /* select clock */
+ verite_out8(0x3c2, 0x67); /* select clock */
setvgareg(0x3c4, 0, 3); /* de-assert synchronous reset */
/* load 8x16 font into plane 2 */
@@ -140,81 +140,81 @@ v_loadvgafont(void)
vbase = xf86MapVidMem(0, fbFlags, 0xa0000, 64*1024);
vidmem=vbase;
for (c=0; c<=255; c++) {
- v_memtobus_cpy(vbase+(32*c), address, 16);
+ verite_memtobus_cpy(vbase+(32*c), address, 16);
address+=16;
}
xf86UnMapVidMem(0, vbase, 64*1024);
/* restore the standard vga register values */
- v_resetvga();
+ verite_resetvga();
}
void
-v_textmode(struct v_board_t *board)
+verite_textmode(struct verite_board_t *board)
{
vu16 iob=board->io_base;
int tmp;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_textmode called\n");
+ ErrorF ("Rendition: Debug verite_textmode called\n");
#endif
/* dac */
- v_out8(iob+DACCOMMAND0, 0x80); /* 6 bit op, enable extended */
- v_out8(iob+DACCOMMAND1, 0x68); /* disable palette bypass */
- v_out8(iob+DACCOMMAND2, 0x00); /* disable cursor & pixel packing */
+ verite_out8(iob+DACCOMMAND0, 0x80); /* 6 bit op, enable extended */
+ verite_out8(iob+DACCOMMAND1, 0x68); /* disable palette bypass */
+ verite_out8(iob+DACCOMMAND2, 0x00); /* disable cursor & pixel packing */
if (V1000_DEVICE == board->chip) {
- v_out8(iob+DACRAMWRITEADR, 0x01); /* select COMMAND3 register */
- v_out8(iob+DACCOMMAND3, 0x00); /* no clock doubling */
+ verite_out8(iob+DACRAMWRITEADR, 0x01); /* select COMMAND3 register */
+ verite_out8(iob+DACCOMMAND3, 0x00); /* no clock doubling */
}
- v_out8(iob+DACCOMMAND0, 0x00); /* 6 bit op */
+ verite_out8(iob+DACCOMMAND0, 0x00); /* 6 bit op */
if (V1000_DEVICE == board->chip) {
- v_out32(iob+DRAMCTL, 0x140000);
+ verite_out32(iob+DRAMCTL, 0x140000);
set_PLL(iob, 0x40000);
usleep(500);
}
else {
/* memctl */
- tmp = 0x1800|v_in32(iob+DRAMCTL);
- v_out32(iob+DRAMCTL, tmp); /* linear mode */
+ tmp = 0x1800|verite_in32(iob+DRAMCTL);
+ verite_out32(iob+DRAMCTL, tmp); /* linear mode */
/* pixel clock */
- v_out32(iob+PCLKPLL, 0x300000);
+ verite_out32(iob+PCLKPLL, 0x300000);
/* system and memory clock */
- v_out32(iob+SCLKPLL, 0x2480C); /* mclk=86 sclk=43 */
+ verite_out32(iob+SCLKPLL, 0x2480C); /* mclk=86 sclk=43 */
/* Need to wait 200uS for PLL to stabilize --
* let's play it safe with 500 */
usleep(500);
/* wait until VBLANK */
- while ((v_in32(iob+CRTCSTATUS)&CRTCSTATUS_VERT_MASK) !=
+ while ((verite_in32(iob+CRTCSTATUS)&CRTCSTATUS_VERT_MASK) !=
CRTCSTATUS_VERT_ACTIVE);
- while ((v_in32(iob+CRTCSTATUS)&CRTCSTATUS_VERT_MASK) ==
+ while ((verite_in32(iob+CRTCSTATUS)&CRTCSTATUS_VERT_MASK) ==
CRTCSTATUS_VERT_ACTIVE);
}
/* vga mode */
- v_out8(iob+MODEREG, VGA_MODE);
+ verite_out8(iob+MODEREG, VGA_MODE);
/* crtc */
- v_out32(iob+CRTCCTL, 0x44cc2);
- v_out32(iob+CRTCHORZ, 0x2b0a4f);
- v_out32(iob+CRTCVERT, 0x9301df);
- v_out32(iob+CRTCOFFSET, 0x40);
+ verite_out32(iob+CRTCCTL, 0x44cc2);
+ verite_out32(iob+CRTCHORZ, 0x2b0a4f);
+ verite_out32(iob+CRTCVERT, 0x9301df);
+ verite_out32(iob+CRTCOFFSET, 0x40);
#ifdef SAVEVGA
- v_loadvgafont();
- v_restoretextmode(board);
- v_restorepalette();
+ verite_loadvgafont();
+ verite_restoretextmode(board);
+ verite_restorepalette();
#else
#ifdef XSERVER
- v_loadvgafont();
- v_restorepalette();
+ verite_loadvgafont();
+ verite_restorepalette();
#endif
#endif
@@ -223,13 +223,13 @@ v_textmode(struct v_board_t *board)
void
-v_savetextmode(struct v_board_t *board)
+verite_savetextmode(struct verite_board_t *board)
{
vu8 *vbase;
int fbFlags;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_savetextmode called\n");
+ ErrorF ("Rendition: Debug verite_savetextmode called\n");
#endif
/* save the cursor position */
@@ -245,20 +245,20 @@ v_savetextmode(struct v_board_t *board)
fbFlags = VIDMEM_MMIO; /* VIDMEM_SPARSE is implied on Alpha */
vbase = xf86MapVidMem(0, fbFlags, 0xb8000, 0x8000);
- v_bustomem_cpy(board->scr_contents, vbase, 0x8000);
+ verite_bustomem_cpy(board->scr_contents, vbase, 0x8000);
xf86UnMapVidMem(0, vbase, 0x8000);
}
void
-v_restoretextmode(struct v_board_t *board)
+verite_restoretextmode(struct verite_board_t *board)
{
vu8 *vbase;
int fbFlags;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_restoretextmode called\n");
+ ErrorF ("Rendition: Debug verite_restoretextmode called\n");
#endif
/* restore the cursor position */
@@ -273,7 +273,7 @@ v_restoretextmode(struct v_board_t *board)
fbFlags = VIDMEM_MMIO; /* VIDMEM_SPARSE is implied on Alpha */
vbase = xf86MapVidMem(0, fbFlags, 0xb8000, 0x8000);
- v_memtobus_cpy(vbase, board->scr_contents, 0x8000);
+ verite_memtobus_cpy(vbase, board->scr_contents, 0x8000);
xf86UnMapVidMem(0, vbase, 0x8000);
xfree(board->scr_contents);
}
@@ -281,18 +281,18 @@ v_restoretextmode(struct v_board_t *board)
void
-v_restorepalette(void)
+verite_restorepalette(void)
{
int c;
vu8 *pal=vga_pal;
#ifdef DEBUG
- ErrorF ("Rendition: Debug v_restorepalette called\n");
+ ErrorF ("Rendition: Debug verite_restorepalette called\n");
#endif
- v_out8(0x3c8, 0);
+ verite_out8(0x3c8, 0);
for (c=0; c<768; c++)
- v_out8(0x3c9, *pal++);
+ verite_out8(0x3c9, *pal++);
}
@@ -309,8 +309,8 @@ v_restorepalette(void)
static vu8
getvgareg(vu16 port, vu8 index)
{
- v_out8(port, index);
- return v_in8(port+1);
+ verite_out8(port, index);
+ return verite_in8(port+1);
}
@@ -323,8 +323,8 @@ getvgareg(vu16 port, vu8 index)
static void
setvgareg(vu16 port, vu8 index, vu8 value)
{
- v_out8(port, index);
- v_out8(port+1, value);
+ verite_out8(port, index);
+ verite_out8(port+1, value);
}
@@ -337,11 +337,11 @@ setvgareg(vu16 port, vu8 index, vu8 value)
static void
updattr(vu8 index, vu8 value)
{
- v_in8(0x3da); /* points to index register for color adapter */
- v_in8(0x3ba); /* points to index register for mono */
- v_out8(0x3c0, index);
- v_out8(0x3c0, value);
- v_out8(0x3c0, index|0x20);
+ verite_in8(0x3da); /* points to index register for color adapter */
+ verite_in8(0x3ba); /* points to index register for mono */
+ verite_out8(0x3c0, index);
+ verite_out8(0x3c0, value);
+ verite_out8(0x3c0, index|0x20);
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h
index b7c3d0f66..ef3299ef2 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h,v 1.3 1999/10/13 04:21:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/rendition/vvga.h,v 1.4 2000/03/31 20:13:29 dawes Exp $ */
/*
* file vvga.h
*
@@ -22,12 +22,12 @@
* function prototypes
*/
-void v_resetvga(void);
-void v_loadvgafont(void);
-void v_textmode(struct v_board_t *board);
-void v_savetextmode(struct v_board_t *board);
-void v_restoretextmode(struct v_board_t *board);
-void v_restorepalette(void);
+void verite_resetvga(void);
+void verite_loadvgafont(void);
+void verite_textmode(struct verite_board_t *board);
+void verite_savetextmode(struct verite_board_t *board);
+void verite_restoretextmode(struct verite_board_t *board);
+void verite_restorepalette(void);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile
index 283763d4f..b8e4746c1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile,v 1.16 2000/02/08 13:13:20 eich Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/Imakefile,v 1.17 2000/03/31 22:55:46 dawes Exp $
/*
*
* Copyright 1995-1998 The XFree86 Project, Inc.
@@ -61,5 +61,6 @@ InstallDriverSDKNonExecFile(s3v_hwcurs.c,$(DRIVERSDKDIR)/drivers/s3virge)
InstallDriverSDKNonExecFile(s3v_i2c.c,$(DRIVERSDKDIR)/drivers/s3virge)
InstallDriverSDKNonExecFile(s3v_macros.h,$(DRIVERSDKDIR)/drivers/s3virge)
InstallDriverSDKNonExecFile(s3v_rop.h,$(DRIVERSDKDIR)/drivers/s3virge)
+InstallDriverSDKNonExecFile(s3v_shadow.c,$(DRIVERSDKDIR)/drivers/s3virge)
InstallDriverSDKObjectModule(s3virge,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/README b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/README
index 7ef54b4fb..93669d92f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/README
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/README
@@ -2,6 +2,8 @@
What works:
- Supports 8bpp, 15/16bpp, 24bpp and 32bpp. Heavy testing on ViRGE DX.
- There is some known instability in ViRGE GX2, please report problems.
+- Silken Mouse is enabled by default, use the generic server option of
+ -nosilk to disable it.
XCONFIG options:
@@ -82,4 +84,4 @@ Debug:
development debug option. Default: off.
-$XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/README,v 1.8 2000/03/05 16:59:15 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/README,v 1.9 2000/06/14 21:57:54 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES
index aeefd248b..aee09b20d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES
@@ -1,7 +1,7 @@
S3 ViRGE 4.0 devel notes
rev:
-26 Jun 1999 KJB
+26 Jun 2000 KJB
Function Implemented
@@ -23,6 +23,28 @@ S3VRestore X
Status
------
+6/26/00 KJB
+GX2 seems to have an accel bug. I see the entire screen go solid color or
+a wide stripe pattern for about 1 second. The S3VGEReset gets called twice,
+and then everything is okay. Unless SilkenMouse is enabled... That seems to
+get you a server lock instead. Short term is to disable SilkenMouse for GX2
+only. SilkenMouse isn't really the problem of course, it just happens that if
+we move the mouse during the 1 second engine lockup we appear more likely to
+never recover.
+
+6/23/00 KJB
+Ver 1.2.0 - Fix console corruption on GX2 caused by reserved bit use in CR3A.
+Fix GX2 noise on screen in hi-res depth 24 by increasing FIFO fill threshold.
+
+6/12/00 KJB
+Ver 1.1.0 - Add Init for SilkenMouse, add xf86SetBackingStore call, move
+int10Symbols[] to remove warnings.
+
+3/3/00 KJB
+Ver 1.0.0 - S3VProbeDDC code for X -configure option added, add timeout to
+WAITIDLE macro in s3v_macros.h, change ImageWriteFlags adding NO_GXCOPY.
+Start of GX2 fixes, use CR regs for FIFO settings. Update copyrights.
+
2/11/00 KJB
Ver 0.11.0 - Add cfb16/24BresS to module symbols to remove warnings.
Fix viewport restore problem after EnterVT in 24 bpp.
@@ -186,4 +208,4 @@ the new config. management stuff may help here.
-$XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES,v 1.11 2000/02/12 20:45:30 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/TODO_NOTES,v 1.15 2000/06/30 17:15:12 dawes Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h
index e39facd2c..5fb13f61c 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h,v 1.20 2000/02/08 17:19:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v.h,v 1.22 2000/04/04 19:25:15 dawes Exp $ */
/*
Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved.
@@ -28,9 +28,6 @@ in this Software without prior written authorization from the XFree86 Project.
#ifndef _S3V_H
#define _S3V_H
-/* Everything using inb/outb, etc needs "compiler.h" */
-#include "compiler.h"
-
/* All drivers should typically include these */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -38,6 +35,9 @@ in this Software without prior written authorization from the XFree86 Project.
/* All drivers need this */
#include "xf86_ansic.h"
+/* Everything using inb/outb, etc needs "compiler.h" */
+#include "compiler.h"
+
/* Drivers for PCI hardware need this */
#include "xf86PciInfo.h"
@@ -131,7 +131,7 @@ typedef struct {
unsigned char CR40, CR41, CR42, CR43, CR45;
unsigned char CR51, CR53, CR54, CR55, CR58, CR5D, CR5E;
unsigned char CR63, CR65, CR66, CR67, CR68, CR69, CR6D; /* Video attrib. */
- unsigned char CR86;
+ unsigned char CR85, CR86;
unsigned char CR90, CR91;
unsigned char ColorStack[8]; /* S3 hw cursor color stack CR4A/CR4B */
unsigned int STREAMS[22]; /* Streams regs */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c
index 59589c176..0e1e48b9f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c
@@ -1,4 +1,29 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c,v 1.5 2000/03/06 22:59:27 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_dga.c,v 1.6 2000/03/31 20:13:31 dawes Exp $ */
+
+/*
+Copyright (C) 1994-2000 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, FIT-
+NESS 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) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c
index e13f4e0c6..4107a4408 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c,v 1.54 2000/03/06 22:59:29 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_driver.c,v 1.62 2000/06/30 17:15:12 dawes Exp $ */
/*
Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved.
@@ -111,6 +111,7 @@ static void S3VDisplayPowerManagementSet(ScrnInfoPtr pScrn,
#endif
static Bool S3Vddc1(int scrnIndex);
static unsigned int S3Vddc1Read(ScrnInfoPtr pScrn);
+static void S3VProbeDDC(ScrnInfoPtr pScrn, int index);
/*
* This is intentionally screen-independent. It indicates the binding
@@ -118,12 +119,11 @@ static unsigned int S3Vddc1Read(ScrnInfoPtr pScrn);
*/
static int pix24bpp = 0;
-
#define S3VIRGE_NAME "S3VIRGE"
#define S3VIRGE_DRIVER_NAME "s3virge"
-#define S3VIRGE_VERSION_NAME "1.0.0"
+#define S3VIRGE_VERSION_NAME "1.2.0"
#define S3VIRGE_VERSION_MAJOR 1
-#define S3VIRGE_VERSION_MINOR 0
+#define S3VIRGE_VERSION_MINOR 2
#define S3VIRGE_PATCHLEVEL 0
#define S3VIRGE_DRIVER_VERSION ((S3VIRGE_VERSION_MAJOR << 24) | \
(S3VIRGE_VERSION_MINOR << 16) | \
@@ -141,9 +141,6 @@ DriverRec S3VIRGE =
{
S3VIRGE_DRIVER_VERSION,
S3VIRGE_DRIVER_NAME,
-#if 0
- "driver for S3 ViRGE based cards, including DX, GX, GX2, VX, MX & MX+",
-#endif
S3VIdentify,
S3VProbe,
S3VAvailableOptions,
@@ -315,12 +312,6 @@ static const char *shadowSymbols[] = {
NULL
};
-static const char *int10Symbols[] = {
- "xf86InitInt10",
- "xf86FreeInt10",
- NULL
-};
-
static const char *vbeSymbols[] = {
"VBEInit",
"vbeDoEDID",
@@ -330,6 +321,12 @@ static const char *vbeSymbols[] = {
#ifdef XFree86LOADER
+static const char *int10Symbols[] = {
+ "xf86InitInt10",
+ "xf86FreeInt10",
+ NULL
+};
+
static const char *cfbSymbols[] = {
#if 1
"cfbScreenInit",
@@ -528,25 +525,25 @@ S3VProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
/* Allocate a ScrnInfoRec and claim the slot */
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv, 0);
-
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = S3VIRGE_DRIVER_VERSION;
- pScrn->driverName = S3VIRGE_DRIVER_NAME;
- pScrn->name = S3VIRGE_NAME;
- pScrn->Probe = S3VProbe;
- pScrn->PreInit = S3VPreInit;
- pScrn->ScreenInit = S3VScreenInit;
- pScrn->SwitchMode = S3VSwitchMode;
- pScrn->AdjustFrame = S3VAdjustFrame;
- pScrn->EnterVT = S3VEnterVT;
- pScrn->LeaveVT = S3VLeaveVT;
- pScrn->FreeScreen = NULL; /*S3VFreeScreen;*/
- pScrn->ValidMode = S3VValidMode;
- foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn,usedChips[i],S3VPciChipsets,
- NULL,NULL, NULL,NULL,NULL);
-
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
+ S3VPciChipsets,NULL,NULL, NULL,
+ NULL,NULL))) {
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = S3VIRGE_DRIVER_VERSION;
+ pScrn->driverName = S3VIRGE_DRIVER_NAME;
+ pScrn->name = S3VIRGE_NAME;
+ pScrn->Probe = S3VProbe;
+ pScrn->PreInit = S3VPreInit;
+ pScrn->ScreenInit = S3VScreenInit;
+ pScrn->SwitchMode = S3VSwitchMode;
+ pScrn->AdjustFrame = S3VAdjustFrame;
+ pScrn->EnterVT = S3VEnterVT;
+ pScrn->LeaveVT = S3VLeaveVT;
+ pScrn->FreeScreen = NULL; /*S3VFreeScreen;*/
+ pScrn->ValidMode = S3VValidMode;
+ foundScreen = TRUE;
+ }
}
xfree(usedChips);
PVERB5(" S3VProbe end\n");
@@ -573,10 +570,13 @@ S3VPreInit(ScrnInfoPtr pScrn, int flags)
vgaHWPtr hwp;
int vgaCRIndex, vgaCRReg, vgaIOBase;
-
- if (flags & PROBE_DETECT) return FALSE;
-
+
PVERB5(" S3VPreInit 1\n");
+
+ if (flags & PROBE_DETECT) {
+ S3VProbeDDC( pScrn, xf86GetEntityInfo(pScrn->entityList[0])->index );
+ return TRUE;
+ }
/*
* Note: This function is only called once at server startup, and
@@ -971,7 +971,7 @@ S3VPreInit(ScrnInfoPtr pScrn, int flags)
xf86LoaderReqSymLists(ddcSymbols, NULL);
if ((ps3v->pVbe)
- && ((pMon = xf86PrintEDID(vbeDoEDID(ps3v->pVbe))) != NULL))
+ && ((pMon = xf86PrintEDID(vbeDoEDID(ps3v->pVbe, NULL))) != NULL))
xf86SetDDCproperties(pScrn,pMon);
else if (!S3Vddc1(pScrn->scrnIndex)) {
if ( xf86LoadSubModule(pScrn, "i2c") ) {
@@ -1034,8 +1034,9 @@ S3VPreInit(ScrnInfoPtr pScrn, int flags)
}
else if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset)) {
switch((config1 & 0xE0) >> 5) {
- case 0:
- ps3v->videoRamKbytes = 8 * 1024;
+ case 0: /* 8MB -- only 4MB usable for display/cursor */
+ ps3v->videoRamKbytes = 4 * 1024;
+ ps3v->MemOffScreen = 4 * 1024;
break;
case 1: /* 32 bit interface -- yuck */
xf86ErrorFVerb(VERBLEV,
@@ -1143,6 +1144,12 @@ S3VPreInit(ScrnInfoPtr pScrn, int flags)
if (pScrn->clock[2] <= 0) pScrn->clock[2] = 135000;
if (pScrn->clock[3] <= 0) pScrn->clock[3] = 135000;
}
+ else if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset)) {
+ if (pScrn->clock[0] <= 0) pScrn->clock[0] = 230000;
+ if (pScrn->clock[1] <= 0) pScrn->clock[1] = 230000;
+ if (pScrn->clock[2] <= 0) pScrn->clock[2] = 135000;
+ if (pScrn->clock[3] <= 0) pScrn->clock[3] = 135000;
+ }
else if (ps3v->Chipset == S3_ViRGE_DXGX || S3_ViRGE_GX2_SERIES(ps3v->Chipset)) {
if (pScrn->clock[0] <= 0) pScrn->clock[0] = 170000;
if (pScrn->clock[1] <= 0) pScrn->clock[1] = 170000;
@@ -1337,7 +1344,7 @@ S3VPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = ps3v->minClock;
clockRanges->maxClock = ps3v->maxClock;
@@ -1663,6 +1670,12 @@ S3VSave (ScrnInfoPtr pScrn)
VGAOUT8(vgaCRIndex, 0x33);
save->CR33 = VGAIN8(vgaCRReg);
+ if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset) || S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )
+ {
+ VGAOUT8(vgaCRIndex, 0x85);
+ save->CR85 = VGAIN8(vgaCRReg);
+ }
if (ps3v->Chipset == S3_ViRGE_DXGX) {
VGAOUT8(vgaCRIndex, 0x86);
save->CR86 = VGAIN8(vgaCRReg);
@@ -1707,6 +1720,7 @@ S3VSave (ScrnInfoPtr pScrn)
if (S3_ViRGE_GX2_SERIES(ps3v->Chipset) || S3_ViRGE_MX_SERIES(ps3v->Chipset)) {
VGAOUT8(0x3c4, 0x29);
save->SR29 = VGAIN8(0x3c5);
+ /* SR 54,55,56,57 undocumented for MX & GX2. Was this supposed to be CR? */
VGAOUT8(0x3c4, 0x54);
save->SR54 = VGAIN8(0x3c5);
VGAOUT8(0x3c4, 0x55);
@@ -1742,10 +1756,18 @@ S3VSave (ScrnInfoPtr pScrn)
}
/* Now save Memory Interface Unit registers */
- save->MMPR0 = INREG(FIFO_CONTROL_REG);
- save->MMPR1 = INREG(MIU_CONTROL_REG);
- save->MMPR2 = INREG(STREAMS_TIMEOUT_REG);
- save->MMPR3 = INREG(MISC_TIMEOUT_REG);
+ if( S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )
+ {
+ /* No MMPR regs on MX & GX2 */
+ }
+ else
+ {
+ save->MMPR0 = INREG(FIFO_CONTROL_REG);
+ save->MMPR1 = INREG(MIU_CONTROL_REG);
+ save->MMPR2 = INREG(STREAMS_TIMEOUT_REG);
+ save->MMPR3 = INREG(MISC_TIMEOUT_REG);
+ }
if (xf86GetVerbosity() > 1) {
/* Debug */
@@ -1930,6 +1952,12 @@ S3VWriteMode (ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, S3VRegPtr restore)
VGAOUT8(vgaCRIndex, 0x33);
VGAOUT8(vgaCRReg, restore->CR33);
+ if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset) || S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )
+ {
+ VGAOUT8(vgaCRIndex, 0x85);
+ VGAOUT8(vgaCRReg, restore->CR85);
+ }
if (ps3v->Chipset == S3_ViRGE_DXGX) {
VGAOUT8(vgaCRIndex, 0x86);
VGAOUT8(vgaCRReg, restore->CR86);
@@ -2040,14 +2068,27 @@ S3VWriteMode (ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, S3VRegPtr restore)
#endif
VerticalRetraceWait();
- OUTREG(FIFO_CONTROL_REG, restore->MMPR0);
- WaitIdle(); /* Don't ask... */
- OUTREG(MIU_CONTROL_REG, restore->MMPR1);
- WaitIdle();
- OUTREG(STREAMS_TIMEOUT_REG, restore->MMPR2);
- WaitIdle();
- OUTREG(MISC_TIMEOUT_REG, restore->MMPR3);
-
+ if (S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )
+ {
+ VGAOUT8(vgaCRIndex, 0x85);
+ /* primary stream threshold */
+ VGAOUT8(vgaCRReg, 0x1f );
+ }
+ else
+ {
+ OUTREG(FIFO_CONTROL_REG, restore->MMPR0);
+ }
+ if( !( S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ ))
+ {
+ WaitIdle(); /* Don't ask... */
+ OUTREG(MIU_CONTROL_REG, restore->MMPR1);
+ WaitIdle();
+ OUTREG(STREAMS_TIMEOUT_REG, restore->MMPR2);
+ WaitIdle();
+ OUTREG(MISC_TIMEOUT_REG, restore->MMPR3);
+ }
/* Restore the standard VGA registers */
/* False indicates no fontinfo restore. */
@@ -2380,6 +2421,15 @@ S3VScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
}
miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ /* Problem with accel appears to crash GX2 on mouse moves */
+ /* re-enable this when fixed. */
+ if( S3_ViRGE_GX2_SERIES(ps3v->Chipset) )
+ {}
+ else
+ {
+ xf86SetSilkenMouse(pScreen);
+ }
/* hardware cursor needs to wrap this layer */
S3VDGAInit(pScreen);
@@ -2623,10 +2673,22 @@ S3VModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
VGAOUT8(vgaCRIndex, 0x3a);
tmp = VGAIN8(vgaCRReg);
- if(ps3v->pci_burst)
- new->CR3A = (tmp & 0x7f) | 0x15; /* ENH 256, PCI burst */
- else
- new->CR3A = tmp | 0x95; /* ENH 256, no PCI burst! */
+ if( S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )
+ {
+ if(ps3v->pci_burst)
+ new->CR3A = (tmp & 0x78) | 0x10; /* ENH 256, PCI burst */
+ else
+ new->CR3A = tmp | 0x90; /* ENH 256, no PCI burst! */
+ }
+ else
+ {
+ if(ps3v->pci_burst)
+ new->CR3A = (tmp & 0x7f) | 0x15; /* ENH 256, PCI burst */
+ else
+ new->CR3A = tmp | 0x95; /* ENH 256, no PCI burst! */
+ }
+
VGAOUT8(vgaCRIndex, 0x55);
new->CR55 = VGAIN8(vgaCRReg);
@@ -2719,7 +2781,6 @@ S3VModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
}
- /*cep*/
xf86ErrorFVerb(VERBLEV, " S3VModeInit dclk=%i \n",
dclk
);
@@ -2810,7 +2871,9 @@ S3VModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
/* Flag STREAMS proc. required */
ps3v->NeedSTREAMS = TRUE;
S3VInitSTREAMS(pScrn, new->STREAMS, mode);
- new->MMPR0 = 0xc098; /* Adjust FIFO slots */
+ /* MXTESTME - remove the next 2 lines completely */
+ if( S3_ViRGE_MX_SERIES(ps3v->Chipset) )
+ new->MMPR0 = 0xc098; /* Adjust FIFO slots */
}
else if (pScrn->bitsPerPixel == 32) {
new->CR67 = 0xd0; /* 32bpp */
@@ -3018,6 +3081,13 @@ S3VModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
new->CR33 = 0x20;
+ if (S3_TRIO_3D_2X_SERIES(ps3v->Chipset) || S3_ViRGE_GX2_SERIES(ps3v->Chipset)
+ /* MXTESTME || S3_ViRGE_MX_SERIES(ps3v->Chipset) */ )
+ {
+ new->CR85 = 0x1f; /* avoid sreen flickering */
+ /* by increasing FIFO filling, larger # fills FIFO from memory earlier */
+ /* on GX2 this affects all depths, not just those running STREAMS. */
+ }
if (ps3v->Chipset == S3_ViRGE_DXGX || S3_TRIO_3D_SERIES(ps3v->Chipset)) {
new->CR86 = 0x80; /* disable DAC power saving to avoid bright left edge */
}
@@ -3612,6 +3682,18 @@ S3Vddc1(int scrnIndex)
OUTREG(DDC_REG,(tmp));
return success;
}
+
+
+static void
+S3VProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+ vbeInfoPtr pVbe;
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ pVbe = VBEInit(NULL,index);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
+ }
+}
+
/*EOF*/
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c
index e039c6ecf..09c929c07 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c
@@ -1,4 +1,29 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c,v 1.3 2000/03/06 22:59:29 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_i2c.c,v 1.4 2000/03/31 20:13:32 dawes Exp $ */
+
+/*
+Copyright (C) 1994-2000 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, FIT-
+NESS 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) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h
index 8512f4480..a6ca27eda 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h,v 1.8 1999/08/21 13:48:40 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_macros.h,v 1.9 2000/03/31 20:13:33 dawes Exp $ */
/*
Copyright (C) 1994-1999 The XFree86 Project, Inc. All Rights Reserved.
@@ -93,11 +93,17 @@ in this Software without prior written authorization from the XFree86 Project.
#define MONO_TRANS_BUG 0x00000002
+#define MAXLOOP 0x0fffff /* timeout value for engine waits, 0.5 secs */
+
#define WAITFIFO(n) if(ps3v->NoPCIRetry) \
while(((INREG(SUBSYS_STAT_REG) >> 8) & 0x1f) < n){}
-#define WAITIDLE() while((INREG(SUBSYS_STAT_REG) & 0x3f00) < 0x3000){}
+#define WAITIDLE()\
+ do { int loop=0; mem_barrier(); \
+ while(((INREG(SUBSYS_STAT_REG) & 0x3f00) < 0x3000) && (loop++<MAXLOOP)) \
+ if (loop >= MAXLOOP) S3VGEReset(pScrn,1,__LINE__,__FILE__); \
+ } while (0)
#define CHECK_DEST_BASE(y,h)\
if((y < ps3v->DestBaseY) || ((y + h) > (ps3v->DestBaseY + 2048))) {\
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c
index 82324ed88..5522aafc0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c
@@ -1,4 +1,29 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c,v 1.2 2000/03/06 22:59:30 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3v_shadow.c,v 1.3 2000/03/31 20:13:33 dawes Exp $ */
+
+/*
+Copyright (C) 1994-2000 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, FIT-
+NESS 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) 1994-2000 The XFree86 Project, Inc. All Rights Reserved.
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp
index 4e801b592..0b9a73b71 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp
@@ -1,13 +1,15 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp,v 1.6 2000/03/05 16:59:16 dawes Exp $
-.TH s3virge __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/s3virge/s3virge.cpp,v 1.9 2000/06/14 02:13:13 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH s3virge __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
s3virge \- S3 ViRGE video driver
.SH SYNOPSIS
-.B "Section ""Device"""
+.B "Section \*qDevice\*q"
.br
-.BI " Identifier """ devname """"
+.BI " Identifier \*q" devname \*q
.br
-.B " Driver ""s3virge"""
+.B " Driver \*qs3virge\*q"
.br
\ \ ...
.br
@@ -63,7 +65,7 @@ parsed by the server, for exmaple, "virge vx" and "VIRGEvx" are equivalent.
The driver auto-detects the chipset type, but the following
.B ChipSet
names may optionally be specified in the config file
-.B """Device"""
+.B \*q"Device\*q"
section, and will override the auto-detection:
.PP
.RS 4
@@ -78,10 +80,10 @@ The following Cursor
.B Options
are supported:
.TP
-.BI "Option ""HWCursor"" [""" boolean """]
+.BI "Option \*qHWCursor\*q [\*q" boolean \*q]
Enable or disable the HW cursor. Default: on.
.TP
-.BI "Option ""SWCursor"" [""" boolean """]
+.BI "Option \*qSWCursor\*q [\*q" boolean \*q]
Inverse of "HWCursor". Default: off.
.PP
@@ -89,10 +91,10 @@ The following display
.B Options
are supported:
.TP
-.BI "Option ""ShadowFB"" [""" boolean """]
+.BI "Option \*qShadowFB\*q [\*q" boolean \*q]
Use shadow framebuffer. Disables HW acceleration. Default: off.
.TP
-.BR "Option ""Rotate"" """ cw " | " ccw """
+.BR "Option \*qRotate\*q \*q" cw " | " ccw \*q
Rotate the screen CW - clockwise or CCW - counter clockwise.
Disables HW Acceleration and HW Cursor, uses ShadowFB.
Default: no rotation.
@@ -102,23 +104,23 @@ The following video memory
.B Options
are supported:
.TP
-.BI "Option ""slow_edodram"""
+.BI "Option \*qslow_edodram\*q"
Switch the standard ViRGE to 2-cycle edo mode. Try this
if you encounter pixel corruption on the ViRGE. Using this option will
cause a large decrease in performance. Default: off.
.TP
-.BI "Option ""fpm_vram"""
+.BI "Option \*qfpm_vram\*q"
Switch the ViRGE/VX to fast page mode vram mode. Default: off.
.TP
-.BR "Option ""slow_dram " | " fast_dram"""
+.BR "Option \*qslow_dram " | " fast_dram\*q"
Change Trio 3D and 3D/2X memory options. Default: Use BIOS defaults.
.TP
-.BR "Option ""early_ras_precharge " | " late_ras_precharge"""
+.BR "Option \*qearly_ras_precharge " | " late_ras_precharge\*q"
adjust memory parameters. One
of these will us the same settings as your video card defaults, and
using neither in the config file does the same. Default: none.
.TP
-.BI "Option ""set_mclk"" """ integer """
+.BI "Option \*qset_mclk\*q \*q" integer \*q
sets the memory clock, where
.I integer
is in kHz, and
@@ -126,7 +128,7 @@ is in kHz, and
<= 100000. Default: probe the memory clock value,
and use it at server start.
.TP
-.BI "Option ""set_refclk"" """ integer """
+.BI "Option \*qset_refclk\*q \*q" integer \*q
sets the ref clock for ViRGE MX, where
.I integer
is in kHz. Default: probe the memory clock value,
@@ -138,7 +140,7 @@ The following acceleration and graphics engine
.B Options
are supported:
.TP
-.B "Option ""NoAccel""
+.B "Option \*qNoAccel\*q"
Disable acceleration. Very useful for determining if the
driver has problems with drawing and acceleration routines. This is the first
option to try if your server runs but you see graphic corruption on the screen.
@@ -146,7 +148,7 @@ Using it decreases performance, as it uses software emulation for drawing
operations the video driver can accelerate with hardware.
Default: acceleration is enabled.
.TP
-.BR "Option ""fifo_aggressive " | " fifo_moderate " | " fifo_conservative"""
+.BR "Option \*qfifo_aggressive " | " fifo_moderate " | " fifo_conservative\*q"
alter the settings
for the threshold at which the pixel FIFO takes over the internal
memory bus to refill itself. The smaller this threshold, the better
@@ -167,11 +169,11 @@ The following PCI bus
.B Options
are supported:
.TP
-.BI "Option ""pci_burst"" [""" boolean """]
+.BI "Option \*qpci_burst\*q [\*q" boolean \*q]
will enable PCI burst mode. This should work on all but a
few broken PCI chipsets, and will increase performance. Default: off.
.TP
-.BI "Option ""pci_retry"" [""" boolean """]
+.BI "Option \*qpci_retry\*q [\*q" boolean \*q]
will allow the driver to rely on PCI Retry to program the
ViRGE registers.
.B "pci_burst"
@@ -185,9 +187,9 @@ The following ViRGE MX LCD
.B Options
are supported:
.TP
-.BI "Option ""lcd_center""
+.BI "Option \*qlcd_center\*q"
.TP
-.BI "Option ""set_lcdclk"" """ integer """
+.BI "Option \*qset_lcdclk\*q \*q" integer \*q
allows setting the clock for a ViRGE MX LCD display.
.I integer
is in Hz. Default: use probed value.
@@ -197,12 +199,12 @@ The following additional
.B Options
are supported:
.TP
-.BI "Option ""ShowCache"" [""" boolean """]
+.BI "Option \*qShowCache\*q [\*q" boolean \*q]
Enable or disable viewing offscreen cache memory. A
development debug option. Default: off.
.SH SEE ALSO
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH SUPPORT
For assistance with this driver, or XFree86 in general, check the XFree86 web
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile
index 3ff10e1a5..4d81b42bd 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile,v 1.11 2000/03/03 01:05:42 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/Imakefile,v 1.16 2000/06/30 17:15:13 dawes Exp $
XCOMM
XCOMM This is an Imakefile for the SIS driver.
XCOMM
@@ -7,12 +7,15 @@ XCOMM
#include <Server.tmpl>
SRCS = sis_driver.c sis_dac.c sis_cursor.c sis_accel.c sis_setup.c\
- sis530_accel.c sis300_accel.c sis_vga.c sis_lcd.c sis_tv.c\
- sis_opt.c sis_bios.c
+ sis530_accel.c sis300_accel.c sis_vga.c sis_tv.c sis_lcd.c\
+ sis_opt.c sis_bios.c sis_dga.c
OBJS = sis_driver.o sis_dac.o sis_cursor.o sis_accel.o sis_setup.o\
- sis530_accel.o sis300_accel.o sis_vga.o sis_lcd.o sis_tv.o\
- sis_opt.o sis_bios.o
+ sis530_accel.o sis300_accel.o sis_vga.o sis_tv.o sis_lcd.o\
+ sis_opt.o sis_bios.o sis_dga.o
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \
-I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
-I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa \
@@ -23,6 +26,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(SERVERSRC)/Xext \
-I$(XF86SRC)/rac \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
-I$(XTOP)/include/extensions
+#endif
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
@@ -41,3 +45,29 @@ InstallModuleManPage(sis)
DependTarget()
+
+InstallDriverSDKNonExecFile(Imakefile,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis300_accel.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis300_accel.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis530_accel.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_accel.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_bios.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_bios.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_cursor.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_cursor.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_dac.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_dga.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_driver.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_driver.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_lcd.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_lcd.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_opt.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_regs.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_regs2.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_setup.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_tv.c,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_tv.h,$(DRIVERSDKDIR)/drivers/sis)
+InstallDriverSDKNonExecFile(sis_vga.c,$(DRIVERSDKDIR)/drivers/sis)
+
+InstallDriverSDKObjectModule(sis,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp
index dfe733bb2..3f58c7c9d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp,v 1.1 2000/03/03 01:05:42 dawes Exp $
-.TH SIS __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.cpp,v 1.4 2000/06/14 02:13:13 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SIS __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
sis \- SiS video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""sis"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsis\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B sis
is an XFree86 driver for SiS video cards.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h
index 5625da104..42719b5d7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h
@@ -25,7 +25,7 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
* David Thomas <davtom@dream.org.uk>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.11 2000/02/12 23:07:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis.h,v 1.14 2000/06/26 22:27:45 tsi Exp $ */
#ifndef _SIS_H
#define _SIS_H_
@@ -35,6 +35,7 @@
#include "xf86Cursor.h"
#include "compiler.h"
#include "xaa.h"
+#include "vgaHW.h"
#define SIS_NAME "SIS"
#define SIS_DRIVER_NAME "sis"
@@ -52,9 +53,31 @@
#define BIOS_BASE 0xC0000
#define BIOS_SIZE 0x10000
-#define CRT2_LCD 0x00000001
-#define CRT2_TV 0x00000002
-#define CRT2_VGA 0x00000004
+#define CRT2_LCD 0x00000010
+#define CRT2_TV 0x00000020
+#define CRT2_VGA 0x00000040
+#define CRT2_ENABLE 0x00000070
+#define LCD_800x600 0x00000100
+#define LCD_1024x768 0x00000200
+#define LCD_1280x1024 0x00000400
+#define LCD_TYPE 0x00000700
+#define TV_NTSC 0x00001000
+#define TV_PAL 0x00002000
+#define TV_HIVISION 0x00004000
+#define TV_TYPE 0x00007000
+#define TV_AVIDEO 0x00010000
+#define TV_SVIDEO 0x00020000
+#define TV_SCART 0x00040000
+#define TV_INTERFACE 0x00070000
+#define SIS301 0x00100000
+#define SIS302 0x00200000
+#define LVDS 0x01000000
+#define CHRONTEL_TV 0x02000000
+#define SINGLE_MODE 0x00000000
+#define SIMU_MODE 0x10000000
+#define MM_MODE 0x20000000
+#define DISPLAY_MODE 0x30000000
+
#ifdef DEBUG
#define PDEBUG(p) p
@@ -63,14 +86,13 @@
#endif
typedef struct {
- unsigned char sisRegs3x4[0x100];
- unsigned char sisRegs3C4[0x100];
- unsigned char sisRegs3C2[0x100];
+ unsigned char sisRegs3C4[0x50];
+ unsigned char sisRegs3D4[0x40];
+ unsigned char sisRegs3C2;
unsigned char VBPart1[0x29];
unsigned char VBPart2[0x46];
unsigned char VBPart3[0x3F];
unsigned char VBPart4[0x1C];
- unsigned char VBPart5[0x100];
} SISRegRec, *SISRegPtr;
#define SISPTR(p) ((SISPtr)((p)->driverPrivate))
@@ -98,6 +120,10 @@ typedef struct {
int MaxClock;
int Flags; /* HW config flags */
long FbMapSize;
+ DGAModePtr DGAModes;
+ int numDGAModes;
+ Bool DGAactive;
+ int DGAViewportStatus;
Bool NoAccel;
Bool HWCursor;
Bool UsePCIRetry;
@@ -129,33 +155,37 @@ typedef struct {
XAAInfoRecPtr AccelInfoPtr;
CloseScreenProcPtr CloseScreen;
unsigned int (*ddc1Read)(ScrnInfoPtr);
- Bool (*FindThreshold)(ScrnInfoPtr pScrn, int mclk, int vclk,
- int bpp, int buswidth, int flags,
- int *ThresaholdLow, int *ThresholdHigh);
Bool (*ModeInit)(ScrnInfoPtr pScrn, DisplayModePtr mode);
Bool (*ModeInit2)(ScrnInfoPtr pScrn, DisplayModePtr mode);
void (*SiSSave)(ScrnInfoPtr pScrn, SISRegPtr sisreg);
- void (*SiSSave1)(ScrnInfoPtr pScrn, SISRegPtr sisreg);
+ void (*SiSSave2)(ScrnInfoPtr pScrn, SISRegPtr sisreg);
void (*SiSRestore)(ScrnInfoPtr pScrn, SISRegPtr sisreg);
- void (*SiSRestore1)(ScrnInfoPtr pScrn, SISRegPtr sisreg);
+ void (*SiSRestore2)(ScrnInfoPtr pScrn, SISRegPtr sisreg);
+ void (*SetThreshold)(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+ void (*SetThreshold2)(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+ void (*LoadCRT2Palette)(ScrnInfoPtr pScrn, int numColors,
+ int *indicies, LOCO *colors, VisualPtr pVisual);
} SISRec, *SISPtr;
/* Prototypes */
-void SiSOptions(ScrnInfoPtr pScrn);
-void SiSVGASetup(ScrnInfoPtr pScrn);
-void SiSLCDPreInit(ScrnInfoPtr pScrn);
-void SiSTVPreInit(ScrnInfoPtr pScrn);
+void SiSOptions(ScrnInfoPtr pScrn);
+void SISVGAPreInit(ScrnInfoPtr pScrn);
+void SISLCDPreInit(ScrnInfoPtr pScrn);
+void SISTVPreInit(ScrnInfoPtr pScrn);
OptionInfoPtr SISAvailableOptions(int chipid, int busid);
+void SISDACPreInit(ScrnInfoPtr pScrn);
+void SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies,
+ LOCO *colors, VisualPtr pVisual);
int compute_vclk(int Clock, int *out_n, int *out_dn, int *out_div,
int *out_sbit, int *out_scale);
void SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD,
unsigned int *vclk);
unsigned int SiSddc1Read(ScrnInfoPtr pScrn);
-void SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg);
-void SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg);
Bool SiSAccelInit(ScreenPtr pScreen);
Bool SiS530AccelInit(ScreenPtr pScreen);
Bool SiS300AccelInit(ScreenPtr pScreen);
@@ -167,4 +197,7 @@ void SiSIODump(ScrnInfoPtr pScreen);
void SiSInitializeAccelerator(ScrnInfoPtr pScrn);
void SiSSetup(ScrnInfoPtr pScrn);
+extern Bool SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+extern void SISAdjustFrame(int scrnIndex, int x, int y, int flags);
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c
index 42a6323b8..326ed77b7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.2 2000/02/12 23:07:58 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis300_accel.c,v 1.3 2000/03/31 20:13:35 dawes Exp $ */
/*
*
@@ -21,6 +21,8 @@
#include <xf86PciInfo.h>
#include <xf86Pci.h>
+#include <compiler.h>
+
#include <miline.h>
#include <xaa.h>
@@ -89,7 +91,6 @@ SiSInitializeAccelerator(ScrnInfoPtr pScrn)
{
SISPtr pSiS = SISPTR(pScrn);
- SiSSetupDSTColorDepth(SISPTR(pScrn)->DstColor);
pSiS->DoColorExpand = FALSE;
}
@@ -109,31 +110,30 @@ SiS300AccelInit(ScreenPtr pScreen)
infoPtr->Flags = LINEAR_FRAMEBUFFER |
OFFSCREEN_PIXMAPS |
- PIXMAP_CACHE |
- NO_PLANEMASK;
+ PIXMAP_CACHE;
/* sync */
infoPtr->Sync = SiSSync;
+ if ((pScrn->bitsPerPixel != 8) && (pScrn->bitsPerPixel != 16) &&
+ (pScrn->bitsPerPixel != 32)) return FALSE;
+
/* BitBlt */
infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy;
infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy;
infoPtr->ScreenToScreenCopyFlags = NO_PLANEMASK | NO_TRANSPARENCY;
-
/* solid fills */
infoPtr->SetupForSolidFill = SiSSetupForSolidFill;
infoPtr->SubsequentSolidFillRect = SiSSubsequentSolidFillRect;
infoPtr->SolidFillFlags = NO_PLANEMASK;
-
/* solid line */
infoPtr->SetupForSolidLine = SiSSetupForSolidLine;
infoPtr->SubsequentSolidTwoPointLine = SiSSubsequentSolidTwoPointLine;
infoPtr->SubsequentSolidHorVertLine = SiSSubsequentSolidHorzVertLine;
infoPtr->SolidFillFlags = NO_PLANEMASK;
-
/* dashed line */
infoPtr->SetupForDashedLine = SiSSetupForDashedLine;
infoPtr->SubsequentDashedTwoPointLine = SiSSubsequentDashedTwoPointLine;
@@ -141,8 +141,7 @@ SiS300AccelInit(ScreenPtr pScreen)
infoPtr->DashedLineFlags = NO_PLANEMASK |
LINE_PATTERN_MSBFIRST_LSBJUSTIFIED;
-
- /* 8x8 mono pattern fill */
+ /* 8x8 mono pattern fill
infoPtr->SetupForMono8x8PatternFill = SiSSetupForMonoPatternFill;
infoPtr->SubsequentMono8x8PatternFillRect =
SiSSubsequentMonoPatternFill;
@@ -151,7 +150,7 @@ SiS300AccelInit(ScreenPtr pScreen)
HARDWARE_PATTERN_PROGRAMMED_BITS |
NO_TRANSPARENCY |
BIT_ORDER_IN_BYTE_MSBFIRST ;
-
+*/
/* 8x8 color pattern fill
infoPtr->SetupForColor8x8PatternFill =
@@ -163,8 +162,7 @@ SiS300AccelInit(ScreenPtr pScreen)
HARDWARE_PATTERN_PROGRAMMED_BITS ;
*/
-
- /* CPU To Screen Color Expand */
+ /* CPU To Screen Color Expand
infoPtr->SetupForCPUToScreenColorExpandFill =
SiSSetupForCPUToScreenColorExpand;
infoPtr->SubsequentCPUToScreenColorExpandFill =
@@ -179,8 +177,7 @@ SiS300AccelInit(ScreenPtr pScreen)
SYNC_AFTER_COLOR_EXPAND |
HARDWARE_PATTERN_SCREEN_ORIGIN |
HARDWARE_PATTERN_PROGRAMMED_BITS ;
-
-
+*/
/* Screen To Screen Color Expand
infoPtr->SetupForScreenToScreenColorExpandFill =
@@ -198,6 +195,7 @@ SiS300AccelInit(ScreenPtr pScreen)
reservedFbSize = 0;
if (pSiS->TurboQueue) reservedFbSize += 1024*512;
if (pSiS->HWCursor) reservedFbSize += 4096;
+ reservedFbSize = 4096*1024;
UsableFbSize = pSiS->FbMapSize - reservedFbSize;
Avail.x1 = 0;
Avail.y1 = 0;
@@ -206,7 +204,7 @@ SiS300AccelInit(ScreenPtr pScreen)
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
"Frame Buffer From (%d,%d) To (%d,%d)\n",
Avail.x1, Avail.y1, Avail.x2, Avail.y2);
- xf86InitFBManager(pScreen, &Avail);
+/* xf86InitFBManager(pScreen, &Avail); */
return(XAAInit(pScreen, infoPtr));
@@ -271,7 +269,7 @@ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn,
unsigned int planemask, int trans_color)
{
SISPtr pSiS = SISPTR(pScrn);
- XAAInfoRecPtr pXAA = XAAPTR(pScrn);
+/* XAAInfoRecPtr pXAA = XAAPTR(pScrn);*/
PDEBUG(ErrorF("Setup ScreenCopy(%d, %d, 0x%x, 0x%x, 0x%x)\n",
xdir, ydir, rop, planemask, trans_color));
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c
index 9071db66e..8c9c128b3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.15 2000/02/18 12:19:59 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_accel.c,v 1.17 2000/06/15 20:50:03 dawes Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -61,7 +61,7 @@ static void SiSSubsequentSolidHorVertLine(ScrnInfoPtr pScrn,
int x, int y, int len, int dir);
-Bool
+Bool
SiSAccelInit(ScreenPtr pScreen)
{
XAAInfoRecPtr infoPtr;
@@ -164,6 +164,7 @@ SiSSetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop,
SISPtr pSiS = SISPTR(pScrn);
sisSETFGCOLOR(color);
+ sisSETBGCOLOR(color);
sisSETROP(XAACopyROP[rop]);
sisSETPITCH(pScrn->displayWidth * pScrn->bitsPerPixel / 8,
pScrn->displayWidth * pScrn->bitsPerPixel / 8);
@@ -182,7 +183,7 @@ SiSSubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h)
int destaddr, op;
destaddr = y * pScrn->displayWidth + x;
- op = sisCMDBLT | sisSRCFG | sisTOP2BOTTOM | sisLEFT2RIGHT;
+ op = sisCMDBLT | sisSRCBG | sisTOP2BOTTOM | sisLEFT2RIGHT;
if (pSiS->ClipEnabled) op |= sisCLIPINTRN | sisCLIPENABL;
destaddr *= (pScrn->bitsPerPixel / 8);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c
index 4065e74be..d3f164ee1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c,v 1.3 2000/02/18 12:20:00 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_bios.c,v 1.5 2000/04/07 03:57:52 tsi Exp $ */
#include "xf86.h"
#include "xf86PciInfo.h"
@@ -443,9 +443,6 @@ SetCRT2Group(ScrnInfoPtr pScrn, CARD16 ModeNo)
SetGroup2(BaseAddr,ROMAddr);
SetGroup3(BaseAddr);
SetGroup4(BaseAddr,ROMAddr,ModeNo);
-#if 0
- SetGroup5(BaseAddr,ROMAddr);
-#endif
LockCRT2(BaseAddr);
if (SetFlag & TV_SIMU_MODE) {
@@ -572,22 +569,22 @@ DisableBridge(CARD16 BaseAddr)
unsigned short part2_base = BaseAddr+0x10;
andSISIDXREG(part2_base, 0, 0xDF);
+ LongWait(BaseAddr+0x5A);
orSISIDXREG(BaseAddr+SROFFSET, 1, 0x20); /* DisplayOff */
andSISIDXREG(BaseAddr+SROFFSET, 0x32, 0xDF);
andSISIDXREG(BaseAddr+SROFFSET, 0x1E, 0xDF);
}
void
-LongWait(CARD16 BaseAddr)
+LongWait(CARD16 p3da)
{
unsigned short i;
- unsigned short p3da = BaseAddr + 0x5A;
for (i=0; i<0xFFFF; i++) {
if (!(inSISREG(p3da) & 0x08)) break;
}
for (i=0; i<0xFFFF; i++) {
- if (inSISREG(p3da) & 0x08) break;
+ if (inSISREG(p3da) & 0x09 == 9) break;
}
}
@@ -665,40 +662,28 @@ EnableBridge(CARD16 BaseAddr)
temp1 = 0x20;
}
}
-#if 0
LongWait(BaseAddr+0x5A);
- VBLongWait(BaseAddr);
-#endif
setSISIDXREG(BaseAddr+SROFFSET, 0x32, ~0x20, temp1);
-#if 0
LongWait(BaseAddr+0x5A);
- VBLongWait(BaseAddr);
-#endif
orSISIDXREG(BaseAddr+SROFFSET, 0x1E, 0x20);
LongWait(BaseAddr+0x5A);
- LongWait(BaseAddr+0x5A);
- LongWait(BaseAddr+0x5A);
-#if 0
- VBLongWait(BaseAddr);
-#endif
setSISIDXREG(part2_base, 0, ~0xE0, 0x20);
LongWait(BaseAddr+0x5A);
- LongWait(BaseAddr+0x5A);
- LongWait(BaseAddr+0x5A);
-#if 0
- VBLongWait(BaseAddr);
-#endif
andSISIDXREG(BaseAddr+SROFFSET, 1, ~0x20); /* DisplayOn */
LongWait(BaseAddr+0x5A);
+ andSISIDXREG(part2_base, 0, ~0xE0);
+ LongWait(BaseAddr+0x5A);
+ setSISIDXREG(part2_base, 0, ~0xE0, 0x20);
+
+/*
LongWait(BaseAddr+0x5A);
LongWait(BaseAddr+0x5A);
-#if 0
VBLongWait(BaseAddr);
-#endif
+*/
}
void
@@ -1447,21 +1432,3 @@ GetVCLK2Ptr(CARD16 BaseAddr, CARD8 *ROMAddr, CARD16 ModeNo)
VCLKTableBase = *(CARD16 *)(ROMAddr+0x208);
return (ROMAddr + VCLKTableBase + index*4);
}
-
-void
-SetGroup5(CARD16 BaseAddr, CARD8 *ROMAddr)
-{
- ErrorF("Enter Group5()\n");
- if (ModeType != MODE_VGA)
- return;
- if (VBInfo & (SET_IN_SLAVE_MODE | DISABLE_LOAD_CRT2DAC))
- return;
-
- ErrorF("Group5 begin to write DAC\n");
- EnableCRT2(BaseAddr);
- ErrorF("Group5 end to write DAC\n");
-#if 0
- LoadDAC();
-#endif
- ErrorF("Leave SetGroup5()\n");
-}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c
index 667961867..687a14086 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c
@@ -25,7 +25,7 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
* David Thomas <davtom@dream.org.uk>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.2 2000/02/14 19:20:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_cursor.c,v 1.3 2000/03/31 20:13:36 dawes Exp $ */
#include "xf86.h"
#include "xf86PciInfo.h"
@@ -39,12 +39,12 @@
static void
SiSShowCursor(ScrnInfoPtr pScrn)
{
- unsigned char temp;
+ unsigned char temp;
- outw(VGA_SEQ_INDEX, 0x8605); /* Unlock Registers */
- outb(VGA_SEQ_INDEX, 0x06);
- temp = inb(VGA_SEQ_DATA) | 0x40;
- outb(VGA_SEQ_DATA, temp);
+ outw(VGA_SEQ_INDEX, 0x8605); /* Unlock Registers */
+ outb(VGA_SEQ_INDEX, 0x06);
+ temp = inb(VGA_SEQ_DATA) | 0x40;
+ outb(VGA_SEQ_DATA, temp);
}
static void
@@ -53,7 +53,7 @@ SiS300ShowCursor(ScrnInfoPtr pScrn)
SISPtr pSiS = SISPTR(pScrn);
sis300EnableHWCursor()
- if (pSiS->VBFlags) {
+ if (pSiS->VBFlags & CRT2_ENABLE) {
sis301EnableHWCursor();
}
}
@@ -61,12 +61,12 @@ SiS300ShowCursor(ScrnInfoPtr pScrn)
static void
SiSHideCursor(ScrnInfoPtr pScrn)
{
- unsigned char temp;
+ unsigned char temp;
- outw(VGA_SEQ_INDEX, 0x8605); /* Unlock Registers */
- outb(VGA_SEQ_INDEX, 0x06);
- temp = inb(VGA_SEQ_DATA) & 0xBF;
- outb(VGA_SEQ_DATA, temp);
+ outw(VGA_SEQ_INDEX, 0x8605); /* Unlock Registers */
+ outb(VGA_SEQ_INDEX, 0x06);
+ temp = inb(VGA_SEQ_DATA) & 0xBF;
+ outb(VGA_SEQ_DATA, temp);
}
static void
@@ -75,7 +75,7 @@ SiS300HideCursor(ScrnInfoPtr pScrn)
SISPtr pSiS = SISPTR(pScrn);
sis300DisableHWCursor()
- if (pSiS->VBFlags) {
+ if (pSiS->VBFlags & CRT2_ENABLE) {
sis301DisableHWCursor()
}
}
@@ -125,8 +125,8 @@ SiS300SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
}
sis300SetCursorPositionX(x, x_preset)
sis300SetCursorPositionY(y, y_preset)
- if (pSiS->VBFlags) {
- sis301SetCursorPositionX(x, x_preset)
+ if (pSiS->VBFlags & CRT2_ENABLE) {
+ sis301SetCursorPositionX(x+13, x_preset)
sis301SetCursorPositionY(y, y_preset)
}
}
@@ -161,7 +161,7 @@ SiS300SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
sis300SetCursorBGColor(bg)
sis300SetCursorFGColor(fg)
- if (pSiS->VBFlags) {
+ if (pSiS->VBFlags & CRT2_ENABLE) {
sis301SetCursorBGColor(bg)
sis301SetCursorFGColor(fg)
}
@@ -187,19 +187,19 @@ SiSLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
/* if set, store the bit [22] to SR3E */
if (cursor_addr & 0x1000) {
outb(VGA_SEQ_INDEX, 0x3E);
- temp = inb(VGA_SEQ_DATA) | 0x04;
- outb(VGA_SEQ_DATA, temp);
+ temp = inb(VGA_SEQ_DATA) | 0x04;
+ outb(VGA_SEQ_DATA, temp);
}
/* set HW cursor pattern, use pattern 0xF */
outb(VGA_SEQ_INDEX, 0x1E);
- temp = inb(VGA_SEQ_DATA) | 0xF0;
- outb(VGA_SEQ_DATA, temp);
+ temp = inb(VGA_SEQ_DATA) | 0xF0;
+ outb(VGA_SEQ_DATA, temp);
/* disable the hardware cursor side pattern */
outb(VGA_SEQ_INDEX, 0x1E);
- temp = inb(VGA_SEQ_DATA) & 0xF7;
- outb(VGA_SEQ_DATA, temp);
+ temp = inb(VGA_SEQ_DATA) & 0xF7;
+ outb(VGA_SEQ_DATA, temp);
}
static void
@@ -216,7 +216,7 @@ SiS300LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
memcpy((unsigned char *)pSiS->FbBase + cursor_addr * 1024, src, 1024);
sis300SetCursorAddress(cursor_addr)
sis300SetCursorPatternSelect(0)
- if (pSiS->VBFlags) {
+ if (pSiS->VBFlags & CRT2_ENABLE) {
sis301SetCursorAddress(cursor_addr)
sis301SetCursorPatternSelect(0)
}
@@ -232,13 +232,17 @@ static Bool
SiS300UseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- SISPtr pSiS = SISPTR(pScrn);
+ DisplayModePtr mode = pScrn->currentMode;
+ SISPtr pSiS = SISPTR(pScrn);
- if ( (pSiS->Chipset==PCI_CHIP_SIS540) ||
- !(pScrn->currentMode->Flags & V_INTERLACE) )
- return TRUE;
- else
- return FALSE;
+ switch (pSiS->Chipset) {
+ case PCI_CHIP_SIS300:
+ case PCI_CHIP_SIS630:
+ if (mode->Flags & V_INTERLACE)
+ return FALSE;
+ break;
+ }
+ return TRUE;
}
#ifdef IMP_REALIZE_CURSOR
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c
index 88eca6366..06cc9c3f0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c
@@ -25,7 +25,7 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
* David Thomas <davtom@dream.org.uk>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.13 2000/02/12 20:45:35 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dac.c,v 1.14 2000/03/31 20:13:36 dawes Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -40,6 +40,29 @@
#include "sis_regs.h"
#include "sis_bios.h"
+static void SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg);
+static void SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg);
+
+static void SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg);
+static void SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg);
+static void SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg);
+static void SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg);
+
+static void SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors,
+ int *indicies, LOCO *colors, VisualPtr pVisual);
+
+static void SiS300Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+static void SiS301Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+static void SiS630Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+static void SiS530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+static void SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High);
+
+static unsigned int GetClock(int Num, int DeNum, int PostScale, int Div);
int
compute_vclk(
@@ -322,16 +345,53 @@ SiSCalcClock(ScrnInfoPtr pScrn, int clock, int max_VLD, unsigned int *vclk)
}
-void
-SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)
+static void
+SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)
{
SISPtr pSiS = SISPTR(pScrn);
int vgaIOBase;
int i,max;
PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
- "SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"));
+ "SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"));
+
+ vgaHWGetIOBase(VGAHWPTR(pScrn));
+ vgaIOBase = VGAHWPTR(pScrn)->IOBase;
+
+ outw(VGA_SEQ_INDEX, 0x8605);
+
+ switch (pSiS->Chipset) {
+ case PCI_CHIP_SIS5597:
+ max=0x39;
+ break;
+ case PCI_CHIP_SIS6326:
+ case PCI_CHIP_SIS530:
+ max=0x3F;
+ break;
+ default:
+ max=0x37;
+ break;
+ }
+
+ for (i = 0x06; i <= max; i++) {
+ outb(VGA_SEQ_INDEX, i);
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA));
+ sisReg->sisRegs3C4[i] = inb(VGA_SEQ_DATA);
+ }
+ sisReg->sisRegs3C2 = inb(0x3CC);
+}
+
+static void
+SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ int vgaIOBase;
+ int i,max;
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n");
vgaHWGetIOBase(VGAHWPTR(pScrn));
vgaIOBase = VGAHWPTR(pScrn)->IOBase;
@@ -348,91 +408,127 @@ SiSRestore(ScrnInfoPtr pScrn, SISRegPtr sisReg)
case PCI_CHIP_SIS530:
max=0x3F;
break;
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- max=0x3D;
- break;
default:
max=0x37;
break;
}
- if ((pSiS->Chipset == PCI_CHIP_SIS630) && (sisReg->sisRegs3C4[0x1e] & 0x40))
- outw(VGA_SEQ_INDEX, sisReg->sisRegs3C4[0x20] << 8 | 0x20);
-
for (i = 0x06; i <= max; i++) {
- if (i== 0x1E || i==0x32) continue;
outb(VGA_SEQ_INDEX,i);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4,
"XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA));
+
outb(VGA_SEQ_DATA,sisReg->sisRegs3C4[i]);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4,
"Restore to - %02X Read after - %02X\n",
sisReg->sisRegs3C4[i], inb(VGA_SEQ_DATA));
}
- if ((pSiS->Chipset == PCI_CHIP_SIS300 || pSiS->Chipset == PCI_CHIP_SIS630 ||
- pSiS->Chipset == PCI_CHIP_SIS540) && (sisReg->sisRegs3C4[0x1e] & 0x40))
- SiSInitializeAccelerator(pScrn);
-
-
- outw(vgaIOBase + 4, (sisReg->sisRegs3x4[Offset] << 8) | Offset);
-
- outb(0x3C2, sisReg->sisRegs3C2[0x00]);
+ outb(0x3C2, sisReg->sisRegs3C2);
/* MemClock needs this to take effect */
-
- outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */
- outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */
+
+ outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */
+ outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */
}
-void
-SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)
+static void
+SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)
{
SISPtr pSiS = SISPTR(pScrn);
int vgaIOBase;
int i,max;
- unsigned char temp;
PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
- "SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"));
+ "SiS300Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n"));
vgaHWGetIOBase(VGAHWPTR(pScrn));
vgaIOBase = VGAHWPTR(pScrn)->IOBase;
- outb(VGA_SEQ_INDEX, 0x05); /* Unlock Registers */
- temp = inb(VGA_SEQ_DATA);
outw(VGA_SEQ_INDEX, 0x8605);
- switch (pSiS->Chipset) {
- case PCI_CHIP_SIS5597:
- max=0x39;
- break;
- case PCI_CHIP_SIS6326:
- case PCI_CHIP_SIS530:
- max=0x3F;
- break;
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- max=0x3D;
- break;
- default:
- max=0x37;
- break;
- }
+ max=0x3D;
for (i = 0x06; i <= max; i++) {
outb(VGA_SEQ_INDEX, i);
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
"XR%02X Contents - %02X \n", i, inb(VGA_SEQ_DATA));
sisReg->sisRegs3C4[i] = inb(VGA_SEQ_DATA);
+ }
+
+ for (i=0x19; i<0x40; i++) {
+ inSISIDXREG(pSiS->RelIO+CROFFSET, i, sisReg->sisRegs3D4[i]);
+ }
+
+ sisReg->sisRegs3C2 = inb(0x3CC);
+
+ if (pSiS->VBFlags & CRT2_ENABLE)
+ (*pSiS->SiSSave2)(pScrn, sisReg);
+}
+
+static void
+SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ int vgaIOBase;
+ int i,max, temp;
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "SiS300Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)\n");
+
+ vgaHWGetIOBase(VGAHWPTR(pScrn));
+ vgaIOBase = VGAHWPTR(pScrn)->IOBase;
+
+ outw(VGA_SEQ_INDEX, 0x8605);
+ inSISIDXREG(VGA_SEQ_INDEX, 0x1E, temp);
+ if (temp & 0x42) {
+ while ( (MMIO_IN16(pSiS->IOBase, 0x8242) & 0xE000) != 0xE000){};
+ }
+
+ max=0x3D;
+ for (i = 0x19; i < 0x40; i++) {
+ outSISIDXREG(pSiS->RelIO+CROFFSET, i, sisReg->sisRegs3D4[i]);
+ }
+ if (pSiS->Chipset != PCI_CHIP_SIS300) {
+ outSISIDXREG(pSiS->RelIO+CROFFSET, 0x1A, sisReg->sisRegs3D4[0x19]);
+ outSISIDXREG(pSiS->RelIO+CROFFSET, 0x19, sisReg->sisRegs3D4[0x1A]);
+ }
+ if ((pSiS->Chipset == PCI_CHIP_SIS630) && (sisReg->sisRegs3C4[0x1e] & 0x40))
+ outw(VGA_SEQ_INDEX, sisReg->sisRegs3C4[0x20] << 8 | 0x20);
+
+ for (i = 0x06; i <= max; i++) {
+ outb(VGA_SEQ_INDEX,i);
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4,
+ "XR%X Contents - %02X ", i, inb(VGA_SEQ_DATA));
+
+ outb(VGA_SEQ_DATA,sisReg->sisRegs3C4[i]);
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO,4,
+ "Restore to - %02X Read after - %02X\n",
+ sisReg->sisRegs3C4[i], inb(VGA_SEQ_DATA));
+ }
+ if (pSiS->VBFlags & CRT2_ENABLE) { /* For SiS301 */
+ (*pSiS->SiSRestore2)(pScrn, sisReg);
}
- /* for SiS301 */
+
+ outb(0x3C2, sisReg->sisRegs3C2);
+
+ /* MemClock needs this to take effect */
+
+ outw(VGA_SEQ_INDEX, 0x0100); /* Synchronous Reset */
+ outw(VGA_SEQ_INDEX, 0x0300); /* End Reset */
+}
+
+static void
+SiS301Save(ScrnInfoPtr pScrn, SISRegPtr sisReg)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ int i;
+
+ /* for SiS301 only */
for (i=0; i<0x29; i++) {
inSISIDXREG(pSiS->RelIO+4, i, sisReg->VBPart1[i]);
}
@@ -445,13 +541,46 @@ SiSSave(ScrnInfoPtr pScrn, SISRegPtr sisReg)
for (i=0; i<0x1C; i++) {
inSISIDXREG(pSiS->RelIO+0x14, i, sisReg->VBPart4[i]);
}
+ sisReg->VBPart2[0] &= ~0x20; /* Disable VB Processor */
+ sisReg->sisRegs3C4[0x32] &= ~0x20; /* Disable Lock Mode */
+}
- outb(vgaIOBase + 4, Offset);
- sisReg->sisRegs3x4[Offset] = inb(VGA_SEQ_DATA);
-
- sisReg->sisRegs3C2[0x00] = inb(0x3CC);
-
- outw(VGA_SEQ_INDEX, (temp << 8) | 0x05); /* Relock Registers */
+static void
+SiS301Restore(ScrnInfoPtr pScrn, SISRegPtr sisReg)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+
+ DisableBridge(pSiS->RelIO);
+ UnLockCRT2(pSiS->RelIO);
+
+ /* SetCRT2ModeRegs() */
+ outSISIDXREG(pSiS->RelIO+0x04, 4, 0);
+ outSISIDXREG(pSiS->RelIO+0x04, 5, 0);
+ outSISIDXREG(pSiS->RelIO+0x04, 6, 0);
+ outSISIDXREG(pSiS->RelIO+0x04, 0, sisReg->VBPart1[0]);
+ outSISIDXREG(pSiS->RelIO+0x04, 1, sisReg->VBPart1[1]);
+ outSISIDXREG(pSiS->RelIO+0x14, 0x0D, sisReg->VBPart4[0x0D]);
+ outSISIDXREG(pSiS->RelIO+0x14, 0x0C, sisReg->VBPart4[0x0C]);
+
+ if (!(sisReg->sisRegs3D4[0x30] & 0x03) &&
+ (sisReg->sisRegs3D4[0x31] & 0x20)) { /* disable CRT2 */
+ LockCRT2(pSiS->RelIO);
+ return;
+ }
+ SetBlock(pSiS->RelIO+0x04, 0x02, 0x23, &(sisReg->VBPart1[0x02]));
+ SetBlock(pSiS->RelIO+0x10, 0x00, 0x45, &(sisReg->VBPart2[0x00]));
+ SetBlock(pSiS->RelIO+0x12, 0x00, 0x3E, &(sisReg->VBPart3[0x00]));
+ SetBlock(pSiS->RelIO+0x14, 0x0E, 0x11, &(sisReg->VBPart4[0x0E]));
+ SetBlock(pSiS->RelIO+0x14, 0x13, 0x1B, &(sisReg->VBPart4[0x13]));
+
+ outSISIDXREG(pSiS->RelIO+0x14, 0x0A, 1);
+ outSISIDXREG(pSiS->RelIO+0x14, 0x0B, sisReg->VBPart4[0x0B]);
+ outSISIDXREG(pSiS->RelIO+0x14, 0x0A, sisReg->VBPart4[0x0A]);
+ outSISIDXREG(pSiS->RelIO+0x14, 0x12, 0);
+ outSISIDXREG(pSiS->RelIO+0x14, 0x12, sisReg->VBPart4[0x12]);
+
+ EnableBridge(pSiS->RelIO);
+ LockCRT2(pSiS->RelIO);
}
unsigned int
@@ -576,18 +705,328 @@ const float magic630[4] = { 1.441177, 1.441177, 2.588235, 1.441177 };
int sis300MemBandWidth(ScrnInfoPtr pScrn)
{
SISPtr pSiS = SISPTR(pScrn);
- int bus = 64;
+ int bus = pSiS->BusWidth;
int mclk = pSiS->MemClock;
int bpp = pScrn->bitsPerPixel;
- float magic;
+ float magic, total;
if (pSiS->Chipset==PCI_CHIP_SIS300)
magic = magic300[bus/64];
else
magic = magic630[bus/64];
-ErrorF("mclk: %d, bus: %d, magic: %g, bpp: %d\n", mclk, bus, magic, bpp);
- return (int)(mclk*bus/magic/bpp);
+ PDEBUG(ErrorF("mclk: %d, bus: %d, magic: %g, bpp: %d\n",
+ mclk, bus, magic, bpp));
+
+ total = mclk*bus/bpp;
+ ErrorF("Total Adapter Bandwidth is %gM\n", total/1000);
+ if (pSiS->VBFlags & CRT2_ENABLE) {
+ if (total/2 > 540000)
+ total = total - 540000;
+ else
+ total = total/2;
+ ErrorF("CRT1 Used Bandwidth is %gM\n", total/1000);
+ }
+
+ return (int)(total/magic);
+}
+
+void
+SISLoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors,
+ VisualPtr pVisual)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ int i, index;
+
+ PDEBUG(ErrorF("SISLoadPalette(%d)\n", numColors));
+ for (i=0; i<numColors; i++) {
+ index = indicies[i];
+ outSISREG(0x3c8, index);
+ outSISREG(0x3c9, colors[index].red >> 2);
+ outSISREG(0x3c9, colors[index].green >> 2);
+ outSISREG(0x3c9, colors[index].blue >> 2);
+ }
+ if (pSiS->VBFlags & CRT2_ENABLE) {
+ (*pSiS->LoadCRT2Palette)(pScrn, numColors, indicies,
+ colors, pVisual);
+ }
+}
+static void
+SiS301LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies,
+ LOCO *colors, VisualPtr pVisual)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ int i, index;
+
+ PDEBUG(ErrorF("SiS301LoadPalette(%d)\n", numColors));
+ for (i=0; i<numColors; i++) {
+ index = indicies[i];
+ outSISREG(pSiS->RelIO+0x16, index);
+ outSISREG(pSiS->RelIO+0x17, colors[index].red);
+ outSISREG(pSiS->RelIO+0x17, colors[index].green);
+ outSISREG(pSiS->RelIO+0x17, colors[index].blue);
+ }
+}
+
+
+struct QConfig {
+ int GT;
+ int QC;
+};
+
+static struct QConfig qconfig[20] = {
+ {1, 0x0}, {1, 0x2}, {1, 0x4}, {1, 0x6}, {1, 0x8},
+ {1, 0x3}, {1, 0x5}, {1, 0x7}, {1, 0x9}, {1, 0xb},
+ {0, 0x0}, {0, 0x2}, {0, 0x4}, {0, 0x6}, {0, 0x8},
+ {0, 0x3}, {0, 0x5}, {0, 0x7}, {0, 0x9}, {0, 0xb}};
+
+static int cycleA[20][2] = {
+ {88,88}, {80,80}, {78,78}, {72,72}, {70,70},
+ {79,72}, {77,70}, {71,64}, {69,62}, {49,44},
+ {73,78}, {65,70}, {63,68}, {57,62}, {55,60},
+ {64,62}, {62,60}, {56,54}, {54,52}, {34,34}};
+
+static void
+SiS630Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ int mclk = pSiS->MemClock;
+ int vclk = mode->Clock;
+ int bpp = pScrn->bitsPerPixel/8;
+ int buswidth = pSiS->BusWidth;
+ CARD32 temp;
+ PCITAG NBridge;
+ int cyclea;
+ int low, lowa;
+
+ int i, j;
+
+
+ if (!bpp) bpp = 1;
+
+ i = 0;
+ j = buswidth/128;
+
+ while (1) {
+#ifdef DEBUG
+ ErrorF("Config %d GT = %d, QC = %x, CycleA = %d\n",
+ i, qconfig[i].GT, qconfig[i].QC, cycleA[i][j]);
+#endif
+ cyclea = cycleA[i][j];
+ lowa = cyclea * vclk * bpp;
+ lowa = (lowa + (mclk-1)) / mclk;
+ lowa = (lowa + 15) / 16;
+ low = lowa + 1;
+ if (low <= 0x13)
+ break;
+ else
+ if (i < 19)
+ i++;
+ else {
+ low = 0x13;
+ PDEBUG(ErrorF("This mode may has threshold "
+ "problem and had better removed\n"));
+ break;
+ }
+ }
+ PDEBUG(ErrorF("Using Config %d with CycleA = %d\n", i, cyclea));
+ *Low = low;
+ if (lowa+4 > 15)
+ *High = 0x0F;
+ else
+ *High = lowa+4;
+
+ /* write PCI configuration space */
+ NBridge = pciTag(0, 0, 0);
+ temp = pciReadLong(NBridge, 0x50);
+ temp &= 0xF0FFFFFF;
+ temp |= qconfig[i].QC << 24;
+ pciWriteLong(NBridge, 0x50, temp);
+
+ temp = pciReadLong(NBridge, 0xA0);
+ temp &= 0xF0FFFFFF;
+ temp |= qconfig[i].GT << 24;
+ pciWriteLong(NBridge, 0xA0, temp);
+
+
+}
+
+struct funcargc {
+ char base;
+ char inc;
+};
+
+static struct funcargc funca[12] = {
+ {61, 3}, {52, 5}, {68, 7}, {100, 11},
+ {43, 3}, {42, 5}, {54, 7}, {78, 11},
+ {34, 3}, {37, 5}, {47, 7}, {67, 11}};
+static struct funcargc funcb[12] = {
+ {81, 4}, {72, 6}, {88, 8}, {120, 12},
+ {55, 4}, {54, 6}, {66, 8}, {90, 12},
+ {42, 4}, {45, 6}, {55, 8}, {75, 12}};
+static char timing[8] = {1, 2, 2, 3, 0, 1, 1, 2};
+
+static void
+SiS300Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ SISRegPtr pReg = &pSiS->ModeReg;
+ int mclk = pSiS->MemClock;
+ int vclk = mode->Clock;
+ int bpp = pScrn->bitsPerPixel/8;
+ int lowa, lowb, low;
+ struct funcargc *p;
+ unsigned int i, j;
+
+ pReg->sisRegs3C4[0x16] = pSiS->SavedReg.sisRegs3C4[0x16];
+
+ if (!bpp) bpp = 1;
+
+ do {
+ i = GETBITSTR(pReg->sisRegs3C4[0x18], 6:5, 2:1) |
+ GETBITS(pReg->sisRegs3C4[0x18], 1:1);
+ j = GETBITSTR(pReg->sisRegs3C4[0x14], 7:6, 3:2) |
+ GETBITS(pReg->sisRegs3C4[0x16], 7:6);
+ p = &funca[j];
+
+ lowa = (p->base + p->inc*timing[i])*vclk*bpp;
+ lowa = (lowa + (mclk-1)) / mclk;
+ lowa = (lowa + 15)/16;
+
+ p = &funcb[j];
+ lowb = (p->base + p->inc*timing[i])*vclk*bpp;
+ lowb = (lowb + (mclk-1)) / mclk;
+ lowb = (lowb + 15)/16;
+
+ if (lowb < 4)
+ lowb = 0;
+ else
+ lowb -= 4;
+
+ low = (lowa > lowb)? lowa: lowb;
+
+ low++;
+
+ if (low <= 0x13) {
+ break;
+ } else {
+ i = GETBITS(pReg->sisRegs3C4[0x16], 7:6);
+ if (!i) {
+ low = 0x13;
+ break;
+ } else {
+ i--;
+ pReg->sisRegs3C4[0x16] &= 0x3C;
+ pReg->sisRegs3C4[0x16] |= (i << 6);
+ }
+ }
+ } while (1);
+
+ *Low = low;
+ if (low+3 > 15)
+ *High = 0x0F;
+ else
+ *High = low+3;
+}
+
+static void
+SiS301Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ SISRegPtr sisReg = &pSiS->ModeReg;
+ unsigned int delay;
+ unsigned int mclk = pSiS->MemClock/1000;
+ unsigned int dclk = mode->Clock/1000;
+ unsigned int buswidth = pSiS->BusWidth/8;
+ unsigned int bpp = (pScrn->bitsPerPixel+7)/8;
+ unsigned int tclk;
+ int i, GT, QC, idx, timing_idx, CRT1RP;
+ int Num, DeNum, PostScale, Div; /* for clock gen */
+ PCITAG NBridge;
+
+ /* Get Delay */
+ if (pSiS->Chipset == PCI_CHIP_SIS300) {
+ idx = GETBITS(sisReg->sisRegs3C4[0x16], 7:6) |
+ GETBITSTR(sisReg->sisRegs3C4[0x14], 7:6, 3:2);
+ timing_idx = GETBITS(sisReg->sisRegs3C4[0x18], 0:0) |
+ GETBITSTR(sisReg->sisRegs3C4[0x18], 6:5, 2:1);
+ delay = funcb[idx].base + funcb[idx].inc * timing[timing_idx];
+ } else {
+ NBridge = pciTag(0,0,0);
+ QC = GETBITS(pciReadLong(NBridge, 0x50), 27:24);
+ GT = GETBITS(pciReadLong(NBridge, 0xA0), 27:24);
+ for (i=0; i<20; i++) {
+ if ((qconfig[i].QC == QC) && (qconfig[i].GT==GT))
+ break;
+ }
+ if (buswidth == 8) /* 64-bits */
+ delay = cycleA[i][0]+20;
+ else
+ delay = cycleA[i][1]+15;
+ }
+ /* Get TCLK */
+ Num = GETBITS(sisReg->VBPart4[0x0A], 6:0);
+ DeNum = GETBITS(sisReg->VBPart4[0x0B], 4:0);
+ PostScale = GETBITS(sisReg->VBPart4[0x0B], 7:5);
+ Div = GETBITS(sisReg->VBPart4[0x0A], 7:7);
+ tclk = GetClock(Num, DeNum, PostScale, Div);
+
+ CRT1RP = delay +
+ (int)(28*16/(buswidth - 1.0*dclk*bpp/mclk) + 0.9999);
+ *Low = 1.0*CRT1RP*tclk*bpp/(16*mclk) + 0.9999; /* Roundup */
+
+ if (*Low < 6) *Low = 6;
+ if (*Low > 0x14) *Low = 0x14;
+
+ *High = 0x16;
+ if (pSiS->Chipset == PCI_CHIP_SIS300) {
+ if (*Low <= 0x0F)
+ *High = 0x13;
+ }
+}
+
+static void
+SiS530Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+ unsigned int factor, z;
+ unsigned int vclk = mode->Clock,
+ bpp = pScrn->bitsPerPixel,
+ mclk = pSiS->MemClock,
+ buswidth = pSiS->BusWidth;
+
+ if (pSiS->Flags & UMA)
+ factor = 0x60;
+ else
+ factor = 0x30;
+ z = factor * vclk * bpp;
+ z = z / mclk / buswidth;
+ *Low = (z+1)/2 + 4;
+ if (*Low > 0x1F)
+ *Low = 0x1F;
+
+ *High = 0x1F;
+}
+
+static void
+SiSThreshold(ScrnInfoPtr pScrn, DisplayModePtr mode,
+ unsigned short *Low, unsigned short *High)
+{
+
+}
+
+static unsigned int
+GetClock(int Num, int DeNum, int PostScale, int Div)
+{
+ Num++;
+ DeNum++;
+ Div++;
+ PostScale = (GETBITS(PostScale, 1:0)+1) * (GETBITS(PostScale, 2:2)+1);
+ return 14318.18*Num*Div/(DeNum*PostScale);
}
void SiSIODump(ScrnInfoPtr pScrn)
@@ -673,3 +1112,49 @@ void SiSIODump(ScrnInfoPtr pScrn)
outw(0x3c4, SR5State << 8 | 0x05);
}
+void
+SISDACPreInit(ScrnInfoPtr pScrn)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+
+ switch (pSiS->Chipset) {
+ case PCI_CHIP_SIS630:
+ case PCI_CHIP_SIS540:
+ pSiS->MaxClock = sis300MemBandWidth(pScrn);
+ pSiS->SiSSave = SiS300Save;
+ pSiS->SiSSave2 = SiS301Save;
+ pSiS->SiSRestore = SiS300Restore;
+ pSiS->SiSRestore2 = SiS301Restore;
+ pSiS->LoadCRT2Palette = SiS301LoadPalette;
+ pSiS->SetThreshold = SiS630Threshold;
+ pSiS->SetThreshold2 = SiS301Threshold;
+ break;
+ case PCI_CHIP_SIS300:
+ pSiS->MaxClock = sis300MemBandWidth(pScrn);
+ pSiS->SiSSave = SiS300Save;
+ pSiS->SiSSave2 = SiS301Save;
+ pSiS->SiSRestore = SiS300Restore;
+ pSiS->SiSRestore2 = SiS301Restore;
+ pSiS->LoadCRT2Palette = SiS301LoadPalette;
+ pSiS->SetThreshold = SiS300Threshold;
+ pSiS->SetThreshold2 = SiS301Threshold;
+ break;
+ case PCI_CHIP_SIS530:
+ pSiS->MaxClock = 230000; /* Guest */
+ pSiS->SiSRestore = SiSRestore;
+ pSiS->SiSSave = SiSSave;
+ pSiS->SetThreshold = SiS530Threshold;
+ break;
+ case PCI_CHIP_SIS6326:
+ pSiS->MaxClock = 175000; /* Guest */
+ pSiS->SiSRestore = SiSRestore;
+ pSiS->SiSSave = SiSSave;
+ pSiS->SetThreshold = SiSThreshold;
+ break;
+ default:
+ pSiS->MaxClock = 135000; /* Guest */
+ pSiS->SiSRestore = SiSRestore;
+ pSiS->SiSSave = SiSSave;
+ pSiS->SetThreshold = SiSThreshold;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c
new file mode 100644
index 000000000..fe29521f0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
+ *
+ * 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>
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_dga.c,v 1.1 2000/06/26 10:26:15 alanh Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "xf86PciInfo.h"
+#include "xaa.h"
+#include "xaalocal.h"
+#include "sis.h"
+#include "sis_regs.h"
+#include "dgaproc.h"
+
+static Bool SIS_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
+ int *, int *, int *);
+static Bool SIS_SetMode(ScrnInfoPtr, DGAModePtr);
+static void SIS_Sync(ScrnInfoPtr);
+static int SIS_GetViewport(ScrnInfoPtr);
+static void SIS_SetViewport(ScrnInfoPtr, int, int, int);
+static void SIS_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
+static void SIS_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
+static void SIS_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int,
+ unsigned long);
+
+static
+DGAFunctionRec SISDGAFuncs = {
+ SIS_OpenFramebuffer,
+ NULL,
+ SIS_SetMode,
+ SIS_SetViewport,
+ SIS_GetViewport,
+ SIS_Sync,
+ SIS_FillRect,
+ SIS_BlitRect,
+#if 0
+ SIS_BlitTransRect
+#else
+ NULL
+#endif
+};
+
+Bool
+SISDGAInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ SISPtr pSIS = SISPTR(pScrn);
+ DGAModePtr modes = NULL, newmodes = NULL, currentMode;
+ DisplayModePtr pMode, firstMode;
+ int Bpp = pScrn->bitsPerPixel >> 3;
+ int num = 0;
+ Bool oneMore;
+
+ pMode = firstMode = pScrn->modes;
+
+ while(pMode) {
+
+ if(0 /*pScrn->displayWidth != pMode->HDisplay*/) {
+ newmodes = xrealloc(modes, (num + 2) * sizeof(DGAModeRec));
+ oneMore = TRUE;
+ } else {
+ newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
+ oneMore = FALSE;
+ }
+
+ if(!newmodes) {
+ xfree(modes);
+ return FALSE;
+ }
+ modes = newmodes;
+
+SECOND_PASS:
+
+ currentMode = modes + num;
+ num++;
+
+ currentMode->mode = pMode;
+ currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
+ currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT;
+ if(pMode->Flags & V_DBLSCAN)
+ currentMode->flags |= DGA_DOUBLESCAN;
+ if(pMode->Flags & V_INTERLACE)
+ currentMode->flags |= DGA_INTERLACED;
+ currentMode->byteOrder = pScrn->imageByteOrder;
+ currentMode->depth = pScrn->depth;
+ currentMode->bitsPerPixel = pScrn->bitsPerPixel;
+ currentMode->red_mask = pScrn->mask.red;
+ currentMode->green_mask = pScrn->mask.green;
+ currentMode->blue_mask = pScrn->mask.blue;
+ currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
+ currentMode->viewportWidth = pMode->HDisplay;
+ currentMode->viewportHeight = pMode->VDisplay;
+ currentMode->xViewportStep = 1;
+ currentMode->yViewportStep = 1;
+ currentMode->viewportFlags = DGA_FLIP_RETRACE;
+ currentMode->offset = 0;
+ currentMode->address = pSIS->FbBase;
+
+ if(oneMore) { /* first one is narrow width */
+ currentMode->bytesPerScanline = ((pMode->HDisplay * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pMode->HDisplay;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ oneMore = FALSE;
+ goto SECOND_PASS;
+ } else {
+ currentMode->bytesPerScanline =
+ ((pScrn->displayWidth * Bpp) + 3) & ~3L;
+ currentMode->imageWidth = pScrn->displayWidth;
+ currentMode->imageHeight = pMode->VDisplay;
+ currentMode->pixmapWidth = currentMode->imageWidth;
+ currentMode->pixmapHeight = currentMode->imageHeight;
+ currentMode->maxViewportX = currentMode->imageWidth -
+ currentMode->viewportWidth;
+ /* this might need to get clamped to some maximum */
+ currentMode->maxViewportY = currentMode->imageHeight -
+ currentMode->viewportHeight;
+ }
+
+ pMode = pMode->next;
+ if(pMode == firstMode)
+ break;
+ }
+
+ pSIS->numDGAModes = num;
+ pSIS->DGAModes = modes;
+
+ return DGAInit(pScreen, &SISDGAFuncs, modes, num);
+}
+
+
+static Bool
+SIS_SetMode(
+ ScrnInfoPtr pScrn,
+ DGAModePtr pMode
+){
+ static int OldDisplayWidth[MAXSCREENS];
+ int index = pScrn->pScreen->myNum;
+ SISPtr pSIS = SISPTR(pScrn);
+
+ if(!pMode) { /* restore the original mode */
+ /* put the ScreenParameters back */
+
+ pScrn->displayWidth = OldDisplayWidth[index];
+
+ SISSwitchMode(index, pScrn->currentMode, 0);
+ pSIS->DGAactive = FALSE;
+ } else {
+ if(!pSIS->DGAactive) { /* save the old parameters */
+ OldDisplayWidth[index] = pScrn->displayWidth;
+
+ pSIS->DGAactive = TRUE;
+ }
+
+ pScrn->displayWidth = pMode->bytesPerScanline /
+ (pMode->bitsPerPixel >> 3);
+
+ SISSwitchMode(index, pMode->mode, 0);
+ }
+
+ return TRUE;
+}
+
+static int
+SIS_GetViewport(
+ ScrnInfoPtr pScrn
+){
+ SISPtr pSIS = SISPTR(pScrn);
+
+ return pSIS->DGAViewportStatus;
+}
+
+static void
+SIS_SetViewport(
+ ScrnInfoPtr pScrn,
+ int x, int y,
+ int flags
+){
+ SISPtr pSIS = SISPTR(pScrn);
+
+ SISAdjustFrame(pScrn->pScreen->myNum, x, y, flags);
+ pSIS->DGAViewportStatus = 0; /* SISAdjustFrame loops until finished */
+}
+
+static void
+SIS_FillRect (
+ ScrnInfoPtr pScrn,
+ int x, int y, int w, int h,
+ unsigned long color
+){
+ SISPtr pSIS = SISPTR(pScrn);
+
+ if(pSIS->AccelInfoPtr) {
+ (*pSIS->AccelInfoPtr->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
+ (*pSIS->AccelInfoPtr->SubsequentSolidFillRect)(pScrn, x, y, w, h);
+ SET_SYNC_FLAG(pSIS->AccelInfoPtr);
+ }
+}
+
+static void
+SIS_Sync(
+ ScrnInfoPtr pScrn
+){
+ SISPtr pSIS = SISPTR(pScrn);
+
+ if(pSIS->AccelInfoPtr) {
+ (*pSIS->AccelInfoPtr->Sync)(pScrn);
+ }
+}
+
+static void
+SIS_BlitRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty
+){
+ SISPtr pSIS = SISPTR(pScrn);
+
+ if(pSIS->AccelInfoPtr) {
+ int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
+ int ydir = (srcy < dsty) ? -1 : 1;
+
+ (*pSIS->AccelInfoPtr->SetupForScreenToScreenCopy)(
+ pScrn, xdir, ydir, GXcopy, ~0, -1);
+ (*pSIS->AccelInfoPtr->SubsequentScreenToScreenCopy)(
+ pScrn, srcx, srcy, dstx, dsty, w, h);
+ SET_SYNC_FLAG(pSIS->AccelInfoPtr);
+ }
+}
+
+
+static void
+SIS_BlitTransRect(
+ ScrnInfoPtr pScrn,
+ int srcx, int srcy,
+ int w, int h,
+ int dstx, int dsty,
+ unsigned long color
+){
+ /* this one should be separate since the XAA function would
+ prohibit usage of ~0 as the key */
+}
+
+
+static Bool
+SIS_OpenFramebuffer(
+ ScrnInfoPtr pScrn,
+ char **name,
+ unsigned char **mem,
+ int *size,
+ int *offset,
+ int *flags
+){
+ SISPtr pSIS = SISPTR(pScrn);
+
+ *name = NULL; /* no special device */
+ *mem = (unsigned char*)pSIS->FbAddress;
+ *size = pSIS->FbMapSize;
+ *offset = 0;
+ *flags = DGA_NEED_ROOT;
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c
index 7da2f85ca..b286e545f 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c
@@ -25,7 +25,7 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
* David Thomas <davtom@dream.org.uk>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.43 2000/03/03 21:26:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_driver.c,v 1.47 2000/06/26 10:26:16 alanh Exp $ */
#define PSZ 8
@@ -79,11 +79,6 @@ static void SISLeaveVT(int scrnIndex, int flags);
static Bool SISCloseScreen(int scrnIndex, ScreenPtr pScreen);
static Bool SISSaveScreen(ScreenPtr pScreen, int mode);
-/* Required if the driver supports mode switching */
-static Bool SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
-/* Required if the driver supports moving the viewport */
-static void SISAdjustFrame(int scrnIndex, int x, int y, int flags);
-
/* Optional functions */
static void SISFreeScreen(int scrnIndex, int flags);
static int SISValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
@@ -94,6 +89,8 @@ static Bool SISMapMem(ScrnInfoPtr pScrn);
static Bool SISUnmapMem(ScrnInfoPtr pScrn);
static void SISSave(ScrnInfoPtr pScrn);
static void SISRestore(ScrnInfoPtr pScrn);
+static Bool SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static void SISModifyModeInfo(DisplayModePtr mode);
#ifdef DEBUG
static void SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode);
@@ -126,7 +123,7 @@ DriverRec SIS = {
};
static SymTabRec SISChipsets[] = {
-#if 0
+#if 0
{ PCI_CHIP_SG86C201, "SIS86c201" },
{ PCI_CHIP_SG86C202, "SIS86c202" },
{ PCI_CHIP_SG86C205, "SIS86c205" },
@@ -426,35 +423,37 @@ SISProbe(DriverPtr drv, int flags)
/* Free it since we don't need that list after this */
if (devSections)
- xfree(devSections);
+ xfree(devSections);
devSections = NULL;
if (numUsed <= 0)
return FALSE;
if (flags & PROBE_DETECT)
- foundScreen = TRUE;
+ foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
ScrnInfoPtr pScrn;
/* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = SIS_CURRENT_VERSION;
- pScrn->driverName = SIS_DRIVER_NAME;
- pScrn->name = SIS_NAME;
- pScrn->Probe = SISProbe;
- pScrn->PreInit = SISPreInit;
- pScrn->ScreenInit = SISScreenInit;
- pScrn->SwitchMode = SISSwitchMode;
- pScrn->AdjustFrame = SISAdjustFrame;
- pScrn->EnterVT = SISEnterVT;
- pScrn->LeaveVT = SISLeaveVT;
- pScrn->FreeScreen = SISFreeScreen;
- pScrn->ValidMode = SISValidMode;
- foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn, usedChips[i], SISPciChipsets,
- NULL, NULL, NULL, NULL, NULL);
+ pScrn = NULL;
+
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ SISPciChipsets, NULL, NULL,
+ NULL, NULL, NULL))) {
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = SIS_CURRENT_VERSION;
+ pScrn->driverName = SIS_DRIVER_NAME;
+ pScrn->name = SIS_NAME;
+ pScrn->Probe = SISProbe;
+ pScrn->PreInit = SISPreInit;
+ pScrn->ScreenInit = SISScreenInit;
+ pScrn->SwitchMode = SISSwitchMode;
+ pScrn->AdjustFrame = SISAdjustFrame;
+ pScrn->EnterVT = SISEnterVT;
+ pScrn->LeaveVT = SISLeaveVT;
+ pScrn->FreeScreen = SISFreeScreen;
+ pScrn->ValidMode = SISValidMode;
+ foundScreen = TRUE;
+ }
}
xfree(usedChips);
return foundScreen;
@@ -582,6 +581,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
/* Check that the returned depth is one we support */
switch (pScrn->depth) {
case 8:
+ case 15:
case 16:
case 24:
/* OK */
@@ -765,11 +765,10 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
pSiS->FbMapSize = pScrn->videoRam * 1024;
- SiSVGASetup(pScrn);
-#if 0
- SiSLCDPreInit(pScrn);
- SiSTVPreInit(pScrn);
-#endif
+ SISVGAPreInit(pScrn);
+ SISLCDPreInit(pScrn);
+ SISTVPreInit(pScrn);
+ SISDACPreInit(pScrn);
outw(VGA_SEQ_INDEX, (unlock << 8) | 0x05);
@@ -813,7 +812,7 @@ SISPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pSiS->MinClock;
clockRanges->maxClock = pSiS->MaxClock;
@@ -1038,7 +1037,66 @@ SISSave(ScrnInfoPtr pScrn)
vgaHWSave(pScrn, vgaReg, VGA_SR_ALL);
- SiSSave(pScrn, sisReg);
+ (*pSiS->SiSSave)(pScrn, sisReg);
+}
+
+/*
+ * Initialise a new mode. This is currently still using the old
+ * "initialise struct, restore/write struct to HW" model. That could
+ * be changed.
+ */
+
+static Bool
+SISModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+{
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ vgaRegPtr vgaReg;
+ SISPtr pSiS = SISPTR(pScrn);
+ SISRegPtr sisReg;
+
+ vgaHWUnlock(hwp);
+
+ SISModifyModeInfo(mode);
+
+ /* Initialise the ModeReg values */
+ if (!vgaHWInit(pScrn, mode))
+ return FALSE;
+ pScrn->vtSema = TRUE;
+
+ if (!(*pSiS->ModeInit)(pScrn, mode))
+ return FALSE;
+
+ if (pSiS->VBFlags & CRT2_ENABLE)
+ if (!(*pSiS->ModeInit2)(pScrn, mode)) { /* Disable VB */
+ pSiS->ModeReg.sisRegs3D4[0x31] |= 0x60;
+ pSiS->ModeReg.sisRegs3D4[0x30] &= 0xFC;
+ }
+
+ PDEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "HDisplay: %d, VDisplay: %d \n",
+ mode->HDisplay, mode->VDisplay));
+
+ /* Program the registers */
+ vgaHWProtect(pScrn, TRUE);
+ vgaReg = &hwp->ModeReg;
+ sisReg = &pSiS->ModeReg;
+
+ vgaReg->Attribute[0x10] = 0x01;
+ if (pScrn->bitsPerPixel > 8)
+ vgaReg->Graphics[0x05] = 0x00;
+
+ vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+
+ (*pSiS->SiSRestore)(pScrn, sisReg);
+
+ vgaHWProtect(pScrn, FALSE);
+
+/* Reserved for debug
+ *
+ SiSDumpModeInfo(pScrn, mode);
+ *
+ */
+ return TRUE;
}
@@ -1052,7 +1110,6 @@ SISRestore(ScrnInfoPtr pScrn)
vgaRegPtr vgaReg;
SISPtr pSiS;
SISRegPtr sisReg;
- unsigned char temp;
hwp = VGAHWPTR(pScrn);
pSiS = SISPTR(pScrn);
@@ -1061,57 +1118,7 @@ SISRestore(ScrnInfoPtr pScrn)
vgaHWProtect(pScrn, TRUE);
- if (pSiS->VBFlags) {
- setSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, 0xFC, SET_SIMU_SCAN_MODE);
-
- inSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp);
- temp &= ~((DRIVER_MODE | DISABLE_CRT2_DISPLAY ) >> 8);
- temp |= (SET_IN_SLAVE_MODE >> 8);
- outSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp);
- }
-
- SiSRestore(pScrn, sisReg);
-
- if (pSiS->VBFlags) {
- /* for SiS301 */
- DisableBridge(pSiS->RelIO);
- UnLockCRT2(pSiS->RelIO);
-
- /* SetCRT2ModeRegs() */
- outSISIDXREG(pSiS->RelIO+4, 4, 0);
- outSISIDXREG(pSiS->RelIO+4, 5, 0);
- outSISIDXREG(pSiS->RelIO+4, 6, 0);
- outSISIDXREG(pSiS->RelIO+4, 0, sisReg->VBPart1[0]);
- outSISIDXREG(pSiS->RelIO+4, 1, sisReg->VBPart1[1]);
- outSISIDXREG(pSiS->RelIO+0x14, 0x0D, sisReg->VBPart4[0x0D]);
- outSISIDXREG(pSiS->RelIO+0x14, 0x0C, sisReg->VBPart4[0x0C]);
-
- SetBlock(pSiS->RelIO+0x04, 2, 0x23, &(sisReg->VBPart1[2]));
-
- SetBlock(pSiS->RelIO+0x10, 0, 0x45, &(sisReg->VBPart2[0]));
-
- SetBlock(pSiS->RelIO+0x12, 0, 0x3E, &(sisReg->VBPart3[0]));
-
- outSISIDXREG(pSiS->RelIO+0x14, 0x0A, 1);
- outSISIDXREG(pSiS->RelIO+0x14, 0x0B, sisReg->VBPart4[0x0B]);
- outSISIDXREG(pSiS->RelIO+0x14, 0x0A, sisReg->VBPart4[0x0A]);
- outSISIDXREG(pSiS->RelIO+0x14, 0x12, 0);
- outSISIDXREG(pSiS->RelIO+0x14, 0x12, sisReg->VBPart4[0x12]);
- SetBlock(pSiS->RelIO+0x14, 0x0E, 0x11, &(sisReg->VBPart4[0x0E]));
- SetBlock(pSiS->RelIO+0x14, 0x13, 0x1B, &(sisReg->VBPart4[0x13]));
-
- /* SetLockRegs()
- LongWait(pSiS->RelIO+0x5A);
- outSISIDXREG(pSiS->RelIO+SROFFSET, 0x32, sisReg->sisRegs3C4[0x32]);
-*/
- EnableBridge(pSiS->RelIO);
-
- /* EnableCRT2()
- outSISIDXREG(pSiS->RelIO+SROFFSET, 0x1E, sisReg->sisRegs3C4[0x1E]);
-*/
- LockCRT2(pSiS->RelIO);
-
- }
+ (*pSiS->SiSRestore)(pScrn, sisReg);
vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL);
@@ -1160,7 +1167,7 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
SISSaveScreen(pScreen, SCREEN_SAVER_ON);
/* Initialise the first mode */
- if (!(*pSiS->ModeInit)(pScrn, pScrn->currentMode))
+ if (!SISModeInit(pScrn, pScrn->currentMode))
return FALSE;
/* Darken the screen for aesthetic reasons and set the viewport */
@@ -1251,10 +1258,15 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
break;
}
if (!ret)
+ {
+ ErrorF ("SetMode Error@!\n");
return FALSE;
+ }
xf86SetBlackWhitePixels(pScreen);
+ SISDGAInit(pScreen);
+
if (pScrn->bitsPerPixel > 8) {
/* Fixup RGB ordering */
visual = pScreen->visuals + pScreen->numVisuals;
@@ -1295,7 +1307,13 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if (!miCreateDefColormap(pScreen))
return FALSE;
- if (!vgaHWHandleColormaps(pScreen))
+/* marked by archer for adding VB palette
+ if (!vgaHWHandleColormaps(pScreen))
+ return FALSE;
+*/
+
+ if (!xf86HandleColormaps(pScreen, 256, 8, SISLoadPalette, NULL,
+ CMAP_RELOAD_ON_MODE_SWITCH))
return FALSE;
#ifdef DPMSExtension
@@ -1319,12 +1337,10 @@ SISScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
/* Usually mandatory */
-static Bool
+Bool
SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
{
- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-
- return (*SISPTR(pScrn)->ModeInit)(pScrn, mode);
+ return SISModeInit(xf86Screens[scrnIndex], mode);
}
@@ -1333,7 +1349,7 @@ SISSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
* displayed location in the video memory.
*/
/* Usually mandatory */
-static void
+void
SISAdjustFrame(int scrnIndex, int x, int y, int flags)
{
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
@@ -1383,6 +1399,13 @@ SISAdjustFrame(int scrnIndex, int x, int y, int flags)
PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3,
"3C5/0Dh set to hex %2X, base 0x%x\n", temp, base));
outb(VGA_SEQ_DATA, temp);
+ if (pSiS->VBFlags) {
+ UnLockCRT2(pSiS->RelIO);
+ outSISIDXREG(pSiS->RelIO+4, 6, GETVAR8(base));
+ outSISIDXREG(pSiS->RelIO+4, 5, GETBITS(base, 15:8));
+ outSISIDXREG(pSiS->RelIO+4, 4, GETBITS(base, 23:16));
+ LockCRT2(pSiS->RelIO);
+ }
break;
default:
outb(VGA_SEQ_INDEX, 0x27);
@@ -1410,7 +1433,7 @@ SISEnterVT(int scrnIndex, int flags)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
/* Should we re-save the text mode on each VT enter? */
- if (!(*SISPTR(pScrn)->ModeInit)(pScrn, pScrn->currentMode))
+ if (!SISModeInit(pScrn, pScrn->currentMode))
return FALSE;
SISAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
@@ -1450,8 +1473,10 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen)
ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
vgaHWPtr hwp = VGAHWPTR(pScrn);
SISPtr pSiS = SISPTR(pScrn);
+ xf86CursorInfoPtr pCursorInfo = pSiS->CursorInfoPtr;
- pSiS->CursorInfoPtr->HideCursor(pScrn);
+ if (pCursorInfo)
+ pCursorInfo->HideCursor(pScrn);
if (pScrn->vtSema) {
SISRestore(pScrn);
@@ -1460,8 +1485,8 @@ SISCloseScreen(int scrnIndex, ScreenPtr pScreen)
}
if(pSiS->AccelInfoPtr)
XAADestroyInfoRec(pSiS->AccelInfoPtr);
- if(pSiS->CursorInfoPtr)
- xf86DestroyCursorInfoRec(pSiS->CursorInfoPtr);
+ if(pCursorInfo)
+ xf86DestroyCursorInfoRec(pCursorInfo);
pScrn->vtSema = FALSE;
pScreen->CloseScreen = pSiS->CloseScreen;
@@ -1476,7 +1501,7 @@ static void
SISFreeScreen(int scrnIndex, int flags)
{
if (xf86LoaderCheckSymbol("vgaHWFreeHWRec"))
- vgaHWFreeHWRec(xf86Screens[scrnIndex]);
+ vgaHWFreeHWRec(xf86Screens[scrnIndex]);
SISFreeRec(xf86Screens[scrnIndex]);
}
@@ -1536,3 +1561,32 @@ SiSDumpModeInfo(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
#endif
+/* local used for debug */
+static void
+SISModifyModeInfo(DisplayModePtr mode)
+{
+/*
+ mode->Clock = 31500;
+ mode->CrtcHTotal = 832;
+ mode->CrtcHDisplay = 640;
+ mode->CrtcHBlankStart = 648;
+ mode->CrtcHSyncStart = 664;
+ mode->CrtcHSyncEnd = 704;
+ mode->CrtcHBlankEnd = 824;
+
+ mode->CrtcVTotal = 520;
+ mode->CrtcVDisplay = 480;
+ mode->CrtcVBlankStart = 488;
+ mode->CrtcVSyncStart = 489;
+ mode->CrtcVSyncEnd = 492;
+ mode->CrtcVBlankEnd = 512;
+*/
+ if (mode->CrtcHBlankStart == mode->CrtcHDisplay)
+ mode->CrtcHBlankStart++;
+ if (mode->CrtcHBlankEnd == mode->CrtcHTotal)
+ mode->CrtcHBlankEnd--;
+ if (mode->CrtcVBlankStart == mode->CrtcVDisplay)
+ mode->CrtcVBlankStart++;
+ if (mode->CrtcVBlankEnd == mode->CrtcVTotal)
+ mode->CrtcVBlankEnd--;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c
index 406defacd..2f1d73bb7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c
@@ -1,60 +1,176 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.c,v 1.3 2000/04/04 19:25:16 dawes Exp $ */
+
#include "xf86.h"
+#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86PciInfo.h"
#include "sis.h"
#include "sis_regs.h"
+#include "sis_lcd.h"
+
-#define LCD_DISABLE 0x00000000
-#define LCD_ENABLE 0x00000001
-#define PANEL_LINK 0x00000002
-#define LCD_SCALED 0x00000004
-#define SIS_VB_301 0x00010000
-#define SIS_VB_LVDS 0x00020000
+static Bool SIS301LCDInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static Bool SiS530LCDModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static void SiS530LCDSave(void);
-static void SiS530LCDRestore(void);
-static Bool SiS301LCDModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static void SiS301LCDSave(void);
-static void SiS301LCDRestore(void);
-static Bool SiSLVDSModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static void SiSLVDSSave(void);
-static void SiSLVDSRestore(void);
+static int XYToRes(int x, int y);
+static int BppToColor(int bpp);
static Bool
-SiS301LCDModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+SIS301LCDInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
- SISPtr pSiS = SISPTR(pScrn);
+ SISPtr pSiS = SISPTR(pScrn);
+ SISRegPtr sisReg = &pSiS->ModeReg;
+ int res, color;
+ unsigned short offset, Threshold_Low, Threshold_High;
+
+ if (mode->Flags & V_INTERLACE)
+ res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay*2);
+ else
+ res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay);
+ color = BppToColor(pScrn->bitsPerPixel);
+ if ((res == -1) || (color == -1))
+ return FALSE;
+
+ switch (pSiS->VBFlags & LCD_TYPE) {
+ case LCD_1024x768:
+ if (mode->CrtcHDisplay > 1024)
+ return FALSE;
+ memcpy(sisReg->VBPart1, sis301_PANEL_1024[res].VBPart1, 0x29);
+ memcpy(sisReg->VBPart2, sis301_PANEL_1024[res].VBPart2, 0x46);
+ memcpy(sisReg->VBPart3, sis301_PANEL_1024[res].VBPart3, 0x3F);
+ memcpy(sisReg->VBPart4, sis301_PANEL_1024[res].VBPart4, 0x1C);
+ break;
+ case LCD_1280x1024:
+ if (mode->CrtcHDisplay > 1280)
+ return FALSE;
+/*
+ memcpy(sisReg->VBPart1, sis301_PANEL_1024[res].VBPart1, 0x29);
+ memcpy(sisReg->VBPart2, sis301_PANEL_1024[res].VBPart2, 0x46);
+ memcpy(sisReg->VBPart3, sis301_PANEL_1024[res].VBPart3, 0x3F);
+ memcpy(sisReg->VBPart4, sis301_PANEL_1024[res].VBPart4, 0x1C);
+*/
+ break;
+ case LCD_800x600:
+ default:
+ if (mode->CrtcHDisplay > 800)
+ return FALSE;
+/*
+ memcpy(sisReg->VBPart1, sis301_VESA[res].VBPart1, 0x29);
+ memcpy(sisReg->VBPart2, sis301_VESA[res].VBPart2, 0x46);
+ memcpy(sisReg->VBPart3, sis301_VESA[res].VBPart3, 0x3F);
+ memcpy(sisReg->VBPart4, sis301_VESA[res].VBPart4, 0x1C);
+*/
+ }
+ sisReg->VBPart2[0x00] &= ~0x20; /* Temp Disable VB Processor */
+
+ sisReg->VBPart1[0x00] &= ~GENMASK(4:0);
+ sisReg->VBPart4[0x0d] &= ~GENMASK(4:3);
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ sisReg->VBPart4[0x0d] |=0x10;
+ sisReg->VBPart1[0] |= 0x10;
+ break;
+ case 16:
+ if (pScrn->depth==15)
+ sisReg->VBPart1[0] |= 0x08;
+ else
+ sisReg->VBPart1[0] |= 0x04;
+ break;
+ case 24:
+ sisReg->VBPart1[0] |= 0x02;
+ break;
+ case 32:
+ sisReg->VBPart1[0] |= 0x01;
+ break;
+ default:
+ return FALSE;
+ }
+ offset = pSiS->scrnOffset >> 3; /* Scrn Offset */
+ sisReg->VBPart1[0x07] = GETVAR8(offset);
+ sisReg->VBPart1[0x09] &= 0xF0;
+ sisReg->VBPart1[0x09] |= GETBITS(offset, 11:8);
+
+ sisReg->VBPart1[3] = (offset >> 3)+1; /* CRT2 FIFO Stop */
+
+ (*pSiS->SetThreshold2)(pScrn, mode, &Threshold_Low, &Threshold_High);
+ sisReg->VBPart1[1] &= ~GENMASK(4:0);
+ sisReg->VBPart1[1] |= GETBITS(Threshold_High, 4:0);
+ sisReg->VBPart1[2] &= ~GENMASK(4:0);
+ sisReg->VBPart1[2] |= GETBITS(Threshold_Low, 4:0);
+
+ sisReg->sisRegs3D4[0x30] |= 0x01; /* Set Needed Scratch Regs */
+ sisReg->sisRegs3D4[0x31] &= ~0x02;
+ sisReg->sisRegs3D4[0x31] |= 0x40;
- return TRUE;
+ return TRUE;
}
+static int
+BppToColor(int bpp)
+{
+ if (bpp == 8) return 0;
+ if (bpp == 15) return 1;
+ if (bpp == 16) return 2;
+ if (bpp == 24) return 3;
+ if (bpp == 32) return 4;
+ return -1;
+}
+
+static int
+XYToRes(int x, int y)
+{
+ if (x==640 && y==480) {
+ return 0;
+ }
+ if (x==800 && y==600) {
+ return 1;
+ }
+ if (x==1024 && y==768) {
+ return 2;
+ }
+ if (x==1280 && y==1024) {
+ return 3;
+ }
+ return -1;
+}
-void SiSLCDPreInit(ScrnInfoPtr pScrn)
+static void
+SIS300_LCDPreInit(ScrnInfoPtr pScrn)
{
SISPtr pSiS = SISPTR(pScrn);
int temp;
- pSiS->LCDFlags = LCD_DISABLE;
- switch(pSiS->Chipset) {
- case PCI_CHIP_SIS530:
- break;
+ inSISIDXREG(pSiS->RelIO+SROFFSET, 0x38, temp);
+ if (!(temp & 0x20))
+ return;
+
+ inSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, temp);
+ if (!(temp & 0x20))
+ return;
+
+ inSISIDXREG(pSiS->RelIO+CROFFSET, 0x36, temp);
+ if (temp == 1)
+ pSiS->VBFlags = CRT2_LCD | LCD_800x600;
+ if (temp == 2)
+ pSiS->VBFlags = CRT2_LCD | LCD_1024x768;
+ if (temp == 3)
+ pSiS->VBFlags = CRT2_LCD | LCD_1280x1024;
+ pSiS->ModeInit2 = SIS301LCDInit;
+}
+
+void
+SISLCDPreInit(ScrnInfoPtr pScrn)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+
+ switch (pSiS->Chipset) {
case PCI_CHIP_SIS300:
case PCI_CHIP_SIS630:
case PCI_CHIP_SIS540:
- inSISIDXREG(pSiS->RelIO+SROFFSET, 0x38, temp);
- if (!(temp & 0x20))
- break;
- inSISIDXREG(pSiS->RelIO+CROFFSET, 0x32, temp);
- if (!(temp & 0x08))
- break;
- pSiS->LCDFlags = LCD_ENABLE;
-
- pSiS->ModeInit2 = SiS301LCDModeInit;
+ SIS300_LCDPreInit(pScrn);
break;
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.h b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.h
new file mode 100644
index 000000000..b9f07dc7c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_lcd.h
@@ -0,0 +1,121 @@
+/* LCD PANEL 1024x768 1024x768x32bpp regs is not correct */
+/* No LCD PANEL 800x600 & 1280x1024 */
+
+
+
+
+static unsigned char Reg301_1_640_480_P1[] = {
+ 0x90, 0xD6, 0x47, 0x0B, 0x00, 0x00, 0x00, 0x50,
+ 0x7F, 0x30, 0x8C, 0xCC, 0x22, 0x4C, 0xF3, 0xDF,
+ 0xEA, 0x1C, 0x09, 0x20, 0x00, 0x00, 0x00, 0x01,
+ 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x4A, 0xBD,
+ 0x82};
+static unsigned char Reg301_1_640_480_P2[] = {
+ 0x3C, 0x36, 0x13, 0xFF, 0x13, 0x25, 0xFF, 0x0C,
+ 0x0C, 0x90, 0x40, 0x01, 0x0A, 0x06, 0x0D, 0x04,
+ 0x0A, 0x06, 0x14, 0x0D, 0x04, 0x0A, 0x00, 0x81,
+ 0x1B, 0x25, 0x60, 0x3F, 0x57, 0x45, 0xEC, 0x07,
+ 0x07, 0xA7, 0x70, 0x07, 0xEB, 0x24, 0xE2, 0x82,
+ 0x52, 0x33, 0xAA, 0x35, 0xFF, 0x58, 0x27, 0xFE,
+ 0xB4, 0x21, 0xED, 0x8A, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x50, 0x00, 0x54};
+static unsigned char Reg301_1_640_480_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x80, 0xF6, 0xBF, 0x20, 0x00, 0x40,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x22, 0x02, 0x00, 0x00};
+static unsigned char Reg301_1_640_480_P4[] = {
+ 0x01, 0x01, 0x01, 0x31, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x5A, 0x64, 0x00, 0x1E, 0x0A, 0x0F,
+ 0x80, 0x00, 0x08, 0x05, 0x0C, 0x19, 0x7F, 0xEE,
+ 0x32, 0x20, 0x80, 0x00};
+
+
+static unsigned char Reg301_1_800_600_P1[] = {
+ 0x90, 0xD6, 0x47, 0x0D, 0x00, 0x00, 0x00, 0x64,
+ 0xFF, 0x30, 0x2C, 0x64, 0x33, 0xD4, 0x70, 0x57,
+ 0x64, 0x26, 0x12, 0x20, 0x00, 0x00, 0x00, 0x01,
+ 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x5E, 0x7F,
+ 0x91};
+static unsigned char Reg301_1_800_600_P2[] = {
+ 0x3C, 0x36, 0x13, 0xFF, 0x13, 0x25, 0xFF, 0x0C,
+ 0x0C, 0x90, 0x40, 0x01, 0x0A, 0x06, 0x0D, 0x04,
+ 0x0A, 0x06, 0x14, 0x0D, 0x04, 0x0A, 0x00, 0x81,
+ 0x1B, 0x25, 0x60, 0x3F, 0x57, 0x45, 0xEC, 0x07,
+ 0x07, 0xA7, 0x70, 0x07, 0xEB, 0x24, 0xE2, 0x82,
+ 0x52, 0x33, 0xAA, 0x35, 0xFF, 0x58, 0xBF, 0xFE,
+ 0xB4, 0x21, 0xED, 0x8A, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x50, 0x00, 0x59};
+static unsigned char Reg301_1_800_600_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x80, 0xF6, 0xBF, 0x20, 0x00, 0x40,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x22, 0x02, 0x00, 0x00};
+static unsigned char Reg301_1_800_600_P4[] = {
+ 0x01, 0x01, 0x01, 0x31, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x5A, 0x64, 0x00, 0x1E, 0x0A, 0x0F,
+ 0x80, 0x00, 0x08, 0x19, 0x2A, 0x1A, 0xFF, 0x6B,
+ 0x32, 0x30, 0x20, 0x00};
+
+
+static unsigned char Reg301_1_1024_768_P1[] = {
+ 0x90, 0xD6, 0x47, 0x11, 0x00, 0x00, 0x00, 0x80,
+ 0x3F, 0x50, 0x0C, 0x5C, 0x44, 0xFC, 0x25, 0xFF,
+ 0x13, 0x36, 0x13, 0x20, 0x00, 0x00, 0x00, 0x01,
+ 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0xC7, 0x8F,
+ 0x81};
+static unsigned char Reg301_1_1024_768_P2[] = {
+ 0x3C, 0x36, 0x13, 0xFF, 0x13, 0x25, 0xFF, 0x0C,
+ 0x0C, 0x90, 0x40, 0x01, 0x0A, 0x06, 0x0D, 0x04,
+ 0x0A, 0x06, 0x14, 0x0D, 0x04, 0x0A, 0x00, 0x81,
+ 0x1B, 0x25, 0x60, 0x3F, 0x57, 0x45, 0xEC, 0x07,
+ 0x07, 0xA7, 0x70, 0x07, 0xEB, 0x24, 0xE2, 0x82,
+ 0x52, 0x33, 0xAA, 0x35, 0xFF, 0x58, 0x3F, 0xFE,
+ 0xB5, 0x21, 0xED, 0x8A, 0x08, 0x00, 0x00, 0x00,
+ 0x00, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x50, 0x00, 0x60};
+static unsigned char Reg301_1_1024_768_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
+ 0x40, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
+ 0x00, 0x01, 0x80, 0xF6, 0xBF, 0x20, 0x00, 0x40,
+ 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50,
+ 0x00, 0x00, 0x00, 0x24, 0x00, 0x01, 0x00, 0x00,
+ 0x00, 0x42, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
+ 0x1A, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x22, 0x02, 0x00, 0x00};
+static unsigned char Reg301_1_1024_768_P4[] = {
+ 0x01, 0x01, 0x01, 0x31, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x5A, 0x64, 0x00, 0x1E, 0x6A, 0x0F,
+ 0x80, 0x00, 0x08, 0x01, 0x01, 0x2B, 0x3F, 0x20,
+ 0x32, 0x40, 0x00, 0x00};
+
+
+
+
+typedef struct _SiS301Reg {
+ CARD8 *VBPart1;
+ CARD8 *VBPart2;
+ CARD8 *VBPart3;
+ CARD8 *VBPart4;
+} SiS301RegRec, SiS301RegPtr;
+
+SiS301RegRec sis301_PANEL_1024[] = {
+ {Reg301_1_640_480_P1, Reg301_1_640_480_P2,
+ Reg301_1_640_480_P3, Reg301_1_640_480_P4},
+ {Reg301_1_800_600_P1, Reg301_1_800_600_P2,
+ Reg301_1_800_600_P3, Reg301_1_800_600_P4},
+ {Reg301_1_1024_768_P1, Reg301_1_1024_768_P2,
+ Reg301_1_1024_768_P3, Reg301_1_1024_768_P4}};
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c
index 99c62af8f..61fedbebb 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c
@@ -25,7 +25,7 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
* David Thomas <davtom@dream.org.uk>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.1 2000/02/12 20:45:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_setup.c,v 1.2 2000/03/31 20:13:37 dawes Exp $ */
#define PSZ 8
@@ -85,7 +85,6 @@ sisOldChipSetup(ScrnInfoPtr pScrn)
{
int ramsize[4] = {1024, 2048, 4096, 1024};
- SISPTR(pScrn)->MaxClock = 135000;
SISPTR(pScrn)->TurboQueue = FALSE;
outb(VGA_SEQ_INDEX, RAMSize);
@@ -102,7 +101,6 @@ sis530Setup(ScrnInfoPtr pScrn)
int temp;
if (pSiS->Chipset == PCI_CHIP_SIS5597) {
- pSiS->MaxClock = 135000;
outb(VGA_SEQ_INDEX, FBSize);
pScrn->videoRam = ((inb(VGA_SEQ_DATA) & 7) + 1)*256;
outb(VGA_SEQ_INDEX, Mode64);
@@ -110,10 +108,6 @@ sis530Setup(ScrnInfoPtr pScrn)
pScrn->videoRam *= 2;
}
else {
- if (pSiS->Chipset == PCI_CHIP_SIS6326)
- pSiS->MaxClock = 175000;
- if (pSiS->Chipset == PCI_CHIP_SIS530)
- pSiS->MaxClock = 230000;
outb(VGA_SEQ_INDEX, RAMSize);
temp = inb(VGA_SEQ_DATA);
config = ((temp & 0x10) >> 2 ) | ((temp & 6) >> 1);
@@ -148,7 +142,6 @@ sis300Setup(ScrnInfoPtr pScrn)
config = inb(VGA_SEQ_DATA);
pScrn->videoRam = ((config & 0x3F) + 1) * 1024;
pSiS->BusWidth =bus[config >> 6];
- pSiS->MaxClock = sis300MemBandWidth(pScrn);
outb(VGA_SEQ_INDEX, 0x3A);
config = inb(VGA_SEQ_DATA) & 3;
@@ -160,9 +153,6 @@ sis300Setup(ScrnInfoPtr pScrn)
pSiS->MemClock/1000.0);
xf86DrvMsg(pScrn->scrnIndex, X_PROBED,
"Detected VRAM bus width is %d\n", pSiS->BusWidth);
- inSISIDXREG(0x3D4, 0x32, config);
- if (config & 0x5F)
- pSiS->VBFlags = 1;
}
void
@@ -187,4 +177,3 @@ SiSSetup(ScrnInfoPtr pScrn)
break;
}
}
-
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c
index 865f73c71..9e92facf8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c
@@ -1,52 +1,190 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.c,v 1.3 2000/04/04 19:25:16 dawes Exp $ */
+
#include "xf86.h"
+#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86PciInfo.h"
#include "sis.h"
#include "sis_regs.h"
+#include "sis_tv.h"
-#define TV_DISABLE 0
-#define SVIDEO 0x00000001
-#define COMPOSITE 0x00000002
-#define SCART 0x00000004
-#define HIVISION 0x00000008
-#define NTSC 0x00000001
-#define PAL 0x00000002
+static Bool SIS301TVInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static Bool SiS530TVModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static void SiS530TVSave(void);
-static void SiS530TVRestore(void);
-static Bool SiS301TVModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
-static void SiS301TVSave(void);
-static void SiS301TVRestore(void);
+static int XYToRes(int x, int y);
+static int BppToColor(int bpp);
static Bool
-SiS530TVModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+SIS301TVInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
- SISPtr pSiS = SISPTR(pScrn);
+ SISPtr pSiS = SISPTR(pScrn);
+ SISRegPtr sisReg = &pSiS->ModeReg;
+ int res, color;
+ unsigned short offset, Threshold_Low, Threshold_High;
+
+ if (mode->Flags & V_INTERLACE)
+ res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay*2);
+ else
+ res = XYToRes(mode->CrtcHDisplay, mode->CrtcVDisplay);
+ color = BppToColor(pScrn->bitsPerPixel);
+ if ((res == -1) || (color == -1))
+ return FALSE;
+
+ switch (pSiS->VBFlags & TV_TYPE) {
+ case TV_PAL:
+ if (mode->CrtcHDisplay > 800)
+ return FALSE;
+ memcpy(sisReg->VBPart1, sis301_PAL[res].VBPart1, 0x29);
+ memcpy(sisReg->VBPart2, sis301_PAL[res].VBPart2, 0x46);
+ memcpy(sisReg->VBPart3, sis301_PAL[res].VBPart3, 0x3F);
+ memcpy(sisReg->VBPart4, sis301_PAL[res].VBPart4, 0x1C);
+ break;
+ case TV_HIVISION:
+ if (mode->CrtcHDisplay > 1280)
+ return FALSE;
+/*
+ memcpy(sisReg->VBPart1, sis301_2[res].VBPart1, 0x29);
+ memcpy(sisReg->VBPart2, sis301_2[res].VBPart2, 0x46);
+ memcpy(sisReg->VBPart3, sis301_2[res].VBPart3, 0x3F);
+ memcpy(sisReg->VBPart4, sis301_2[res].VBPart4, 0x1C);
+*/
+ break;
+ case TV_NTSC:
+ default:
+ if (mode->CrtcHDisplay > 800)
+ return FALSE;
+ memcpy(sisReg->VBPart1, sis301_NTSC[res].VBPart1, 0x29);
+ memcpy(sisReg->VBPart2, sis301_NTSC[res].VBPart2, 0x46);
+ memcpy(sisReg->VBPart3, sis301_NTSC[res].VBPart3, 0x3F);
+ memcpy(sisReg->VBPart4, sis301_NTSC[res].VBPart4, 0x1C);
+ break;
+ }
+ sisReg->VBPart1[0x00] &= ~GENMASK(4:0);
+ sisReg->VBPart4[0x0d] &= ~GENMASK(4:3);
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ sisReg->VBPart4[0x0d] |=0x10;
+ sisReg->VBPart1[0] |= 0x10;
+ break;
+ case 16:
+ if (pScrn->depth==15)
+ sisReg->VBPart1[0] |= 0x08;
+ else
+ sisReg->VBPart1[0] |= 0x04;
+ break;
+ case 24:
+ sisReg->VBPart1[0] |= 0x02;
+ break;
+ case 32:
+ sisReg->VBPart1[0] |= 0x01;
+ break;
+ default:
+ return FALSE;
+ }
+ /* Set TV Interface */
+ sisReg->VBPart2[0] &= GENMASK(4:4) | GENMASK(0:0);
+ switch (pSiS->VBFlags & TV_INTERFACE) {
+ case TV_SVIDEO:
+ sisReg->VBPart2[0] |= 0x08;
+ break;
+ case TV_SCART:
+ sisReg->VBPart2[0] |= 0x02;
+ break;
+ case TV_AVIDEO: /* Composite */
+ default:
+ sisReg->VBPart2[0] |= 0x04;
+ }
+
+ offset = pSiS->scrnOffset >> 3; /* Scrn Offset */
+ sisReg->VBPart1[0x07] = GETVAR8(offset);
+ sisReg->VBPart1[0x09] &= 0xF0;
+ sisReg->VBPart1[0x09] |= GETBITS(offset, 11:8);
+
+ sisReg->VBPart1[3] = (offset >> 3)+1; /* CRT2 FIFO Stop */
+
+ (*pSiS->SetThreshold2)(pScrn, mode, &Threshold_Low, &Threshold_High);
+ sisReg->VBPart1[1] &= ~GENMASK(4:0);
+ sisReg->VBPart1[1] |= GETBITS(Threshold_High, 4:0);
+ sisReg->VBPart1[2] &= ~GENMASK(4:0);
+ sisReg->VBPart1[2] |= GETBITS(Threshold_Low, 4:0);
+
+ sisReg->sisRegs3D4[0x30] |= 0x01; /* Set Needed Scratch Regs */
+ sisReg->sisRegs3D4[0x31] &= ~0x02;
+ sisReg->sisRegs3D4[0x31] |= 0x40;
return TRUE;
}
+static int
+BppToColor(int bpp)
+{
+ if (bpp == 8) return 0;
+ if (bpp == 15) return 1;
+ if (bpp == 16) return 2;
+ if (bpp == 24) return 3;
+ if (bpp == 32) return 4;
+ return -1;
+}
+
+static int
+XYToRes(int x, int y)
+{
+ if (x==640 && y==480) {
+ return 0;
+ }
+ if (x==800 && y==600) {
+ return 1;
+ }
+ if (x==1024 && y==768) {
+ return 2;
+ }
+ if (x==1280 && y==1024) {
+ return 3;
+ }
+ return -1;
+}
-void SiSTVPreInit(ScrnInfoPtr pScrn)
+static void
+SIS300_TVPreInit(ScrnInfoPtr pScrn)
{
SISPtr pSiS = SISPTR(pScrn);
int temp;
- switch(pSiS->Chipset) {
- case PCI_CHIP_SIS530:
- inSISIDXREG(pSiS->RelIO+SROFFSET, 0x36, temp);
- break;
+ inSISIDXREG(pSiS->RelIO+SROFFSET, 0x38, temp);
+ if (!(temp & 0x20))
+ return;
+
+ inSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, temp);
+ if (temp & 0x10)
+ pSiS->VBFlags = CRT2_TV | TV_SCART;
+ else if (temp & 0x08)
+ pSiS->VBFlags = CRT2_TV | TV_SVIDEO;
+ else if (temp & 0x04)
+ pSiS->VBFlags = CRT2_TV | TV_AVIDEO;
+ else
+ return;
+
+ inSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp);
+ if (temp & 0x01)
+ pSiS->VBFlags |= TV_PAL;
+ else
+ pSiS->VBFlags |= TV_NTSC;
+ pSiS->ModeInit2 = SIS301TVInit;
+}
+
+void
+SISTVPreInit(ScrnInfoPtr pScrn)
+{
+ SISPtr pSiS = SISPTR(pScrn);
+
+ switch (pSiS->Chipset) {
case PCI_CHIP_SIS300:
case PCI_CHIP_SIS630:
case PCI_CHIP_SIS540:
-
+ SIS300_TVPreInit(pScrn);
break;
- default:
- pSiS->TVFlags = TV_DISABLE;
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.h b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.h
new file mode 100644
index 000000000..3758037c6
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_tv.h
@@ -0,0 +1,158 @@
+/* No AVIDEO interface Regs */
+/* No SCART interface Regs */
+/* No Hi-Vision TV Regs */
+
+typedef struct _SiS301Reg {
+ CARD8 *VBPart1;
+ CARD8 *VBPart2;
+ CARD8 *VBPart3;
+ CARD8 *VBPart4;
+} SiS301RegRec, SiS301RegPtr;
+
+/* NTSC 640x480 */
+static unsigned char Reg301_0_640_480_P1[] = {
+ 0x90, 0xF6, 0x49, 0x0B, 0x00, 0x00, 0x00, 0x50,
+ 0x43, 0x30, 0x8C, 0xBD, 0x22, 0x1F, 0x0A, 0xDF,
+ 0xF5, 0x18, 0x0A, 0x08, 0x00, 0x00, 0x00, 0x21,
+ 0x03, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x61, 0x61,
+ 0x12};
+static unsigned char Reg301_0_640_480_P2[] = {
+ 0x38, 0x17, 0x1D, 0x03, 0x09, 0x05, 0x06, 0x0C,
+ 0x0C, 0x94, 0x49, 0x01, 0x0A, 0x06, 0x0D, 0x04,
+ 0x0A, 0x06, 0x14, 0x0D, 0x04, 0x0A, 0x00, 0x85,
+ 0x1B, 0x0C, 0x50, 0xB3, 0x99, 0x06, 0xEC, 0x4A,
+ 0x17, 0x88, 0x10, 0x4B, 0xA5, 0x30, 0xE2, 0x3C,
+ 0x62, 0xD3, 0x4A, 0x65, 0x9D, 0xF8, 0x14, 0xDA,
+ 0x13, 0x21, 0xED, 0x8A, 0x08, 0xF1, 0x05, 0x1F,
+ 0x16, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x50, 0x21, 0x50};
+static unsigned char Reg301_0_640_480_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0xF6, 0xBF, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char Reg301_0_640_480_P4[] = {
+ 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x52, 0x2A, 0x40, 0x1F, 0x8A, 0x0F,
+ 0x80, 0x00, 0x08, 0x4C, 0x8F, 0x1A, 0x43, 0x0A,
+ 0xE0, 0x40, 0x5D, 0x18};
+
+
+/* NTSC 800x600 */
+static unsigned char Reg301_0_800_600_P1[] = {
+ 0x90, 0xF6, 0x49, 0x0D, 0x00, 0x00, 0x00, 0x64,
+ 0x1F, 0x40, 0x2C, 0x6C, 0x33, 0xEC, 0x82, 0x57,
+ 0x6D, 0x20, 0x12, 0x08, 0x00, 0x00, 0x00, 0x21,
+ 0x03, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0xB5, 0x65,
+ 0x92};
+static unsigned char Reg301_0_800_600_P2[] = {
+ 0x38, 0x17, 0x1D, 0x03, 0x09, 0x05, 0x06, 0x0C,
+ 0x0C, 0x94, 0xC9, 0x01, 0x0A, 0x06, 0x0D, 0x04,
+ 0x0A, 0x06, 0x14, 0x0D, 0x04, 0x0A, 0x00, 0x85,
+ 0x1B, 0x0C, 0x50, 0xB3, 0x99, 0x06, 0xEC, 0x4A,
+ 0x17, 0x88, 0x10, 0x4B, 0xA5, 0x30, 0xE2, 0x3C,
+ 0x62, 0xD3, 0x4A, 0x65, 0x9D, 0xF8, 0x14, 0xDA,
+ 0x13, 0x21, 0xED, 0x8A, 0x08, 0xF4, 0x10, 0x1C,
+ 0x00, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x50, 0x29, 0x54};
+static unsigned char Reg301_0_800_600_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0xF6, 0xBF, 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, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
+static unsigned char Reg301_0_800_600_P4[] = {
+ 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x52, 0x2A, 0x40, 0x1F, 0x8A, 0x0F,
+ 0x80, 0x00, 0x08, 0x78, 0x8F, 0x22, 0x1F, 0x82,
+ 0x20, 0x52, 0x74, 0x5E};
+
+
+/* PAL 640x480 */
+static unsigned char Reg301_1_640_480_P1[] = {
+ 0x90, 0xF6, 0x49, 0x0B, 0x00, 0x00, 0x00, 0x50,
+ 0x4F, 0x30, 0x8C, 0xC0, 0x22, 0x28, 0x0F, 0xDF,
+ 0xF8, 0x1C, 0x0A, 0x08, 0x00, 0x00, 0x00, 0x21,
+ 0x03, 0xF0, 0x00, 0x00, 0x20, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x03, 0x33, 0x2D,
+ 0x91};
+static unsigned char Reg301_1_640_480_P2[] = {
+ 0x28, 0x19, 0x52, 0x35, 0x6E, 0x04, 0x38, 0x3D,
+ 0x70, 0x94, 0x49, 0x01, 0x12, 0x06, 0x3E, 0x35,
+ 0x6D, 0x06, 0x14, 0x3E, 0x35, 0x6D, 0x00, 0x45,
+ 0x2B, 0x70, 0x50, 0xBF, 0x97, 0x06, 0xD7, 0x5D,
+ 0x17, 0x88, 0x70, 0x45, 0xA5, 0x30, 0xE8, 0x48,
+ 0x62, 0xDD, 0x00, 0x68, 0xB0, 0x8B, 0x2D, 0x07,
+ 0x53, 0x2A, 0x05, 0xD3, 0x00, 0xF5, 0xFB, 0x1B,
+ 0x2A, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x63, 0x21, 0x50};
+static unsigned char Reg301_1_640_480_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xFA, 0xC8, 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,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00};
+static unsigned char Reg301_1_640_480_P4[] = {
+ 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x52, 0x2A, 0x40, 0x1F, 0x8A, 0x0F,
+ 0x80, 0x00, 0x08, 0x04, 0x09, 0x1A, 0x4F, 0x0F,
+ 0x32, 0x30, 0x9F, 0x66};
+
+
+/* PAL 800x600 */
+static unsigned char Reg301_1_800_600_P1[] = {
+ 0x90, 0xF6, 0x49, 0x0D, 0x00, 0x00, 0x00, 0x64,
+ 0x23, 0x40, 0x2C, 0x6D, 0x33, 0xEF, 0x87, 0x57,
+ 0x70, 0x24, 0x12, 0x08, 0x00, 0x00, 0x00, 0x21,
+ 0x03, 0x30, 0x00, 0x00, 0x20, 0x00, 0x02, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x27, 0x75,
+ 0x82};
+static unsigned char Reg301_1_800_600_P2[] = {
+ 0x28, 0x19, 0x52, 0x35, 0x6E, 0x04, 0x38, 0x3D,
+ 0x70, 0x94, 0x49, 0x01, 0x12, 0x06, 0x3E, 0x35,
+ 0x6D, 0x06, 0x14, 0x3E, 0x35, 0x6D, 0x00, 0x45,
+ 0x2B, 0x70, 0x50, 0xBF, 0x97, 0x06, 0xD7, 0x5D,
+ 0x17, 0x88, 0x70, 0x45, 0xA5, 0x30, 0xE8, 0x48,
+ 0x62, 0xDD, 0x00, 0x68, 0xB0, 0x8B, 0x2D, 0x07,
+ 0x53, 0x2A, 0x05, 0xD3, 0x00, 0xEB, 0x05, 0x25,
+ 0x16, 0x92, 0x8F, 0x40, 0x60, 0x80, 0x14, 0x90,
+ 0x8C, 0x60, 0x14, 0x63, 0x29, 0x54};
+static unsigned char Reg301_1_800_600_P3[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xFA, 0xC8, 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,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00};
+static unsigned char Reg301_1_800_600_P4[] = {
+ 0x01, 0x01, 0x01, 0x07, 0x00, 0x00, 0x00, 0xFF,
+ 0x7F, 0x55, 0x52, 0x2A, 0x40, 0x1F, 0x8A, 0x0F,
+ 0x80, 0x00, 0x08, 0x19, 0x24, 0x22, 0x23, 0x87,
+ 0xD6, 0x41, 0x87, 0x3F};
+
+
+SiS301RegRec sis301_NTSC[] = {
+ {Reg301_0_640_480_P1, Reg301_0_640_480_P2,
+ Reg301_0_640_480_P3, Reg301_0_640_480_P4},
+ {Reg301_0_800_600_P1, Reg301_0_800_600_P2,
+ Reg301_0_800_600_P3, Reg301_0_800_600_P4}};
+
+SiS301RegRec sis301_PAL[] = {
+ {Reg301_1_640_480_P1, Reg301_1_640_480_P2,
+ Reg301_1_640_480_P3, Reg301_1_640_480_P4},
+ {Reg301_1_800_600_P1, Reg301_1_800_600_P2,
+ Reg301_1_800_600_P3, Reg301_1_800_600_P4}};
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c
index 5d4553130..00307edab 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c
@@ -25,7 +25,7 @@
* Mitani Hiroshi <hmitani@drl.mei.co.jp>
* David Thomas <davtom@dream.org.uk>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.2 2000/02/18 12:20:01 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sis/sis_vga.c,v 1.3 2000/03/31 20:13:38 dawes Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -56,259 +56,39 @@
#define TOLERANCE 0.01 /* search smallest M and N in this tolerance */
+static Bool SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
+static Bool SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode);
-/* local used for debug */
-static void
-SiSModifyModeInfo(DisplayModePtr mode)
-{
-/*
- mode->Clock = 31500;
- mode->CrtcHTotal = 832;
- mode->CrtcHDisplay = 640;
- mode->CrtcHBlankStart = 648;
- mode->CrtcHSyncStart = 664;
- mode->CrtcHSyncEnd = 704;
- mode->CrtcHBlankEnd = 824;
-
- mode->CrtcVTotal = 520;
- mode->CrtcVDisplay = 480;
- mode->CrtcVBlankStart = 488;
- mode->CrtcVSyncStart = 489;
- mode->CrtcVSyncEnd = 492;
- mode->CrtcVBlankEnd = 512;
-*/
- if (mode->CrtcHBlankStart == mode->CrtcHDisplay)
- mode->CrtcHBlankStart++;
- if (mode->CrtcHBlankEnd == mode->CrtcHTotal)
- mode->CrtcHBlankEnd--;
- if (mode->CrtcVBlankStart == mode->CrtcVDisplay)
- mode->CrtcVBlankStart++;
- if (mode->CrtcVBlankEnd == mode->CrtcVTotal)
- mode->CrtcVBlankEnd--;
-}
-
-static void
-Find530Threshold(ScrnInfoPtr pScrn, int mclk, int vclk, int bpp,
- int buswidth, int flags, int *low, int *high)
-{
- int factor, z;
-
- *high = 0x1F;
- if (flags & UMA)
- factor = 0x60;
- else
- factor = 0x30;
- z = factor * vclk * bpp;
- z = z / mclk / buswidth;
- *low = (z+1)/2 + 4;
- if (*low > 0x1F)
- *low = 0x1F;
-}
-
-struct funcargc {
- char base;
- char inc;
-};
-
-struct funcargc funca[12] = {
- {61, 3}, {52, 5}, {68, 7}, {100, 11},
- {43, 3}, {42, 5}, {54, 7}, {78, 11},
- {34, 3}, {37, 5}, {47, 7}, {67, 11}};
-
-struct funcargc funcb[12] = {
- {81, 4}, {72, 6}, {88, 8}, {120, 12},
- {55, 4}, {54, 6}, {66, 8}, {90, 12},
- {42, 4}, {45, 6}, {55, 8}, {75, 12}};
-
-char timing[8] = {1, 2, 2, 3, 0, 1, 1, 2};
-
-static void
-Find300_Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- SISPtr pSiS = SISPTR(pScrn);
- SISRegPtr pReg = &pSiS->ModeReg;
- int mclk = pSiS->MemClock;
- int vclk = mode->Clock;
- int bpp = pScrn->bitsPerPixel/8;
- int lowa, lowb, low;
- struct funcargc *p;
- unsigned int i, j;
-
- pReg->sisRegs3C4[0x16] = pSiS->SavedReg.sisRegs3C4[0x16];
-
- if (!bpp) bpp = 1;
-
- do {
- i = ((pReg->sisRegs3C4[0x18] & 0x60) >> 4) |
- ((pReg->sisRegs3C4[0x18] & 0x02) >> 1);
- j = ((pReg->sisRegs3C4[0x14] & 0xC0) >> 4) |
- (pReg->sisRegs3C4[0x16] >> 6);
- p = &funca[j];
-
- lowa = (p->base + p->inc*timing[i])*vclk*bpp;
- lowa = (lowa + (mclk-1)) / mclk;
- lowa = (lowa + 15)/16;
-
- p = &funcb[j];
- lowb = (p->base + p->inc*timing[i])*vclk*bpp;
- lowb = (lowb + (mclk-1)) / mclk;
- lowb = (lowb + 15)/16;
-
- if (lowb < 4)
- lowb = 0;
- else
- lowb -= 4;
-
- low = (lowa > lowb)? lowa: lowb;
-
- low++;
-
- if (low <= 0x13) {
- break;
- } else {
- i = (pReg->sisRegs3C4[0x16] >> 6) & 3;
- if (!i) {
- low = 0x13;
- break;
- } else {
- i--;
- pReg->sisRegs3C4[0x16] &= 0x3C;
- pReg->sisRegs3C4[0x16] |= (i << 6);
- }
- }
- } while (1);
-
- pReg->sisRegs3C4[0x08] = ((low & 0xF) << 4) | 0xF;
- pReg->sisRegs3C4[0x0F] = (low & 0x10) << 1;
- pReg->sisRegs3C4[0x09] &= 0xF0;
- if (low+3 > 15)
- pReg->sisRegs3C4[0x09] |= 0x0F;
- else
- pReg->sisRegs3C4[0x09] |= low + 3;
-}
-
-struct QConfig {
- int GT;
- int QC;
-};
-
-struct QConfig qconfig[20] = {
- {1, 0x0}, {1, 0x2}, {1, 0x4}, {1, 0x6}, {1, 0x8},
- {1, 0x3}, {1, 0x5}, {1, 0x7}, {1, 0x9}, {1, 0xb},
- {0, 0x0}, {0, 0x2}, {0, 0x4}, {0, 0x6}, {0, 0x8},
- {0, 0x3}, {0, 0x5}, {0, 0x7}, {0, 0x9}, {0, 0xb}};
-
-int cycleA[20][2] = {
- {88,88}, {80,80}, {78,78}, {72,72}, {70,70},
- {79,72}, {77,70}, {71,64}, {69,62}, {49,44},
- {73,78}, {65,70}, {63,68}, {57,62}, {55,60},
- {64,62}, {62,60}, {56,54}, {54,52}, {34,34}};
-
-static void
-Find630_Threshold(ScrnInfoPtr pScrn, DisplayModePtr mode)
-{
- SISPtr pSiS = SISPTR(pScrn);
- SISRegPtr pReg = &pSiS->ModeReg;
- int mclk = pSiS->MemClock;
- int vclk = mode->Clock;
- int bpp = pScrn->bitsPerPixel/8;
- CARD32 temp;
- PCITAG NBridge;
- int low, lowa, cyclea;
- int i, j;
-
- if (!bpp) bpp = 1;
-
- i = 0;
- j = (pReg->sisRegs3C4[0x14] >> 6) - 1;
-
- while (1) {
-#ifdef DEBUG
- ErrorF("Config %d GT = %d, QC = %x, CycleA = %d\n",
- i, qconfig[i].GT, qconfig[i].QC, cycleA[i][j]);
-#endif
- cyclea = cycleA[i][j];
- lowa = cyclea * vclk * bpp;
- lowa = (lowa + (mclk-1)) / mclk;
- lowa = (lowa + 15) / 16;
- low = lowa + 1;
- if (low <= 0x13)
- break;
- else
- if (i < 19)
- i++;
- else {
- low = 0x13;
-#ifdef DEBUG
- ErrorF("This mode may has threshold problem and had better removed\n");
-#endif
- break;
- }
- }
-#ifdef DEBUG
- ErrorF("Using Config %d with CycleA = %d\n", i, cyclea);
-#endif
- pReg->sisRegs3C4[0x08] = ((low & 0xF) << 4) | 0xF;
- pReg->sisRegs3C4[0x0F] &= 0xDF;
- pReg->sisRegs3C4[0x0F] |= (low & 0x10) << 1;
- pReg->sisRegs3C4[0x09] &= 0xF0;
- if (lowa+4 > 15)
- pReg->sisRegs3C4[0x09] |= 0x0F;
- else
- pReg->sisRegs3C4[0x09] |= (lowa+4);
-
- /* write PCI configuration space */
- NBridge = pciTag(0, 0, 0);
- temp = pciReadLong(NBridge, 0x50);
- temp &= 0xF0FFFFFF;
- temp |= qconfig[i].QC << 24;
- pciWriteLong(NBridge, 0x50, temp);
-
- temp = pciReadLong(NBridge, 0xA0);
- temp &= 0xF0FFFFFF;
- temp |= qconfig[i].GT << 24;
- pciWriteLong(NBridge, 0xA0, temp);
-
-#ifdef DEBUG
- temp = pciReadLong(NBridge, 0x50);
- ErrorF("QueueConfig: 0x80000050 = %x\n", temp);
- temp = pciReadLong(NBridge, 0xA0);
- ErrorF("QueueConfig: 0x800000A0 = %x\n", temp);
-#endif
-
-}
-
static Bool
-SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+SISInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
SISPtr pSiS = SISPTR(pScrn);
SISRegPtr pReg = &pSiS->ModeReg;
+ vgaRegPtr vgaReg = &VGAHWPTR(pScrn)->ModeReg;
int gap, safetymargin, MemBand;
int vgaIOBase;
- unsigned char temp, SR5State;
- unsigned short temp1;
+ unsigned char temp;
int Base,mclk;
int offset;
int clock = mode->Clock;
unsigned int vclk[5];
- int CRT_CPUthresholdLow ;
- int CRT_CPUthresholdHigh ;
- unsigned int CRT_ENGthreshold ;
+ unsigned short CRT_CPUthresholdLow ;
+ unsigned short CRT_CPUthresholdHigh ;
+ unsigned short CRT_ENGthreshold ;
int num, denum, div, sbit, scale;
- PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "SiSInit()\n"));
+ PDEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 3, "SISInit()\n"));
vgaHWGetIOBase(VGAHWPTR(pScrn));
vgaIOBase = VGAHWPTR(pScrn)->IOBase;
- SiSSave(pScrn, pReg);
+ (*pSiS->SiSSave)(pScrn, pReg);
- outb(VGA_SEQ_INDEX, 0x05); /* Unlock Registers */
- SR5State = inb(VGA_SEQ_DATA);
outw(VGA_SEQ_INDEX, 0x8605);
pSiS->scrnOffset = pScrn->displayWidth * pScrn->bitsPerPixel / 8;
+
if ((mode->Flags & V_INTERLACE)==0) {
offset = pScrn->displayWidth >> 3;
pReg->sisRegs3C4[0x06] &= 0xDF;
@@ -326,58 +106,33 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->sisRegs3C4[0x0C] |= 0xA0;
pReg->sisRegs3C4[0x0B] |= 0x60;
break;
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- pReg->sisRegs3C4[0x20] |= 0x81;
- pReg->sisRegs3C4[0x06] |= 0x02;
- break;
default:
pReg->sisRegs3C4[BankReg] |= 0x82;
}
switch (pScrn->bitsPerPixel) {
case 8:
- pSiS->DstColor = 0x0000;
break;
case 15:
- pSiS->DstColor = 0x4000;
offset <<= 1;
pReg->sisRegs3C4[BankReg] |= 0x04;
break;
case 16:
- pSiS->DstColor = (short)0x8000;
offset <<= 1;
pReg->sisRegs3C4[BankReg] |= 0x08;
break;
case 24:
offset += (offset << 1);
- switch (pSiS->Chipset) {
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- pReg->sisRegs3C4[0x06] |= 0x0C;
- break;
- default:
- pReg->sisRegs3C4[BankReg] |= 0x10;
- pReg->sisRegs3C4[MMIOEnable] |= 0x90;
- }
+ pReg->sisRegs3C4[BankReg] |= 0x10;
+ pReg->sisRegs3C4[MMIOEnable] |= 0x90;
break;
case 32:
- pSiS->DstColor = (short)0xC000;
offset <<= 2;
- switch (pSiS->Chipset) {
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- pReg->sisRegs3C4[0x06] &= 0xE3;
- pReg->sisRegs3C4[0x06] |= 0x10;
- break;
- case PCI_CHIP_SIS530:
+ if (pSiS->Chipset == PCI_CHIP_SIS530) {
pReg->sisRegs3C4[BankReg] |= 0x10;
pReg->sisRegs3C4[MMIOEnable] |= 0x90;
pReg->sisRegs3C4[0x09] |= 0x80;
- default:
+ } else {
return FALSE;
}
break;
@@ -416,80 +171,36 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
break;
}
- switch (pSiS->Chipset) {
- case PCI_CHIP_SIS5597:
- case PCI_CHIP_SIS6326:
- case PCI_CHIP_SIS530:
- /* Screen Offset */
- pReg->sisRegs3x4[Offset] = offset & 0xFF;
- pReg->sisRegs3C4[CRTCOff] = ((offset & 0xF00) >> 4) |
+ /* Screen Offset */
+ vgaReg->CRTC[0x13] = offset & 0xFF;
+ pReg->sisRegs3C4[CRTCOff] = ((offset & 0xF00) >> 4) |
(((mode->CrtcVTotal-2) & 0x400) >> 10 ) |
(((mode->CrtcVDisplay-1) & 0x400) >> 9 ) |
(((mode->CrtcVSyncStart-1) & 0x400) >> 8 ) |
(((mode->CrtcVSyncStart) & 0x400) >> 7 ) ;
- /* Extended Horizontal Overflow Register */
- pReg->sisRegs3C4[0x12] &= 0xE0;
- pReg->sisRegs3C4[0x12] |= (
+ /* Extended Horizontal Overflow Register */
+ pReg->sisRegs3C4[0x12] &= 0xE0;
+ pReg->sisRegs3C4[0x12] |= (
(((mode->CrtcHTotal >> 3) - 5) & 0x100) >> 8 |
(((mode->CrtcHDisplay >> 3) - 1) & 0x100) >> 7 |
(((mode->CrtcHSyncStart >> 3) - 1) & 0x100) >> 6 |
((mode->CrtcHSyncStart >> 3) & 0x100) >> 5 |
- ((mode->CrtcHSyncEnd >> 3) & 0x40) >> 2);
+ (((mode->CrtcHBlankEnd >> 3) -1) & 0x40) >> 2);
+/* ((mode->CrtcHSyncEnd >> 3) & 0x40) >> 2); */
- if (mode->CrtcVDisplay > 1024)
+ if (mode->CrtcVDisplay > 1024)
/* disable line compare */
pReg->sisRegs3C4[0x38] |= 0x04;
- else
+ else
pReg->sisRegs3C4[0x38] &= 0xFB;
- if (( pScrn->depth == 24) || (pScrn->depth == 32) ||
+ if (( pScrn->depth == 24) || (pScrn->depth == 32) ||
(mode->CrtcHDisplay >= 1280))
/* Enable high speed DCLK */
pReg->sisRegs3C4[0x3E] |= 1;
- else
+ else
pReg->sisRegs3C4[0x3E] &= 0xFE;
- break;
-
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- /* Screen Offset */
- pReg->sisRegs3x4[Offset] = offset & 0xFF;
- pReg->sisRegs3C4[0x0E] &= 0xF0;
- pReg->sisRegs3C4[0x0E] |= ((offset & 0xF00) >> 8);
-
- pReg->sisRegs3C4[0x10] =
- ((mode->CrtcHDisplay *(pScrn->bitsPerPixel >>3) + 63) >> 6) +1;
- pReg->sisRegs3C4[0x06] |= 0x01;
-
- /* Extended Vertical Overflow */
- pReg->sisRegs3C4[0x0A] =
- (((mode->CrtcVTotal -2) & 0x400) >> 10) |
- (((mode->CrtcVDisplay -1) & 0x400) >> 9 ) |
- (((mode->CrtcVBlankStart ) & 0x400) >> 8 ) |
- (((mode->CrtcVSyncStart ) & 0x400) >> 7 ) |
- (((mode->CrtcVBlankEnd ) & 0x100) >> 4 ) |
- (((mode->CrtcVSyncEnd ) & 0x010) << 1 );
-
- /* Extended Horizontal Overflow */
- pReg->sisRegs3C4[0x0B] =
- (((mode->CrtcHTotal >> 3) - 5) & 0x300) >> 8 |
- (((mode->CrtcHDisplay >> 3) - 1) & 0x300) >> 6 |
- ((mode->CrtcHBlankStart >> 3) & 0x300) >> 4 |
- ((mode->CrtcHSyncStart >> 3) & 0x300) >> 2 ;
- pReg->sisRegs3C4[0x0C] &= 0xF8;
- pReg->sisRegs3C4[0x0C] |=
- ((mode->CrtcHBlankEnd >> 3) & 0x0C0) >> 6 |
- ((mode->CrtcHSyncEnd >> 3) & 0x020) >> 3;
-
- /* line compare */
- if (mode->CrtcHDisplay > 0)
- pReg->sisRegs3C4[0x0F] |= 0x08;
- else
- pReg->sisRegs3C4[0x0F] &= 0xF7;
- break;
- }
/* Set vclk */
@@ -509,18 +220,6 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->sisRegs3C4[ClockBase] &= 0xBF;
break;
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- pReg->sisRegs3C4[0x2B] = (num -1) & 0x7f;
- if (div == 2)
- pReg->sisRegs3C4[0x2B] |= 0x80;
- pReg->sisRegs3C4[0x2C] = ((denum -1) & 0x1f);
- pReg->sisRegs3C4[0x2C] |= (((scale-1)&3) << 5);
- if (sbit)
- pReg->sisRegs3C4[0x2C] |= 0x80;
- pReg->sisRegs3C4[0x2D] = 0x80;
- break;
}
}
else {
@@ -547,58 +246,13 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
pReg->sisRegs3C4[XR2B] |= 0x80 ; /* gain for high frequency */
break;
-
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- pReg->sisRegs3C4[0x2B] = (vclk[Midx] - 1) & 0x7f ;
- pReg->sisRegs3C4[0x2B] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ;
-
- /* bits [4:0] contain denumerator -MC */
- pReg->sisRegs3C4[0x2C] = (vclk[Nidx] -1) & 0x1f ;
-
- if (vclk[Pidx] <= 4) {
- /* postscale 1,2,3,4 */
- pReg->sisRegs3C4[0x2C] |= (vclk[Pidx] -1 ) << 5 ;
- pReg->sisRegs3C4[0x2C] &= 0x7F;
- } else {
- /* postscale 6,8 */
- pReg->sisRegs3C4[0x2C] |= ((vclk[Pidx] / 2) -1 ) << 5 ;
- pReg->sisRegs3C4[0x2C] |= 0x80;
- }
- pReg->sisRegs3C4[0x2D] = 0x80;
- break;
}
} /* end of set vclk */
- switch (pSiS->Chipset) {
- case PCI_CHIP_SIS5597:
- case PCI_CHIP_SIS6326:
- case PCI_CHIP_SIS530:
- if (clock > 135000) pReg->sisRegs3C4[ClockReg] |= 0x02;
- break;
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- if (clock > 150000) { /* enable two-pixel mode */
- pReg->sisRegs3C4[0x07] |= 0x80;
- pReg->sisRegs3C4[0x32] |= 0x08;
- } else {
- pReg->sisRegs3C4[0x07] &= 0x7F;
- pReg->sisRegs3C4[0x32] &= 0xF7;
- }
+ if (clock > 135000)
+ pReg->sisRegs3C4[ClockReg] |= 0x02;
- pReg->sisRegs3C4[0x07] |= 0x10;
- pReg->sisRegs3C4[0x07] &= 0xFC;
- if (clock < 100000)
- pReg->sisRegs3C4[0x07] |= 0x03;
- else if (clock < 200000)
- pReg->sisRegs3C4[0x07] |= 0x02;
- else if (clock < 250000)
- pReg->sisRegs3C4[0x07] |= 0x01;
- break;
- }
- pReg->sisRegs3C2[0x00] = inb(0x3CC) | 0x0C; /* Programmable Clock */
+ pReg->sisRegs3C2 = inb(0x3CC) | 0x0C; /* Programmable Clock */
if (pSiS->FastVram && ((pSiS->Chipset == PCI_CHIP_SIS530) ||
(pSiS->Chipset == PCI_CHIP_SIS6326) ||
@@ -659,16 +313,6 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->sisRegs3C4[MMIOEnable] |= 0x60; /* At PCI base */
pReg->sisRegs3C4[Mode64] |= 0x80;
break;
- case PCI_CHIP_SIS300:
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540:
- pReg->sisRegs3C4[0x1E] |= 0x40;
- if (pSiS->TurboQueue) { /* set Turbo Queue as 512k */
- temp1 = ((pScrn->videoRam/64)-4);
- pReg->sisRegs3C4[0x26] = temp1 & 0xFF;
- pReg->sisRegs3C4[0x27] = ((temp1 >> 8) & 3) || 0xF0;
- }
- break;
}
}
@@ -731,9 +375,8 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
break;
case PCI_CHIP_SIS530:
- Find530Threshold(pScrn, pSiS->MemClock, mode->Clock,
- pScrn->bitsPerPixel, pSiS->BusWidth, pSiS->Flags,
- &CRT_CPUthresholdLow, &CRT_CPUthresholdHigh);
+ (*pSiS->SetThreshold)(pScrn, mode, &CRT_CPUthresholdLow,
+ &CRT_CPUthresholdHigh);
pReg->sisRegs3C4[8] = (CRT_CPUthresholdLow & 0xf) << 4 | 0xF;
pReg->sisRegs3C4[9] &= 0xF0;
pReg->sisRegs3C4[9] |= (CRT_CPUthresholdHigh & 0xF);
@@ -742,90 +385,205 @@ SiSInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
(CRT_CPUthresholdLow & 0x10) >> 2 |
0x08;
break;
- case PCI_CHIP_SIS300:
- Find300_Threshold(pScrn, mode);
- break;
- case PCI_CHIP_SIS630:
- case PCI_CHIP_SIS540: /* temperary settings */
- Find630_Threshold(pScrn, mode);
- break;
}
- outw(VGA_SEQ_INDEX, (SR5State << 8) | 0x05); /* Relock Registers */
+
return(TRUE);
}
-/*
- * Initialise a new mode. This is currently still using the old
- * "initialise struct, restore/write struct to HW" model. That could
- * be changed.
- */
-
-static Bool
-SiSModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
+Bool
+SIS300Init(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
- vgaHWPtr hwp = VGAHWPTR(pScrn);
- vgaRegPtr vgaReg;
- SISPtr pSiS = SISPTR(pScrn);
- SISRegPtr sisReg;
- unsigned char temp;
+ SISPtr pSiS = SISPTR(pScrn);
+ SISRegPtr pReg = &pSiS->ModeReg;
+ vgaRegPtr vgaReg = &VGAHWPTR(pScrn)->ModeReg;
+ int vgaIOBase;
+ unsigned short temp;
+ int offset;
+ int clock = mode->Clock;
+ unsigned int vclk[5];
+
+ int num, denum, div, sbit, scale;
+ unsigned short Threshold_Low, Threshold_High;
+
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4, "SIS300Init()\n");
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 4,
+ "virtualX = %d depth = %d Logical width = %d\n",
+ pScrn->virtualX, pScrn->bitsPerPixel,
+ pScrn->virtualX * pScrn->bitsPerPixel/8);
- vgaHWUnlock(hwp);
+ vgaHWGetIOBase(VGAHWPTR(pScrn));
+ vgaIOBase = VGAHWPTR(pScrn)->IOBase;
- SiSModifyModeInfo(mode);
+ (*pSiS->SiSSave)(pScrn, pReg);
- /* Initialise the ModeReg values */
- if (!vgaHWInit(pScrn, mode))
- return FALSE;
- pScrn->vtSema = TRUE;
+ outw(VGA_SEQ_INDEX, 0x8605);
- setSISIDXREG(pSiS->RelIO+CROFFSET, 0x30, 0xFC, SWITCH_TO_CRT2);
+ pReg->sisRegs3C4[6] &= ~GENMASK(4:2);
+
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ pSiS->DstColor = 0x0000;
+ pReg->sisRegs3C4[6] |= 0x03;
+ break;
+ case 16:
+ if (pScrn->depth==15) {
+ pSiS->DstColor = 0x4000;
+ pReg->sisRegs3C4[6] |= ((1 << 2) | 0x03);
+ } else {
+ pSiS->DstColor = (short) 0x8000;
+ pReg->sisRegs3C4[6] |= ((2 << 2) | 0x03);
+ }
+ break;
+ case 24:
+ pReg->sisRegs3C4[6] |= ((3 << 2) | 0x03);
+ break;
+ case 32:
+ pSiS->DstColor = (short) 0xC000;
+ pReg->sisRegs3C4[6] |= ((4 << 2) | 0x03);
+ break;
+ }
+
+ pSiS->scrnOffset = pScrn->displayWidth * ((pScrn->bitsPerPixel+7)/8);
+
+ pReg->sisRegs3D4[0x19] = 0;
+ pReg->sisRegs3D4[0x1A] &= 0xFC;
+
+ if (mode->Flags & V_INTERLACE) {
+ offset = pSiS->scrnOffset >> 2;
+ pReg->sisRegs3C4[0x06] |= 0x20;
+ if (pSiS->Chipset != PCI_CHIP_SIS300) {
+ temp = (mode->CrtcHSyncStart >> 3) -
+ (mode->CrtcHTotal >> 3)/2;
+ pReg->sisRegs3D4[0x19] = GETVAR8(temp);
+ pReg->sisRegs3D4[0x1A] |= GETBITS(temp, 9:8);
+ }
+ } else {
+ offset = pSiS->scrnOffset >> 3;
+ pReg->sisRegs3C4[0x06] &= ~0x20;
+ }
+
+ pReg->sisRegs3C4[0x07] |= 0x10; /* enable High Speed DAC */
+ pReg->sisRegs3C4[0x07] &= 0xFC;
+ if (clock < 100000)
+ pReg->sisRegs3C4[0x07] |= 0x03;
+ else if (clock < 200000)
+ pReg->sisRegs3C4[0x07] |= 0x02;
+ else if (clock < 250000)
+ pReg->sisRegs3C4[0x07] |= 0x01;
+
+ /* Extended Vertical Overflow */
+ pReg->sisRegs3C4[0x0A] =
+ GETBITSTR(mode->CrtcVTotal -2, 10:10, 0:0) |
+ GETBITSTR(mode->CrtcVDisplay -1, 10:10, 1:1) |
+ GETBITSTR(mode->CrtcVBlankStart , 10:10, 2:2) |
+ GETBITSTR(mode->CrtcVSyncStart , 10:10, 3:3) |
+ GETBITSTR(mode->CrtcVBlankEnd , 8:8, 4:4) |
+ GETBITSTR(mode->CrtcVSyncEnd , 4:4, 5:5) ;
+
+ /* Extended Horizontal Overflow */
+ pReg->sisRegs3C4[0x0B] =
+ GETBITSTR((mode->CrtcHTotal >> 3) - 5, 9:8, 1:0) |
+ GETBITSTR((mode->CrtcHDisplay >> 3) - 1, 9:8, 3:2) |
+ GETBITSTR((mode->CrtcHBlankStart >> 3) , 9:8, 5:4) |
+ GETBITSTR((mode->CrtcHSyncStart >> 3) , 9:8, 7:6) ;
+
+ pReg->sisRegs3C4[0x0C] &= 0xF8;
+ pReg->sisRegs3C4[0x0C] |=
+ GETBITSTR(mode->CrtcHBlankEnd >> 3, 7:6, 1:0) |
+ GETBITSTR(mode->CrtcHSyncEnd >> 3, 5:5, 2:2) ;
+
+ /* Screen Offset */
+ vgaReg->CRTC[0x13] = GETVAR8(offset);
+ pReg->sisRegs3C4[0x0E] &= 0xF0;
+ pReg->sisRegs3C4[0x0E] |= GETBITS(offset, 11:8);
+
+ /* line compare */
+ if (mode->CrtcHDisplay > 0)
+ pReg->sisRegs3C4[0x0F] |= 0x08;
+ else
+ pReg->sisRegs3C4[0x0F] &= 0xF7;
- inSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp);
- temp &= 0xDD;
- temp |= (DRIVER_MODE |DISABLE_CRT2_DISPLAY) >> 8;
- outSISIDXREG(pSiS->RelIO+CROFFSET, 0x31, temp);
+ pReg->sisRegs3C4[0x10] =
+ ((mode->CrtcHDisplay *((pScrn->bitsPerPixel+7)/8) + 63) >> 6)+1;
- if (!SiSInit(pScrn, mode))
- return FALSE;
+ /* Enable Linear */
+ pReg->sisRegs3C4[0x20] |= 0x81;
- PDEBUG(xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "HDisplay: %d, VDisplay: %d \n",
- mode->HDisplay, mode->VDisplay));
- /* Program the registers */
- vgaHWProtect(pScrn, TRUE);
- vgaReg = &hwp->ModeReg;
- sisReg = &pSiS->ModeReg;
- vgaReg->Attribute[0x10] = 0x01;
- if (pScrn->bitsPerPixel > 8)
- vgaReg->Graphics[0x05] = 0x00;
+ /* Set vclk */
+ if (compute_vclk(clock, &num, &denum, &div, &sbit, &scale)) {
+ pReg->sisRegs3C4[0x2B] = (num -1) & 0x7f;
+ if (div == 2)
+ pReg->sisRegs3C4[0x2B] |= 0x80;
+ pReg->sisRegs3C4[0x2C] = ((denum -1) & 0x1f);
+ pReg->sisRegs3C4[0x2C] |= (((scale-1)&3) << 5);
+ if (sbit)
+ pReg->sisRegs3C4[0x2C] |= 0x80;
+ pReg->sisRegs3C4[0x2D] = 0x80;
+ }
+ else {
+ /* if compute_vclk cannot handle the request clock try sisCalcClock! */
+ SiSCalcClock(pScrn, clock, 2, vclk);
+ pReg->sisRegs3C4[0x2B] = (vclk[Midx] - 1) & 0x7f ;
+ pReg->sisRegs3C4[0x2B] |= ((vclk[VLDidx] == 2 ) ? 1 : 0 ) << 7 ;
- vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+ /* bits [4:0] contain denumerator -MC */
+ pReg->sisRegs3C4[0x2C] = (vclk[Nidx] -1) & 0x1f ;
- SiSRestore(pScrn, sisReg);
+ if (vclk[Pidx] <= 4) {
+ /* postscale 1,2,3,4 */
+ pReg->sisRegs3C4[0x2C] |= (vclk[Pidx] -1 ) << 5 ;
+ pReg->sisRegs3C4[0x2C] &= 0x7F;
+ } else {
+ /* postscale 6,8 */
+ pReg->sisRegs3C4[0x2C] |= ((vclk[Pidx] / 2) -1 ) << 5 ;
+ pReg->sisRegs3C4[0x2C] |= 0x80;
+ }
+ pReg->sisRegs3C4[0x2D] = 0x80;
+ } /* end of set vclk */
- if (pSiS->VBFlags) {
- SiSSetMode(pScrn, 0x44);
- outSISIDXREG(pSiS->RelIO+CROFFSET, 0x32,
- sisReg->sisRegs3C4[0x32]);
+ if (clock > 150000) { /* enable two-pixel mode */
+ pReg->sisRegs3C4[0x07] |= 0x80;
+ pReg->sisRegs3C4[0x32] |= 0x08;
+ } else {
+ pReg->sisRegs3C4[0x07] &= 0x7F;
+ pReg->sisRegs3C4[0x32] &= 0xF7;
}
- vgaHWProtect(pScrn, FALSE);
- if (pSiS->MemClock)
- xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
- "Memory clock is set to %3.3fMHz\n", pSiS->MemClock/1.0);
+ pReg->sisRegs3C2 = inb(0x3CC) | 0x0C; /* Programmable Clock */
-/* Reserved for debug
- *
- SiSIODump(pScrn);
- SiSDumpModeInfo(pScrn, mode);
- *
- */
- return TRUE;
+ if (!pSiS->NoAccel) {
+ pReg->sisRegs3C4[0x1E] |= 0x42;
+ if (pSiS->TurboQueue) { /* set Turbo Queue as 512k */
+ temp = ((pScrn->videoRam/64)-4);
+ pReg->sisRegs3C4[0x26] = temp & 0xFF;
+ pReg->sisRegs3C4[0x27] = ((temp >> 8) & 3) || 0xF0;
+ }
+ }
+
+ /* set threshold value */
+ (*pSiS->SetThreshold)(pScrn, mode, &Threshold_Low, &Threshold_High);
+ pReg->sisRegs3C4[0x08] = GETBITSTR(Threshold_Low, 3:0, 7:4) | 0xF;
+ pReg->sisRegs3C4[0x0F] &= ~GENMASK(5:5);
+ pReg->sisRegs3C4[0x0F] |= GETBITSTR(Threshold_Low, 4:4, 5:5);
+ pReg->sisRegs3C4[0x09] &= ~GENMASK(3:0);
+ pReg->sisRegs3C4[0x09] |= GETBITS(Threshold_High, 3:0);
+
+ return(TRUE);
}
-void SiSVGASetup(ScrnInfoPtr pScrn)
+void SISVGAPreInit(ScrnInfoPtr pScrn)
{
- SISPTR(pScrn)->ModeInit = SiSModeInit;
+ SISPtr pSiS = SISPTR(pScrn);
+
+ switch (pSiS->Chipset) {
+ case PCI_CHIP_SIS300:
+ case PCI_CHIP_SIS630:
+ case PCI_CHIP_SIS540:
+ pSiS->ModeInit = SIS300Init;
+ break;
+ default:
+ pSiS->ModeInit = SISInit;
+ }
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/Imakefile
new file mode 100644
index 000000000..9059e9a16
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/Imakefile
@@ -0,0 +1,38 @@
+XCOMM
+XCOMM This is an Imakefile for the bw2 driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/Imakefile,v 1.1 2000/06/30 17:15:13 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = bw2_driver.c
+OBJS = bw2_driver.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(XF86SRC)/xf1bpp \
+ -I$(XF86SRC)/ramdac \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(sunbw2,$(OBJS))
+
+InstallObjectModule(sunbw2,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(sunbw2,)
+InstallModuleManPage(sunbw2)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2.h b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2.h
new file mode 100644
index 000000000..a1284c854
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2.h
@@ -0,0 +1,50 @@
+/*
+ * BW2 framebuffer - defines.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2.h,v 1.1 2000/06/30 17:15:13 dawes Exp $ */
+
+#ifndef BW2_H
+#define BW2_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "xf86sbusBus.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define BW2_RAM_VOFF 0
+
+typedef struct {
+ unsigned char *fb;
+ int width;
+ int height;
+
+ sbusDevicePtr psdp;
+ CloseScreenProcPtr CloseScreen;
+} Bw2Rec, *Bw2Ptr;
+
+#define GET_BW2_FROM_SCRN(p) ((Bw2Ptr)((p)->driverPrivate))
+
+#endif /* BW2_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c
new file mode 100644
index 000000000..6bfe6916c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c
@@ -0,0 +1,588 @@
+/*
+ * BW2 framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/bw2_driver.c,v 1.1 2000/06/30 17:15:14 dawes Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#include "xf1bpp.h"
+#include "xf86cmap.h"
+#include "bw2.h"
+
+static OptionInfoPtr BW2AvailableOptions(int chipid, int busid);
+static void BW2Identify(int flags);
+static Bool BW2Probe(DriverPtr drv, int flags);
+static Bool BW2PreInit(ScrnInfoPtr pScrn, int flags);
+static Bool BW2ScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool BW2EnterVT(int scrnIndex, int flags);
+static void BW2LeaveVT(int scrnIndex, int flags);
+static Bool BW2CloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool BW2SaveScreen(ScreenPtr pScreen, int mode);
+
+/* Required if the driver supports mode switching */
+static Bool BW2SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void BW2AdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void BW2FreeScreen(int scrnIndex, int flags);
+static int BW2ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void BW2Sync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define BW2_NAME "SUNBW2"
+#define BW2_DRIVER_NAME "sunbw2"
+#define BW2_MAJOR_VERSION 1
+#define BW2_MINOR_VERSION 0
+#define BW2_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNBW2 = {
+ VERSION,
+ BW2_DRIVER_NAME,
+ BW2Identify,
+ BW2Probe,
+ BW2AvailableOptions,
+ NULL,
+ 0
+};
+
+static OptionInfoRec BW2Options[] = {
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(bw2Setup);
+
+static XF86ModuleVersionInfo sunbw2VersRec =
+{
+ "sunbw2",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ BW2_MAJOR_VERSION, BW2_MINOR_VERSION, BW2_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData sunbw2ModuleData = { &sunbw2VersRec, bw2Setup, NULL };
+
+pointer
+bw2Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNBW2, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+BW2GetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an Bw2Rec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(Bw2Rec), 1);
+ return TRUE;
+}
+
+static void
+BW2FreeRec(ScrnInfoPtr pScrn)
+{
+ Bw2Ptr pBw2;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pBw2 = GET_BW2_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+BW2AvailableOptions(int chipid, int busid)
+{
+ return BW2Options;
+}
+
+/* Mandatory */
+static void
+BW2Identify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for BWtwo\n", BW2_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+BW2Probe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(BW2_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(BW2_NAME, SBUS_DEVICE_BW2,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = BW2_DRIVER_NAME;
+ pScrn->name = BW2_NAME;
+ pScrn->Probe = BW2Probe;
+ pScrn->PreInit = BW2PreInit;
+ pScrn->ScreenInit = BW2ScreenInit;
+ pScrn->SwitchMode = BW2SwitchMode;
+ pScrn->AdjustFrame = BW2AdjustFrame;
+ pScrn->EnterVT = BW2EnterVT;
+ pScrn->LeaveVT = BW2LeaveVT;
+ pScrn->FreeScreen = BW2FreeScreen;
+ pScrn->ValidMode = BW2ValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+BW2PreInit(ScrnInfoPtr pScrn, int flags)
+{
+ Bw2Ptr pBw2;
+ sbusDevicePtr psdp;
+ MessageType from;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the Bw2Rec driverPrivate */
+ if (!BW2GetRec(pScrn)) {
+ return FALSE;
+ }
+ pBw2 = GET_BW2_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* BW2 is purely SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pBw2->psdp = psdp;
+ } else
+ return FALSE;
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, NoDepth24Support)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 1:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* Set the bits per RGB for 8bpp mode */
+ from = X_DEFAULT;
+
+ if (xf86LoadSubModule(pScrn, "xf1bpp") == NULL) {
+ BW2FreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "BW2 does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pBw2->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+BW2ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ Bw2Ptr pBw2;
+ int ret;
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pBw2 = GET_BW2_FROM_SCRN(pScrn);
+
+ /* Map the BW2 memory */
+ pBw2->fb =
+ xf86MapSbusMem (pBw2->psdp, BW2_RAM_VOFF,
+ (pBw2->psdp->width * pBw2->psdp->height / 8));
+
+ if (! pBw2->fb)
+ return FALSE;
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ BW2SaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Set the bits per RGB for 8bpp mode */
+ pScrn->rgbBits = 8;
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ ret = xf1bppScreenInit(pScreen, pBw2->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX);
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ pBw2->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = BW2CloseScreen;
+ pScreen->SaveScreen = BW2SaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ BW2SaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+BW2SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+BW2AdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+BW2EnterVT(int scrnIndex, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+BW2LeaveVT(int scrnIndex, int flags)
+{
+ return;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+BW2CloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ Bw2Ptr pBw2 = GET_BW2_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ xf86UnmapSbusMem(pBw2->psdp, pBw2->fb,
+ (pBw2->psdp->width * pBw2->psdp->height / 8));
+
+ pScreen->CloseScreen = pBw2->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+BW2FreeScreen(int scrnIndex, int flags)
+{
+ BW2FreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+BW2ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+BW2SaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+BW2Sync(ScrnInfoPtr pScrn)
+{
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp
new file mode 100644
index 000000000..5cba0b860
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunbw2/sunbw2.cpp,v 1.1 2000/06/30 17:15:14 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNBW2 __drivermansuffix__ "Version 4.0" "XFree86"
+.SH NAME
+sunbw2 \- BW2 video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsunbw2\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B sunbw2
+is an XFree86 driver for Sun BW2 video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B sunbw2
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg14/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/Imakefile
new file mode 100644
index 000000000..9cd0a3922
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/Imakefile
@@ -0,0 +1,38 @@
+XCOMM
+XCOMM This is an Imakefile for the cg14 driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/Imakefile,v 1.1 2000/06/30 17:15:14 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = cg14_driver.c
+OBJS = cg14_driver.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \
+ -I$(XF86SRC)/ramdac \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(suncg14,$(OBJS))
+
+InstallObjectModule(suncg14,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(suncg14,)
+InstallModuleManPage(suncg14)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14.h b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14.h
new file mode 100644
index 000000000..04df5dd5c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14.h
@@ -0,0 +1,71 @@
+/*
+ * CG14 framebuffer - defines.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14.h,v 1.1 2000/06/30 17:15:14 dawes Exp $ */
+
+#ifndef CG14_H
+#define CG14_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "xf86sbusBus.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define CG14_REGS_VOFF 0x00000000 /* registers */
+#define CG14_XLUT_VOFF 0x00003000 /* X Look Up Table */
+#define CG14_CLUT1_VOFF 0x00004000 /* Color Look Up Table */
+#define CG14_CLUT2_VOFF 0x00005000 /* Color Look Up Table */
+#define CG14_CLUT3_VOFF 0x00006000 /* Color Look Up Table */
+#define CG14_DIRECT_VOFF 0x10000000
+#define CG14_CTLREG_VOFF 0x20000000
+#define CG14_CURSOR_VOFF 0x30000000
+#define CG14_SHDW_VRT_VOFF 0x40000000
+#define CG14_XBGR_VOFF 0x50000000
+#define CG14_BGR_VOFF 0x60000000
+#define CG14_X16_VOFF 0x70000000
+#define CG14_C16_VOFF 0x80000000
+#define CG14_X32_VOFF 0x90000000
+#define CG14_B32_VOFF 0xa0000000
+#define CG14_G32_VOFF 0xb0000000
+#define CG14_R32_VOFF 0xc0000000
+
+typedef struct {
+ unsigned int *fb;
+ unsigned char *x32;
+ unsigned char *xlut;
+ int width;
+ int height;
+ sbusDevicePtr psdp;
+ CloseScreenProcPtr CloseScreen;
+} Cg14Rec, *Cg14Ptr;
+
+#define GET_CG14_FROM_SCRN(p) ((Cg14Ptr)((p)->driverPrivate))
+
+#ifdef linux
+#define CG14_SET_PIXELMODE (('M' << 8) | 3)
+#endif
+
+#endif /* CG14_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c
new file mode 100644
index 000000000..542933ce5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c
@@ -0,0 +1,673 @@
+/*
+ * CG14 framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/cg14_driver.c,v 1.1 2000/06/30 17:15:14 dawes Exp $ */
+
+#define PSZ 8
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "xf86cmap.h"
+#include "cg14.h"
+
+static OptionInfoPtr CG14AvailableOptions(int chipid, int busid);
+static void CG14Identify(int flags);
+static Bool CG14Probe(DriverPtr drv, int flags);
+static Bool CG14PreInit(ScrnInfoPtr pScrn, int flags);
+static Bool CG14ScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool CG14EnterVT(int scrnIndex, int flags);
+static void CG14LeaveVT(int scrnIndex, int flags);
+static Bool CG14CloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool CG14SaveScreen(ScreenPtr pScreen, int mode);
+static void CG14InitCplane24(ScrnInfoPtr pScrn);
+static void CG14ExitCplane24(ScrnInfoPtr pScrn);
+
+/* Required if the driver supports mode switching */
+static Bool CG14SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void CG14AdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void CG14FreeScreen(int scrnIndex, int flags);
+static int CG14ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void CG14Sync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define CG14_NAME "SUNCG14"
+#define CG14_DRIVER_NAME "suncg14"
+#define CG14_MAJOR_VERSION 1
+#define CG14_MINOR_VERSION 0
+#define CG14_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNCG14 = {
+ VERSION,
+ CG14_DRIVER_NAME,
+ CG14Identify,
+ CG14Probe,
+ CG14AvailableOptions,
+ NULL,
+ 0
+};
+
+static OptionInfoRec CG14Options[] = {
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(cg14Setup);
+
+static XF86ModuleVersionInfo suncg14VersRec =
+{
+ "suncg14",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ CG14_MAJOR_VERSION, CG14_MINOR_VERSION, CG14_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData suncg14ModuleData = { &suncg14VersRec, cg14Setup, NULL };
+
+pointer
+cg14Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNCG14, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+CG14GetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an Cg14Rec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(Cg14Rec), 1);
+ return TRUE;
+}
+
+static void
+CG14FreeRec(ScrnInfoPtr pScrn)
+{
+ Cg14Ptr pCg14;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pCg14 = GET_CG14_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+CG14AvailableOptions(int chipid, int busid)
+{
+ return CG14Options;
+}
+
+/* Mandatory */
+static void
+CG14Identify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for CG14\n", CG14_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+CG14Probe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(CG14_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(CG14_NAME, SBUS_DEVICE_CG14,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = CG14_DRIVER_NAME;
+ pScrn->name = CG14_NAME;
+ pScrn->Probe = CG14Probe;
+ pScrn->PreInit = CG14PreInit;
+ pScrn->ScreenInit = CG14ScreenInit;
+ pScrn->SwitchMode = CG14SwitchMode;
+ pScrn->AdjustFrame = CG14AdjustFrame;
+ pScrn->EnterVT = CG14EnterVT;
+ pScrn->LeaveVT = CG14LeaveVT;
+ pScrn->FreeScreen = CG14FreeScreen;
+ pScrn->ValidMode = CG14ValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+CG14PreInit(ScrnInfoPtr pScrn, int flags)
+{
+ Cg14Ptr pCg14;
+ sbusDevicePtr psdp = NULL;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the Cg14Rec driverPrivate */
+ if (!CG14GetRec(pScrn)) {
+ return FALSE;
+ }
+ pCg14 = GET_CG14_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* CG14 is purely AFX, but we handle it like SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pCg14->psdp = psdp;
+ } else
+ return FALSE;
+ }
+ if (psdp == NULL)
+ return FALSE;
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 32:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ /* Collect all of the relevant option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+ /* Process the options */
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, CG14Options);
+
+ /*
+ * This must happen after pScrn->display has been set because
+ * xf86SetWeight references it.
+ */
+ if (pScrn->depth > 8) {
+ rgb weight = {10, 11, 11};
+ rgb mask = {0xff, 0xff00, 0xff0000};
+
+ if (!xf86SetWeight(pScrn, weight, mask)) {
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+ else if (pScrn->depth > 8) {
+ /* We don't currently support DirectColor */
+ if (pScrn->defaultVisual != TrueColor) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
+ " (%s) is not supported\n",
+ xf86GetVisualName(pScrn->defaultVisual));
+ return FALSE;
+ }
+ }
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ if (xf86LoadSubModule(pScrn, "cfb32") == NULL) {
+ CG14FreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "CG14 does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pCg14->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+CG14ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ Cg14Ptr pCg14;
+ VisualPtr visual;
+ int ret;
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pCg14 = GET_CG14_FROM_SCRN(pScrn);
+
+ /* Map the CG14 memory */
+ pCg14->fb = xf86MapSbusMem (pCg14->psdp, CG14_BGR_VOFF, 4 *
+ (pCg14->psdp->width * pCg14->psdp->height));
+ pCg14->x32 = xf86MapSbusMem (pCg14->psdp, CG14_X32_VOFF,
+ (pCg14->psdp->width * pCg14->psdp->height));
+ pCg14->xlut = xf86MapSbusMem (pCg14->psdp, CG14_XLUT_VOFF, 4096);
+
+ if (! pCg14->fb || !pCg14->x32 || !pCg14->xlut)
+ return FALSE;
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ CG14SaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth, TrueColorMask,
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ CG14InitCplane24(pScrn);
+ ret = cfb32ScreenInit(pScreen, pCg14->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX);
+
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ 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;
+ }
+ }
+ }
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ pCg14->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = CG14CloseScreen;
+ pScreen->SaveScreen = CG14SaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ CG14SaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+CG14SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+CG14AdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+CG14EnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ CG14InitCplane24 (pScrn);
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+CG14LeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ CG14ExitCplane24 (pScrn);
+ return;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+CG14CloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ xf86UnmapSbusMem(pCg14->psdp, pCg14->fb,
+ (pCg14->psdp->width * pCg14->psdp->height * 4));
+ xf86UnmapSbusMem(pCg14->psdp, pCg14->x32,
+ (pCg14->psdp->width * pCg14->psdp->height));
+ xf86UnmapSbusMem(pCg14->psdp, pCg14->xlut, 4096);
+
+ pScreen->CloseScreen = pCg14->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+CG14FreeScreen(int scrnIndex, int flags)
+{
+ CG14FreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+CG14ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+CG14SaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+CG14Sync(ScrnInfoPtr pScrn)
+{
+ return;
+}
+
+/*
+ * This initializes the card for 24 bit mode.
+ */
+static void
+CG14InitCplane24(ScrnInfoPtr pScrn)
+{
+ Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
+ int size, bpp;
+
+ size = pScrn->virtualX * pScrn->virtualY;
+ bpp = 32;
+ ioctl (pCg14->psdp->fd, CG14_SET_PIXELMODE, &bpp);
+ memset (pCg14->fb, 0, size * 4);
+ memset (pCg14->x32, 0, size);
+ memset (pCg14->xlut, 0, 0x200);
+}
+
+/*
+ * This initializes the card for 8 bit mode.
+ */
+static void
+CG14ExitCplane24(ScrnInfoPtr pScrn)
+{
+ Cg14Ptr pCg14 = GET_CG14_FROM_SCRN(pScrn);
+ int bpp = 8;
+
+ ioctl (pCg14->psdp->fd, CG14_SET_PIXELMODE, &bpp);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp
new file mode 100644
index 000000000..e15f8ecd7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg14/suncg14.cpp,v 1.1 2000/06/30 17:15:14 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNCG14 __drivermansuffix__ "Version 4.0" "XFree86"
+.SH NAME
+suncg14 \- CG14 video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsuncg14\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B suncg14
+is an XFree86 driver for Sun CG14 video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B suncg14
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg3/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/Imakefile
new file mode 100644
index 000000000..f0f8bea69
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/Imakefile
@@ -0,0 +1,38 @@
+XCOMM
+XCOMM This is an Imakefile for the cg3 driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/Imakefile,v 1.1 2000/06/30 17:15:15 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = cg3_driver.c
+OBJS = cg3_driver.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \
+ -I$(XF86SRC)/ramdac \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(suncg3,$(OBJS))
+
+InstallObjectModule(suncg3,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(suncg3,)
+InstallModuleManPage(suncg3)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3.h b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3.h
new file mode 100644
index 000000000..c2efa9443
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3.h
@@ -0,0 +1,50 @@
+/*
+ * Cg3 framebuffer - defines.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3.h,v 1.1 2000/06/30 17:15:15 dawes Exp $ */
+
+#ifndef CG3_H
+#define CG3_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "xf86sbusBus.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define CG3_RAM_VOFF 0x4000000
+
+typedef struct {
+ unsigned char *fb;
+ int width;
+ int height;
+
+ sbusDevicePtr psdp;
+ CloseScreenProcPtr CloseScreen;
+} Cg3Rec, *Cg3Ptr;
+
+#define GET_CG3_FROM_SCRN(p) ((Cg3Ptr)((p)->driverPrivate))
+
+#endif /* CG3_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c
new file mode 100644
index 000000000..a7030d536
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c
@@ -0,0 +1,592 @@
+/*
+ * Cg3 framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/cg3_driver.c,v 1.1 2000/06/30 17:15:15 dawes Exp $ */
+
+#define PSZ 8
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#include "cfb.h"
+#include "xf86cmap.h"
+#include "cg3.h"
+
+static OptionInfoPtr CG3AvailableOptions(int chipid, int busid);
+static void CG3Identify(int flags);
+static Bool CG3Probe(DriverPtr drv, int flags);
+static Bool CG3PreInit(ScrnInfoPtr pScrn, int flags);
+static Bool CG3ScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool CG3EnterVT(int scrnIndex, int flags);
+static void CG3LeaveVT(int scrnIndex, int flags);
+static Bool CG3CloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool CG3SaveScreen(ScreenPtr pScreen, int mode);
+
+/* Required if the driver supports mode switching */
+static Bool CG3SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void CG3AdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void CG3FreeScreen(int scrnIndex, int flags);
+static int CG3ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void CG3Sync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define CG3_NAME "SUNCG3"
+#define CG3_DRIVER_NAME "suncg3"
+#define CG3_MAJOR_VERSION 1
+#define CG3_MINOR_VERSION 0
+#define CG3_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNCG3 = {
+ VERSION,
+ CG3_DRIVER_NAME,
+ CG3Identify,
+ CG3Probe,
+ CG3AvailableOptions,
+ NULL,
+ 0
+};
+
+static OptionInfoRec CG3Options[] = {
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(cg3Setup);
+
+static XF86ModuleVersionInfo suncg3VersRec =
+{
+ "suncg3",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ CG3_MAJOR_VERSION, CG3_MINOR_VERSION, CG3_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData suncg3ModuleData = { &suncg3VersRec, cg3Setup, NULL };
+
+pointer
+cg3Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNCG3, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+CG3GetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an Cg3Rec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(Cg3Rec), 1);
+ return TRUE;
+}
+
+static void
+CG3FreeRec(ScrnInfoPtr pScrn)
+{
+ Cg3Ptr pCg3;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pCg3 = GET_CG3_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+CG3AvailableOptions(int chipid, int busid)
+{
+ return CG3Options;
+}
+
+/* Mandatory */
+static void
+CG3Identify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for CGthree\n", CG3_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+CG3Probe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(CG3_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(CG3_NAME, SBUS_DEVICE_CG3,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = CG3_DRIVER_NAME;
+ pScrn->name = CG3_NAME;
+ pScrn->Probe = CG3Probe;
+ pScrn->PreInit = CG3PreInit;
+ pScrn->ScreenInit = CG3ScreenInit;
+ pScrn->SwitchMode = CG3SwitchMode;
+ pScrn->AdjustFrame = CG3AdjustFrame;
+ pScrn->EnterVT = CG3EnterVT;
+ pScrn->LeaveVT = CG3LeaveVT;
+ pScrn->FreeScreen = CG3FreeScreen;
+ pScrn->ValidMode = CG3ValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+CG3PreInit(ScrnInfoPtr pScrn, int flags)
+{
+ Cg3Ptr pCg3;
+ sbusDevicePtr psdp;
+ MessageType from;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the Cg3Rec driverPrivate */
+ if (!CG3GetRec(pScrn)) {
+ return FALSE;
+ }
+ pCg3 = GET_CG3_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* CG3 is purely SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pCg3->psdp = psdp;
+ } else
+ return FALSE;
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, NoDepth24Support)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 8:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* Set the bits per RGB for 8bpp mode */
+ from = X_DEFAULT;
+
+ if (xf86LoadSubModule(pScrn, "cfb") == NULL) {
+ CG3FreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "CG3 does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pCg3->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+CG3ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ Cg3Ptr pCg3;
+ int ret;
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pCg3 = GET_CG3_FROM_SCRN(pScrn);
+
+ /* Map the CG3 memory */
+ pCg3->fb =
+ xf86MapSbusMem (pCg3->psdp, CG3_RAM_VOFF,
+ (pCg3->psdp->width * pCg3->psdp->height));
+
+ if (! pCg3->fb)
+ return FALSE;
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ CG3SaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Set the bits per RGB for 8bpp mode */
+ pScrn->rgbBits = 8;
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ ret = cfbScreenInit(pScreen, pCg3->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX);
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ if(!xf86SbusHandleColormaps(pScreen, pCg3->psdp))
+ return FALSE;
+
+ pCg3->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = CG3CloseScreen;
+ pScreen->SaveScreen = CG3SaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ CG3SaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+CG3SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+CG3AdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+CG3EnterVT(int scrnIndex, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+CG3LeaveVT(int scrnIndex, int flags)
+{
+ return;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+CG3CloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ Cg3Ptr pCg3 = GET_CG3_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ xf86UnmapSbusMem(pCg3->psdp, pCg3->fb,
+ (pCg3->psdp->width * pCg3->psdp->height));
+
+ pScreen->CloseScreen = pCg3->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+CG3FreeScreen(int scrnIndex, int flags)
+{
+ CG3FreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+CG3ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+CG3SaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+CG3Sync(ScrnInfoPtr pScrn)
+{
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp
new file mode 100644
index 000000000..65fb08cf0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg3/suncg3.cpp,v 1.1 2000/06/30 17:15:15 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNCG3 __drivermansuffix__ "Version 4.0" "XFree86"
+.SH NAME
+suncg3 \- CG3 video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsuncg3\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B suncg3
+is an XFree86 driver for Sun CG3 video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B suncg3
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg6/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/Imakefile
new file mode 100644
index 000000000..94df6aca0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/Imakefile
@@ -0,0 +1,38 @@
+XCOMM
+XCOMM This is an Imakefile for the cg6 driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/Imakefile,v 1.2 2000/06/30 17:15:15 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = cg6_driver.c cg6_cursor.c
+OBJS = cg6_driver.o cg6_cursor.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \
+ -I$(XF86SRC)/ramdac \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(suncg6,$(OBJS))
+
+InstallObjectModule(suncg6,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(suncg6,)
+InstallModuleManPage(suncg6)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6.h b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6.h
new file mode 100644
index 000000000..5945b201f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6.h
@@ -0,0 +1,97 @@
+/*
+ * GX and Turbo GX framebuffer - defines.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6.h,v 1.2 2000/06/30 17:15:15 dawes Exp $ */
+
+#ifndef CG6_H
+#define CG6_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "cg6_regs.h"
+#include "xf86sbusBus.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define CG6_FBC_VOFF 0x70000000
+#define CG6_TEC_VOFF 0x70001000
+#define CG6_BTREGS_VOFF 0x70002000
+#define CG6_FHC_VOFF 0x70004000
+#define CG6_THC_VOFF 0x70005000
+#define CG6_ROM_VOFF 0x70006000
+#define CG6_RAM_VOFF 0x70016000
+#define CG6_DHC_VOFF 0x80000000
+
+typedef struct {
+ unsigned int fg, bg; /* FG/BG colors for stipple */
+ unsigned int patalign; /* X/Y alignment of bits */
+ unsigned int alu; /* Transparent/Opaque + rop */
+ unsigned int bits[32]; /* The stipple bits themselves */
+} Cg6StippleRec, *Cg6StipplePtr;
+
+typedef struct {
+ int type;
+ Cg6StipplePtr stipple;
+} Cg6PrivGCRec, *Cg6PrivGCPtr;
+
+typedef struct {
+ unsigned char *fb;
+ Cg6FbcPtr fbc;
+ Cg6ThcPtr thc;
+ int vclipmax;
+ int width;
+ int height;
+
+ sbusDevicePtr psdp;
+ Bool HWCursor;
+ Bool NoAccel;
+ CloseScreenProcPtr CloseScreen;
+ xf86CursorInfoPtr CursorInfoRec;
+ unsigned int CursorXY;
+ int CursorBg, CursorFg;
+ Bool CursorEnabled;
+} Cg6Rec, *Cg6Ptr;
+
+extern int Cg6ScreenPrivateIndex;
+extern int Cg6GCPrivateIndex;
+extern int Cg6WindowPrivateIndex;
+
+#define GET_CG6_FROM_SCRN(p) ((Cg6Ptr)((p)->driverPrivate))
+
+#define Cg6GetScreenPrivate(s) \
+((Cg6Ptr) (s)->devPrivates[Cg6ScreenPrivateIndex].ptr)
+
+#define Cg6GetGCPrivate(g) \
+((Cg6PrivGCPtr) (g)->devPrivates [Cg6GCPrivateIndex].ptr)
+
+#define Cg6GetWindowPrivate(w) \
+((Cg6StipplePtr) (w)->devPrivates[Cg6WindowPrivateIndex].ptr)
+
+#define Cg6SetWindowPrivate(w,p) \
+((w)->devPrivates[Cg6WindowPrivateIndex].ptr = (pointer) p)
+
+extern int cg6RopTable[];
+
+#endif /* CG6_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_cursor.c
new file mode 100644
index 000000000..72a396f0e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_cursor.c
@@ -0,0 +1,121 @@
+/*
+ * Hardware cursor support for GX or Turbo GX
+ *
+ * Copyright 2000 by Jakub Jelinek <jakub@redhat.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 of Jakub
+ * Jelinek not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Jakub Jelinek makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL JAKUB JELINEK 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_cursor.c,v 1.1 2000/06/30 19:30:46 dawes Exp $ */
+
+#include "cg6.h"
+
+static void CG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void CG6ShowCursor(ScrnInfoPtr pScrn);
+static void CG6HideCursor(ScrnInfoPtr pScrn);
+static void CG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void CG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+
+static void
+CG6LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+ int i;
+ unsigned int *data = (unsigned int *)src;
+
+ for (i = 0; i < 32; i++)
+ pCg6->thc->thc_cursmask[i] = *data++;
+ for (i = 0; i < 32; i++)
+ pCg6->thc->thc_cursbits[i] = *data++;
+}
+
+static void
+CG6ShowCursor(ScrnInfoPtr pScrn)
+{
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ pCg6->thc->thc_cursxy = pCg6->CursorXY;
+ pCg6->CursorEnabled = TRUE;
+}
+
+static void
+CG6HideCursor(ScrnInfoPtr pScrn)
+{
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ pCg6->thc->thc_cursxy = ((65536 - 32) << 16) | (65536 - 32);
+ pCg6->CursorEnabled = FALSE;
+}
+
+static void
+CG6SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ pCg6->CursorXY = ((x & 0xffff) << 16) | (y & 0xffff);
+ if (pCg6->CursorEnabled)
+ pCg6->thc->thc_cursxy = pCg6->CursorXY;
+}
+
+static void
+CG6SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ if (bg != pCg6->CursorBg || fg != pCg6->CursorFg) {
+ xf86SbusSetOsHwCursorCmap(pCg6->psdp, bg, fg);
+ pCg6->CursorBg = bg;
+ pCg6->CursorFg = fg;
+ }
+}
+
+Bool
+CG6HWCursorInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ Cg6Ptr pCg6;
+ xf86CursorInfoPtr infoPtr;
+
+ pCg6 = GET_CG6_FROM_SCRN(pScrn);
+ pCg6->CursorXY = 0;
+ pCg6->CursorBg = pCg6->CursorFg = 0;
+ pCg6->CursorEnabled = FALSE;
+
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ pCg6->CursorInfoRec = infoPtr;
+
+ infoPtr->MaxWidth = 32;
+ infoPtr->MaxHeight = 32;
+ infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED |
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
+
+ infoPtr->SetCursorColors = CG6SetCursorColors;
+ infoPtr->SetCursorPosition = CG6SetCursorPosition;
+ infoPtr->LoadCursorImage = CG6LoadCursorImage;
+ infoPtr->HideCursor = CG6HideCursor;
+ infoPtr->ShowCursor = CG6ShowCursor;
+ infoPtr->UseHWCursor = NULL;
+
+ return xf86InitCursor(pScreen, infoPtr);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c
new file mode 100644
index 000000000..ffdf5ff90
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c
@@ -0,0 +1,665 @@
+/*
+ * GX and Turbo GX framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_driver.c,v 1.2 2000/06/30 17:15:15 dawes Exp $ */
+
+#define PSZ 8
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#include "cfb.h"
+#include "xf86cmap.h"
+#include "cg6.h"
+
+static OptionInfoPtr CG6AvailableOptions(int chipid, int busid);
+static void CG6Identify(int flags);
+static Bool CG6Probe(DriverPtr drv, int flags);
+static Bool CG6PreInit(ScrnInfoPtr pScrn, int flags);
+static Bool CG6ScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool CG6EnterVT(int scrnIndex, int flags);
+static void CG6LeaveVT(int scrnIndex, int flags);
+static Bool CG6CloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool CG6SaveScreen(ScreenPtr pScreen, int mode);
+
+/* Required if the driver supports mode switching */
+static Bool CG6SwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void CG6AdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void CG6FreeScreen(int scrnIndex, int flags);
+static int CG6ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void CG6Sync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define CG6_NAME "SUNCG6"
+#define CG6_DRIVER_NAME "suncg6"
+#define CG6_MAJOR_VERSION 1
+#define CG6_MINOR_VERSION 0
+#define CG6_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNCG6 = {
+ VERSION,
+ CG6_DRIVER_NAME,
+ CG6Identify,
+ CG6Probe,
+ CG6AvailableOptions,
+ NULL,
+ 0
+};
+
+typedef enum {
+ OPTION_SW_CURSOR,
+ OPTION_HW_CURSOR,
+ OPTION_NOACCEL
+} CG6Opts;
+
+static OptionInfoRec CG6Options[] = {
+ { OPTION_SW_CURSOR, "SWcursor", 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 }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(cg6Setup);
+
+static XF86ModuleVersionInfo suncg6VersRec =
+{
+ "suncg6",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ CG6_MAJOR_VERSION, CG6_MINOR_VERSION, CG6_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData suncg6ModuleData = { &suncg6VersRec, cg6Setup, NULL };
+
+pointer
+cg6Setup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNCG6, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+CG6GetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an Cg6Rec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(Cg6Rec), 1);
+ return TRUE;
+}
+
+static void
+CG6FreeRec(ScrnInfoPtr pScrn)
+{
+ Cg6Ptr pCg6;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+CG6AvailableOptions(int chipid, int busid)
+{
+ return CG6Options;
+}
+
+/* Mandatory */
+static void
+CG6Identify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for CGsix (GX and Turbo GX)\n", CG6_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+CG6Probe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(CG6_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(CG6_NAME, SBUS_DEVICE_CG6,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = CG6_DRIVER_NAME;
+ pScrn->name = CG6_NAME;
+ pScrn->Probe = CG6Probe;
+ pScrn->PreInit = CG6PreInit;
+ pScrn->ScreenInit = CG6ScreenInit;
+ pScrn->SwitchMode = CG6SwitchMode;
+ pScrn->AdjustFrame = CG6AdjustFrame;
+ pScrn->EnterVT = CG6EnterVT;
+ pScrn->LeaveVT = CG6LeaveVT;
+ pScrn->FreeScreen = CG6FreeScreen;
+ pScrn->ValidMode = CG6ValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+CG6PreInit(ScrnInfoPtr pScrn, int flags)
+{
+ Cg6Ptr pCg6;
+ sbusDevicePtr psdp;
+ MessageType from;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the Cg6Rec driverPrivate */
+ if (!CG6GetRec(pScrn)) {
+ return FALSE;
+ }
+ pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* CG6 is purely SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pCg6->psdp = psdp;
+ } else
+ return FALSE;
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, NoDepth24Support)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 8:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ /* Collect all of the relevant option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+ /* Process the options */
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, CG6Options);
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* Set the bits per RGB for 8bpp mode */
+ from = X_DEFAULT;
+
+ /* determine whether we use hardware or software cursor */
+
+ pCg6->HWCursor = TRUE;
+ if (xf86GetOptValBool(CG6Options, OPTION_HW_CURSOR, &pCg6->HWCursor))
+ from = X_CONFIG;
+ if (xf86ReturnOptValBool(CG6Options, OPTION_SW_CURSOR, FALSE)) {
+ from = X_CONFIG;
+ pCg6->HWCursor = FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+ pCg6->HWCursor ? "HW" : "SW");
+
+ if (xf86ReturnOptValBool(CG6Options, OPTION_NOACCEL, FALSE)) {
+ pCg6->NoAccel = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
+ }
+
+ if (xf86LoadSubModule(pScrn, "cfb") == NULL) {
+ CG6FreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (pCg6->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) {
+ CG6FreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "CG6 does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pCg6->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+CG6ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ Cg6Ptr pCg6;
+ int ret;
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ /* Map the CG6 memory */
+ pCg6->fbc =
+ xf86MapSbusMem (pCg6->psdp, CG6_FBC_VOFF,
+ CG6_RAM_VOFF - CG6_FBC_VOFF +
+ (pCg6->psdp->width * pCg6->psdp->height));
+
+ if (! pCg6->fbc)
+ return FALSE;
+
+ pCg6->fb = (unsigned char *)pCg6->fbc + CG6_RAM_VOFF - CG6_FBC_VOFF;
+ pCg6->thc = (Cg6ThcPtr)((char *)pCg6->fbc + CG6_THC_VOFF - CG6_FBC_VOFF);
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ CG6SaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Set the bits per RGB for 8bpp mode */
+ pScrn->rgbBits = 8;
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ ret = cfbScreenInit(pScreen, pCg6->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX);
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+#if 0
+ if (!pCg6->NoAccel) {
+ extern Bool CG6AccelInit(ScreenPtr pScreen, Cg6Ptr pCg6);
+
+ if (!CG6AccelInit(pScreen, pCg6))
+ return FALSE;
+ xf86Msg(X_INFO, "%s: Using acceleration\n", pCg6->psdp->device);
+ }
+#endif
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialize HW cursor layer.
+ Must follow software cursor initialization*/
+ if (pCg6->HWCursor) {
+ extern Bool CG6HWCursorInit(ScreenPtr pScreen);
+
+ if(!CG6HWCursorInit(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed\n");
+ return(FALSE);
+ }
+ xf86SbusHideOsHwCursor(pCg6->psdp);
+ }
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ if(!xf86SbusHandleColormaps(pScreen, pCg6->psdp))
+ return FALSE;
+
+ pCg6->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = CG6CloseScreen;
+ pScreen->SaveScreen = CG6SaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ CG6SaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+CG6SwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+CG6AdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+CG6EnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ if (pCg6->HWCursor) {
+ xf86SbusHideOsHwCursor (pCg6->psdp);
+ pCg6->CursorFg = 0;
+ pCg6->CursorBg = 0;
+ }
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+CG6LeaveVT(int scrnIndex, int flags)
+{
+ return;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+CG6CloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ Cg6Ptr pCg6 = GET_CG6_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ xf86UnmapSbusMem(pCg6->psdp, pCg6->fbc,
+ CG6_RAM_VOFF - CG6_FBC_VOFF +
+ (pCg6->psdp->width * pCg6->psdp->height));
+
+ pScreen->CloseScreen = pCg6->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+CG6FreeScreen(int scrnIndex, int flags)
+{
+ CG6FreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+CG6ValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+CG6SaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+CG6Sync(ScrnInfoPtr pScrn)
+{
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_regs.h
new file mode 100644
index 000000000..f6f3f0578
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_regs.h
@@ -0,0 +1,194 @@
+/*
+ * GX and Turbo GX framebuffer - hardware registers.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/cg6_regs.h,v 1.1 2000/05/23 04:47:43 dawes Exp $ */
+
+#ifndef CG6_REGS_H
+#define CG6_REGS_H
+
+/* FHC definitions */
+#define CG6_FHC_FBID_SHIFT 24
+#define CG6_FHC_FBID_MASK 255
+#define CG6_FHC_REV_SHIFT 20
+#define CG6_FHC_REV_MASK 15
+#define CG6_FHC_FROP_DISABLE (1 << 19)
+#define CG6_FHC_ROW_DISABLE (1 << 18)
+#define CG6_FHC_SRC_DISABLE (1 << 17)
+#define CG6_FHC_DST_DISABLE (1 << 16)
+#define CG6_FHC_RESET (1 << 15)
+#define CG6_FHC_LITTLE_ENDIAN (1 << 13)
+#define CG6_FHC_RES_MASK (3 << 11)
+#define CG6_FHC_1024 (0 << 11)
+#define CG6_FHC_1152 (1 << 11)
+#define CG6_FHC_1280 (2 << 11)
+#define CG6_FHC_1600 (3 << 11)
+#define CG6_FHC_CPU_MASK (3 << 9)
+#define CG6_FHC_CPU_SPARC (0 << 9)
+#define CG6_FHC_CPU_68020 (1 << 9)
+#define CG6_FHC_CPU_386 (2 << 9)
+#define CG6_FHC_TEST (1 << 8)
+#define CG6_FHC_TEST_X_SHIFT 4
+#define CG6_FHC_TEST_X_MASK 15
+#define CG6_FHC_TEST_Y_SHIFT 0
+#define CG6_FHC_TEST_Y_MASK 15
+
+/* FBC mode definitions */
+#define CG6_FBC_BLIT_IGNORE 0x00000000
+#define CG6_FBC_BLIT_NOSRC 0x00100000
+#define CG6_FBC_BLIT_SRC 0x00200000
+#define CG6_FBC_BLIT_ILLEGAL 0x00300000
+#define CG6_FBC_BLIT_MASK 0x00300000
+
+#define CG6_FBC_VBLANK 0x00080000
+
+#define CG6_FBC_MODE_IGNORE 0x00000000
+#define CG6_FBC_MODE_COLOR8 0x00020000
+#define CG6_FBC_MODE_COLOR1 0x00040000
+#define CG6_FBC_MODE_HRMONO 0x00060000
+#define CG6_FBC_MODE_MASK 0x00060000
+
+#define CG6_FBC_DRAW_IGNORE 0x00000000
+#define CG6_FBC_DRAW_RENDER 0x00008000
+#define CG6_FBC_DRAW_PICK 0x00010000
+#define CG6_FBC_DRAW_ILLEGAL 0x00018000
+#define CG6_FBC_DRAW_MASK 0x00018000
+
+#define CG6_FBC_BWRITE0_IGNORE 0x00000000
+#define CG6_FBC_BWRITE0_ENABLE 0x00002000
+#define CG6_FBC_BWRITE0_DISABLE 0x00004000
+#define CG6_FBC_BWRITE0_ILLEGAL 0x00006000
+#define CG6_FBC_BWRITE0_MASK 0x00006000
+
+#define CG6_FBC_BWRITE1_IGNORE 0x00000000
+#define CG6_FBC_BWRITE1_ENABLE 0x00000800
+#define CG6_FBC_BWRITE1_DISABLE 0x00001000
+#define CG6_FBC_BWRITE1_ILLEGAL 0x00001800
+#define CG6_FBC_BWRITE1_MASK 0x00001800
+
+#define CG6_FBC_BREAD_IGNORE 0x00000000
+#define CG6_FBC_BREAD_0 0x00000200
+#define CG6_FBC_BREAD_1 0x00000400
+#define CG6_FBC_BREAD_ILLEGAL 0x00000600
+#define CG6_FBC_BREAD_MASK 0x00000600
+
+#define CG6_FBC_BDISP_IGNORE 0x00000000
+#define CG6_FBC_BDISP_0 0x00000080
+#define CG6_FBC_BDISP_1 0x00000100
+#define CG6_FBC_BDISP_ILLEGAL 0x00000180
+#define CG6_FBC_BDISP_MASK 0x00000180
+
+#define CG6_FBC_INDEX_MOD 0x00000040
+#define CG6_FBC_INDEX_MASK 0x00000030
+
+/* THC definitions */
+#define CG6_THC_MISC_REV_SHIFT 16
+#define CG6_THC_MISC_REV_MASK 15
+#define CG6_THC_MISC_RESET (1 << 12)
+#define CG6_THC_MISC_VIDEO (1 << 10)
+#define CG6_THC_MISC_SYNC (1 << 9)
+#define CG6_THC_MISC_VSYNC (1 << 8)
+#define CG6_THC_MISC_SYNC_ENAB (1 << 7)
+#define CG6_THC_MISC_CURS_RES (1 << 6)
+#define CG6_THC_MISC_INT_ENAB (1 << 5)
+#define CG6_THC_MISC_INT (1 << 4)
+#define CG6_THC_MISC_INIT 0x9f
+
+typedef struct cg6_tec {
+ volatile unsigned int tec_matrix;
+ volatile unsigned int tec_clip;
+ volatile unsigned int tec_vdc;
+} Cg6Tec, *Cg6TecPtr;
+
+typedef struct cg6_thc {
+ unsigned int thc_pad0[512];
+ volatile unsigned int thc_hs; /* hsync timing */
+ volatile unsigned int thc_hsdvs;
+ volatile unsigned int thc_hd;
+ volatile unsigned int thc_vs; /* vsync timing */
+ volatile unsigned int thc_vd;
+ volatile unsigned int thc_refresh;
+ volatile unsigned int thc_misc;
+ unsigned int thc_pad1[56];
+ volatile unsigned int thc_cursxy; /* cursor x,y position (16 bits each) */
+ volatile unsigned int thc_cursmask[32];/* cursor mask bits */
+ volatile unsigned int thc_cursbits[32];/* what to show where mask enabled */
+} Cg6Thc, *Cg6ThcPtr;
+
+typedef struct cg6_fbc {
+ unsigned int xxx0[1];
+ volatile unsigned int mode;
+ volatile unsigned int clip;
+ unsigned int xxx1[1];
+ volatile unsigned int s;
+ volatile unsigned int draw;
+ volatile unsigned int blit;
+ volatile unsigned int font;
+ unsigned int xxx2[24];
+ volatile unsigned int x0, y0, z0, color0;
+ volatile unsigned int x1, y1, z1, color1;
+ volatile unsigned int x2, y2, z2, color2;
+ volatile unsigned int x3, y3, z3, color3;
+ volatile unsigned int offx, offy;
+ unsigned int xxx3[2];
+ volatile unsigned int incx, incy;
+ unsigned int xxx4[2];
+ volatile unsigned int clipminx, clipminy;
+ unsigned int xxx5[2];
+ volatile unsigned int clipmaxx, clipmaxy;
+ unsigned int xxx6[2];
+ volatile unsigned int fg;
+ volatile unsigned int bg;
+ volatile unsigned int alu;
+ volatile unsigned int pm;
+ volatile unsigned int pixelm;
+ unsigned int xxx7[2];
+ volatile unsigned int patalign;
+ volatile unsigned int pattern[8];
+ unsigned int xxx8[432];
+ volatile unsigned int apointx, apointy, apointz;
+ unsigned int xxx9[1];
+ volatile unsigned int rpointx, rpointy, rpointz;
+ unsigned int xxx10[5];
+ volatile unsigned int pointr, pointg, pointb, pointa;
+ volatile unsigned int alinex, aliney, alinez;
+ unsigned int xxx11[1];
+ volatile unsigned int rlinex, rliney, rlinez;
+ unsigned int xxx12[5];
+ volatile unsigned int liner, lineg, lineb, linea;
+ volatile unsigned int atrix, atriy, atriz;
+ unsigned int xxx13[1];
+ volatile unsigned int rtrix, rtriy, rtriz;
+ unsigned int xxx14[5];
+ volatile unsigned int trir, trig, trib, tria;
+ volatile unsigned int aquadx, aquady, aquadz;
+ unsigned int xxx15[1];
+ volatile unsigned int rquadx, rquady, rquadz;
+ unsigned int xxx16[5];
+ volatile unsigned int quadr, quadg, quadb, quada;
+ volatile unsigned int arectx, arecty, arectz;
+ unsigned int xxx17[1];
+ volatile unsigned int rrectx, rrecty, rrectz;
+ unsigned int xxx18[5];
+ volatile unsigned int rectr, rectg, rectb, recta;
+} Cg6Fbc, *Cg6FbcPtr;
+
+#endif /* CG6_REGS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp
new file mode 100644
index 000000000..b48106f47
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suncg6/suncg6.cpp,v 1.2 2000/06/14 02:13:14 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNCG6 __drivermansuffix__ "Version 4.0.1" "XFree86"
+.SH NAME
+suncg6 \- GX/Turbo GX video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsuncg6\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B suncg6
+is an XFree86 driver for Sun GX and Turbo GX (also known as cgsix) video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B suncg6
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile
new file mode 100644
index 000000000..9968798a4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile
@@ -0,0 +1,126 @@
+XCOMM
+XCOMM This is an Imakefile for the ffb driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/Imakefile,v 1.4 2000/06/26 23:46:13 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if BuildXF86DRI
+DRISRCS = ffb_dri.c
+DRIOBJS = ffb_dri.o
+DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include
+DRIDEFINES = $(GLX_DEFINES)
+#endif
+
+#if defined(AsVISOption) && defined(UseElfFormat)
+VISOBJS = VISmoveImage.o ffb_asm.o
+VISOPTIONS = -DUSE_VIS
+ASVISOPTION = AsVISOption
+GCCVISOPTION = -Wa,$(ASVISOPTION)
+#if AsOutputArchSize == 32
+#define FFBCObjectRule(name) @@\
+name.o: name.c @@\
+ ObjectCompile(-mv8 -mtune=ultrasparc $(GCCVISOPTION) $(VISOPTIONS) $(DRIDEFINES)) @@\
+ dd if=/dev/zero bs=1 count=3 | dd of=$@ bs=1 count=3 seek=36 conv=notrunc @@\
+ echo -e '\002' | dd of=$@ bs=1 count=1 seek=19 conv=notrunc @@\
+ @@\
+name.i: name.c @@\
+ CPPOnlyCompile(name.c,-mv8 $(GCCVISOPTION) $(VISOPTIONS) $(DRIDEFINES)) @@\
+ @@\
+CenterLoadTarget(debug_src,name.c,NullParameter,$(ALLDEFINES) -mv8 $(GCCVISOPTION) $(VISOPTIONS) $(DRIDEFINES))
+#define FFBsObjectRule(name) @@\
+name.o: name.s @@\
+ $(RM) $@ @@\
+ $(CPP) $*.s | $(AS) $(ASVISOPTION) -o $@ - @@\
+ dd if=/dev/zero bs=1 count=3 | dd of=$@ bs=1 count=3 seek=36 conv=notrunc @@\
+ echo -e '\002' | dd of=$@ bs=1 count=1 seek=19 conv=notrunc
+#else
+#define FFBCObjectRule(name) SpecialCObjectRule(name,,$(GCCVISOPTION) $(VISOPTIONS) $(DRIDEFINES))
+#define FFBsObjectRule(name) @@\
+name.o: name.s @@\
+ $(RM) $@ @@\
+ $(CPP) $*.s | $(AS) $(ASVISOPTION) -o $@ -
+#endif
+#else
+VISOBJS =
+VISOPTIONS =
+ASVISOPTION =
+#define FFBCObjectRule(name)
+#define FFBsObjectRule(name)
+#endif
+
+SRCS = ffb_driver.c ffb_accel.c ffb_attr.c ffb_stip.c ffb_bcopy.c ffb_cplane.c \
+ ffb_fspans.c ffb_point.c ffb_seg.c ffb_plygon.c ffb_line.c ffb_glyph.c \
+ ffb_frect.c ffb_circle.c ffb_checks.c ffb_stubs.c ffb_gc.c \
+ ffb_gspans.c ffb_sspans.c ffb_zeroarc.c ffb_cursor.c ffb_dga.c ffb_dac.c \
+ ffb_wid.c ffb_dbe.c $(DRISRCS)
+OBJS = ffb_driver.o ffb_accel.o ffb_attr.o ffb_stip.o ffb_bcopy.o ffb_cplane.o \
+ ffb_fspans.o ffb_point.o ffb_seg.o ffb_plygon.o ffb_line.o ffb_glyph.o \
+ ffb_frect.o ffb_circle.o ffb_checks.o ffb_stubs.o ffb_gc.o \
+ ffb_gspans.o ffb_sspans.o ffb_zeroarc.o ffb_cursor.o ffb_dga.o ffb_dac.o \
+ ffb_wid.o ffb_dbe.o $(VISOBJS) $(DRIOBJS)
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \
+ -I$(SERVERSRC)/dbe \
+ -I$(XF86SRC)/xf8_32wid \
+ -I$(XF86SRC)/ramdac \
+ -I$(XF86SRC)/ddc \
+ -I$(XF86SRC)/i2c \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC) \
+ $(DRIINCLUDES)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(sunffb,$(OBJS))
+
+InstallObjectModule(sunffb,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(sunffb,)
+InstallModuleManPage(sunffb)
+#endif
+
+FFBCObjectRule(ffb_accel)
+FFBCObjectRule(ffb_driver)
+FFBCObjectRule(ffb_attr)
+FFBCObjectRule(ffb_stip)
+FFBCObjectRule(ffb_bcopy)
+FFBCObjectRule(ffb_cplane)
+FFBCObjectRule(ffb_fspans)
+FFBCObjectRule(ffb_point)
+FFBCObjectRule(ffb_seg)
+FFBCObjectRule(ffb_plygon)
+FFBCObjectRule(ffb_line)
+FFBCObjectRule(ffb_glyph)
+FFBCObjectRule(ffb_frect)
+FFBCObjectRule(ffb_circle)
+FFBCObjectRule(ffb_checks)
+FFBCObjectRule(ffb_stubs)
+FFBCObjectRule(ffb_gc)
+FFBCObjectRule(ffb_gspans)
+FFBCObjectRule(ffb_sspans)
+FFBCObjectRule(ffb_zeroarc)
+FFBCObjectRule(ffb_cursor)
+FFBCObjectRule(ffb_dga)
+FFBCObjectRule(ffb_dac)
+FFBCObjectRule(ffb_wid)
+FFBCObjectRule(ffb_dbe)
+FFBsObjectRule(VISmoveImage)
+FFBsObjectRule(ffb_asm)
+#if BuildXF86DRI
+FFBCObjectRule(ffb_dri)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/VISmoveImage.s b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/VISmoveImage.s
new file mode 100644
index 000000000..43815f567
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/VISmoveImage.s
@@ -0,0 +1,2710 @@
+/*
+ * VISmoveImage.S: High speed moveImage operations utilizing the UltraSPARC
+ * Visual Instruction Set.
+ *
+ * Copyright (C) 1998,1999 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/VISmoveImage.s,v 1.2 2000/05/23 04:47:43 dawes Exp $ */
+
+
+/* NOTE NOTE NOTE: All loads in these routines _MUST_ be 64-byte block
+ * loads. If any non-block loads are done to the frame-
+ * buffer when prefetching is enabled (which we use, when
+ * available) this will cause lockups on FFB2 due to a
+ * hardware bug. -DaveM
+ */
+
+/*
+ void
+ VISmoveImageLR(unsigned char *src, unsigned char *dst, long w, long h, long skind, long dkind)
+ {
+ int i;
+
+ // Handles copying non-overlapping images and for overlapping images
+ // copying where dstx <= srcx.
+ // To copy overlapping images where dsty > srcy, set src and dst
+ // to start of the last scanline and negate both skind and dkind arguments.
+
+ assert(abs(skind) >= w && abs(dkind) >= w);
+
+ while (h--) {
+ for (i = 0; i < w; i++)
+ *d++ = *s++;
+ s += skind - w;
+ d += dkind - w;
+ }
+ }
+
+ void
+ VISmoveImageRL(unsigned char *src, unsigned char *dst, long w, long h, long skind, long dkind)
+ {
+ int i;
+
+ // Handles copying non-overlapping images and for overlapping images
+ // copying where dstx >= srcx.
+ // To copy overlapping images where dsty > srcy, set src and dst
+ // to start of the last scanline and negate both skind and dkind arguments.
+
+ assert(abs(skind) >= w && abs(dkind) >= w);
+
+ s += w;
+ d += w;
+ while (h--) {
+ for (i = 0; i < w; i++)
+ *--d = *--s;
+ s += skind + w;
+ d += dkind + w;
+ }
+ }
+
+ */
+
+#if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
+#define SMUL mulx
+#define ICC xcc
+#else
+#define SMUL smul
+#define ICC icc
+#endif
+
+#define ASI_PST8_P 0xc0
+#define ASI_BLK_P 0xf0
+#define SYNC 0x40
+
+/* Register usage: */
+/* integer registers: */
+#define src i0
+#define dst i1
+#define w i2
+#define h i3
+#define skind i4
+#define dkind i5
+#define branchbase l0
+#define tmp1 l1
+#define tmp4 l2
+#define tmp5 l3
+#define leftw l4
+#define rightw l5
+#define srcstart l6
+#define mode l7
+#define fregset o0 /* Must be [og]? for v8plusa */
+#define srcend o1
+#define srcn o2
+#define srcnext o3
+#define rightw2 o4
+#define tmp2 o5 /* Must be [og]? for v8plusa */
+#define narrow o7
+#define prepw g1 /* Must be [og]? for v8plusa */
+#define srcstop g2
+#define srcnotdone g3
+#define curw g4 /* Must be [og]? for v8plusa */
+#define leftw2 rightw2
+#define tmp3 g5 /* Must be [og]? for v8plusa */
+/* floating point registers: */
+#define ftmp1 f0
+#define ftmp2 f2
+#define ftmp3 f4
+#define ftmp4 f6
+#define ftmp5 f8
+#define ftmp6 f10
+#define ftmp7 f12
+#define ftmp8 f14
+#define store_regs f16-f31
+#define load_bank1 f32-f46
+#define load_bank2 f48-f62
+#define fnop fmovd %ftmp2, %ftmp2
+
+#define LOAD(f32,f46,tgt,tgtr) \
+ subcc %curw, 64, %curw; \
+ bleu,pn %ICC, tgt; \
+ fmovd %f46, %ftmp1; \
+ ldda [%src] ASI_BLK_P, %f32; \
+ add %src, 64, %src; \
+tgtr:
+
+#define PREPLOAD(f32,f46,tgt,tgtr) \
+ brlez,pn %prepw, tgt; \
+ fmovd %f46, %ftmp1; \
+ ldda [%src] ASI_BLK_P, %f32; \
+ add %src, 64, %src; \
+tgtr:
+
+#define STORE \
+ stda %f16, [%dst] ASI_BLK_P;
+
+#define FREG_FROB(f0,A0,F2,f2,A1,F4,f4,A2,F6,f6,A3,F8,f8,A4,F10,f10,A5,F12,f12,A6,F14,f14,A7,F16) \
+ A0 \
+ faligndata %f0,%F2,%f16; \
+ A1 \
+ faligndata %f2,%F4,%f18; \
+ A2 \
+ faligndata %f4,%F6,%f20; \
+ A3 \
+ faligndata %f6,%F8,%f22; \
+ A4 \
+ faligndata %f8,%F10,%f24; \
+ A5 \
+ faligndata %f10,%F12,%f26; \
+ A6 \
+ faligndata %f12,%F14,%f28; \
+ A7 \
+ faligndata %f14,%F16,%f30;
+
+ .section ".rodata"
+ .asciz "VISmoveImage (C) 1998,1999 Jakub Jelinek"
+
+/* The code might not be self-explanatory, but it was written to be processed
+ * by machines, not humans. Comments are deliberately left as an exercise
+ * to the occasional reader. */
+
+ .text
+ .globl VISmoveImageLR
+ .align 32
+VISmoveImageLR:
+ save %sp, -160, %sp ! Group 0
+0: rd %pc, %tmp3 ! Group 1
+ sub %src, %dst, %mode ! Group 7
+ brz,pn %h, return
+ neg %dst, %leftw ! Group 8
+ mov %src, %srcstart
+ andn %src, 63, %src ! Group 9
+ cmp %w, 128
+ blu,pn %ICC, prepare_narrow
+ and %mode, 63, %mode ! Group 10
+ add %dst, %w, %rightw
+ ldda [%src] ASI_BLK_P, %f32 ! Group 11
+ add %src, 64, %src ! Group 12
+ clr %narrow
+ ldda [%src] ASI_BLK_P, %f48 ! Group 13
+ and %leftw, 63, %leftw ! Group 14
+ sub %rightw, 1, %rightw
+ andn %dst, 63, %dst ! Group 15
+ and %rightw, 63, %rightw
+ alignaddr %mode, %g0, %g0 ! Group 16
+ add %rightw, 1, %rightw ! Group 17
+ clr %fregset
+ add %src, 64, %src ! Group 18
+ add %tmp3, (BranchBase - 0b), %branchbase
+ mov 64, %prepw ! Group 19
+ ba,pt %xcc, roll_wide
+ sub %h, 1, %srcnotdone
+prepare_narrow:
+#if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
+ brlez,pn %w, return
+#else
+ tst %w
+ ble,pn %icc, return
+#endif
+ add %dst, %w, %rightw ! Group 11
+ and %leftw, 63, %leftw
+ ldda [%src] ASI_BLK_P, %f32 ! Group 12
+ sub %rightw, 1, %rightw ! Group 13
+ andn %dst, 63, %dst
+ and %rightw, 63, %rightw ! Group 14
+ sub %w, %leftw, %tmp2
+ add %rightw, 1, %rightw ! Group 15
+ clr %fregset
+ subcc %tmp2, %rightw, %curw ! Group 16
+ and %srcstart, 63, %tmp1
+ mov %curw, %prepw ! Group 17
+ add %tmp1, %w, %tmp1
+ bg,pt %ICC, 1f
+ add %src, 64, %src ! Group 18
+ cmp %tmp1, 128
+ movg %icc, 64, %prepw ! Group 19
+1: add %srcstart, %w, %srcend
+ sub %h, 1, %srcnotdone ! Group 20
+ add %srcstart, %skind, %srcnext
+ add %srcend, 63, %tmp4 ! Group 21
+ andn %srcnext, 63, %srcnext
+ add %w, 64, %tmp2 ! Group 22
+ cmp %skind, 0
+ bl,pn %ICC, 1f
+ clr %srcstop ! Group 23
+ cmp %skind, %tmp2
+ bgeu,pt %ICC, 2f
+ andn %tmp4, 63, %tmp2 ! Group 24
+ SMUL %skind, %srcnotdone, %srcstop
+ ba,pt %xcc, 2f
+ add %tmp4, %srcstop, %srcstop
+1: addcc %tmp2, %skind, %g0
+ ble,pt %ICC, 2f
+ sub %srcnext, 64, %tmp2
+ SMUL %skind, %srcnotdone, %srcstop
+ sub %srcstart, 64, %narrow
+ add %srcstop, %narrow, %srcstop
+2: add %srcnext, 64, %narrow
+ andn %tmp4, 63, %srcend ! Group 25
+ mov %srcnext, %srcn
+ cmp %narrow, %srcend ! Group 26
+ andn %srcstop, 63, %srcstop
+ move %ICC, %tmp2, %srcnext ! Group 27
+ alignaddr %mode, %g0, %g0 ! Group 28
+ add %tmp3, (BranchBase - 0b), %branchbase
+ mov 1, %narrow ! Group 29
+ cmp %srcnext, %srcstop
+ move %ICC, 0, %srcnotdone ! Group 30
+ cmp %tmp1, 64
+ bleu,pn %ICC, 1f
+ dec %h ! Group 31
+ ldda [%src] ASI_BLK_P, %f48 ! Group 32
+ ba,pt %xcc, roll_narrow ! Group 33
+ addcc %src, 64, %src
+1: brz,a,pn %srcnotdone, roll_narrow
+ membar #Sync
+ ldda [%srcnext] ASI_BLK_P, %f48
+ ba,pt %xcc, roll_narrow
+ addcc %srcnext, 64, %src
+
+ .align 32
+prepr0: faligndata %f32, %f34, %f16
+ faligndata %f34, %f36, %f18
+ faligndata %f36, %f38, %f20
+ faligndata %f38, %f40, %f22
+ faligndata %f40, %f42, %f24
+ faligndata %f42, %f44, %f26
+ ba,pt %xcc, 4f
+ faligndata %f44, %f46, %f28
+ .align 32
+prepr1: faligndata %f48, %f50, %f16
+ faligndata %f50, %f52, %f18
+ faligndata %f52, %f54, %f20
+ faligndata %f54, %f56, %f22
+ faligndata %f56, %f58, %f24
+ faligndata %f58, %f60, %f26
+ ba,pt %xcc, 5f
+ faligndata %f60, %f62, %f28
+ .align 32
+prepr2: faligndata %f34, %f36, %f16
+ faligndata %f36, %f38, %f18
+ faligndata %f38, %f40, %f20
+ faligndata %f40, %f42, %f22
+ faligndata %f42, %f44, %f24
+ faligndata %f44, %f46, %f26
+ ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f28
+ .align 32
+prepr3: faligndata %f50, %f52, %f16
+ faligndata %f52, %f54, %f18
+ faligndata %f54, %f56, %f20
+ faligndata %f56, %f58, %f22
+ faligndata %f58, %f60, %f24
+ faligndata %f60, %f62, %f26
+ ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f28
+ .align 32
+prepr4: faligndata %f36, %f38, %f16
+ faligndata %f38, %f40, %f18
+ faligndata %f40, %f42, %f20
+ faligndata %f42, %f44, %f22
+ faligndata %f44, %f46, %f24
+ ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f26
+ .align 32
+prepr5: faligndata %f52, %f54, %f16
+ faligndata %f54, %f56, %f18
+ faligndata %f56, %f58, %f20
+ faligndata %f58, %f60, %f22
+ faligndata %f60, %f62, %f24
+ ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f26
+ .align 32
+prepr6: faligndata %f38, %f40, %f16
+ faligndata %f40, %f42, %f18
+ faligndata %f42, %f44, %f20
+ faligndata %f44, %f46, %f22
+ ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f24
+ .align 32
+prepr7: faligndata %f54, %f56, %f16
+ faligndata %f56, %f58, %f18
+ faligndata %f58, %f60, %f20
+ faligndata %f60, %f62, %f22
+ ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f24
+ .align 32
+prepr8: faligndata %f40, %f42, %f16
+ faligndata %f42, %f44, %f18
+ faligndata %f44, %f46, %f20
+ ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f22
+ .align 32
+prepr9: faligndata %f56, %f58, %f16
+ faligndata %f58, %f60, %f18
+ faligndata %f60, %f62, %f20
+ ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f22
+ .align 32
+prepr10:faligndata %f42, %f44, %f16
+ faligndata %f44, %f46, %f18
+ ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f20
+ .align 32
+prepr11:faligndata %f58, %f60, %f16
+ faligndata %f60, %f62, %f18
+ ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f20
+ .align 32
+prepr12:faligndata %f44, %f46, %f16
+ ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f18
+ .align 32
+prepr13:faligndata %f60, %f62, %f16
+ ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f18
+ .align 32
+prepr14:ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f16
+ nop
+ nop
+4: ba,pt %xcc, narrowst
+ faligndata %f46, %f0, %f30
+ .align 32
+prepr15:ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f16
+ nop
+ nop
+5: ba,pt %xcc, narrowst
+ faligndata %f62, %f0, %f30
+
+ .align 32
+prepn0: faligndata %ftmp1, %f32, %f30
+ ba,pt %xcc, leftst
+ mov (vis0 - BranchBase), %tmp3
+ nop
+1: ba,pt %xcc, leftst
+ mov (vis12 - BranchBase), %tmp3
+ .align 32
+prepn1: faligndata %ftmp1, %f48, %f30
+ ba,pt %xcc, leftst
+ mov (vis1 - BranchBase), %tmp3
+ nop
+2: ba,pt %xcc, leftst
+ mov (vis13 - BranchBase), %tmp3
+ .align 32
+prepn2: faligndata %ftmp1, %f32, %f28
+ faligndata %f32, %f34, %f30
+ ba,pt %xcc, leftst
+ mov (vis2 - BranchBase), %tmp3
+3: faligndata %f44, %f46, %f30
+ ba,pt %xcc, leftst
+ mov (vis14 - BranchBase), %tmp3
+ .align 32
+prepn3: faligndata %ftmp1, %f48, %f28
+ faligndata %f48, %f50, %f30
+ ba,pt %xcc, leftst
+ mov (vis3 - BranchBase), %tmp3
+ .align 32
+prepn4: faligndata %ftmp1, %f32, %f26
+ faligndata %f32, %f34, %f28
+ faligndata %f34, %f36, %f30
+ ba,pt %xcc, leftst
+ mov (vis4 - BranchBase), %tmp3
+ .align 32
+prepn5: faligndata %ftmp1, %f48, %f26
+ faligndata %f48, %f50, %f28
+ faligndata %f50, %f52, %f30
+ ba,pt %xcc, leftst
+ mov (vis5 - BranchBase), %tmp3
+ .align 32
+prepn6: faligndata %ftmp1, %f32, %f24
+ faligndata %f32, %f34, %f26
+ faligndata %f34, %f36, %f28
+ faligndata %f36, %f38, %f30
+ ba,pt %xcc, leftst
+ mov (vis6 - BranchBase), %tmp3
+ .align 32
+prepn7: faligndata %ftmp1, %f48, %f24
+ faligndata %f48, %f50, %f26
+ faligndata %f50, %f52, %f28
+ faligndata %f52, %f54, %f30
+ ba,pt %xcc, leftst
+ mov (vis7 - BranchBase), %tmp3
+ .align 32
+prepn8: faligndata %ftmp1, %f32, %f22
+ faligndata %f32, %f34, %f24
+ faligndata %f34, %f36, %f26
+ faligndata %f36, %f38, %f28
+ faligndata %f38, %f40, %f30
+ ba,pt %xcc, leftst
+ mov (vis8 - BranchBase), %tmp3
+ .align 32
+prepn9: faligndata %ftmp1, %f48, %f22
+ faligndata %f48, %f50, %f24
+ faligndata %f50, %f52, %f26
+ faligndata %f52, %f54, %f28
+ faligndata %f54, %f56, %f30
+ ba,pt %xcc, leftst
+ mov (vis9 - BranchBase), %tmp3
+ .align 32
+prepn10:faligndata %ftmp1, %f32, %f20
+ faligndata %f32, %f34, %f22
+ faligndata %f34, %f36, %f24
+ faligndata %f36, %f38, %f26
+ faligndata %f38, %f40, %f28
+ faligndata %f40, %f42, %f30
+ ba,pt %xcc, leftst
+ mov (vis10 - BranchBase), %tmp3
+ .align 32
+prepn11:faligndata %ftmp1, %f48, %f20
+ faligndata %f48, %f50, %f22
+ faligndata %f50, %f52, %f24
+ faligndata %f52, %f54, %f26
+ faligndata %f54, %f56, %f28
+ faligndata %f56, %f58, %f30
+ ba,pt %xcc, leftst
+ mov (vis11 - BranchBase), %tmp3
+ .align 32
+prepn12:faligndata %ftmp1, %f32, %f18
+ faligndata %f32, %f34, %f20
+ faligndata %f34, %f36, %f22
+ faligndata %f36, %f38, %f24
+ faligndata %f38, %f40, %f26
+ faligndata %f40, %f42, %f28
+ ba,pt %xcc, 1b
+ faligndata %f42, %f44, %f30
+ .align 32
+prepn13:faligndata %ftmp1, %f48, %f18
+ faligndata %f48, %f50, %f20
+ faligndata %f50, %f52, %f22
+ faligndata %f52, %f54, %f24
+ faligndata %f54, %f56, %f26
+ faligndata %f56, %f58, %f28
+ ba,pt %xcc, 2b
+ faligndata %f58, %f60, %f30
+ .align 32
+prepn14:faligndata %ftmp1, %f32, %f16
+ faligndata %f32, %f34, %f18
+ faligndata %f34, %f36, %f20
+ faligndata %f36, %f38, %f22
+ faligndata %f38, %f40, %f24
+ faligndata %f40, %f42, %f26
+ ba,pt %xcc, 3b
+ faligndata %f42, %f44, %f28
+ .align 32
+prepn15:faligndata %ftmp1, %f48, %f16
+ faligndata %f48, %f50, %f18
+ faligndata %f50, %f52, %f20
+ faligndata %f52, %f54, %f22
+ faligndata %f54, %f56, %f24
+ faligndata %f56, %f58, %f26
+ faligndata %f58, %f60, %f28
+ faligndata %f60, %f62, %f30
+ ba,pt %xcc, leftst
+ mov (vis15 - BranchBase), %tmp3
+
+ .align 64
+BranchBase:
+prepl0: FREG_FROB(f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,PREPLOAD(f32,f46,prep0e,prep0r),f48)
+ ba,pt %xcc, leftst
+ mov (vis1 - BranchBase), %tmp3
+ .align 64
+prepl1: FREG_FROB(f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,PREPLOAD(f48,f62,prep1e,prep1r),f32)
+ ba,pt %xcc, leftst
+ mov (vis0 - BranchBase), %tmp3
+ .align 64
+prepl2: FREG_FROB(f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,PREPLOAD(f32,f46,prep2e,prep2r),f48,f48,,f50)
+ ba,pt %xcc, leftst
+ mov (vis3 - BranchBase), %tmp3
+ .align 64
+prepl3: FREG_FROB(f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,PREPLOAD(f48,f62,prep3e,prep3r),f32,f32,,f34)
+ ba,pt %xcc, leftst
+ mov (vis2 - BranchBase), %tmp3
+ .align 64
+prepl4: FREG_FROB(f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,PREPLOAD(f32,f46,prep4e,prep4r),f48,f48,,f50,f50,,f52)
+ ba,pt %xcc, leftst
+ mov (vis5 - BranchBase), %tmp3
+ .align 64
+prepl5: FREG_FROB(f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,PREPLOAD(f48,f62,prep5e,prep5r),f32,f32,,f34,f34,,f36)
+ ba,pt %xcc, leftst
+ mov (vis4 - BranchBase), %tmp3
+ .align 64
+prepl6: FREG_FROB(f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,PREPLOAD(f32,f46,prep6e,prep6r),f48,f48,,f50,f50,,f52,f52,,f54)
+ ba,pt %xcc, leftst
+ mov (vis7 - BranchBase), %tmp3
+ .align 64
+prepl7: FREG_FROB(f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,PREPLOAD(f48,f62,prep7e,prep7r),f32,f32,,f34,f34,,f36,f36,,f38)
+ ba,pt %xcc, leftst
+ mov (vis6 - BranchBase), %tmp3
+ .align 64
+prepl8: FREG_FROB(f40,,f42,f42,,f44,f44,,f46,ftmp1,PREPLOAD(f32,f46,prep8e,prep8r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56)
+ ba,pt %xcc, leftst
+ mov (vis9 - BranchBase), %tmp3
+ .align 64
+prepl9: FREG_FROB(f56,,f58,f58,,f60,f60,,f62,ftmp1,PREPLOAD(f48,f62,prep9e,prep9r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40)
+ ba,pt %xcc, leftst
+ mov (vis8 - BranchBase), %tmp3
+ .align 64
+prepl10:FREG_FROB(f42,,f44,f44,,f46,ftmp1,PREPLOAD(f32,f46,prep10e,prep10r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58)
+ ba,pt %xcc, leftst
+ mov (vis11 - BranchBase), %tmp3
+ .align 64
+prepl11:FREG_FROB(f58,,f60,f60,,f62,ftmp1,PREPLOAD(f48,f62,prep11e,prep11r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42)
+ ba,pt %xcc, leftst
+ mov (vis10 - BranchBase), %tmp3
+ .align 64
+prepl12:FREG_FROB(f44,,f46,ftmp1,PREPLOAD(f32,f46,prep12e,prep12r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60)
+ ba,pt %xcc, leftst
+ mov (vis13 - BranchBase), %tmp3
+ .align 64
+prepl13:FREG_FROB(f60,,f62,ftmp1,PREPLOAD(f48,f62,prep13e,prep13r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44)
+ ba,pt %xcc, leftst
+ mov (vis12 - BranchBase), %tmp3
+ .align 64
+prepl14:FREG_FROB(ftmp1,PREPLOAD(f32,f46,prep14e,prep14r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62)
+ ba,pt %xcc, leftst
+ mov (vis15 - BranchBase), %tmp3
+ .align 64
+prepl15:FREG_FROB(ftmp1,PREPLOAD(f48,f62,prep15e,prep15r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46)
+ ba,pt %xcc, leftst
+ mov (vis14 - BranchBase), %tmp3
+
+ .align 128
+vis0: FREG_FROB(f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,LOAD(f32,f46,vis0e,vis0r),f48)
+ STORE
+ add %dst, 64, %dst
+vis1: FREG_FROB(f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,LOAD(f48,f62,vis1e,vis1r),f32)
+ STORE
+ ba,pt %xcc, vis0
+ add %dst, 64, %dst
+ .align 128
+vis2: FREG_FROB(f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,LOAD(f32,f46,vis2e,vis2r),f48,f48,,f50)
+ STORE
+ add %dst, 64, %dst
+vis3: FREG_FROB(f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,LOAD(f48,f62,vis3e,vis3r),f32,f32,,f34)
+ STORE
+ ba,pt %xcc, vis2
+ add %dst, 64, %dst
+ .align 128
+vis4: FREG_FROB(f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,LOAD(f32,f46,vis4e,vis4r),f48,f48,,f50,f50,,f52)
+ STORE
+ add %dst, 64, %dst
+vis5: FREG_FROB(f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,LOAD(f48,f62,vis5e,vis5r),f32,f32,,f34,f34,,f36)
+ STORE
+ ba,pt %xcc, vis4
+ add %dst, 64, %dst
+ .align 128
+vis6: FREG_FROB(f38,,f40,f40,,f42,f42,,f44,f44,,f46,ftmp1,LOAD(f32,f46,vis6e,vis6r),f48,f48,,f50,f50,,f52,f52,,f54)
+ STORE
+ add %dst, 64, %dst
+vis7: FREG_FROB(f54,,f56,f56,,f58,f58,,f60,f60,,f62,ftmp1,LOAD(f48,f62,vis7e,vis7r),f32,f32,,f34,f34,,f36,f36,,f38)
+ STORE
+ ba,pt %xcc, vis6
+ add %dst, 64, %dst
+ .align 128
+vis8: FREG_FROB(f40,,f42,f42,,f44,f44,,f46,ftmp1,LOAD(f32,f46,vis8e,vis8r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56)
+ STORE
+ add %dst, 64, %dst
+vis9: FREG_FROB(f56,,f58,f58,,f60,f60,,f62,ftmp1,LOAD(f48,f62,vis9e,vis9r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40)
+ STORE
+ ba,pt %xcc, vis8
+ add %dst, 64, %dst
+ .align 128
+vis10: FREG_FROB(f42,,f44,f44,,f46,ftmp1,LOAD(f32,f46,vis10e,vis10r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58)
+ STORE
+ add %dst, 64, %dst
+vis11: FREG_FROB(f58,,f60,f60,,f62,ftmp1,LOAD(f48,f62,vis11e,vis11r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42)
+ STORE
+ ba,pt %xcc, vis10
+ add %dst, 64, %dst
+ .align 128
+vis12: FREG_FROB(f44,,f46,ftmp1,LOAD(f32,f46,vis12e,vis12r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60)
+ STORE
+ add %dst, 64, %dst
+vis13: FREG_FROB(f60,,f62,ftmp1,LOAD(f48,f62,vis13e,vis13r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44)
+ STORE
+ ba,pt %xcc, vis12
+ add %dst, 64, %dst
+ .align 128
+vis14: FREG_FROB(ftmp1,LOAD(f32,f46,vis14e,vis14r),f48,f48,,f50,f50,,f52,f52,,f54,f54,,f56,f56,,f58,f58,,f60,f60,,f62)
+ STORE
+ add %dst, 64, %dst
+vis15: FREG_FROB(ftmp1,LOAD(f48,f62,vis15e,vis15r),f32,f32,,f34,f34,,f36,f36,,f38,f38,,f40,f40,,f42,f42,,f44,f44,,f46)
+ STORE
+ ba,pt %xcc, vis14
+ add %dst, 64, %dst
+
+leftst: brlz,pn %curw, narrowst + 4
+ and %leftw, 0x38, %tmp1
+ andcc %leftw, 7, %g0
+ be,pn %icc, 1f
+ neg %tmp1
+ sub %dst, %leftw, %tmp4
+ add %branchbase, (2f - BranchBase - 8), %tmp2
+ edge8 %tmp4, %g0, %tmp5
+ jmpl %tmp2 + %tmp1, %g0
+ andn %tmp4, 7, %tmp4
+1: addcc %branchbase, (3f - BranchBase), %tmp2
+ sra %tmp1, 1, %tmp1
+ jmpl %tmp2 + %tmp1, %g0
+ nop
+ ba,pt %xcc, 2f+0x00
+ stda %f16, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 2f+0x04
+ stda %f18, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 2f+0x08
+ stda %f20, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 2f+0x0c
+ stda %f22, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 2f+0x10
+ stda %f24, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 2f+0x14
+ stda %f26, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 2f+0x18
+ stda %f28, [%tmp4 + %tmp5] ASI_PST8_P
+ jmpl %branchbase + %tmp3, %g0
+ stda %f30, [%tmp4 + %tmp5] ASI_PST8_P
+2: std %f18, [%dst - 0x38]
+ std %f20, [%dst - 0x30]
+ std %f22, [%dst - 0x28]
+ std %f24, [%dst - 0x20]
+ std %f26, [%dst - 0x18]
+ std %f28, [%dst - 0x10]
+ std %f30, [%dst - 0x08]
+3: jmpl %branchbase + %tmp3, %g0
+ nop
+
+rightst:cmp %rightw, 64
+ be,pn %icc, 2f
+ and %rightw, 0x38, %tmp1
+ andcc %rightw, 7, %g0
+ be,pn %icc, 1f
+ neg %tmp1
+ sub %g0, %rightw, %tmp5
+ add %branchbase, (3f - BranchBase - 8), %tmp2
+ edge8l %tmp5, %g0, %tmp5
+ add %mode, %skind, %mode
+ jmpl %tmp1 + %tmp2, %g0
+ sub %dst, %tmp1, %tmp4
+1: addcc %branchbase, (4f - BranchBase), %tmp2
+ sra %tmp1, 1, %tmp1
+ jmpl %tmp1 + %tmp2, %g0
+2: add %mode, %skind, %mode
+ ba,pt %xcc, 4f
+ stda %f16, [%dst] ASI_BLK_P
+ ba,pt %xcc, 3f+0x00
+ stda %f30, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x04
+ stda %f28, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x08
+ stda %f26, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x0c
+ stda %f24, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x10
+ stda %f22, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x14
+ stda %f20, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x18
+ stda %f18, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x1c
+ stda %f16, [%tmp4 + %tmp5] ASI_PST8_P
+3: std %f28, [%dst + 0x30]
+ std %f26, [%dst + 0x28]
+ std %f24, [%dst + 0x20]
+ std %f22, [%dst + 0x18]
+ std %f20, [%dst + 0x10]
+ std %f18, [%dst + 0x08]
+ std %f16, [%dst + 0x00]
+4: brnz,pn %narrow, narrow_cont
+ deccc %srcnotdone
+ blu,pn %ICC, return
+ sub %mode, %dkind, %mode
+ alignaddr %mode, %g0, %g0
+ and %mode, 63, %mode
+ cmp %srcnext, %srcn
+ bne,a,pn %ICC, 6f
+ xor %fregset, 64, %fregset
+ brnz,a,pn %fregset, 5f
+ ldda [%src] ASI_BLK_P, %f32
+ ldda [%src] ASI_BLK_P, %f48
+5: add %src, 64, %src
+6: add %dst, %dkind, %dst
+ sub %w, %rightw, %tmp1
+ add %srcstart, %skind, %srcstart
+ sub %dst, %tmp1, %dst
+ add %rightw, %dkind, %rightw
+ andn %dst, 63, %dst
+ sub %rightw, 1, %rightw
+ sub %leftw, %dkind, %leftw
+ and %rightw, 63, %rightw
+ and %leftw, 63, %leftw
+ add %rightw, 1, %rightw
+roll_wide:
+ add %srcstart, %w, %srcend
+ add %srcstart, %skind, %srcnext
+ fnop
+ add %srcend, 63, %srcend
+ andncc %srcnext, 63, %srcnext
+ fnop
+ sll %mode, 4, %tmp1
+ andn %srcend, 63, %srcend
+ fnop
+ mov %srcnext, %srcn
+ and %mode, 7, %rightw2
+ fnop
+ andn %tmp1, 127, %tmp1
+ add %rightw2, %rightw, %rightw2
+ fnop
+ add %tmp1, %fregset, %tmp1
+ subcc %w, %leftw, %tmp3
+ fnop
+ srl %tmp1, 1, %tmp2
+ add %srcnext, 64, %tmp4
+ fnop
+ add %tmp2, (prepn0 - BranchBase), %tmp2
+ cmp %mode, %leftw
+ movgeu %icc, %tmp2, %tmp1
+ cmp %tmp4, %srcend
+ add %dst, 64, %tmp4
+ move %ICC, %srcend, %srcnext
+ movrnz %leftw, %tmp4, %dst
+ jmpl %branchbase + %tmp1, %g0
+ sub %tmp3, %rightw, %curw
+
+return: return %i7+8
+ wr %g0, 0, %fprs
+
+narrowst:
+ and %leftw, 0x38, %tmp1
+ sub %dst, %leftw, %tmp5
+ sub %w, 1, %fregset
+ andcc %leftw, 7, %tmp4
+ add %fregset, %tmp5, %fregset
+ neg %tmp1
+ and %fregset, 7, %srcend
+ be,pn %icc, 1f
+ edge8 %g0, %srcend, %srcend
+ add %tmp1, (2f - BranchBase - 8), %tmp1
+ edge8 %tmp5, %fregset, %tmp2
+ andn %tmp5, 7, %tmp5
+ andn %fregset, 7, %fregset
+ jmpl %branchbase + %tmp1, %g0
+ sub %w, %tmp4, %tmp4
+1: addcc %branchbase, (3f - BranchBase - 8), %tmp2
+ sll %tmp1, 1, %tmp1
+ andn %fregset, 7, %fregset
+ jmpl %tmp2 + %tmp1, %g0
+ mov %w, %tmp4
+ ba,pt %xcc, 2f+0x00
+ stda %f16, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 2f+0x10
+ stda %f18, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 2f+0x20
+ stda %f20, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 2f+0x30
+ stda %f22, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 2f+0x40
+ stda %f24, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 2f+0x50
+ stda %f26, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 2f+0x60
+ stda %f28, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 4f
+ stda %f30, [%tmp5 + %tmp2] ASI_PST8_P
+2: subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x00
+ fnop
+ std %f18, [%dst - 0x38]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x10
+ fnop
+ std %f20, [%dst - 0x30]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x20
+ fnop
+ std %f22, [%dst - 0x28]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x30
+ fnop
+ std %f24, [%dst - 0x20]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x40
+ fnop
+ std %f26, [%dst - 0x18]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x50
+ fnop
+ std %f28, [%dst - 0x10]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 3f+0x60
+ fnop
+ std %f30, [%dst - 0x08]
+ ba,pt %xcc, 4f
+ nop
+3: cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f18, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 4f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f20, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 4f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f22, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 4f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f24, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 4f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f26, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 4f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f28, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 4f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 4f
+ stda %f30, [%fregset + %srcend] ASI_PST8_P
+4: and %tmp3, 60, %tmp3
+ sub %dst, 64, %dst
+ add %tmp3, 96, %tmp3
+ add %mode, %skind, %mode
+ brz,pn %h, return
+ and %tmp3, 64, %fregset
+narrow_cont:
+ deccc %h
+ blu,pn %ICC, return
+ sub %mode, %dkind, %mode
+ alignaddr %mode, %g0, %g0
+ and %mode, 63, %mode
+ sub %srcnext, %srcn, %tmp4
+ add %dst, %dkind, %dst
+ sub %w, %rightw, %tmp1
+ add %srcstart, %skind, %srcstart
+ sub %dst, %tmp1, %dst
+ add %rightw, %dkind, %rightw
+ sub %leftw, %dkind, %leftw
+ sub %rightw, 1, %rightw
+ and %leftw, 63, %leftw
+ and %rightw, 63, %rightw
+ add %srcstart, %w, %srcend
+ add %rightw, 1, %rightw
+ add %srcstart, %skind, %srcnext
+ add %srcend, 63, %srcend
+ andn %srcnext, 63, %srcnext
+ andn %srcend, 63, %srcend
+ sub %w, %leftw, %prepw
+ mov %srcnext, %srcn
+ add %srcnext, 64, %tmp2
+ sub %srcnext, 64, %tmp3
+ and %srcstart, 63, %tmp1
+ cmp %skind, 0
+ movg %ICC, %srcend, %tmp3
+ sub %prepw, %rightw, %prepw
+ add %tmp1, %w, %tmp1
+ cmp %tmp2, %srcend
+ mov %prepw, %curw
+ move %ICC, %tmp3, %srcnext
+ mov %h, %srcnotdone
+ cmp %tmp1, 128
+ movg %ICC, 64, %prepw
+ andn %dst, 63, %dst
+ cmp %srcnext, %srcstop
+ move %ICC, 0, %srcnotdone
+ brnz,a,pn %tmp4, roll_narrow
+ xor %fregset, 64, %fregset
+ cmp %tmp1, 64
+ bg,pt %ICC, 5f
+ tst %srcnotdone
+ be,a,pn %ICC, roll_narrow
+ membar SYNC
+ mov %srcnext, %src
+5: brnz,a,pn %fregset, 6f
+ ldda [%src] ASI_BLK_P, %f32
+ ldda [%src] ASI_BLK_P, %f48
+6: addcc %src, 64, %src
+roll_narrow:
+ fnop
+ sll %mode, 4, %tmp2
+ and %mode, 7, %rightw2
+ fnop
+ andn %tmp2, 127, %tmp2
+ add %dst, 64, %tmp4
+ fnop
+ add %tmp2, %fregset, %tmp2
+ addcc %rightw2, %rightw, %rightw2
+ fnop
+ srl %tmp2, 1, %tmp3
+ movrnz %leftw, %tmp4, %dst
+ fnop
+ add %tmp3, (prepr0 - BranchBase), %tmp4
+ cmp %tmp1, 64
+ movleu %icc, %tmp4, %tmp2
+ fnop
+ add %tmp3, (prepn0 - BranchBase), %tmp4
+ cmp %mode, %leftw
+ fnop
+ movgeu %icc, %tmp4, %tmp2
+ jmpl %branchbase + %tmp2, %g0
+ and %tmp3, 32, %tmp3
+
+#define VISEND(i,tgt,tgtr,fi,fset) \
+tgt: \
+ brnz,pt %curw, 1f; \
+ cmp %rightw2, (64 - (i&14)*4); \
+ bgu,pn %icc, tgtr - 8; \
+ tst %srcnotdone; \
+ be,a,pn %ICC, tgtr; \
+ membar SYNC; \
+ ba,pt %xcc, tgtr - 8; \
+ mov %srcnext, %src; \
+1: mov ((i & 1) ^ 1) * 64, %fregset; \
+ bleu,pn %icc, rightst; \
+ faligndata %ftmp1, %ftmp2, %fi; \
+ brz,a,pn %srcnotdone, 3f; \
+ membar SYNC; \
+ ldda [%srcnext] ASI_BLK_P, %fset; \
+ add %srcnext, 64, %src; \
+3: mov (i & 1) * 64, %fregset;
+
+VISEND(0,vis0e,vis0r,f30,f32)
+ ba,pt %xcc, rightst
+ faligndata %ftmp1, %f48, %f30
+VISEND(1,vis1e,vis1r,f30,f48)
+ ba,pt %xcc, rightst
+ faligndata %ftmp1, %f32, %f30
+VISEND(2,vis2e,vis2r,f28,f32)
+ faligndata %ftmp1, %f48, %f28
+ ba,pt %xcc, rightst
+ faligndata %f48, %f50, %f30
+VISEND(3,vis3e,vis3r,f28,f48)
+ faligndata %ftmp1, %f32, %f28
+ ba,pt %xcc, rightst
+ faligndata %f32, %f34, %f30
+VISEND(4,vis4e,vis4r,f26,f32)
+ faligndata %ftmp1, %f48, %f26
+ faligndata %f48, %f50, %f28
+ ba,pt %xcc, rightst
+ faligndata %f50, %f52, %f30
+VISEND(5,vis5e,vis5r,f26,f48)
+ faligndata %ftmp1, %f32, %f26
+ faligndata %f32, %f34, %f28
+ ba,pt %xcc, rightst
+ faligndata %f34, %f36, %f30
+VISEND(6,vis6e,vis6r,f24,f32)
+ faligndata %ftmp1, %f48, %f24
+ faligndata %f48, %f50, %f26
+ faligndata %f50, %f52, %f28
+ ba,pt %xcc, rightst
+ faligndata %f52, %f54, %f30
+VISEND(7,vis7e,vis7r,f24,f48)
+ faligndata %ftmp1, %f32, %f24
+ faligndata %f32, %f34, %f26
+ faligndata %f34, %f36, %f28
+ ba,pt %xcc, rightst
+ faligndata %f36, %f38, %f30
+VISEND(8,vis8e,vis8r,f22,f32)
+ faligndata %ftmp1, %f48, %f22
+ faligndata %f48, %f50, %f24
+ faligndata %f50, %f52, %f26
+ faligndata %f52, %f54, %f28
+ ba,pt %xcc, rightst
+ faligndata %f54, %f56, %f30
+VISEND(9,vis9e,vis9r,f22,f48)
+ faligndata %ftmp1, %f32, %f22
+ faligndata %f32, %f34, %f24
+ faligndata %f34, %f36, %f26
+ faligndata %f36, %f38, %f28
+ ba,pt %xcc, rightst
+ faligndata %f38, %f40, %f30
+VISEND(10,vis10e,vis10r,f20,f32)
+ faligndata %ftmp1, %f48, %f20
+ faligndata %f48, %f50, %f22
+ faligndata %f50, %f52, %f24
+ faligndata %f52, %f54, %f26
+ faligndata %f54, %f56, %f28
+ ba,pt %xcc, rightst
+ faligndata %f56, %f58, %f30
+VISEND(11,vis11e,vis11r,f20,f48)
+ faligndata %ftmp1, %f32, %f20
+ faligndata %f32, %f34, %f22
+ faligndata %f34, %f36, %f24
+ faligndata %f36, %f38, %f26
+ faligndata %f38, %f40, %f28
+ ba,pt %xcc, rightst
+ faligndata %f40, %f42, %f30
+VISEND(12,vis12e,vis12r,f18,f32)
+ faligndata %ftmp1, %f48, %f18
+ faligndata %f48, %f50, %f20
+ faligndata %f50, %f52, %f22
+ faligndata %f52, %f54, %f24
+ faligndata %f54, %f56, %f26
+ faligndata %f56, %f58, %f28
+ ba,pt %xcc, rightst
+ faligndata %f58, %f60, %f30
+VISEND(13,vis13e,vis13r,f18,f48)
+ faligndata %ftmp1, %f32, %f18
+ faligndata %f32, %f34, %f20
+ faligndata %f34, %f36, %f22
+ faligndata %f36, %f38, %f24
+ faligndata %f38, %f40, %f26
+ faligndata %f40, %f42, %f28
+ ba,pt %xcc, rightst
+ faligndata %f42, %f44, %f30
+VISEND(14,vis14e,vis14r,f16,f32)
+ faligndata %ftmp1, %f48, %f16
+ faligndata %f48, %f50, %f18
+ faligndata %f50, %f52, %f20
+ faligndata %f52, %f54, %f22
+ faligndata %f54, %f56, %f24
+ faligndata %f56, %f58, %f26
+ faligndata %f58, %f60, %f28
+ ba,pt %xcc, rightst
+ faligndata %f60, %f62, %f30
+VISEND(15,vis15e,vis15r,f16,f48)
+ faligndata %ftmp1, %f32, %f16
+ faligndata %f32, %f34, %f18
+ faligndata %f34, %f36, %f20
+ faligndata %f36, %f38, %f22
+ faligndata %f38, %f40, %f24
+ faligndata %f40, %f42, %f26
+ faligndata %f42, %f44, %f28
+ ba,pt %xcc, rightst
+ faligndata %f44, %f46, %f30
+
+#define PREPEND(tgt,tgtr) \
+tgt: \
+ brnz,pt %srcnotdone, tgtr - 8; \
+ mov %srcnext, %src; \
+ ba,pt %xcc, tgtr; \
+ membar SYNC;
+
+ .align 16
+PREPEND(prep0e,prep0r)
+PREPEND(prep1e,prep1r)
+PREPEND(prep2e,prep2r)
+PREPEND(prep3e,prep3r)
+PREPEND(prep4e,prep4r)
+PREPEND(prep5e,prep5r)
+PREPEND(prep6e,prep6r)
+PREPEND(prep7e,prep7r)
+PREPEND(prep8e,prep8r)
+PREPEND(prep9e,prep9r)
+PREPEND(prep10e,prep10r)
+PREPEND(prep11e,prep11r)
+PREPEND(prep12e,prep12r)
+PREPEND(prep13e,prep13r)
+PREPEND(prep14e,prep14r)
+PREPEND(prep15e,prep15r)
+
+/* The other way is even more complicated, as the hardware prefers
+ * going from lower addresses up. */
+
+#define RLOAD(f32,tgt,tgtr) \
+ subcc %curw, 64, %curw; \
+ bleu,pn %ICC, tgt; \
+ fmovd %f32, %ftmp1; \
+ ldda [%src] ASI_BLK_P, %f32; \
+ sub %src, 64, %src; \
+tgtr:
+
+#if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__) || !defined(SIGNAL_CLOBBERS_OG_REGS)
+
+#define RPREPLOAD(f32,tgt,tgtr) \
+ brlez,pn %prepw, tgt; \
+ fmovd %f32, %ftmp1; \
+ ldda [%src] ASI_BLK_P, %f32; \
+ sub %src, 64, %src; \
+tgtr:
+
+#else
+
+#define RPREPLOAD(f32,tgt,tgtr) \
+ tst %prepw; \
+ ble,pn %ICC, tgt; \
+ fmovd %f32, %ftmp1; \
+ ldda [%src] ASI_BLK_P, %f32; \
+ sub %src, 64, %src; \
+tgtr:
+
+#endif
+
+ .globl VISmoveImageRL
+ .align 32
+VISmoveImageRL:
+ save %sp, -160, %sp ! Group 0
+0: rd %pc, %tmp3 ! Group 1
+ and %dst, 63, %leftw ! Group 7
+ mov 64, %tmp1
+ add %src, %w, %src ! Group 8
+ add %dst, %w, %dst
+ sub %src, %dst, %mode ! Group 9
+ brz,pn %h, rreturn
+ sub %dst, 1, %rightw ! Group 10
+ mov %src, %srcstart
+ dec %src ! Group 11
+ cmp %w, 128
+ blu,pn %ICC, rprepare_narrow
+ and %mode, 63, %mode ! Group 12
+ andn %src, 63, %src
+ ldda [%src] ASI_BLK_P, %f32 ! Group 13
+ sub %src, 64, %src ! Group 14
+ clr %narrow
+ ldda [%src] ASI_BLK_P, %f48 ! Group 15
+ sub %tmp1, %leftw, %leftw ! Group 16
+ and %rightw, 63, %rightw
+ dec %dst ! Group 17
+ add %rightw, 1, %rightw
+ alignaddr %mode, %g0, %g0 ! Group 18
+ andn %dst, 63, %dst ! Group 19
+ clr %fregset
+ sub %src, 64, %src ! Group 20
+ add %tmp3, (BranchBaseR - 0b), %branchbase
+ mov 64, %prepw ! Group 21
+ ba,pt %xcc, rroll_wide
+ sub %h, 1, %srcnotdone
+rprepare_narrow:
+#if defined(__sparc_v9__) || defined(__sparcv9) || defined(__arch64__)
+ brlez,pn %w, rreturn
+#else
+ tst %w
+ ble,pn %icc, rreturn
+#endif
+ andn %src, 63, %src ! Group 12
+ sub %tmp1, %leftw, %leftw
+ ldda [%src] ASI_BLK_P, %f32 ! Group 13
+ and %rightw, 63, %rightw ! Group 14
+ dec %dst
+ add %rightw, 1, %rightw ! Group 15
+ andn %dst, 63, %dst
+ sub %w, %leftw, %tmp2 ! Group 16
+ sub %srcstart, 1, %tmp1
+ subcc %tmp2, %rightw, %curw ! Group 17
+ and %tmp1, 63, %tmp1
+ mov %curw, %prepw ! Group 18
+ sub %tmp1, %w, %tmp1
+ bg,pt %ICC, 1f
+ sub %src, 64, %src ! Group 19
+ cmp %tmp1, -65
+ movl %ICC, 64, %prepw ! Group 20
+1: add %srcstart, %skind, %srcnext
+ sub %h, 1, %srcnotdone ! Group 21
+ sub %srcstart, %w, %tmp4
+ sub %srcnext, 1, %srcnext ! Group 22
+ andn %tmp4, 63, %srcend
+ andn %srcnext, 63, %srcnext ! Group 23
+ cmp %skind, 0
+ add %w, 64, %tmp2 ! Group 24
+ mov %srcnext, %srcn
+ bl,pn %ICC, 1f
+ clr %srcstop ! Group 25
+ cmp %skind, %tmp2
+ bgeu,pt %ICC, 3f
+ add %srcnext, 64, %fregset
+ SMUL %skind, %srcnotdone, %srcstop
+ ba,pt %xcc, 2f
+ add %srcstart, 63, %tmp4
+1: addcc %tmp2, %skind, %g0
+ ble,pt %ICC, 3f
+ sub %srcnext, 64, %fregset
+ SMUL %skind, %srcnotdone, %srcstop
+ sub %tmp4, 64, %tmp4
+2: add %srcstop, %tmp4, %srcstop
+3: cmp %srcnext, %srcend
+ andn %srcstop, 63, %srcstop
+ move %ICC, %fregset, %srcnext
+ cmp %srcnext, %srcstop
+ clr %fregset
+ move %ICC, 0, %srcnotdone
+ alignaddr %mode, %g0, %g0
+ add %tmp3, (BranchBaseR - 0b), %branchbase
+ mov 1, %narrow
+ cmp %tmp1, -1
+ bge,pn %ICC, 1f
+ dec %h
+ ldda [%src] ASI_BLK_P, %f48
+ ba,pt %xcc, rroll_narrow
+ subcc %src, 64, %src
+1: brz,a,pn %srcnotdone, rroll_narrow
+ membar #Sync
+ ldda [%srcnext] ASI_BLK_P, %f48
+ ba,pt %xcc, rroll_narrow
+ subcc %srcnext, 64, %src
+
+ .align 32
+rrepr0: ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f30
+ nop
+ nop
+1: ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f16
+ .align 32
+rrepr1: ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f30
+ nop
+ nop
+2: ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f16
+ .align 32
+rrepr2: faligndata %f32, %f34, %f30
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f28
+ .align 32
+rrepr3: faligndata %f48, %f50, %f30
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f28
+ .align 32
+rrepr4: faligndata %f34, %f36, %f30
+ faligndata %f32, %f34, %f28
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f26
+ .align 32
+rrepr5: faligndata %f50, %f52, %f30
+ faligndata %f48, %f50, %f28
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f26
+ .align 32
+rrepr6: faligndata %f36, %f38, %f30
+ faligndata %f34, %f36, %f28
+ faligndata %f32, %f34, %f26
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f24
+ .align 32
+rrepr7: faligndata %f52, %f54, %f30
+ faligndata %f50, %f52, %f28
+ faligndata %f48, %f50, %f26
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f24
+ .align 32
+rrepr8: faligndata %f38, %f40, %f30
+ faligndata %f36, %f38, %f28
+ faligndata %f34, %f36, %f26
+ faligndata %f32, %f34, %f24
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f22
+ .align 32
+rrepr9: faligndata %f54, %f56, %f30
+ faligndata %f52, %f54, %f28
+ faligndata %f50, %f52, %f26
+ faligndata %f48, %f50, %f24
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f22
+ .align 32
+rrepr10:faligndata %f40, %f42, %f30
+ faligndata %f38, %f40, %f28
+ faligndata %f36, %f38, %f26
+ faligndata %f34, %f36, %f24
+ faligndata %f32, %f34, %f22
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f20
+ .align 32
+rrepr11:faligndata %f56, %f58, %f30
+ faligndata %f54, %f56, %f28
+ faligndata %f52, %f54, %f26
+ faligndata %f50, %f52, %f24
+ faligndata %f48, %f50, %f22
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f20
+ .align 32
+rrepr12:faligndata %f42, %f44, %f30
+ faligndata %f40, %f42, %f28
+ faligndata %f38, %f40, %f26
+ faligndata %f36, %f38, %f24
+ faligndata %f34, %f36, %f22
+ faligndata %f32, %f34, %f20
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f32, %f18
+ .align 32
+rrepr13:faligndata %f58, %f60, %f30
+ faligndata %f56, %f58, %f28
+ faligndata %f54, %f56, %f26
+ faligndata %f52, %f54, %f24
+ faligndata %f50, %f52, %f22
+ faligndata %f48, %f50, %f20
+ ba,pt %xcc, narrowstr
+ faligndata %ftmp1, %f48, %f18
+ .align 32
+rrepr14:faligndata %f44, %f46, %f30
+ faligndata %f42, %f44, %f28
+ faligndata %f40, %f42, %f26
+ faligndata %f38, %f40, %f24
+ faligndata %f36, %f38, %f22
+ faligndata %f34, %f36, %f20
+ ba,pt %xcc, 1b
+ faligndata %f32, %f34, %f18
+ .align 32
+rrepr15:faligndata %f60, %f62, %f30
+ faligndata %f58, %f60, %f28
+ faligndata %f56, %f58, %f26
+ faligndata %f54, %f56, %f24
+ faligndata %f52, %f54, %f22
+ faligndata %f50, %f52, %f20
+ ba,pt %xcc, 2b
+ faligndata %f48, %f50, %f18
+
+ .align 32
+rrepn0: faligndata %f46, %ftmp1, %f30
+ faligndata %f44, %f46, %f28
+ faligndata %f42, %f44, %f26
+ faligndata %f40, %f42, %f24
+ faligndata %f38, %f40, %f22
+ faligndata %f36, %f38, %f20
+ ba,pt %xcc, 1f
+ faligndata %f34, %f36, %f18
+ .align 32
+rrepn1: faligndata %f62, %ftmp1, %f30
+ faligndata %f60, %f62, %f28
+ faligndata %f58, %f60, %f26
+ faligndata %f56, %f58, %f24
+ faligndata %f54, %f56, %f22
+ faligndata %f52, %f54, %f20
+ ba,pt %xcc, 2f
+ faligndata %f50, %f52, %f18
+ .align 32
+rrepn2: faligndata %f46, %ftmp1, %f28
+ faligndata %f44, %f46, %f26
+ faligndata %f42, %f44, %f24
+ faligndata %f40, %f42, %f22
+ faligndata %f38, %f40, %f20
+ faligndata %f36, %f38, %f18
+ ba,pt %xcc, 3f
+ faligndata %f34, %f36, %f16
+ .align 32
+rrepn3: faligndata %f62, %ftmp1, %f28
+ faligndata %f60, %f62, %f26
+ faligndata %f58, %f60, %f24
+ faligndata %f56, %f58, %f22
+ faligndata %f54, %f56, %f20
+ faligndata %f52, %f54, %f18
+ ba,pt %xcc, 4f
+ faligndata %f50, %f52, %f16
+ .align 32
+rrepn4: faligndata %f46, %ftmp1, %f26
+ faligndata %f44, %f46, %f24
+ faligndata %f42, %f44, %f22
+ faligndata %f40, %f42, %f20
+ faligndata %f38, %f40, %f18
+ faligndata %f36, %f38, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis4 - BranchBaseR), %tmp3
+ .align 32
+rrepn5: faligndata %f62, %ftmp1, %f26
+ faligndata %f60, %f62, %f24
+ faligndata %f58, %f60, %f22
+ faligndata %f56, %f58, %f20
+ faligndata %f54, %f56, %f18
+ faligndata %f52, %f54, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis5 - BranchBaseR), %tmp3
+ .align 32
+rrepn6: faligndata %f46, %ftmp1, %f24
+ faligndata %f44, %f46, %f22
+ faligndata %f42, %f44, %f20
+ faligndata %f40, %f42, %f18
+ faligndata %f38, %f40, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis6 - BranchBaseR), %tmp3
+ .align 32
+rrepn7: faligndata %f62, %ftmp1, %f24
+ faligndata %f60, %f62, %f22
+ faligndata %f58, %f60, %f20
+ faligndata %f56, %f58, %f18
+ faligndata %f54, %f56, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis7 - BranchBaseR), %tmp3
+ .align 32
+rrepn8: faligndata %f46, %ftmp1, %f22
+ faligndata %f44, %f46, %f20
+ faligndata %f42, %f44, %f18
+ faligndata %f40, %f42, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis8 - BranchBaseR), %tmp3
+ .align 32
+rrepn9: faligndata %f62, %ftmp1, %f22
+ faligndata %f60, %f62, %f20
+ faligndata %f58, %f60, %f18
+ faligndata %f56, %f58, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis9 - BranchBaseR), %tmp3
+ .align 32
+rrepn10:faligndata %f46, %ftmp1, %f20
+ faligndata %f44, %f46, %f18
+ faligndata %f42, %f44, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis10 - BranchBaseR), %tmp3
+ .align 32
+rrepn11:faligndata %f62, %ftmp1, %f20
+ faligndata %f60, %f62, %f18
+ faligndata %f58, %f60, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis11 - BranchBaseR), %tmp3
+ .align 32
+rrepn12:faligndata %f46, %ftmp1, %f18
+ faligndata %f44, %f46, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis12 - BranchBaseR), %tmp3
+ nop
+ nop
+3: ba,pt %xcc, rightstr
+ mov (rvis2 - BranchBaseR), %tmp3
+ .align 32
+rrepn13:faligndata %f62, %ftmp1, %f18
+ faligndata %f60, %f62, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis13 - BranchBaseR), %tmp3
+ nop
+ nop
+4: ba,pt %xcc, rightstr
+ mov (rvis3 - BranchBaseR), %tmp3
+ .align 32
+rrepn14:faligndata %f46, %ftmp1, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis14 - BranchBaseR), %tmp3
+ nop
+1: faligndata %f32, %f34, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis0 - BranchBaseR), %tmp3
+ .align 32
+rrepn15:faligndata %f62, %ftmp1, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis15 - BranchBaseR), %tmp3
+ nop
+2: faligndata %f48, %f50, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis1 - BranchBaseR), %tmp3
+
+ .align 64
+BranchBaseR:
+rrepl0: RPREPLOAD(f32,rrep0e,rrep0r)
+ fnop
+ faligndata %f48, %f50, %f16
+ faligndata %f50, %f52, %f18
+ faligndata %f52, %f54, %f20
+ faligndata %f54, %f56, %f22
+ faligndata %f56, %f58, %f24
+ faligndata %f58, %f60, %f26
+ faligndata %f60, %f62, %f28
+ faligndata %f62, %ftmp1, %f30
+ ba,pt %xcc, rightstr
+ mov (rvis1 - BranchBaseR), %tmp3
+ nop
+ nop
+ .align 32
+rrepl1: RPREPLOAD(f48,rrep1e,rrep1r)
+ fnop
+ faligndata %f32, %f34, %f16
+ faligndata %f34, %f36, %f18
+ faligndata %f36, %f38, %f20
+ faligndata %f38, %f40, %f22
+ faligndata %f40, %f42, %f24
+ faligndata %f42, %f44, %f26
+ faligndata %f44, %f46, %f28
+ faligndata %f46, %ftmp1, %f30
+ ba,pt %xcc, rightstr
+ mov (rvis0 - BranchBaseR), %tmp3
+ nop
+ nop
+ .align 32
+rrepl2: faligndata %f32, %f34, %f30
+ RPREPLOAD(f32,rrep2e,rrep2r)
+ fnop
+ fnop
+ faligndata %f50, %f52, %f16
+ faligndata %f52, %f54, %f18
+ faligndata %f54, %f56, %f20
+ faligndata %f56, %f58, %f22
+ faligndata %f58, %f60, %f24
+ faligndata %f60, %f62, %f26
+ faligndata %f62, %ftmp1, %f28
+ ba,pt %xcc, rightstr
+ mov (rvis3 - BranchBaseR), %tmp3
+ nop
+ .align 32
+rrepl3: faligndata %f48, %f50, %f30
+ RPREPLOAD(f48,rrep3e,rrep3r)
+ fnop
+ fnop
+ faligndata %f34, %f36, %f16
+ faligndata %f36, %f38, %f18
+ faligndata %f38, %f40, %f20
+ faligndata %f40, %f42, %f22
+ faligndata %f42, %f44, %f24
+ faligndata %f44, %f46, %f26
+ faligndata %f46, %ftmp1, %f28
+ ba,pt %xcc, rightstr
+ mov (rvis2 - BranchBaseR), %tmp3
+ nop
+ .align 32
+rrepl4: faligndata %f32, %f34, %f28
+ faligndata %f34, %f36, %f30
+ RPREPLOAD(f32,rrep4e,rrep4r)
+ fnop
+ fnop
+ fnop
+ faligndata %f52, %f54, %f16
+ faligndata %f54, %f56, %f18
+ faligndata %f56, %f58, %f20
+ faligndata %f58, %f60, %f22
+ faligndata %f60, %f62, %f24
+ faligndata %f62, %ftmp1, %f26
+ ba,pt %xcc, rightstr
+ mov (rvis5 - BranchBaseR), %tmp3
+ .align 32
+rrepl5: faligndata %f48, %f50, %f28
+ faligndata %f50, %f52, %f30
+ RPREPLOAD(f48,rrep5e,rrep5r)
+ fnop
+ fnop
+ fnop
+ faligndata %f36, %f38, %f16
+ faligndata %f38, %f40, %f18
+ faligndata %f40, %f42, %f20
+ faligndata %f42, %f44, %f22
+ faligndata %f44, %f46, %f24
+ faligndata %f46, %ftmp1, %f26
+ ba,pt %xcc, rightstr
+ mov (rvis4 - BranchBaseR), %tmp3
+ .align 32
+rrepl6: faligndata %f32, %f34, %f26
+ faligndata %f34, %f36, %f28
+ faligndata %f36, %f38, %f30
+ RPREPLOAD(f32,rrep6e,rrep6r)
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f54, %f56, %f16
+ faligndata %f56, %f58, %f18
+ faligndata %f58, %f60, %f20
+ faligndata %f60, %f62, %f22
+ faligndata %f62, %ftmp1, %f24
+ ba,pt %xcc, rightstr
+ mov (rvis7 - BranchBaseR), %tmp3
+ .align 32
+rrepl7: faligndata %f48, %f50, %f26
+ faligndata %f50, %f52, %f28
+ faligndata %f52, %f54, %f30
+ RPREPLOAD(f48,rrep7e,rrep7r)
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f38, %f40, %f16
+ faligndata %f40, %f42, %f18
+ faligndata %f42, %f44, %f20
+ faligndata %f44, %f46, %f22
+ faligndata %f46, %ftmp1, %f24
+ ba,pt %xcc, rightstr
+ mov (rvis6 - BranchBaseR), %tmp3
+ .align 32
+rrepl8: faligndata %f32, %f34, %f24
+ faligndata %f34, %f36, %f26
+ faligndata %f36, %f38, %f28
+ faligndata %f38, %f40, %f30
+ RPREPLOAD(f32,rrep8e,rrep8r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f56, %f58, %f16
+ faligndata %f58, %f60, %f18
+ faligndata %f60, %f62, %f20
+ faligndata %f62, %ftmp1, %f22
+ ba,pt %xcc, rightstr
+ mov (rvis9 - BranchBaseR), %tmp3
+ .align 32
+rrepl9: faligndata %f48, %f50, %f24
+ faligndata %f50, %f52, %f26
+ faligndata %f52, %f54, %f28
+ faligndata %f54, %f56, %f30
+ RPREPLOAD(f48,rrep9e,rrep9r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f40, %f42, %f16
+ faligndata %f42, %f44, %f18
+ faligndata %f44, %f46, %f20
+ faligndata %f46, %ftmp1, %f22
+ ba,pt %xcc, rightstr
+ mov (rvis8 - BranchBaseR), %tmp3
+ .align 32
+rrepl10:faligndata %f32, %f34, %f22
+ faligndata %f34, %f36, %f24
+ faligndata %f36, %f38, %f26
+ faligndata %f38, %f40, %f28
+ faligndata %f40, %f42, %f30
+ RPREPLOAD(f32,rrep10e,rrep10r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f58, %f60, %f16
+ faligndata %f60, %f62, %f18
+ faligndata %f62, %ftmp1, %f20
+ ba,pt %xcc, rightstr
+ mov (rvis11 - BranchBaseR), %tmp3
+ .align 32
+rrepl11:faligndata %f48, %f50, %f22
+ faligndata %f50, %f52, %f24
+ faligndata %f52, %f54, %f26
+ faligndata %f54, %f56, %f28
+ faligndata %f56, %f58, %f30
+ RPREPLOAD(f48,rrep11e,rrep11r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f42, %f44, %f16
+ faligndata %f44, %f46, %f18
+ faligndata %f46, %ftmp1, %f20
+ ba,pt %xcc, rightstr
+ mov (rvis10 - BranchBaseR), %tmp3
+ .align 32
+rrepl12:faligndata %f32, %f34, %f20
+ faligndata %f34, %f36, %f22
+ faligndata %f36, %f38, %f24
+ faligndata %f38, %f40, %f26
+ faligndata %f40, %f42, %f28
+ faligndata %f42, %f44, %f30
+ RPREPLOAD(f32,rrep12e,rrep12r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f60, %f62, %f16
+ faligndata %f62, %ftmp1, %f18
+ ba,pt %xcc, rightstr
+ mov (rvis13 - BranchBaseR), %tmp3
+ .align 32
+rrepl13:faligndata %f48, %f50, %f20
+ faligndata %f50, %f52, %f22
+ faligndata %f52, %f54, %f24
+ faligndata %f54, %f56, %f26
+ faligndata %f56, %f58, %f28
+ faligndata %f58, %f60, %f30
+ RPREPLOAD(f48,rrep13e,rrep13r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f44, %f46, %f16
+ faligndata %f46, %ftmp1, %f18
+ ba,pt %xcc, rightstr
+ mov (rvis12 - BranchBaseR), %tmp3
+ .align 32
+rrepl14:faligndata %f32, %f34, %f18
+ faligndata %f34, %f36, %f20
+ faligndata %f36, %f38, %f22
+ faligndata %f38, %f40, %f24
+ faligndata %f40, %f42, %f26
+ faligndata %f42, %f44, %f28
+ faligndata %f44, %f46, %f30
+ RPREPLOAD(f32,rrep14e,rrep14r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f62, %ftmp1, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis15 - BranchBaseR), %tmp3
+ .align 32
+rrepl15:faligndata %f48, %f50, %f18
+ faligndata %f50, %f52, %f20
+ faligndata %f52, %f54, %f22
+ faligndata %f54, %f56, %f24
+ faligndata %f56, %f58, %f26
+ faligndata %f58, %f60, %f28
+ faligndata %f60, %f62, %f30
+ RPREPLOAD(f48,rrep15e,rrep15r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f46, %ftmp1, %f16
+ ba,pt %xcc, rightstr
+ mov (rvis14 - BranchBaseR), %tmp3
+
+ .align 64
+rvis0: nop
+ RLOAD(f32,rvis0e,rvis0r)
+ fnop
+ faligndata %f48, %f50, %f16
+ faligndata %f50, %f52, %f18
+ faligndata %f52, %f54, %f20
+ faligndata %f54, %f56, %f22
+ faligndata %f56, %f58, %f24
+ faligndata %f58, %f60, %f26
+ faligndata %f60, %f62, %f28
+ faligndata %f62, %ftmp1, %f30
+ STORE
+ sub %dst, 64, %dst
+rvis1: RLOAD(f48,rvis1e,rvis1r)
+ fnop
+ faligndata %f32, %f34, %f16
+ faligndata %f34, %f36, %f18
+ faligndata %f36, %f38, %f20
+ faligndata %f38, %f40, %f22
+ faligndata %f40, %f42, %f24
+ faligndata %f42, %f44, %f26
+ faligndata %f44, %f46, %f28
+ faligndata %f46, %ftmp1, %f30
+ STORE
+ ba,pt %xcc, rvis0+0x04
+ sub %dst, 64, %dst
+ .align 64
+rvis2: faligndata %f32, %f34, %ftmp8
+ RLOAD(f32,rvis2e,rvis2r)
+ fnop
+ fnop
+ faligndata %f50, %f52, %f16
+ faligndata %f52, %f54, %f18
+ faligndata %f54, %f56, %f20
+ faligndata %f56, %f58, %f22
+ faligndata %f58, %f60, %f24
+ faligndata %f60, %f62, %f26
+ faligndata %f62, %ftmp1, %f28
+ fmovd %ftmp8, %f30
+ STORE
+ sub %dst, 64, %dst
+rvis3: faligndata %f48, %f50, %ftmp8
+ RLOAD(f48,rvis3e,rvis3r)
+ fnop
+ fnop
+ faligndata %f34, %f36, %f16
+ faligndata %f36, %f38, %f18
+ faligndata %f38, %f40, %f20
+ faligndata %f40, %f42, %f22
+ faligndata %f42, %f44, %f24
+ faligndata %f44, %f46, %f26
+ faligndata %f46, %ftmp1, %f28
+ fmovd %ftmp8, %f30
+ STORE
+ ba,pt %xcc, rvis2
+ sub %dst, 64, %dst
+ .align 64
+rvis4: faligndata %f32, %f34, %ftmp7
+ faligndata %f34, %f36, %ftmp8
+ RLOAD(f32,rvis4e,rvis4r)
+ fnop
+ fnop
+ fnop
+ faligndata %f52, %f54, %f16
+ faligndata %f54, %f56, %f18
+ faligndata %f56, %f58, %f20
+ faligndata %f58, %f60, %f22
+ faligndata %f60, %f62, %f24
+ faligndata %f62, %ftmp1, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ STORE
+ sub %dst, 64, %dst
+rvis5: faligndata %f48, %f50, %ftmp7
+ faligndata %f50, %f52, %ftmp8
+ RLOAD(f48,rvis5e,rvis5r)
+ fnop
+ fnop
+ fnop
+ faligndata %f36, %f38, %f16
+ faligndata %f38, %f40, %f18
+ faligndata %f40, %f42, %f20
+ faligndata %f42, %f44, %f22
+ faligndata %f44, %f46, %f24
+ faligndata %f46, %ftmp1, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ STORE
+ ba,pt %xcc, rvis4
+ sub %dst, 64, %dst
+ .align 64
+rvis6: faligndata %f32, %f34, %ftmp6
+ faligndata %f34, %f36, %ftmp7
+ faligndata %f36, %f38, %ftmp8
+ RLOAD(f32,rvis6e,rvis6r)
+ fnop
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f54, %f56, %f16
+ faligndata %f56, %f58, %f18
+ faligndata %f58, %f60, %f20
+ faligndata %f60, %f62, %f22
+ faligndata %f62, %ftmp1, %f24
+ STORE
+ sub %dst, 64, %dst
+rvis7: faligndata %f48, %f50, %ftmp6
+ faligndata %f50, %f52, %ftmp7
+ faligndata %f52, %f54, %ftmp8
+ RLOAD(f48,rvis7e,rvis7r)
+ fnop
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f38, %f40, %f16
+ faligndata %f40, %f42, %f18
+ faligndata %f42, %f44, %f20
+ faligndata %f44, %f46, %f22
+ faligndata %f46, %ftmp1, %f24
+ STORE
+ ba,pt %xcc, rvis6
+ sub %dst, 64, %dst
+ .align 64
+rvis8: faligndata %f32, %f34, %ftmp5
+ faligndata %f34, %f36, %ftmp6
+ faligndata %f36, %f38, %ftmp7
+ faligndata %f38, %f40, %ftmp8
+ RLOAD(f32,rvis8e,rvis8r)
+ fnop
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f56, %f58, %f16
+ faligndata %f58, %f60, %f18
+ faligndata %f60, %f62, %f20
+ faligndata %f62, %ftmp1, %f22
+ STORE
+ sub %dst, 64, %dst
+rvis9: faligndata %f48, %f50, %ftmp5
+ faligndata %f50, %f52, %ftmp6
+ faligndata %f52, %f54, %ftmp7
+ faligndata %f54, %f56, %ftmp8
+ RLOAD(f48,rvis9e,rvis9r)
+ fnop
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f40, %f42, %f16
+ faligndata %f42, %f44, %f18
+ faligndata %f44, %f46, %f20
+ faligndata %f46, %ftmp1, %f22
+ STORE
+ ba,pt %xcc, rvis8
+ sub %dst, 64, %dst
+ .align 64
+rvis10: faligndata %f32, %f34, %ftmp4
+ faligndata %f34, %f36, %ftmp5
+ faligndata %f36, %f38, %ftmp6
+ faligndata %f38, %f40, %ftmp7
+ faligndata %f40, %f42, %ftmp8
+ RLOAD(f32,rvis10e,rvis10r)
+ fnop
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f58, %f60, %f16
+ faligndata %f60, %f62, %f18
+ faligndata %f62, %ftmp1, %f20
+ STORE
+ sub %dst, 64, %dst
+rvis11: faligndata %f48, %f50, %ftmp4
+ faligndata %f50, %f52, %ftmp5
+ faligndata %f52, %f54, %ftmp6
+ faligndata %f54, %f56, %ftmp7
+ faligndata %f56, %f58, %ftmp8
+ RLOAD(f48,rvis11e,rvis11r)
+ fnop
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f42, %f44, %f16
+ faligndata %f44, %f46, %f18
+ faligndata %f46, %ftmp1, %f20
+ STORE
+ ba,pt %xcc, rvis10
+ sub %dst, 64, %dst
+ .align 64
+rvis12: faligndata %f32, %f34, %ftmp3
+ faligndata %f34, %f36, %ftmp4
+ faligndata %f36, %f38, %ftmp5
+ faligndata %f38, %f40, %ftmp6
+ faligndata %f40, %f42, %ftmp7
+ faligndata %f42, %f44, %ftmp8
+ RLOAD(f32,rvis12e,rvis12r)
+ fnop
+ fmovd %ftmp3, %f20
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f60, %f62, %f16
+ faligndata %f62, %ftmp1, %f18
+ STORE
+ sub %dst, 64, %dst
+rvis13: faligndata %f48, %f50, %ftmp3
+ faligndata %f50, %f52, %ftmp4
+ faligndata %f52, %f54, %ftmp5
+ faligndata %f54, %f56, %ftmp6
+ faligndata %f56, %f58, %ftmp7
+ faligndata %f58, %f60, %ftmp8
+ RLOAD(f48,rvis13e,rvis13r)
+ fnop
+ fmovd %ftmp3, %f20
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ fmovd %ftmp8, %f30
+ faligndata %f44, %f46, %f16
+ faligndata %f46, %ftmp1, %f18
+ STORE
+ ba,pt %xcc, rvis12
+ sub %dst, 64, %dst
+ .align 64
+rvis14: fnop
+ faligndata %f32, %f34, %f18
+ faligndata %f34, %f36, %f20
+ faligndata %f36, %f38, %f22
+ faligndata %f38, %f40, %f24
+ faligndata %f40, %f42, %f26
+ faligndata %f42, %f44, %f28
+ faligndata %f44, %f46, %f30
+ RLOAD(f32,rvis14e,rvis14r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f62, %ftmp1, %f16
+ STORE
+ sub %dst, 64, %dst
+rvis15: fnop
+ faligndata %f48, %f50, %f18
+ faligndata %f50, %f52, %f20
+ faligndata %f52, %f54, %f22
+ faligndata %f54, %f56, %f24
+ faligndata %f56, %f58, %f26
+ faligndata %f58, %f60, %f28
+ faligndata %f60, %f62, %f30
+ RLOAD(f48,rvis15e,rvis15r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f46, %ftmp1, %f16
+ STORE
+ ba,pt %xcc, rvis14
+ sub %dst, 64, %dst
+
+rightstr:
+ brlz,pn %curw, narrowstr + 4
+ cmp %rightw, 64
+ be,pn %icc, 2f
+ and %rightw, 0x38, %tmp1
+ andcc %rightw, 7, %g0
+ be,pn %icc, 1f
+ neg %tmp1
+ sub %g0, %rightw, %tmp5
+ add %branchbase, (3f - BranchBaseR - 8), %tmp2
+ edge8l %tmp5, %g0, %tmp5
+ sub %dst, %tmp1, %tmp4
+ jmpl %tmp1 + %tmp2, %g0
+ add %tmp4, 0x40, %tmp4
+1: addcc %branchbase, (4f - BranchBaseR), %tmp2
+ sra %tmp1, 1, %tmp1
+ jmpl %tmp1 + %tmp2, %g0
+2: add %dst, 0x40, %tmp1
+ jmpl %branchbase + %tmp3, %g0
+ stda %f16, [%tmp1] ASI_BLK_P
+ ba,pt %xcc, 3f+0x00
+ stda %f30, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x04
+ stda %f28, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x08
+ stda %f26, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x0c
+ stda %f24, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x10
+ stda %f22, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x14
+ stda %f20, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x18
+ stda %f18, [%tmp4 + %tmp5] ASI_PST8_P
+ jmpl %branchbase + %tmp3, %g0
+ stda %f16, [%tmp4 + %tmp5] ASI_PST8_P
+3: std %f28, [%dst + 0x70]
+ std %f26, [%dst + 0x68]
+ std %f24, [%dst + 0x60]
+ std %f22, [%dst + 0x58]
+ std %f20, [%dst + 0x50]
+ std %f18, [%dst + 0x48]
+ std %f16, [%dst + 0x40]
+4: jmpl %branchbase + %tmp3, %g0
+ nop
+
+leftstr:cmp %leftw, 64
+ be,pn %icc, 2f
+ and %leftw, 0x38, %tmp1
+ andcc %leftw, 7, %g0
+ be,pn %icc, 1f
+ neg %tmp1
+ sub %dst, %leftw, %tmp4
+ add %branchbase, (3f - BranchBaseR - 8), %tmp2
+ edge8 %tmp4, %g0, %tmp5
+ andn %tmp4, 7, %tmp4
+ add %mode, %skind, %mode
+ jmpl %tmp2 + %tmp1, %g0
+ add %tmp4, 0x40, %tmp4
+1: add %branchbase, (4f - BranchBaseR), %tmp2
+ sra %tmp1, 1, %tmp1
+ jmpl %tmp2 + %tmp1, %g0
+2: add %mode, %skind, %mode
+ ba,pt %xcc, 4f
+ stda %f16, [%dst] ASI_BLK_P
+ ba,pt %xcc, 3f+0x00
+ stda %f16, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x04
+ stda %f18, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x08
+ stda %f20, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x0c
+ stda %f22, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x10
+ stda %f24, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x14
+ stda %f26, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x18
+ stda %f28, [%tmp4 + %tmp5] ASI_PST8_P
+ ba,pt %xcc, 3f+0x1c
+ stda %f30, [%tmp4 + %tmp5] ASI_PST8_P
+3: std %f18, [%dst + 0x08]
+ std %f20, [%dst + 0x10]
+ std %f22, [%dst + 0x18]
+ std %f24, [%dst + 0x20]
+ std %f26, [%dst + 0x28]
+ std %f28, [%dst + 0x30]
+ std %f30, [%dst + 0x38]
+4: brnz,pn %narrow, rnarrow_cont
+ deccc %srcnotdone
+ blu,pn %ICC, rreturn
+ sub %mode, %dkind, %mode
+ alignaddr %mode, %g0, %g0
+ and %mode, 63, %mode
+ cmp %srcnext, %srcn
+ bne,a,pn %ICC, 6f
+ xor %fregset, 64, %fregset
+ brnz,a,pn %fregset, 5f
+ ldda [%src] ASI_BLK_P, %f32
+ ldda [%src] ASI_BLK_P, %f48
+5: sub %src, 64, %src
+6: add %dst, %dkind, %dst
+ sub %w, %leftw, %tmp1
+ add %srcstart, %skind, %srcstart
+ add %dst, %tmp1, %dst
+ add %rightw, %dkind, %rightw
+ add %dst, 63, %dst
+ sub %rightw, 1, %rightw
+ sub %dkind, %leftw, %leftw
+ and %rightw, 63, %rightw
+ and %leftw, 63, %leftw
+ add %rightw, 1, %rightw
+ mov 64, %tmp1
+ andn %dst, 63, %dst
+ sub %tmp1, %leftw, %leftw
+rroll_wide:
+ add %srcstart, %skind, %srcnext
+ sub %srcstart, %w, %srcend
+ fnop
+ deccc %srcnext
+ sll %mode, 4, %tmp4
+ fnop
+ andn %srcnext, 63, %srcnext
+ andn %srcend, 63, %srcend
+ fnop
+ mov %srcnext, %srcn
+ and %mode, 7, %leftw2
+ fnop
+ andn %tmp4, 127, %tmp4
+ sub %leftw, %leftw2, %leftw2
+ fnop
+ add %tmp4, %fregset, %tmp4
+ subcc %w, %leftw, %curw
+ fnop
+ srl %tmp4, 1, %tmp3
+ sub %tmp1, %mode, %tmp1
+ fnop
+ add %tmp3, (rrepn0 - BranchBaseR), %tmp2
+ cmp %tmp1, %rightw
+ add %tmp4, %tmp3, %tmp4
+ sub %srcnext, 64, %tmp1
+ movgeu %icc, %tmp2, %tmp4
+ cmp %srcnext, %srcend
+ sub %dst, 64, %dst
+ move %ICC, %tmp1, %srcnext
+ jmpl %branchbase + %tmp4, %g0
+ sub %curw, %rightw, %curw
+
+rreturn:return %i7+8
+ wr %g0, 0, %fprs
+
+narrowstr:
+ cmp %rightw, 64
+ add %dst, 0x80, %fregset
+ and %rightw, 0x38, %tmp1
+ sub %fregset, %leftw, %tmp2
+ mov %w, %tmp4
+ andn %tmp2, 7, %fregset
+ be,pn %icc, 2f
+ edge8 %tmp2, %g0, %srcend
+ andcc %rightw, 7, %g0
+ be,pn %icc, 1f
+ neg %tmp1
+ sub %g0, %rightw, %tmp4
+ add %tmp1, (2f - BranchBaseR - 8), %tmp1
+ add %dst, 0x40, %tmp5
+ sub %leftw, 0x41, %tmp2
+ add %tmp5, %rightw, %tmp5
+ edge8l %tmp4, %tmp2, %tmp2
+ and %rightw, 7, %tmp4
+ andn %tmp5, 7, %tmp5
+ jmpl %branchbase + %tmp1, %g0
+ sub %w, %tmp4, %tmp4
+1: addcc %branchbase, (4f - BranchBaseR - 8), %tmp2
+ sll %tmp1, 1, %tmp1
+ jmpl %tmp2 + %tmp1, %g0
+ nop
+ ba,pt %xcc, 3f+0x00
+ stda %f30, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x10
+ stda %f28, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x20
+ stda %f26, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x30
+ stda %f24, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x40
+ stda %f22, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x50
+ stda %f20, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x60
+ stda %f18, [%tmp5 + %tmp2] ASI_PST8_P
+ ba,pt %xcc, 3f+0x70
+ stda %f16, [%tmp5 + %tmp2] ASI_PST8_P
+2: subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x00
+ fnop
+ std %f30, [%dst + 0x78]
+3: subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x10
+ fnop
+ std %f28, [%dst + 0x70]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x20
+ fnop
+ std %f26, [%dst + 0x68]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x30
+ fnop
+ std %f24, [%dst + 0x60]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x40
+ fnop
+ std %f22, [%dst + 0x58]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x50
+ fnop
+ std %f20, [%dst + 0x50]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x60
+ fnop
+ std %f18, [%dst + 0x48]
+ subcc %tmp4, 8, %tmp4
+ bl,pn %icc, 4f+0x70
+ fnop
+ std %f16, [%dst + 0x40]
+ ba,pt %xcc, 5f
+ nop
+4: cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f30, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f28, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f26, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f24, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f22, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f20, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f18, [%fregset + %srcend] ASI_PST8_P
+ ba,a,pt %xcc, 5f
+ cmp %tmp4, -8
+ bg,a,pn %ICC, 5f
+ stda %f16, [%fregset + %srcend] ASI_PST8_P
+5: and %tmp3, 60, %tmp3
+ add %dst, 64, %dst
+ xor %tmp3, 60, %tmp3
+ add %mode, %skind, %mode
+ add %tmp3, 4, %tmp3
+ brz,pn %h, rreturn
+ and %tmp3, 64, %fregset
+rnarrow_cont:
+ deccc %h
+ blu,pn %ICC, rreturn
+ sub %mode, %dkind, %mode
+ alignaddr %mode, %g0, %g0
+ and %mode, 63, %mode
+ sub %srcnext, %srcn, %tmp4
+ add %dst, %dkind, %dst
+ sub %w, %leftw, %tmp1
+ add %srcstart, %skind, %srcstart
+ add %dst, %tmp1, %dst
+ add %rightw, %dkind, %rightw
+ sub %dkind, %leftw, %leftw
+ sub %rightw, 1, %rightw
+ and %leftw, 63, %leftw
+ add %dst, 63, %dst
+ mov 64, %tmp1
+ and %rightw, 63, %rightw
+ sub %tmp1, %leftw, %leftw
+ add %srcstart, %skind, %srcnext
+ add %rightw, 1, %rightw
+ sub %srcstart, %w, %srcend
+ dec %srcnext
+ andn %srcend, 63, %srcend
+ andn %srcnext, 63, %srcnext
+ sub %w, %leftw, %prepw
+ mov %srcnext, %srcn
+ sub %srcnext, 64, %tmp3
+ add %srcnext, 64, %tmp2
+ cmp %skind, 0
+ movg %ICC, %tmp2, %tmp3
+ mov %h, %srcnotdone
+ sub %prepw, %rightw, %prepw
+ sub %srcstart, 1, %tmp1
+ cmp %srcnext, %srcend
+ move %ICC, %tmp3, %srcnext
+ and %tmp1, 63, %tmp1
+ sub %srcnext, 64, %tmp3
+ sub %tmp1, %w, %tmp1
+ cmp %srcnext, %srcend
+ move %ICC, %tmp3, %srcnext
+ mov %prepw, %curw
+ cmp %tmp1, -65
+ movl %ICC, 64, %prepw
+ andn %dst, 63, %dst
+ cmp %srcnext, %srcstop
+ move %ICC, 0, %srcnotdone
+ brnz,a,pn %tmp4, rroll_narrow
+ xor %fregset, 64, %fregset
+ cmp %tmp1, -1
+ bl,pt %ICC, 6f
+ tst %srcnotdone
+ be,a,pn %ICC, rroll_narrow
+ membar SYNC
+ mov %srcnext, %src
+6: brnz,a,pn %fregset, 7f
+ ldda [%src] ASI_BLK_P, %f32
+ ldda [%src] ASI_BLK_P, %f48
+7: subcc %src, 64, %src
+rroll_narrow:
+ fnop
+ sll %mode, 4, %tmp2
+ and %mode, 7, %leftw2
+ fnop
+ andn %tmp2, 127, %tmp2
+ sub %dst, 64, %dst
+ fnop
+ add %tmp2, %fregset, %tmp2
+ subcc %leftw, %leftw2, %leftw2
+ fnop
+ srl %tmp2, 1, %tmp3
+ add %tmp3, (rrepr0 - BranchBaseR), %tmp4
+ fnop
+ add %tmp2, %tmp3, %tmp2
+ cmp %tmp1, -1
+ fnop
+ mov 64, %tmp1
+ movge %icc, %tmp4, %tmp2
+ sub %tmp1, %mode, %tmp1
+ add %tmp3, (rrepn0 - BranchBaseR), %tmp4
+ fnop
+ cmp %tmp1, %rightw
+ movgeu %icc, %tmp4, %tmp2
+ jmpl %branchbase + %tmp2, %g0
+ and %tmp3, 32, %tmp3
+
+#define RVISEND1(i,tgt,tgtr) \
+tgt: \
+ brnz,pt %curw, 1f; \
+ cmp %leftw2, ((i&14)*4); \
+ bg,pn %icc, tgtr - 8; \
+ tst %srcnotdone; \
+ be,a,pn %ICC, tgtr; \
+ membar SYNC; \
+ ba,pt %xcc, tgtr - 8; \
+ mov %srcnext, %src; \
+1: mov ((i & 1) ^ 1) * 64, %fregset;
+
+#define RVISEND2(i,fset) \
+ brz,a,pn %srcnotdone, 3f; \
+ membar SYNC; \
+ ldda [%srcnext] ASI_BLK_P, %fset; \
+ sub %srcnext, 64, %src; \
+3: mov (i & 1) * 64, %fregset;
+
+RVISEND1(0,rvis0e,rvis0r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ ble,pn %icc, leftstr
+ faligndata %ftmp2, %ftmp1, %f30
+RVISEND2(0,f32)
+ fnop
+ faligndata %f48, %f50, %f16
+ faligndata %f50, %f52, %f18
+ faligndata %f52, %f54, %f20
+ faligndata %f54, %f56, %f22
+ faligndata %f56, %f58, %f24
+ faligndata %f58, %f60, %f26
+ faligndata %f60, %f62, %f28
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f30
+RVISEND1(1,rvis1e,rvis1r)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ ble,pn %icc, leftstr
+ faligndata %ftmp2, %ftmp1, %f30
+RVISEND2(1,f48)
+ fnop
+ faligndata %f32, %f34, %f16
+ faligndata %f34, %f36, %f18
+ faligndata %f36, %f38, %f20
+ faligndata %f38, %f40, %f22
+ faligndata %f40, %f42, %f24
+ faligndata %f42, %f44, %f26
+ faligndata %f44, %f46, %f28
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f30
+RVISEND1(2,rvis2e,rvis2r)
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %ftmp2, %ftmp1, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(2,f32)
+ fnop
+ fnop
+ faligndata %f50, %f52, %f16
+ faligndata %f52, %f54, %f18
+ faligndata %f54, %f56, %f20
+ faligndata %f56, %f58, %f22
+ faligndata %f58, %f60, %f24
+ faligndata %f60, %f62, %f26
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f28
+RVISEND1(3,rvis3e,rvis3r)
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %ftmp2, %ftmp1, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(3,f48)
+ fnop
+ fnop
+ faligndata %f34, %f36, %f16
+ faligndata %f36, %f38, %f18
+ faligndata %f38, %f40, %f20
+ faligndata %f40, %f42, %f22
+ faligndata %f42, %f44, %f24
+ faligndata %f44, %f46, %f26
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f28
+RVISEND1(4,rvis4e,rvis4r)
+ fnop
+ fnop
+ faligndata %ftmp2, %ftmp1, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(4,f32)
+ fnop
+ fnop
+ fnop
+ faligndata %f52, %f54, %f16
+ faligndata %f54, %f56, %f18
+ faligndata %f56, %f58, %f20
+ faligndata %f58, %f60, %f22
+ faligndata %f60, %f62, %f24
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f26
+RVISEND1(5,rvis5e,rvis5r)
+ fnop
+ fnop
+ faligndata %ftmp2, %ftmp1, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(5,f48)
+ fnop
+ fnop
+ fnop
+ faligndata %f36, %f38, %f16
+ faligndata %f38, %f40, %f18
+ faligndata %f40, %f42, %f20
+ faligndata %f42, %f44, %f22
+ faligndata %f44, %f46, %f24
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f26
+RVISEND1(6,rvis6e,rvis6r)
+ faligndata %ftmp2, %ftmp1, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(6,f32)
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f54, %f56, %f16
+ faligndata %f56, %f58, %f18
+ faligndata %f58, %f60, %f20
+ faligndata %f60, %f62, %f22
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f24
+RVISEND1(7,rvis7e,rvis7r)
+ faligndata %ftmp2, %ftmp1, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(7,f48)
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f38, %f40, %f16
+ faligndata %f40, %f42, %f18
+ faligndata %f42, %f44, %f20
+ faligndata %f44, %f46, %f22
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f24
+RVISEND1(8,rvis8e,rvis8r)
+ faligndata %ftmp2, %ftmp1, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(8,f32)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f56, %f58, %f16
+ faligndata %f58, %f60, %f18
+ faligndata %f60, %f62, %f20
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f22
+RVISEND1(9,rvis9e,rvis9r)
+ faligndata %ftmp2, %ftmp1, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(9,f48)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f40, %f42, %f16
+ faligndata %f42, %f44, %f18
+ faligndata %f44, %f46, %f20
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f22
+RVISEND1(10,rvis10e,rvis10r)
+ faligndata %ftmp2, %ftmp1, %f20
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(10,f32)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f58, %f60, %f16
+ faligndata %f60, %f62, %f18
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f20
+RVISEND1(11,rvis11e,rvis11r)
+ faligndata %ftmp2, %ftmp1, %f20
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(11,f48)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f42, %f44, %f16
+ faligndata %f44, %f46, %f18
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f20
+RVISEND1(12,rvis12e,rvis12r)
+ faligndata %ftmp2, %ftmp1, %f18
+ fmovd %ftmp3, %f20
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(12,f32)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f60, %f62, %f16
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f18
+RVISEND1(13,rvis13e,rvis13r)
+ faligndata %ftmp2, %ftmp1, %f18
+ fmovd %ftmp3, %f20
+ fmovd %ftmp4, %f22
+ fmovd %ftmp5, %f24
+ fmovd %ftmp6, %f26
+ fmovd %ftmp7, %f28
+ ble,pn %icc, leftstr
+ fmovd %ftmp8, %f30
+RVISEND2(13,f48)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ faligndata %f44, %f46, %f16
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f18
+RVISEND1(14,rvis14e,rvis14r)
+ ble,pn %icc, leftstr
+ faligndata %ftmp2, %ftmp1, %f16
+RVISEND2(14,f32)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ ba,pt %xcc, leftstr
+ faligndata %f62, %ftmp1, %f16
+RVISEND1(15,rvis15e,rvis15r)
+ ble,pn %icc, leftstr
+ faligndata %ftmp2, %ftmp1, %f16
+RVISEND2(15,f48)
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ fnop
+ ba,pt %xcc, leftstr
+ faligndata %f46, %ftmp1, %f16
+
+#define RREPEND(tgt,tgtr) \
+tgt: \
+ brnz,pt %srcnotdone, tgtr - 8; \
+ mov %srcnext, %src; \
+ ba,pt %xcc, tgtr; \
+ membar SYNC;
+
+ .align 16
+RREPEND(rrep0e,rrep0r)
+RREPEND(rrep1e,rrep1r)
+RREPEND(rrep2e,rrep2r)
+RREPEND(rrep3e,rrep3r)
+RREPEND(rrep4e,rrep4r)
+RREPEND(rrep5e,rrep5r)
+RREPEND(rrep6e,rrep6r)
+RREPEND(rrep7e,rrep7r)
+RREPEND(rrep8e,rrep8r)
+RREPEND(rrep9e,rrep9r)
+RREPEND(rrep10e,rrep10r)
+RREPEND(rrep11e,rrep11r)
+RREPEND(rrep12e,rrep12r)
+RREPEND(rrep13e,rrep13r)
+RREPEND(rrep14e,rrep14r)
+RREPEND(rrep15e,rrep15r)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h
new file mode 100644
index 000000000..89efd0c14
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb.h
@@ -0,0 +1,317 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - defines.
+ *
+ * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb.h,v 1.4 2000/06/23 19:29:45 dawes Exp $ */
+
+#ifndef FFB_H
+#define FFB_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "windowstr.h"
+#include "ffb_regs.h"
+#include "xf86sbusBus.h"
+#include "ffb_dac.h"
+#ifdef XF86DRI
+#include "xf86drm.h"
+#include "ffb_drishare.h"
+#endif
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+/* Note: do not mmap FFB_DFB8R_VOFF and following mappings using one mmap together
+ with any previous SFB mapping, otherwise the OS won't be able to use 4M pages
+ for the DFB mappings. -jj */
+#define FFB_SFB8R_VOFF 0x00000000
+#define FFB_SFB8G_VOFF 0x00400000
+#define FFB_SFB8B_VOFF 0x00800000
+#define FFB_SFB8X_VOFF 0x00c00000
+#define FFB_SFB32_VOFF 0x01000000
+#define FFB_SFB64_VOFF 0x02000000
+#define FFB_FBC_REGS_VOFF 0x04000000
+#define FFB_BM_FBC_REGS_VOFF 0x04002000
+#define FFB_DFB8R_VOFF 0x04004000
+#define FFB_DFB8G_VOFF 0x04404000
+#define FFB_DFB8B_VOFF 0x04804000
+#define FFB_DFB8X_VOFF 0x04c04000
+#define FFB_DFB24_VOFF 0x05004000
+#define FFB_DFB32_VOFF 0x06004000
+#define FFB_DFB422A_VOFF 0x07004000 /* DFB 422 mode write to A */
+#define FFB_DFB422AD_VOFF 0x07804000 /* DFB 422 mode with line doubling */
+#define FFB_DFB24B_VOFF 0x08004000 /* DFB 24bit mode write to B */
+#define FFB_DFB422B_VOFF 0x09004000 /* DFB 422 mode write to B */
+#define FFB_DFB422BD_VOFF 0x09804000 /* DFB 422 mode with line doubling */
+#define FFB_SFB16Z_VOFF 0x0a004000 /* 16bit mode Z planes */
+#define FFB_SFB8Z_VOFF 0x0a404000 /* 8bit mode Z planes */
+#define FFB_SFB422_VOFF 0x0ac04000 /* SFB 422 mode write to A/B */
+#define FFB_SFB422D_VOFF 0x0b404000 /* SFB 422 mode with line doubling */
+#define FFB_FBC_KREGS_VOFF 0x0bc04000
+#define FFB_DAC_VOFF 0x0bc06000
+#define FFB_PROM_VOFF 0x0bc08000
+#define FFB_EXP_VOFF 0x0bc18000
+
+#if defined(__GNUC__) && defined(USE_VIS)
+#define FFB_ALIGN64 __attribute__((aligned(8)))
+#else
+#define FFB_ALIGN64
+#endif
+
+typedef struct {
+ unsigned int fg FFB_ALIGN64, bg; /* FG/BG colors for stipple */
+ unsigned int patalign; /* X/Y alignment of bits */
+ unsigned char alu; /* ALU operation */
+ unsigned char inhw; /* Cached in FFB */
+ unsigned char pagable; /* Can be used in a pagefill */
+ unsigned char ph; /* Page buffer height */
+ unsigned int bits[32]; /* The stipple bits themselves */
+} CreatorStippleRec, *CreatorStipplePtr;
+
+typedef struct {
+ int type;
+ unsigned int linepat;
+ CreatorStipplePtr stipple;
+ void (*PolySegment)(DrawablePtr, GCPtr, int, xSegment *);
+ void (*Polylines)(DrawablePtr, GCPtr, int, int, DDXPointPtr);
+} CreatorPrivGCRec, *CreatorPrivGCPtr;
+
+/* WID and framebuffer controls are a property of the
+ * window.
+ */
+typedef struct {
+ CreatorStipplePtr Stipple;
+ unsigned int fbc_base;
+ unsigned int wid;
+} CreatorPrivWinRec, *CreatorPrivWinPtr;
+
+enum ffb_resolution {
+ ffb_res_standard = 0, /* 1280 x 1024 */
+ ffb_res_high, /* 1920 x 1360 */
+ ffb_res_stereo, /* 960 x 580 */
+ ffb_res_portrait /* 1280 x 2048 */
+};
+
+enum ffb_chip_type {
+ ffb1_prototype = 0, /* Early pre-FCS FFB */
+ ffb1_standard, /* First FCS FFB, 100Mhz UPA, 66MHz gclk */
+ ffb1_speedsort, /* Second FCS FFB, 100Mhz UPA, 75MHz gclk */
+ ffb2_prototype, /* Early pre-FCS vertical FFB2 */
+ ffb2_vertical, /* First FCS FFB2/vertical, 100Mhz UPA, 100MHZ gclk,
+ 75(SingleBuffer)/83(DoubleBuffer) MHz fclk */
+ ffb2_vertical_plus, /* Second FCS FFB2/vertical, same timings */
+ ffb2_horizontal, /* First FCS FFB2/horizontal, same timings as FFB2/vert */
+ ffb2_horizontal_plus, /* Second FCS FFB2/horizontal, same timings */
+ afb_m3, /* FCS Elite3D, 3 float chips */
+ afb_m6 /* FCS Elite3D, 6 float chips */
+};
+
+#ifdef XF86DRI
+typedef struct {
+ int index;
+} FFBConfigPrivRec, *FFBConfigPrivPtr;
+#endif
+
+typedef struct {
+ unsigned short fifo_cache;
+ unsigned short rp_active;
+ ffb_fbcPtr regs;
+ unsigned int ppc_cache;
+ unsigned int pmask_cache;
+ unsigned int rop_cache;
+ unsigned int drawop_cache;
+ unsigned int fg_cache;
+ unsigned int bg_cache;
+ unsigned int fontw_cache;
+ unsigned int fontinc_cache;
+ unsigned int fbc_cache;
+ unsigned int wid_cache;
+ enum ffb_chip_type ffb_type;
+ CreatorStipplePtr laststipple;
+ unsigned *fb;
+ unsigned *sfb32;
+ unsigned *sfb8r;
+ unsigned *sfb8x;
+ unsigned *dfb24;
+ unsigned *dfb8r;
+ unsigned *dfb8x;
+
+ /* Slot offset 0x0200000, used to probe board type. */
+ volatile unsigned int *strapping_bits;
+
+ /* Needed for some 3DRAM revisions and ffb1 in hires */
+ unsigned char disable_pagefill;
+
+ /* Needed for FFB2/AFB when in stereo or hires */
+ unsigned char disable_fastfill_ap;
+
+ /* Needed for FFB1 in highres mode */
+ unsigned char disable_vscroll;
+
+ /* Needed on all FFB1 boards. */
+ unsigned char has_brline_bug;
+
+ /* Available on FFB2 and AFB */
+ unsigned char use_blkread_prefetch;
+
+ /* Framebuffer configuration */
+ unsigned char has_double_res;
+ unsigned char has_z_buffer;
+ unsigned char has_double_buffer;
+
+ enum ffb_resolution ffb_res;
+ BoxRec ClippedBoxBuf[64];
+ xRectangle Pf_Fixups[4];
+ short Pf_AlignTab[0x800];
+
+ ffb_dacPtr dac;
+ sbusDevicePtr psdp;
+ Bool HWCursor;
+ Bool NoAccel;
+ CloseScreenProcPtr CloseScreen;
+ xf86CursorInfoPtr CursorInfoRec;
+ unsigned char CursorShiftX, CursorShiftY;
+ unsigned char *CursorData;
+
+ PixmapPtr pix32, pix8;
+
+ void *I2C;
+ struct ffb_dac_info dac_info;
+
+#ifdef XF86DRI
+ void *pDRIInfo;
+ int numVisualConfigs;
+ void *pVisualConfigs;
+ FFBConfigPrivPtr pVisualConfigsPriv;
+ int drmSubFD;
+ Bool dri_enabled;
+ ffb_dri_state_t *pFfbSarea;
+#endif
+} FFBRec, *FFBPtr;
+
+/* Acceleration */
+extern Bool FFBAccelInit(ScreenPtr, FFBPtr);
+extern void CreatorVtChange (ScreenPtr pScreen, int enter);
+
+/* HW cursor support */
+extern Bool FFBHWCursorInit(ScreenPtr);
+
+/* Exported DAC layer routines. */
+extern void FFBDacLoadCursorPos(FFBPtr, int, int);
+extern void FFBDacLoadCursorColor(FFBPtr, int, int);
+extern void FFBDacCursorEnableDisable(FFBPtr, int);
+extern void FFBDacCursorLoadBitmap(FFBPtr, int, int, unsigned int *);
+extern void FFBDacLoadPalette(ScrnInfoPtr, int, int *, LOCO *, VisualPtr);
+extern Bool FFBDacInit(FFBPtr);
+extern void FFBDacFini(FFBPtr);
+extern void FFBDacEnterVT(FFBPtr);
+extern void FFBDacLeaveVT(FFBPtr);
+
+/* Exported WID layer routines. */
+extern void FFBWidPoolInit(FFBPtr);
+extern unsigned int FFBWidAlloc(FFBPtr, int, int, Bool);
+extern void FFBWidFree(FFBPtr, unsigned int);
+extern unsigned int FFBWidUnshare(FFBPtr, unsigned int);
+extern unsigned int FFBWidReshare(FFBPtr, unsigned int);
+extern void FFBWidChangeBuffer(FFBPtr, unsigned int, int);
+extern Bool FFBWidIsShared(FFBPtr pFfb, unsigned int wid);
+
+/* Accelerated double-buffering. */
+extern Bool FFBDbePreInit(ScreenPtr);
+
+#ifdef XF86DRI
+/* DRI support */
+extern Bool FFBDRIScreenInit(ScreenPtr);
+extern Bool FFBDRIFinishScreenInit(ScreenPtr);
+extern void FFBDRICloseScreen(ScreenPtr);
+#endif
+
+/* The fastfill and pagefill buffer sizes change based upon
+ * the resolution.
+ */
+struct fastfill_parms {
+ int fastfill_small_area;
+ int pagefill_small_area;
+
+ int fastfill_height;
+ int fastfill_width;
+ int pagefill_height;
+ int pagefill_width;
+};
+
+extern struct fastfill_parms ffb_fastfill_parms[];
+
+#define FFB_FFPARMS(__fpriv) (ffb_fastfill_parms[(__fpriv)->ffb_res])
+
+extern int CreatorScreenPrivateIndex;
+extern int CreatorGCPrivateIndex;
+extern int CreatorWindowPrivateIndex;
+
+#define GET_FFB_FROM_SCRN(p) ((FFBPtr)((p)->driverPrivate))
+
+#define GET_FFB_FROM_SCREEN(s) \
+((FFBPtr)(s)->devPrivates[CreatorScreenPrivateIndex].ptr)
+
+#define CreatorGetGCPrivate(g) \
+((CreatorPrivGCPtr) (g)->devPrivates [CreatorGCPrivateIndex].ptr)
+
+#define CreatorGetWindowPrivate(w) \
+((CreatorPrivWinPtr) (w)->devPrivates[CreatorWindowPrivateIndex].ptr)
+
+#define CreatorSetWindowPrivate(w,p) \
+((w)->devPrivates[CreatorWindowPrivateIndex].ptr = (pointer) p)
+
+#undef DEBUG_FFB
+
+#ifdef DEBUG_FFB
+
+#include <stdio.h>
+
+extern FILE *FDEBUG_FD;
+
+static __inline__ void FFB_DEBUG_init(void)
+{
+ FDEBUG_FD = fopen("/tmp/FFB.DEBUG", "a");
+}
+#define FDEBUG(__x) \
+do { fprintf __x; \
+ fflush(FDEBUG_FD); \
+} while(0)
+#else
+#define FFB_DEBUG_init() do { } while(0)
+#define FDEBUG(__x) do { } while(0)
+#endif
+
+/* Enable this to get very verbose tracing of the driver onto stderr. */
+#undef TRACE_FFB
+#ifdef TRACE_FFB
+#define FFBLOG(__x) ErrorF __x
+#else
+#define FFBLOG(__x) do { } while(0)
+#endif
+
+#endif /* FFB_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c
new file mode 100644
index 000000000..f65b6dcd5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_accel.c
@@ -0,0 +1,951 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer.
+ *
+ * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999,2000 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb_accel.c,v 1.3 2000/06/23 19:29:45 dawes Exp $ */
+
+#include <asm/types.h>
+#include <math.h>
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "mibstore.h"
+#include "mifillarc.h"
+#include "miwideline.h"
+#include "miline.h"
+#include "fastblt.h"
+#include "mergerop.h"
+#include "migc.h"
+#include "mi.h"
+
+#include "cfb8_32wid.h"
+
+#include "ffb.h"
+#include "ffb_fifo.h"
+#include "ffb_rcache.h"
+#include "ffb_loops.h"
+#include "ffb_regs.h"
+#include "ffb_stip.h"
+#include "ffb_gc.h"
+
+int CreatorScreenPrivateIndex;
+int CreatorGCPrivateIndex;
+int CreatorWindowPrivateIndex;
+int CreatorGeneration;
+
+/* Indexed by ffb resolution enum. */
+struct fastfill_parms ffb_fastfill_parms[] = {
+ /* fsmall, psmall, ffh, ffw, pfh, pfw */
+ { 0x00c0, 0x1400, 0x04, 0x08, 0x10, 0x50 }, /* Standard: 1280 x 1024 */
+ { 0x0140, 0x2800, 0x04, 0x10, 0x10, 0xa0 }, /* High: 1920 x 1360 */
+ { 0x0080, 0x0a00, 0x02, 0x08, 0x08, 0x50 }, /* Stereo: 960 x 580 */
+/*XXX*/ { 0x00c0, 0x0a00, 0x04, 0x08, 0x08, 0x50 }, /* Portrait: 1280 x 2048 XXX */
+};
+
+static Bool
+CreatorCreateWindow (WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ CreatorPrivWinPtr pFfbPrivWin;
+ unsigned int fbc;
+ int depth = (pWin->drawable.depth == 8) ? 8 : 24;
+ int i, visual, visclass;
+
+ if (depth == 8) {
+ if (!cfbCreateWindow (pWin))
+ return FALSE;
+ } else {
+ if (!cfb32CreateWindow (pWin))
+ return FALSE;
+ }
+
+ pFfbPrivWin = xalloc(sizeof(CreatorPrivWinRec));
+ if (!pFfbPrivWin)
+ return FALSE;
+
+ fbc = FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_RB_A;
+ fbc |= FFB_FBC_WE_FORCEON;
+ fbc |= FFB_FBC_SB_BOTH;
+ fbc |= FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF;
+ if (depth == 8)
+ fbc |= (FFB_FBC_RE_MASK | FFB_FBC_GE_OFF | FFB_FBC_BE_OFF);
+ else
+ fbc |= FFB_FBC_RGBE_MASK;
+ fbc |= FFB_FBC_XE_ON;
+ pFfbPrivWin->fbc_base = fbc;
+
+ visual = wVisual(pWin);
+ visclass = 0;
+ for (i = 0; i < pScreen->numVisuals; i++) {
+ if (pScreen->visuals[i].vid == visual) {
+ visclass = pScreen->visuals[i].class;
+ break;
+ }
+ }
+
+ pFfbPrivWin->wid = FFBWidAlloc(pFfb, visclass, wColormap(pWin), TRUE);
+ if (pFfbPrivWin->wid == (unsigned int) -1) {
+ xfree(pFfbPrivWin);
+ return FALSE;
+ }
+ FFBLOG(("CreatorCreateWindow: pWin %p depth %d wid %x fbc_base %x\n",
+ pWin, depth, pFfbPrivWin->wid, pFfbPrivWin->fbc_base));
+
+ pFfbPrivWin->Stipple = NULL;
+ CreatorSetWindowPrivate(pWin, pFfbPrivWin);
+
+ return TRUE;
+}
+
+static Bool
+CreatorDestroyWindow (WindowPtr pWin)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen);
+ CreatorPrivWinPtr pFfbPrivWin;
+ int depth = (pWin->drawable.depth == 8) ? 8 : 24;
+
+ FFBLOG(("CreatorDestroyWindow: pWin %p depth %d\n", pWin, depth));
+ pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ if (pFfbPrivWin->Stipple)
+ xfree(pFfbPrivWin->Stipple);
+ FFBWidFree(pFfb, pFfbPrivWin->wid);
+ xfree(pFfbPrivWin);
+
+ if (depth == 8)
+ return cfbDestroyWindow (pWin);
+ else
+ return cfb32DestroyWindow (pWin);
+}
+
+extern CreatorStipplePtr FFB_tmpStipple;
+
+static int
+CreatorChangeWindowAttributes (WindowPtr pWin, Mask mask)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen);
+ CreatorPrivWinPtr pFfbPrivWin;
+ CreatorStipplePtr stipple;
+ Mask index;
+ WindowPtr pBgWin;
+ register cfbPrivWin *pPrivWin;
+ int width, depth;
+
+ FFBLOG(("CreatorChangeWindowAttributes: WIN(%p) mask(%08x)\n", pWin, mask));
+ pPrivWin = (cfbPrivWin *)(pWin->devPrivates[cfbWindowPrivateIndex].ptr);
+ pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ depth = pWin->drawable.depth;
+
+ /*
+ * When background state changes from ParentRelative and
+ * we had previously rotated the fast border pixmap to match
+ * the parent relative origin, rerotate to match window
+ */
+ if (mask & (CWBackPixmap | CWBackPixel) &&
+ pWin->backgroundState != ParentRelative &&
+ pPrivWin->fastBorder &&
+ (pPrivWin->oldRotate.x != pWin->drawable.x ||
+ pPrivWin->oldRotate.y != pWin->drawable.y)) {
+ if (depth == 8) {
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ } else {
+ cfb32XRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.x - pPrivWin->oldRotate.x);
+ cfb32YRotatePixmap(pPrivWin->pRotatedBorder,
+ pWin->drawable.y - pPrivWin->oldRotate.y);
+ }
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ }
+ while (mask) {
+ index = lowbit(mask);
+ mask &= ~index;
+ switch (index) {
+ case CWBackPixmap:
+ stipple = pFfbPrivWin->Stipple;
+ if (pWin->backgroundState == None ||
+ pWin->backgroundState == ParentRelative) {
+ pPrivWin->fastBackground = FALSE;
+ if (stipple) {
+ xfree (stipple);
+ pFfbPrivWin->Stipple = NULL;
+ }
+ /* Rotate border to match parent origin */
+ if (pWin->backgroundState == ParentRelative &&
+ pPrivWin->pRotatedBorder) {
+ for (pBgWin = pWin->parent;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent);
+ if (depth == 8) {
+ cfbXRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ cfbYRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ } else {
+ cfb32XRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x - pPrivWin->oldRotate.x);
+ cfb32YRotatePixmap(pPrivWin->pRotatedBorder,
+ pBgWin->drawable.y - pPrivWin->oldRotate.y);
+ }
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ }
+ break;
+ }
+ if (!stipple) {
+ if (!FFB_tmpStipple)
+ FFB_tmpStipple = (CreatorStipplePtr)
+ xalloc (sizeof *FFB_tmpStipple);
+ stipple = FFB_tmpStipple;
+ }
+ if (stipple) {
+ int ph = FFB_FFPARMS(pFfb).pagefill_height;
+
+ if (CreatorCheckTile (pWin->background.pixmap, stipple,
+ ((DrawablePtr)pWin)->x & 31,
+ ((DrawablePtr)pWin)->y & 31, ph)) {
+ stipple->alu = GXcopy;
+ pPrivWin->fastBackground = FALSE;
+ if (stipple == FFB_tmpStipple) {
+ pFfbPrivWin->Stipple = stipple;
+ FFB_tmpStipple = 0;
+ }
+ break;
+ }
+ }
+ if ((stipple = pFfbPrivWin->Stipple) != NULL) {
+ xfree (stipple);
+ pFfbPrivWin->Stipple = NULL;
+ }
+ if (((width = (pWin->background.pixmap->drawable.width *
+ pWin->background.pixmap->drawable.bitsPerPixel)) <= 32) &&
+ !(width & (width - 1))) {
+ if (depth == 8) {
+ cfbCopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ } else {
+ cfb32CopyRotatePixmap(pWin->background.pixmap,
+ &pPrivWin->pRotatedBackground,
+ pWin->drawable.x,
+ pWin->drawable.y);
+ }
+ if (pPrivWin->pRotatedBackground) {
+ pPrivWin->fastBackground = TRUE;
+ pPrivWin->oldRotate.x = pWin->drawable.x;
+ pPrivWin->oldRotate.y = pWin->drawable.y;
+ } else
+ pPrivWin->fastBackground = FALSE;
+ break;
+ }
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBackPixel:
+ pPrivWin->fastBackground = FALSE;
+ break;
+
+ case CWBorderPixmap:
+ /* don't bother with accelerator for border tiles (just lazy) */
+ if (((width = (pWin->border.pixmap->drawable.width *
+ pWin->border.pixmap->drawable.bitsPerPixel)) <= 32) &&
+ !(width & (width - 1))) {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent)
+ ;
+ if (depth == 8) {
+ cfbCopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x,
+ pBgWin->drawable.y);
+ } else {
+ cfb32CopyRotatePixmap(pWin->border.pixmap,
+ &pPrivWin->pRotatedBorder,
+ pBgWin->drawable.x,
+ pBgWin->drawable.y);
+ }
+ if (pPrivWin->pRotatedBorder) {
+ pPrivWin->fastBorder = TRUE;
+ pPrivWin->oldRotate.x = pBgWin->drawable.x;
+ pPrivWin->oldRotate.y = pBgWin->drawable.y;
+ } else
+ pPrivWin->fastBorder = FALSE;
+ } else
+ pPrivWin->fastBorder = FALSE;
+ break;
+
+ case CWBorderPixel:
+ pPrivWin->fastBorder = FALSE;
+ break;
+ }
+ }
+ return (TRUE);
+}
+
+static void
+CreatorPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pWin->drawable.pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ register cfbPrivWin *pPrivWin;
+ CreatorPrivWinPtr pFfbPrivWin;
+ CreatorStipplePtr stipple;
+ WindowPtr pBgWin;
+ int depth = pWin->drawable.depth;
+
+ FFBLOG(("CreatorPaintWindow: WIN(%p) what(%d)\n", pWin, what));
+ pPrivWin = cfbGetWindowPrivate(pWin);
+ pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ switch (what) {
+ case PW_BACKGROUND:
+ stipple = pFfbPrivWin->Stipple;
+ switch (pWin->backgroundState) {
+ case None:
+ return;
+ case ParentRelative:
+ do {
+ pWin = pWin->parent;
+ } while (pWin->backgroundState == ParentRelative);
+ (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion, what);
+ return;
+ case BackgroundPixmap:
+ if (stipple) {
+ CreatorFillBoxStipple ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ stipple);
+ return;
+ }
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pPrivWin->fastBackground) {
+ if (depth == 8) {
+ cfbFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBackground);
+ } else {
+ cfb32FillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBackground);
+ }
+ } else {
+ if (depth == 8) {
+ cfbFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixmap,
+ (int) pWin->drawable.x,
+ (int) pWin->drawable.y);
+ } else {
+ cfb32FillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixmap,
+ (int) pWin->drawable.x,
+ (int) pWin->drawable.y);
+ }
+ }
+ return;
+ case BackgroundPixel:
+ CreatorFillBoxSolid ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->background.pixel);
+ return;
+ }
+ break;
+ case PW_BORDER:
+ if (pWin->borderIsPixel) {
+ CreatorFillBoxSolid ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixel);
+ return;
+ }
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pPrivWin->fastBorder) {
+ if (depth == 8) {
+ cfbFillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBorder);
+ } else {
+ cfb32FillBoxTile32 ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pPrivWin->pRotatedBorder);
+ }
+ } else {
+ for (pBgWin = pWin;
+ pBgWin->backgroundState == ParentRelative;
+ pBgWin = pBgWin->parent)
+ ;
+
+ if (depth == 8) {
+ cfbFillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixmap,
+ (int) pBgWin->drawable.x,
+ (int) pBgWin->drawable.y);
+ } else {
+ cfb32FillBoxTileOdd ((DrawablePtr)pWin,
+ (int)REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion),
+ pWin->border.pixmap,
+ (int) pBgWin->drawable.x,
+ (int) pBgWin->drawable.y);
+ }
+ }
+ return;
+ }
+}
+
+static void
+CreatorCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pScreen);
+ DDXPointPtr pptSrc;
+ DDXPointPtr ppt;
+ RegionRec rgnDst;
+ BoxPtr pbox;
+ int dx, dy;
+ int i, nbox;
+ WindowPtr pwinRoot;
+
+ FFBLOG(("CreatorCopyWindow: WIN(%p)\n", pWin));
+
+ REGION_INIT(pScreen, &rgnDst, NullBox, 0);
+
+ 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(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+
+ ppt = pptSrc;
+ for (i = nbox; --i >= 0; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ /* XXX Optimize this later to only gcopy/vcopy the 8bpp+WID plane
+ * XXX when possible. -DaveM
+ */
+
+ pwinRoot = WindowTable[pScreen->myNum];
+
+ if (!pFfb->disable_vscroll && (!dx && dy)) {
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+
+ FFB_ATTR_VSCROLL_WINCOPY(pFfb);
+ CreatorDoVertBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, &rgnDst, pptSrc, ~0L);
+ } else {
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFB_ATTR_SFB_VAR_WINCOPY(pFfb);
+ FFBWait(pFfb, ffb);
+ CreatorDoBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, &rgnDst, pptSrc, ~0L);
+ }
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_UNINIT(pScreen, &rgnDst);
+}
+
+static void
+CreatorSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin)
+{
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int i;
+ PixmapPtr pScrPix;
+
+ FFBLOG(("CreatorSaveAreas: WIN(%p)\n", pWin));
+ i = REGION_NUM_RECTS(prgnSave);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnSave);
+ pPt = pPtsInit;
+ while (--i >= 0) {
+ pPt->x = pBox->x1 + xorg;
+ pPt->y = pBox->y1 + yorg;
+ pPt++;
+ pBox++;
+ }
+
+ if (pWin->drawable.bitsPerPixel == 8)
+ pScrPix = (PixmapPtr) pScreenPriv->pix8;
+ else
+ pScrPix = (PixmapPtr) pScreenPriv->pix32;
+
+ /* SRC is the framebuffer, DST is a pixmap. The SFB_VAR attributes may
+ * seem silly, but they are needed even in this case to handle
+ * double-buffered windows properly.
+ */
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ CreatorDoBitblt((DrawablePtr) pScrPix, (DrawablePtr)pPixmap,
+ GXcopy, prgnSave, pPtsInit, ~0L);
+
+ DEALLOCATE_LOCAL (pPtsInit);
+}
+
+static void
+CreatorRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin)
+{
+ FFBPtr pFfb;
+ ffb_fbcPtr ffb;
+ register DDXPointPtr pPt;
+ DDXPointPtr pPtsInit;
+ register BoxPtr pBox;
+ register int i;
+ ScreenPtr pScreen = pPixmap->drawable.pScreen;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ PixmapPtr pScrPix;
+
+ FFBLOG(("CreatorRestoreAreas: WIN(%p)\n", pWin));
+ i = REGION_NUM_RECTS(prgnRestore);
+ pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
+ if (!pPtsInit)
+ return;
+
+ pBox = REGION_RECTS(prgnRestore);
+ pPt = pPtsInit;
+ while (--i >= 0) {
+ pPt->x = pBox->x1 - xorg;
+ pPt->y = pBox->y1 - yorg;
+ pPt++;
+ pBox++;
+ }
+
+ if (pWin->drawable.bitsPerPixel == 8)
+ pScrPix = (PixmapPtr) pScreenPriv->pix8;
+ else
+ pScrPix = (PixmapPtr) pScreenPriv->pix32;
+
+ pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ ffb = pFfb->regs;
+
+ /* SRC is a pixmap, DST is the framebuffer */
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ CreatorDoBitblt((DrawablePtr)pPixmap, (DrawablePtr) pScrPix,
+ GXcopy, prgnRestore, pPtsInit, ~0L);
+
+ DEALLOCATE_LOCAL (pPtsInit);
+}
+
+static void
+CreatorGetImage(DrawablePtr pDrawable, int sx, int sy, int w, int h, unsigned int format, unsigned long planeMask, char* pdstLine)
+{
+ BoxRec box;
+ DDXPointRec ptSrc;
+ RegionRec rgnDst;
+ ScreenPtr pScreen;
+ PixmapPtr pPixmap;
+
+ FFBLOG(("CreatorGetImage: s[%08x:%08x] wh[%08x:%08x]\n", sx, sy, w, h));
+ if ((w == 0) || (h == 0))
+ return;
+ if (pDrawable->bitsPerPixel == 1) {
+ mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+ return;
+ }
+ pScreen = pDrawable->pScreen;
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!cfbDrawableEnabled (pDrawable))
+ return;
+ if(format == ZPixmap) {
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ /* We have to have the full planemask. */
+ if (pDrawable->type == DRAWABLE_WINDOW) {
+ WindowPtr pWin = (WindowPtr) pDrawable;
+
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ }
+
+ if (pDrawable->bitsPerPixel == 8) {
+ if((planeMask & 0x000000ff) != 0x000000ff) {
+ cfbGetImage(pDrawable, sx, sy, w, h,
+ format, planeMask, pdstLine);
+ return;
+ }
+ } else {
+ if((planeMask & 0x00ffffff) != 0x00ffffff) {
+ cfb32GetImage(pDrawable, sx, sy, w, h,
+ format, planeMask, pdstLine);
+ return;
+ }
+ }
+
+ /* SRC is the framebuffer, DST is a pixmap */
+ if (pDrawable->type == DRAWABLE_WINDOW && w == 1 && h == 1) {
+ /* Benchmarks do this make sure the acceleration hardware
+ * has completed all of it's operations, therefore I feel
+ * it is not cheating to special case this because if
+ * anything it gives the benchmarks more accurate results.
+ */
+ if (pDrawable->bitsPerPixel == 32) {
+ unsigned char *sfb = (unsigned char *)pFfb->sfb32;
+ unsigned int *dstPixel = (unsigned int *)pdstLine;
+ unsigned int tmp;
+
+ tmp = *((unsigned int *)(sfb +
+ ((sy + pDrawable->y) << 13) +
+ ((sx + pDrawable->x) << 2)));
+ *dstPixel = (tmp & 0x00ffffff);
+ } else {
+ unsigned char *sfb = (unsigned char *)pFfb->sfb8r;
+ unsigned char *dstPixel = (unsigned char *)pdstLine;
+
+ *dstPixel = *((unsigned char *)(sfb +
+ ((sy + pDrawable->y) << 11) +
+ ((sx + pDrawable->x) << 0)));
+ }
+ return;
+ }
+ pPixmap = GetScratchPixmapHeader(pScreen, w, h,
+ pDrawable->depth, pDrawable->bitsPerPixel,
+ PixmapBytePad(w,pDrawable->depth), (pointer)pdstLine);
+ if (!pPixmap)
+ return;
+ ptSrc.x = sx + pDrawable->x;
+ ptSrc.y = sy + pDrawable->y;
+ box.x1 = 0;
+ box.y1 = 0;
+ box.x2 = w;
+ box.y2 = h;
+ REGION_INIT(pScreen, &rgnDst, &box, 1);
+ CreatorDoBitblt(pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst,
+ &ptSrc, planeMask);
+ REGION_UNINIT(pScreen, &rgnDst);
+ FreeScratchPixmapHeader(pPixmap);
+ } else
+ miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+}
+
+extern void
+CreatorGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
+ int *pwidth, int nspans, char *pchardstStart);
+
+void
+CreatorVtChange (ScreenPtr pScreen, int enter)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, ffb);
+ pFfb->fifo_cache = -1;
+ pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED |
+ FFB_FBC_RB_A | FFB_FBC_SB_BOTH| FFB_FBC_XE_OFF |
+ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_MASK);
+ pFfb->ppc_cache = (FFB_PPC_FW_DISABLE |
+ FFB_PPC_VCE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST |
+ FFB_PPC_XS_CONST | FFB_PPC_YS_CONST | FFB_PPC_ZS_CONST|
+ FFB_PPC_DCE_DISABLE | FFB_PPC_ABE_DISABLE | FFB_PPC_TBE_OPAQUE);
+
+ pFfb->pmask_cache = ~0;
+ pFfb->rop_cache = FFB_ROP_EDIT_BIT;
+ pFfb->drawop_cache = FFB_DRAWOP_RECTANGLE;
+ pFfb->fg_cache = pFfb->bg_cache = 0;
+ pFfb->fontw_cache = 32;
+ pFfb->fontinc_cache = (1 << 16) | 0;
+ pFfb->laststipple = NULL;
+ FFBFifo(pFfb, 9);
+ ffb->fbc = pFfb->fbc_cache;
+ ffb->ppc = pFfb->ppc_cache;
+ ffb->pmask = pFfb->pmask_cache;
+ ffb->rop = pFfb->rop_cache;
+ ffb->drawop = pFfb->drawop_cache;
+ ffb->fg = pFfb->fg_cache;
+ ffb->bg = pFfb->bg_cache;
+ ffb->fontw = pFfb->fontw_cache;
+ ffb->fontinc = pFfb->fontinc_cache;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, ffb);
+
+ /* Fixup the FBC/PPC caches to deal with actually using
+ * a WID for every ROP.
+ */
+ pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED |
+ FFB_FBC_RB_A | FFB_FBC_SB_BOTH | FFB_FBC_XE_ON |
+ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_ON);
+ pFfb->ppc_cache &= ~FFB_PPC_XS_MASK;
+ pFfb->ppc_cache |= FFB_PPC_XS_WID;
+ pFfb->wid_cache = 0xff;
+ FFBFifo(pFfb, 8);
+ ffb->fbc = pFfb->fbc_cache;
+ ffb->ppc = FFB_PPC_XS_WID;
+ ffb->wid = pFfb->wid_cache;
+ ffb->xpmask = 0xff;
+ ffb->xclip = FFB_XCLIP_TEST_ALWAYS;
+ ffb->cmp = 0x80808080;
+ ffb->matchab = 0x80808080;
+ ffb->magnab = 0x80808080;
+ FFBWait(pFfb, ffb);
+}
+
+/* Multiplies and divides suck... */
+static void CreatorAlignTabInit(FFBPtr pFfb)
+{
+ struct fastfill_parms *ffp = &FFB_FFPARMS(pFfb);
+ short *tab = pFfb->Pf_AlignTab;
+ int i;
+
+ for(i = 0; i < 0x800; i++) {
+ int alignval;
+
+ alignval = (i / ffp->pagefill_width) * ffp->pagefill_width;
+ *tab++ = alignval;
+ }
+}
+
+static Bool
+CreatorPositionWindow(WindowPtr pWin, int x, int y)
+{
+ if (pWin->drawable.bitsPerPixel == 8)
+ return cfbPositionWindow(pWin, x, y);
+ else
+ return cfb32PositionWindow(pWin, x, y);
+}
+
+extern Bool CreatorCreateGC (GCPtr pGC);
+
+#ifdef DEBUG_FFB
+FILE *FDEBUG_FD = NULL;
+#endif
+
+BSFuncRec CreatorBSFuncRec = {
+ CreatorSaveAreas,
+ CreatorRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+Bool FFBAccelInit (ScreenPtr pScreen, FFBPtr pFfb)
+{
+ ffb_fbcPtr ffb;
+
+ if (serverGeneration != CreatorGeneration) {
+ CreatorScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (CreatorScreenPrivateIndex == -1) return FALSE;
+ CreatorGCPrivateIndex = AllocateGCPrivateIndex ();
+ CreatorWindowPrivateIndex = AllocateWindowPrivateIndex ();
+ CreatorGeneration = serverGeneration;
+ }
+
+ if (!AllocateGCPrivate(pScreen, CreatorGCPrivateIndex, sizeof(CreatorPrivGCRec)))
+ return FALSE;
+ if (!AllocateWindowPrivate(pScreen, CreatorWindowPrivateIndex, 0))
+ return FALSE;
+ pScreen->devPrivates[CreatorScreenPrivateIndex].ptr = pFfb;
+
+ pFfb->fifo_cache = 0;
+ ffb = pFfb->regs;
+
+ /* Replace various screen functions. */
+ pScreen->CreateGC = CreatorCreateGC;
+ pScreen->CreateWindow = CreatorCreateWindow;
+ pScreen->DestroyWindow = CreatorDestroyWindow;
+ pScreen->PositionWindow = CreatorPositionWindow;
+ pScreen->ChangeWindowAttributes = CreatorChangeWindowAttributes;
+ pScreen->PaintWindowBackground = CreatorPaintWindow;
+ pScreen->PaintWindowBorder = CreatorPaintWindow;
+ pScreen->GetSpans = CreatorGetSpans;
+ pScreen->CopyWindow = CreatorCopyWindow;
+ pScreen->GetImage = CreatorGetImage;
+ pScreen->BackingStoreFuncs = CreatorBSFuncRec;
+
+ /* cfb8_32wid took over this to init the WID plane,
+ * and with how our code works that is not necessary.
+ */
+ pScreen->WindowExposures = miWindowExposures;
+
+ /* Set FFB line-bias for clipping. */
+ miSetZeroLineBias(pScreen, OCTANT3 | OCTANT4 | OCTANT6 | OCTANT1);
+
+ FFB_DEBUG_init();
+ FDEBUG((FDEBUG_FD,
+ "FFB: cfg0(%08x) cfg1(%08x) cfg2(%08x) cfg3(%08x) ppcfg(%08x)\n",
+ ffb->fbcfg0, ffb->fbcfg1, ffb->fbcfg2, ffb->fbcfg3, ffb->ppcfg));
+
+ /* Determine the current screen resolution type. This is
+ * needed to figure out the fastfill/pagefill parameters.
+ */
+ switch(ffb->fbcfg0 & FFB_FBCFG0_RES_MASK) {
+ default:
+ case FFB_FBCFG0_RES_STD:
+ pFfb->ffb_res = ffb_res_standard;
+ break;
+ case FFB_FBCFG0_RES_HIGH:
+ pFfb->ffb_res = ffb_res_high;
+ break;
+ case FFB_FBCFG0_RES_STEREO:
+ pFfb->ffb_res = ffb_res_stereo;
+ break;
+ case FFB_FBCFG0_RES_PRTRAIT:
+ pFfb->ffb_res = ffb_res_portrait;
+ break;
+ };
+ CreatorAlignTabInit(pFfb);
+
+ /* Next, determine the hwbug workarounds and feature enables
+ * we should be using on this board.
+ */
+ pFfb->disable_pagefill = 0;
+ pFfb->disable_vscroll = 0;
+ pFfb->has_brline_bug = 0;
+ pFfb->use_blkread_prefetch = 0;
+ if (pFfb->ffb_type == ffb1_prototype ||
+ pFfb->ffb_type == ffb1_standard ||
+ pFfb->ffb_type == ffb1_speedsort) {
+ pFfb->has_brline_bug = 1;
+ if (pFfb->ffb_res == ffb_res_high)
+ pFfb->disable_vscroll = 1;
+ if (pFfb->ffb_res == ffb_res_high ||
+ pFfb->ffb_res == ffb_res_stereo)
+ pFfb->disable_pagefill = 1;
+
+ } else {
+ /* FFB2 has blkread prefetch. AFB supposedly does too
+ * but the chip locks up on me when I try to use it. -DaveM
+ */
+#define AFB_PREFETCH_IS_BUGGY 1
+ if (!AFB_PREFETCH_IS_BUGGY ||
+ (pFfb->ffb_type != afb_m3 &&
+ pFfb->ffb_type != afb_m6)) {
+ pFfb->use_blkread_prefetch = 1;
+ }
+ /* XXX I still cannot get page/block fast fills
+ * XXX to work reliably on any of my AFB boards. -DaveM
+ */
+#define AFB_FASTFILL_IS_BUGGY 1
+ if (AFB_FASTFILL_IS_BUGGY &&
+ (pFfb->ffb_type == afb_m3 ||
+ pFfb->ffb_type == afb_m6))
+ pFfb->disable_pagefill = 1;
+ }
+ pFfb->disable_fastfill_ap = 0;
+ if (pFfb->ffb_res == ffb_res_stereo ||
+ pFfb->ffb_res == ffb_res_high)
+ pFfb->disable_fastfill_ap = 1;
+
+ pFfb->ppc_cache = (FFB_PPC_FW_DISABLE |
+ FFB_PPC_VCE_DISABLE | FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST |
+ FFB_PPC_XS_CONST | FFB_PPC_YS_CONST | FFB_PPC_ZS_CONST |
+ FFB_PPC_DCE_DISABLE | FFB_PPC_ABE_DISABLE | FFB_PPC_TBE_OPAQUE);
+
+ pFfb->pmask_cache = ~0;
+ pFfb->rop_cache = (FFB_ROP_ZERO | (FFB_ROP_NEW << 8));
+ pFfb->drawop_cache = FFB_DRAWOP_RECTANGLE;
+ pFfb->fg_cache = pFfb->bg_cache = 0;
+ pFfb->fontw_cache = 32;
+ pFfb->fontinc_cache = (1 << 16) | 0;
+ pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED |
+ FFB_FBC_RB_A | FFB_FBC_SB_BOTH | FFB_FBC_XE_OFF |
+ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_MASK);
+ pFfb->laststipple = NULL;
+
+ /* We will now clear the screen: we'll draw a rectangle covering all the
+ * viewscreen, using a 'blackness' ROP.
+ */
+ FFBFifo(pFfb, 13);
+ ffb->fbc = pFfb->fbc_cache;
+ ffb->ppc = pFfb->ppc_cache;
+ ffb->pmask = pFfb->pmask_cache;
+ ffb->rop = pFfb->rop_cache;
+ ffb->drawop = pFfb->drawop_cache;
+ ffb->fg = pFfb->fg_cache;
+ ffb->bg = pFfb->bg_cache;
+ ffb->fontw = pFfb->fontw_cache;
+ ffb->fontinc = pFfb->fontinc_cache;
+ FFB_WRITE64(&ffb->by, 0, 0);
+ FFB_WRITE64_2(&ffb->bh, pFfb->psdp->height, pFfb->psdp->width);
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, ffb);
+
+ /* Fixup the FBC/PPC caches to deal with actually using
+ * a WID for every ROP.
+ */
+ pFfb->fbc_cache = (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED |
+ FFB_FBC_RB_A | FFB_FBC_SB_BOTH | FFB_FBC_XE_ON |
+ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_ON);
+ pFfb->ppc_cache &= ~FFB_PPC_XS_MASK;
+ pFfb->ppc_cache |= FFB_PPC_XS_WID;
+ pFfb->wid_cache = 0xff;
+ FFBFifo(pFfb, 8);
+ ffb->fbc = pFfb->fbc_cache;
+ ffb->ppc = FFB_PPC_XS_WID;
+ ffb->wid = pFfb->wid_cache;
+ ffb->xpmask = 0xff;
+ ffb->xclip = FFB_XCLIP_TEST_ALWAYS;
+ ffb->cmp = 0x80808080;
+ ffb->matchab = 0x80808080;
+ ffb->magnab = 0x80808080;
+ FFBWait(pFfb, ffb);
+
+ /* Success */
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_asm.s b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_asm.s
new file mode 100644
index 000000000..37ca92e80
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_asm.s
@@ -0,0 +1,349 @@
+/*
+ * ffb_asm.s: Fast Creator raster op inner loops.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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 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/drivers/sunffb/ffb_asm.s,v 1.1 2000/05/18 23:21:35 dawes Exp $ */
+
+/* Hardware register offsets */
+#define FFB_BY 0x0060
+#define FFB_DY 0x0068
+#define FFB_BH 0x0070
+#define FFB_PPC 0x0200
+#define FFB_DRAWOP 0x0300
+#define FFB_UCSR 0x0900
+
+#define FFB_DRAWOP_VSCROLL 0x0b
+
+#define FIFO_CACHE 0x00
+
+#define BOX_X1 0x00
+#define BOX_Y1 0x02
+#define BOX_X2 0x04
+#define BOX_Y2 0x06
+
+#define POINT_X 0x00
+#define POINT_Y 0x02
+
+#define RECT_X 0x00
+#define RECT_Y 0x02
+#define RECT_W 0x04
+#define RECT_H 0x06
+
+#define SEG_X1 0x00
+#define SEG_Y1 0x02
+#define SEG_X2 0x04
+#define SEG_Y2 0x06
+
+ .text
+
+ .align 32
+ .globl FFB_STIPPLE_LOAD
+ /* %o0 = &ffbregs->pattern[0]
+ * %o1 = &stipple->bits[0]
+ */
+FFB_STIPPLE_LOAD:
+ cmp %g0, 0
+1: ldx [%o1 + 0x00], %g1
+ ldx [%o1 + 0x08], %g2
+ ldx [%o1 + 0x10], %g3
+
+ ldx [%o1 + 0x18], %g4
+ add %o0, 0x40, %o0
+ ldx [%o1 + 0x20], %g5
+ ldx [%o1 + 0x28], %o2
+
+ ldx [%o1 + 0x30], %o3
+ ldx [%o1 + 0x38], %o4
+ stx %g1, [%o0 - 0x40]
+ stx %g2, [%o0 - 0x38]
+
+ stx %g3, [%o0 - 0x30]
+ stx %g4, [%o0 - 0x28]
+ add %o1, 0x40, %o1
+ stx %g5, [%o0 - 0x20]
+
+ stx %o2, [%o0 - 0x18]
+ stx %o3, [%o0 - 0x10]
+ stx %o4, [%o0 - 0x08]
+ be,pt %icc, 1b
+
+ cmp %g0, 1
+ retl
+ nop
+
+#define FIFO_WAIT(ffbregs, goal, this_label, done_label) \
+this_label: \
+ lduw [ffbregs + FFB_UCSR], %g1; \
+ and %g1, 0xfff, %g1; \
+ subcc %g1, (4 + goal), %g1; \
+ bge,pt %icc, done_label; \
+ nop; \
+ ba,a,pt %xcc, this_label
+
+ .align 32
+ .globl FFB_PPT_BOX_LOOP
+ /* This is only used (currently) by vscroll, so we put
+ * the creator hwbug workaround in here (writing
+ * the drawop each iteration).
+ *
+ * %o0 = ffbpriv, %o1 = ffbregs,
+ * %o2 = pbox, %o3 = pbox_last, %o4 = ppt
+ */
+FFB_PPT_BOX_LOOP:
+ lduh [%o0 + FIFO_CACHE], %g1 /* Load Group */
+ sethi %hi(FFB_DRAWOP), %g2 /* IEU0 */
+ cmp %o2, %o3 /* IEU1 */
+ bgu,pn %icc, 2f /* CTI */
+
+ or %g2,%lo(FFB_DRAWOP),%g2 /* IEU0 Group */
+1: lduh [%o4 + POINT_X], %g3 /* Load Group */
+ lduh [%o4 + POINT_Y], %g4 /* Load Group */
+ lduh [%o2 + BOX_Y2], %g5 /* Load Group */
+
+ lduh [%o2 + BOX_Y1], %o5 /* Load Group */
+ sllx %g4, 32, %g4 /* IEU0 */
+ or %g3, %g4, %g3 /* IEU0 Group */
+ sub %g5, %o5, %g5 /* IEU1 */
+
+ sllx %o5, 32, %g4 /* IEU0 Group */
+ sllx %g5, 32, %g5 /* IEU0 Group */
+ lduh [%o2 + BOX_X2], %o5 /* Load */
+ add %o4, 0x4, %o4 /* IEU1 */
+
+ lduh [%o2 + BOX_X1], %g7 /* Load Group */
+ add %o2, 0x8, %o2 /* IEU0 */
+ sub %o5, %g7, %o5 /* IEU0 Group */
+ or %g4, %g7, %g4 /* IEU1 */
+
+ or %g5, %o5, %g5 /* IEU0 Group */
+ subcc %g1, 7, %g1 /* IEU1 */
+ bl,pn %icc, FFB_PPT_BOX_WAIT /* CTI */
+9: cmp %o2, %o3 /* IEU1 Group */
+
+ /* This works around BUG ID 1189858 -DaveM */
+ mov FFB_DRAWOP_VSCROLL, %o5 /* IEU0 */
+ stw %o5, [%o1 + %g2] /* STORE */
+ stx %g3, [%o1 + FFB_BY] /* STORE Group */
+ stx %g4, [%o1 + FFB_DY] /* STORE Group */
+
+ bleu,pt %icc, 1b /* CTI */
+ stx %g5, [%o1 + FFB_BH] /* STORE Group */
+2: retl /* CTI Group */
+ sth %g1, [%o0 + FIFO_CACHE] /* STORE */
+
+ FIFO_WAIT(%o1, 7, FFB_PPT_BOX_WAIT, 9b)
+
+ .align 32
+ .globl FFB_BOX_LOOP
+ /* %o0 = ffbpriv, %o1 = ffbregs,
+ * %o2 = pbox, %o3 = pbox_last
+ */
+FFB_BOX_LOOP:
+ lduh [%o0 + FIFO_CACHE], %g1 /* Load Group */
+ cmp %o2, %o3 /* IEU0 */
+ bgu,pn %icc, 2f /* CTI */
+ nop /* IEU0 Group */
+
+1: lduw [%o2 + BOX_X1], %g4 /* Load Group */
+ lduw [%o2 + BOX_X2], %g3 /* Load Group */
+ sllx %g4, 32, %o5 /* IEU0 */
+ srl %g4, 16, %g7 /* IEU0 Group */
+
+ add %o2, 8, %o2 /* IEU1 */
+ sllx %g3, 32, %g5 /* IEU0 Group */
+ subcc %g1, 4, %g1 /* IEU1 */
+ srl %g3, 16, %o4 /* IEU0 Group */
+
+ or %o5, %g7, %o5 /* IEU1 */
+ or %g5, %o4, %g5 /* IEU0 Group */
+ bl,pn %icc, FFB_BOX_WAIT /* CTI */
+ sub %g5, %o5, %g5 /* IEU0 Group */
+
+9: cmp %o2, %o3 /* IEU1 */
+ stx %o5, [%o1 + FFB_BY] /* Store */
+ bleu,pt %icc, 1b /* CTI Group */
+ stx %g5, [%o1 + FFB_BH] /* Store */
+2: retl /* CTI Group */
+ sth %g1, [%o0 + FIFO_CACHE] /* Store */
+
+ FIFO_WAIT(%o1, 4, FFB_BOX_WAIT, 9b)
+
+ .align 32
+ .globl FFB_RECT_LOOP
+ /* %o0 = ffbpriv, %o1 = ffbregs,
+ * %o2 = prect, %o3 = prect_last,
+ * %o4 = xOrg, %o5 = yOrg
+ */
+FFB_RECT_LOOP:
+ lduh [%o0 + FIFO_CACHE], %g1 /* Load Group */
+ sllx %o5, 32, %o5 /* IEU0 */
+ cmp %o2, %o3 /* IEU1 */
+ bgu,pn %icc, 2f /* CTI */
+
+ or %o4, %o5, %o4 /* IEU0 Group */
+1: lduh [%o2 + RECT_X], %g4 /* Load Group */
+ lduh [%o2 + RECT_Y], %o5 /* Load Group */
+ lduh [%o2 + RECT_W], %g3 /* Load Group */
+
+ lduh [%o2 + RECT_H], %g2 /* Load Group */
+ sllx %o5, 32, %g7 /* IEU0 */
+ add %o2, 8, %o2 /* IEU1 */
+ orcc %g7, %g4, %g7 /* IEU1 Group */
+
+ sllx %g2, 32, %g5 /* IEU0 */
+ or %g5, %g3, %g5 /* IEU0 Group */
+ add %g7, %o4, %g7 /* IEU1 */
+ subcc %g1, 4, %g1 /* IEU1 Group */
+
+ bl,pn %icc, FFB_RECT_WAIT /* CTI */
+9: cmp %o2, %o3 /* IEU1 Group */
+ stx %g7, [%o1 + FFB_BY] /* Store */
+ bleu,pt %icc, 1b /* CTI */
+
+ stx %g5, [%o1 + FFB_BH] /* Store Group */
+2: retl /* CTI Group */
+ sth %g1, [%o0 + FIFO_CACHE] /* Store */
+
+ FIFO_WAIT(%o1, 4, FFB_RECT_WAIT, 9b)
+
+ .align 32
+ .globl FFB_PPT_WIDTH_LOOP
+ /* %o0 = ffbpriv, %o1 = ffbregs,
+ * %o2 = ppt, %o3 = ppt_last,
+ * %o4 = pwidth
+ */
+FFB_PPT_WIDTH_LOOP:
+ lduh [%o0 + FIFO_CACHE], %g1 /* Load Group */
+ cmp %o2, %o3 /* IEU1 */
+ bgu,pn %icc, 2f /* CTI */
+ nop
+
+8: lduw [%o2 + POINT_X], %g4 /* Load Group */
+ lduw [%o4], %g2 /* Load Group */
+ sllx %g4, 32, %g7
+1: srl %g4, 16, %g5 /* IEU0 Group */
+
+ add %o2, 4, %o2 /* IEU1 */
+ brz,pn %g2, 8b /* CTI+IEU1 Group */
+ add %o4, 4, %o4 /* IEU0 */
+ or %g5, %g7, %g7 /* IEU0 Group */
+
+ subcc %g1, 5, %g1 /* IEU1 */
+ bl,pn %icc, FFB_PPT_WIDTH_WAIT/* CTI */
+ add %g7, %g2, %o5 /* IEU0 Group */
+9: stw %g0, [%o1 + FFB_PPC] /* Store Group */
+
+ cmp %o2, %o3 /* IEU1 */
+ stx %g7, [%o1 + FFB_BY] /* Store Group */
+ bleu,pt %icc, 8b /* CTI */
+ stx %o5, [%o1 + FFB_BH] /* Store Group */
+
+2: retl /* CTI Group */
+ sth %g1, [%o0 + FIFO_CACHE] /* Store */
+
+ FIFO_WAIT(%o1, 5, FFB_PPT_WIDTH_WAIT, 9b)
+
+ .align 32
+ .globl FFB_LINE_LOOP1
+ /* %o0 = ffbpriv, %o1 = ffbregs,
+ * %o2 = ppt, %o3 = ppt_last,
+ * %o4 = xOrg, %o5 = yOrg
+ *
+ * We return ppt_last + 1.
+ */
+FFB_LINE_LOOP1:
+ lduh [%o0 + FIFO_CACHE], %g1
+ sllx %o5, 32, %o5
+ and %o4, 0x7ff, %o4
+ cmp %o2, %o3
+
+ bgu,pn %icc, 2f
+ or %o4, %o5, %o4
+1: lduw [%o2 + POINT_X], %g4
+ sllx %g4, 32, %g7
+
+ srl %g4, 16, %g3
+ add %o2, 4, %o2
+ or %g7, %g3, %g7
+ subcc %g1, 3, %g1
+
+ bl,pn %icc, FFB_LINE1_WAIT
+ add %g7, %o4, %g7
+9: cmp %o2, %o3
+ stw %g0, [%o1 + FFB_PPC]
+
+ bleu,pt %icc, 1b
+ stx %g7, [%o1 + FFB_BH]
+2: nop
+ sth %g1, [%o0 + FIFO_CACHE]
+
+ retl
+ mov %o2, %o0
+
+ FIFO_WAIT(%o1, 3, FFB_LINE1_WAIT, 9b)
+
+ .align 32
+ .globl FFB_LINE_LOOP2
+ /* %o0 = ffbpriv, %o1 = ffbregs,
+ * %o2 = ppt, %o3 = ppt_last,
+ * %o4 = &xOrg, %o5 = &yOrg
+ *
+ * We return ppt_last + 1.
+ * The only difference between the previous routine
+ * is that here we accumulate the origin values.
+ */
+FFB_LINE_LOOP2:
+ lduw [%o5], %g5
+ lduw [%o4], %g2
+ lduh [%o0 + FIFO_CACHE], %g1
+ sllx %g5, 32, %g5
+
+ and %g2, 0x7ff, %g2
+ cmp %o2, %o3
+ bgu,pn %icc, 2f
+ or %g5, %g2, %g5
+
+1: lduw [%o2 + POINT_X], %g4
+ sllx %g4, 32, %g7
+ srl %g4, 16, %g3
+ add %o2, 4, %o2
+
+ or %g7, %g3, %g7
+ subcc %g1, 3, %g1
+ bl,pn %icc, FFB_LINE2_WAIT
+ add %g7, %g5, %g5
+
+9: cmp %o2, %o3
+ stw %g0, [%o1 + FFB_PPC]
+ bleu,pt %icc, 1b
+ stx %g5, [%o1 + FFB_BH]
+
+2: sth %g1, [%o0 + FIFO_CACHE]
+ srlx %g5, 32, %g4
+ stw %g5, [%o4]
+ stw %g4, [%o5]
+
+ retl
+ mov %o2, %o0
+
+ FIFO_WAIT(%o1, 3, FFB_LINE2_WAIT, 9b)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_attr.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_attr.c
new file mode 100644
index 000000000..c3baf31f3
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_attr.c
@@ -0,0 +1,256 @@
+/*
+ * Attribute setting for the Creator and Creator3D framebuffer.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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 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/drivers/sunffb/ffb_attr.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_fifo.h"
+#include "ffb_rcache.h"
+
+/* If we're going to write any attributes, write them all. */
+void __FFB_Attr_Raw(FFBPtr pFfb, unsigned int ppc, unsigned int ppc_mask,
+ unsigned int pmask, unsigned int rop,
+ int drawop, int fg, unsigned int fbc, unsigned int wid)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBLOG(("WRATTRS_RAW: PPC[%08x:%08x] PMSK[%08x] ROP[%08x] DOP[%08x] FG[%08x] FBC[%08x] WID[%02x]\n",
+ ppc, ppc_mask, pmask, rop, drawop, fg, fbc, wid));
+ pFfb->ppc_cache &= ~ppc_mask;
+ pFfb->ppc_cache |= ppc;
+ pFfb->fg_cache = fg;
+ pFfb->fbc_cache = fbc;
+ pFfb->wid_cache = wid;
+ pFfb->rop_cache = rop;
+ pFfb->pmask_cache = pmask;
+ pFfb->drawop_cache = drawop;
+ pFfb->rp_active = 1;
+ FFBFifo(pFfb, 7);
+ ffb->ppc = ppc;
+ ffb->fg = fg;
+ ffb->fbc = fbc;
+ ffb->wid = wid;
+ ffb->rop = rop;
+ ffb->pmask = pmask;
+ ffb->drawop = drawop;
+}
+
+void __FFB_Attr_SFB_VAR(FFBPtr pFfb, unsigned int ppc, unsigned int ppc_mask, unsigned int fbc,
+ unsigned int wid, unsigned int rop, unsigned int pmask)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBLOG(("WRATTRS_SFBVAR: PPC[%08x:%08x] PMSK[%08x] ROP[%08x] FBC[%08x] WID[%02x]\n",
+ ppc, ppc_mask, pmask, rop, fbc, wid));
+ pFfb->ppc_cache &= ~ppc_mask;
+ pFfb->ppc_cache |= ppc;
+ pFfb->fbc_cache = fbc;
+ pFfb->wid_cache = wid;
+ pFfb->rop_cache = rop;
+ pFfb->pmask_cache = pmask;
+ pFfb->rp_active = 1;
+ FFBFifo(pFfb, 5);
+ ffb->ppc = ppc;
+ ffb->fbc = fbc;
+ ffb->wid = wid;
+ ffb->rop = rop;
+ ffb->pmask = pmask;
+}
+
+#define NEED_PPC 0x00000001
+#define NEED_PMASK 0x00000002
+#define NEED_ROP 0x00000004
+#define NEED_DRAWOP 0x00000008
+#define NEED_FG 0x00000010
+#define NEED_BG 0x00000020
+#define NEED_FBC 0x00000040
+#define NEED_WID 0x00000080
+
+void __FFB_Attr_GC(FFBPtr pFfb, GCPtr pGC, WindowPtr pWin, unsigned int ppc, int drawop)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int rop, need_mask, need_count;
+
+ need_mask = need_count = 0;
+ if ((pFfb->ppc_cache & FFB_PPC_GCMASK) != ppc) {
+ unsigned int newppc = pFfb->ppc_cache & ~FFB_PPC_GCMASK;
+
+ newppc |= (ppc & FFB_PPC_GCMASK);
+ pFfb->ppc_cache = newppc;
+ need_mask |= NEED_PPC;
+ need_count++;
+ }
+
+ if (pFfb->pmask_cache != pGC->planemask) {
+ pFfb->pmask_cache = pGC->planemask;
+ need_mask |= NEED_PMASK;
+ need_count++;
+ }
+
+ rop = (pGC->alu | FFB_ROP_EDIT_BIT)|(FFB_ROP_NEW<<8);
+ if (pFfb->rop_cache != rop) {
+ pFfb->rop_cache = rop;
+ need_mask |= NEED_ROP;
+ need_count++;
+ }
+
+ if (pFfb->drawop_cache != drawop) {
+ pFfb->drawop_cache = drawop;
+ need_mask |= NEED_DRAWOP;
+ need_count++;
+ }
+
+ if (pFfb->fg_cache != pGC->fgPixel) {
+ pFfb->fg_cache = pGC->fgPixel;
+ need_mask |= NEED_FG;
+ need_count++;
+ }
+
+ {
+ CreatorPrivWinPtr WinPriv = CreatorGetWindowPrivate(pWin);
+ unsigned int fbc = WinPriv->fbc_base;
+
+ fbc &= ~FFB_FBC_XE_MASK;
+ fbc |= FFB_FBC_XE_OFF;
+
+ if (pFfb->fbc_cache != fbc) {
+ pFfb->fbc_cache = fbc;
+ need_mask |= NEED_FBC;
+ need_count++;
+ }
+
+ }
+ pFfb->rp_active = 1;
+
+ FFBLOG(("WRATTRS_GC: PPC[%08x:%08x] PMSK[%08x] ROP[%08x] "
+ "DOP[%08x] FG[%08x] FBC[%08x]\n",
+ pFfb->ppc_cache & FFB_PPC_GCMASK, FFB_PPC_GCMASK,
+ pFfb->pmask_cache, pFfb->rop_cache,
+ pFfb->drawop_cache, pFfb->fg_cache, pFfb->fbc_cache));
+
+ FFBFifo(pFfb, need_count);
+ if (need_mask & NEED_PPC)
+ ffb->ppc = (pFfb->ppc_cache & FFB_PPC_GCMASK);
+ if (need_mask & NEED_PMASK)
+ ffb->pmask = pFfb->pmask_cache;
+ if (need_mask & NEED_ROP)
+ ffb->rop = pFfb->rop_cache;
+ if (need_mask & NEED_DRAWOP)
+ ffb->drawop = pFfb->drawop_cache;
+ if (need_mask & NEED_FG)
+ ffb->fg = pFfb->fg_cache;
+ if (need_mask & NEED_FBC)
+ ffb->fbc = pFfb->fbc_cache;
+}
+
+void __FFB_Attr_FastfillWin(FFBPtr pFfb, WindowPtr pWin,
+ unsigned int ppc, unsigned int pixel)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int rop, need_mask, need_count;
+
+ need_mask = need_count = 0;
+ if ((pFfb->ppc_cache & FFB_PPC_WINMASK) != ppc) {
+ unsigned int newppc = pFfb->ppc_cache & ~FFB_PPC_WINMASK;
+
+ newppc |= (ppc & FFB_PPC_WINMASK);
+ pFfb->ppc_cache = newppc;
+ need_mask |= NEED_PPC;
+ need_count++;
+ }
+
+ if (pFfb->pmask_cache != 0x00ffffff) {
+ pFfb->pmask_cache = 0x00ffffff;
+ need_mask |= NEED_PMASK;
+ need_count++;
+ }
+
+ rop = FFB_ROP_NEW | (FFB_ROP_NEW<<8);
+ if (pFfb->rop_cache != rop) {
+ pFfb->rop_cache = rop;
+ need_mask |= NEED_ROP;
+ need_count++;
+ }
+
+ if (pFfb->drawop_cache != FFB_DRAWOP_FASTFILL) {
+ pFfb->drawop_cache = FFB_DRAWOP_FASTFILL;
+ need_mask |= NEED_DRAWOP;
+ need_count++;
+ }
+
+ if (pFfb->fg_cache != pixel) {
+ pFfb->fg_cache = pixel;
+ need_mask |= NEED_FG;
+ need_count++;
+ }
+
+ {
+ CreatorPrivWinPtr pWinPriv = CreatorGetWindowPrivate(pWin);
+ unsigned int fbc = pWinPriv->fbc_base;
+
+ if (pFfb->has_double_buffer) {
+ fbc &= ~FFB_FBC_WB_MASK;
+ fbc |= FFB_FBC_WB_AB;
+ }
+ fbc &= ~(FFB_FBC_XE_MASK | FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_XE_ON | FFB_FBC_RGBE_ON;
+ if (pFfb->ffb_res == ffb_res_high)
+ fbc |= FFB_FBC_WB_B;
+
+ if (pFfb->fbc_cache != fbc) {
+ pFfb->fbc_cache = fbc;
+ need_mask |= NEED_FBC;
+ need_count++;
+ }
+
+ if (pFfb->wid_cache != pWinPriv->wid) {
+ pFfb->wid_cache = pWinPriv->wid;
+ need_mask |= NEED_WID;
+ need_count++;
+ }
+ }
+
+ pFfb->rp_active = 1;
+
+ FFBLOG(("WRATTRS_GC: PPC[%08x:%08x] PMSK[%08x] ROP[%08x] DOP[%08x] FG[%08x] FBC[%08x] WID[%02x]\n",
+ pFfb->ppc_cache & FFB_PPC_WINMASK, FFB_PPC_WINMASK,
+ pFfb->pmask_cache, pFfb->rop_cache,
+ pFfb->drawop_cache, pFfb->fg_cache, pFfb->fbc_cache, pFfb->wid_cache));
+
+ FFBFifo(pFfb, need_count);
+ if (need_mask & NEED_PPC)
+ ffb->ppc = (pFfb->ppc_cache & FFB_PPC_WINMASK);
+ if (need_mask & NEED_PMASK)
+ ffb->pmask = pFfb->pmask_cache;
+ if (need_mask & NEED_ROP)
+ ffb->rop = pFfb->rop_cache;
+ if (need_mask & NEED_DRAWOP)
+ ffb->drawop = pFfb->drawop_cache;
+ if (need_mask & NEED_FG)
+ ffb->fg = pFfb->fg_cache;
+ if (need_mask & NEED_FBC)
+ ffb->fbc = pFfb->fbc_cache;
+ if (need_mask & NEED_WID)
+ ffb->wid = pFfb->wid_cache;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c
new file mode 100644
index 000000000..6de0eac70
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_bcopy.c
@@ -0,0 +1,561 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Bit-blit copies.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_bcopy.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_loops.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "cfb8_32wid.h"
+
+#ifdef FFB_BLOCKCOPY_IMPLEMENTED
+/* Due to VIS based copyarea and ffb rop vertscroll being significantly faster
+ * than the blockcopy rop, blockcopy was not implemented at all in the final
+ * FFB hardware design. This code is left here for hack value. -DaveM
+ */
+#error To use it, we would need to fix this to use WIDs in FFB attributes -DaveM
+void
+CreatorDoHWBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pSrc->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ BoxPtr pboxTmp;
+ DDXPointPtr pptTmp;
+ int nbox;
+ BoxPtr pboxNext, pboxBase, pbox;
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+
+ FFB_WRITE_ATTRIBUTES(pFfb,
+ FFB_PPC_ACE_DISABLE|FFB_PPC_APE_DISABLE|FFB_PPC_CS_CONST,
+ FFB_PPC_ACE_MASK|FFB_PPC_APE_MASK|FFB_PPC_CS_MASK,
+ planemask,
+ FFB_ROP_NEW,
+ FFB_DRAWOP_BCOPY, pFfb->fg_cache,
+ FFB_FBC_DEFAULT);
+
+ /* need to blit rectangles in different orders, depending on the direction of copy
+ so that an area isnt overwritten before it is blitted */
+ if (pptSrc->y < pbox->y1 && nbox > 1) {
+ if (pptSrc->x < pbox->x1) {
+ pboxTmp = pbox + nbox;
+ pptTmp = pptSrc + nbox;
+ while(nbox--) {
+ pboxTmp--;
+ pptTmp--;
+ FFBFifo(pFfb, 6);
+ FFB_WRITE64(&ffb->by, pptTmp->y, pptTmp->x);
+ FFB_WRITE64_2(&ffb->dy, pboxTmp->y1, pboxTmp->x1);
+ FFB_WRITE64_3(&ffb->bh,
+ (pboxTmp->y2 - pboxTmp->y1),
+ (pboxTmp->x2 - pboxTmp->x1));
+ }
+ } else {
+ /* keep ordering in each band, reverse order of bands */
+ pboxBase = pboxNext = pbox+nbox-1;
+
+ while (pboxBase >= pbox) { /* for each band */
+ /* find first box in band */
+ while (pboxNext >= pbox && pboxBase->y1 == pboxNext->y1)
+ pboxNext--;
+
+ pboxTmp = pboxNext + 1; /* first box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* first point in band */
+
+ while (pboxTmp <= pboxBase) { /* for each box in band */
+ FFBFifo(pFfb, 6);
+ FFB_WRITE64(&ffb->by, pptTmp->y, pptTmp->x);
+ FFB_WRITE64_2(&ffb->dy, pboxTmp->y1, pboxTmp->x1);
+ FFB_WRITE64_3(&ffb->bh,
+ (pboxTmp->y2 - pboxTmp->y1),
+ (pboxTmp->x2 - pboxTmp->x1));
+ ++pboxTmp;
+ ++pptTmp;
+ }
+ pboxBase = pboxNext;
+ }
+ }
+ } else {
+ if((pptSrc->x < pbox->x1) && (nbox > 1)) {
+ 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) {
+ --pboxTmp;
+ --pptTmp;
+ FFBFifo(pFfb, 6);
+ FFB_WRITE64(&ffb->by, pptTmp->y, pptTmp->x);
+ FFB_WRITE64_2(&ffb->dy, pboxTmp->y1, pboxTmp->x1);
+ FFB_WRITE64_3(&ffb->bh,
+ (pboxTmp->y2 - pboxTmp->y1),
+ (pboxTmp->x2 - pboxTmp->x1));
+ }
+ pboxBase = pboxNext;
+ }
+ } else {
+ /* dont need to change order of anything */
+ pptTmp = pptSrc;
+ pboxTmp = pbox;
+
+ while (nbox--) {
+ FFBFifo(pFfb, 6);
+ FFB_WRITE64(&ffb->by, pptTmp->y, pptTmp->x);
+ FFB_WRITE64_2(&ffb->dy, pboxTmp->y1, pboxTmp->x1);
+ FFB_WRITE64_3(&ffb->bh,
+ (pboxTmp->y2 - pboxTmp->y1),
+ (pboxTmp->x2 - pboxTmp->x1));
+ pboxTmp++;
+ pptTmp++;
+ }
+ }
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+#endif /* FFB_BLOCKCOPY_IMPLEMENTED */
+
+/* We know here that only y is changing and that the hw attributes
+ * have been set higher up in the call chain.
+ */
+void
+CreatorDoVertBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pSrc->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ BoxPtr pbox;
+ int nbox;
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ /* No garbage please. */
+ if(nbox <= 0)
+ return;
+
+ FFBLOG(("VSCROLL(%d): ", nbox));
+
+ /* Need to blit rectangles in different orders, depending
+ * on the direction of copy so that an area isnt overwritten
+ * before it is blitted.
+ */
+ if (nbox > 1 && pptSrc->y < pbox->y1) {
+ BoxPtr pboxBase = pbox + nbox - 1;
+ BoxPtr pboxNext = pboxBase;
+
+ /* Keep ordering in each band, reverse order of bands. */
+ while (pboxBase >= pbox) { /* for each band */
+ BoxPtr pboxTmp;
+ DDXPointPtr pptTmp;
+
+ /* find first box in band */
+ while (pboxNext >= pbox && pboxBase->y1 == pboxNext->y1)
+ pboxNext--;
+
+ pboxTmp = pboxNext + 1; /* first box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* first point in band */
+ while (pboxTmp <= pboxBase) {
+ FFBLOG(("1[%08x:%08x:%08x:%08x:%08x:%08x] ",
+ pptTmp->x, pptTmp->y, pboxTmp->x1, pboxTmp->y1,
+ pboxTmp->x2, pboxTmp->y2));
+ FFBFifo(pFfb, 7);
+ ffb->drawop = FFB_DRAWOP_VSCROLL;
+ FFB_WRITE64(&ffb->by, pptTmp->y, pptTmp->x);
+ FFB_WRITE64_2(&ffb->dy, pboxTmp->y1, pboxTmp->x1);
+ FFB_WRITE64_3(&ffb->bh, (pboxTmp->y2 - pboxTmp->y1),
+ (pboxTmp->x2 - pboxTmp->x1));
+ pboxTmp++;
+ pptTmp++;
+ }
+ pboxBase = pboxNext;
+ }
+ } else {
+ /* Dont need to change order of anything. */
+ while (nbox--) {
+ FFBLOG(("2[%08x:%08x:%08x:%08x:%08x:%08x] ",
+ pptSrc->x, pptSrc->y, pbox->x1, pbox->y1,
+ pbox->x2, pbox->y2));
+ FFBFifo(pFfb, 7);
+ ffb->drawop = FFB_DRAWOP_VSCROLL;
+ FFB_WRITE64(&ffb->by, pptSrc->y, pptSrc->x);
+ FFB_WRITE64_2(&ffb->dy, pbox->y1, pbox->x1);
+ FFB_WRITE64_3(&ffb->bh, (pbox->y2 - pbox->y1),
+ (pbox->x2 - pbox->x1));
+ pbox++;
+ pptSrc++;
+ }
+ }
+ pFfb->rp_active = 1;
+ FFBLOG(("done\n"));
+ FFBSync(pFfb, ffb);
+}
+
+extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long);
+extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long);
+
+/* The hw attributes have been set by someone higher up in the call
+ * chain.
+ */
+void
+CreatorDoBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDst->pScreen);
+ BoxPtr pboxTmp, pboxNext, pboxBase, pbox;
+ DDXPointPtr pptTmp;
+ unsigned char *psrcBase, *pdstBase;
+ int nbox, widthSrc, widthDst, careful, use_prefetch;
+ int psz_shift;
+
+ cfbGetByteWidthAndPointer (pSrc, widthSrc, psrcBase)
+ cfbGetByteWidthAndPointer (pDst, widthDst, pdstBase)
+
+ careful = ((pSrc == pDst) ||
+ ((pSrc->type == DRAWABLE_WINDOW) &&
+ (pDst->type == DRAWABLE_WINDOW)));
+ use_prefetch = (pFfb->use_blkread_prefetch &&
+ (psrcBase == (unsigned char *)pFfb->sfb32 ||
+ psrcBase == (unsigned char *)pFfb->sfb8r));
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pptTmp = pptSrc;
+ pboxTmp = pbox;
+
+ FFBLOG(("GCOPY(%d): ", nbox));
+
+ if (pSrc->bitsPerPixel == 8)
+ psz_shift = 0;
+ else
+ psz_shift = 2;
+
+ if (careful && pptSrc->y < pbox->y1) {
+ if (pptSrc->x < pbox->x1) {
+ /* reverse order of bands and rects in each band */
+ pboxTmp=pbox+nbox;
+ pptTmp=pptSrc+nbox;
+
+ while (nbox--){
+ pboxTmp--;
+ pptTmp--;
+ FFBLOG(("[%08x:%08x:%08x:%08x:%08x:%08x] ",
+ pptTmp->x, pptTmp->y, pboxTmp->x1, pboxTmp->y1,
+ pboxTmp->x2, pboxTmp->y2));
+ if (pptTmp->x < pbox->x2) {
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_EDRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ VISmoveImageRL ((psrcBase +
+ ((pptTmp->y + pboxTmp->y2 - pboxTmp->y1 - 1) *
+ widthSrc) +
+ (pptTmp->x << psz_shift)),
+ (pdstBase +
+ ((pboxTmp->y2 - 1) * widthDst) +
+ (pboxTmp->x1 << psz_shift)),
+ (pboxTmp->x2 - pboxTmp->x1) << psz_shift,
+ (pboxTmp->y2 - pboxTmp->y1),
+ -widthSrc, -widthDst);
+ } else {
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_EIRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ VISmoveImageLR ((psrcBase +
+ ((pptTmp->y + pboxTmp->y2 - pboxTmp->y1 - 1) *
+ widthSrc) +
+ (pptTmp->x << psz_shift)),
+ (pdstBase +
+ ((pboxTmp->y2 - 1) * widthDst) +
+ (pboxTmp->x1 << psz_shift)),
+ (pboxTmp->x2 - pboxTmp->x1) << psz_shift,
+ (pboxTmp->y2 - pboxTmp->y1),
+ -widthSrc, -widthDst);
+ }
+ }
+ } else {
+ /* keep ordering in each band, reverse order of bands */
+ pboxBase = pboxNext = pbox+nbox-1;
+
+ while (pboxBase >= pbox) { /* for each band */
+
+ /* find first box in band */
+ while (pboxNext >= pbox &&
+ pboxBase->y1 == pboxNext->y1)
+ pboxNext--;
+
+ pboxTmp = pboxNext+1; /* first box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* first point in band */
+
+ FFBLOG(("[%08x:%08x:%08x:%08x:%08x:%08x] ",
+ pptTmp->x, pptTmp->y, pboxTmp->x1, pboxTmp->y1,
+ pboxTmp->x2, pboxTmp->y2));
+ while (pboxTmp <= pboxBase) { /* for each box in band */
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_EIRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ VISmoveImageLR ((psrcBase +
+ ((pptTmp->y + pboxTmp->y2 - pboxTmp->y1 - 1) *
+ widthSrc) +
+ (pptTmp->x << psz_shift)),
+ (pdstBase +
+ ((pboxTmp->y2 - 1) * widthDst) +
+ (pboxTmp->x1 << psz_shift)),
+ (pboxTmp->x2 - pboxTmp->x1) << psz_shift,
+ (pboxTmp->y2 - pboxTmp->y1),
+ -widthSrc, -widthDst);
+ ++pboxTmp;
+ ++pptTmp;
+ }
+ pboxBase = pboxNext;
+
+ }
+ }
+ } else {
+ if (careful && pptSrc->x < pbox->x1) {
+ /* reverse order of rects in each band */
+
+ pboxBase = pboxNext = pbox;
+
+ while (pboxBase < pbox+nbox) { /* for each band */
+
+ /* find last box in band */
+ while (pboxNext < pbox+nbox &&
+ pboxNext->y1 == pboxBase->y1)
+ pboxNext++;
+
+ pboxTmp = pboxNext; /* last box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* last point in band */
+
+ while (pboxTmp != pboxBase) { /* for each box in band */
+ --pboxTmp;
+ --pptTmp;
+ FFBLOG(("[%08x:%08x:%08x:%08x:%08x:%08x] ",
+ pptTmp->x, pptTmp->y, pboxTmp->x1, pboxTmp->y1,
+ pboxTmp->x2, pboxTmp->y2));
+ if (pptTmp->x < pbox->x2) {
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_EDRA;
+ pFfb->regs->mer = FFB_MER_EIRA;
+ pFfb->rp_active = 1;
+ }
+ VISmoveImageRL ((psrcBase +
+ (pptTmp->y * widthSrc) +
+ (pptTmp->x << psz_shift)),
+ (pdstBase +
+ (pboxTmp->y1 * widthDst) +
+ (pboxTmp->x1 << psz_shift)),
+ (pboxTmp->x2 - pboxTmp->x1) << psz_shift,
+ (pboxTmp->y2 - pboxTmp->y1),
+ widthSrc, widthDst);
+ } else {
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_EIRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ VISmoveImageLR ((psrcBase +
+ (pptTmp->y * widthSrc) +
+ (pptTmp->x << psz_shift)),
+ (pdstBase +
+ (pboxTmp->y1 * widthDst) +
+ (pboxTmp->x1 << psz_shift)),
+ (pboxTmp->x2 - pboxTmp->x1) << psz_shift,
+ (pboxTmp->y2 - pboxTmp->y1),
+ widthSrc, widthDst);
+ }
+ }
+ pboxBase = pboxNext;
+ }
+ } else {
+ while (nbox--) {
+ FFBLOG(("[%08x:%08x:%08x:%08x:%08x:%08x] ",
+ pptTmp->x, pptTmp->y, pboxTmp->x1, pboxTmp->y1,
+ pboxTmp->x2, pboxTmp->y2));
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_EIRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ VISmoveImageLR ((psrcBase +
+ (pptTmp->y * widthSrc) +
+ (pptTmp->x << psz_shift)),
+ (pdstBase +
+ (pboxTmp->y1 * widthDst) +
+ (pboxTmp->x1 << psz_shift)),
+ (pboxTmp->x2 - pboxTmp->x1) << psz_shift,
+ (pboxTmp->y2 - pboxTmp->y1),
+ widthSrc, widthDst);
+ pboxTmp++;
+ pptTmp++;
+ }
+ }
+ }
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ pFfb->regs->mer = FFB_MER_DRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ FFBLOG(("done\n"));
+}
+
+RegionPtr
+CreatorCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDstDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ RegionPtr ret;
+ unsigned char *dptr, *sptr, *sfb;
+ int garbage, all_planes;
+
+ cfbGetByteWidthAndPointer (pDstDrawable, garbage, dptr);
+ cfbGetByteWidthAndPointer (pSrcDrawable, garbage, sptr);
+ if (pSrcDrawable->bitsPerPixel == 8) {
+ sfb = (unsigned char *) pFfb->sfb8r;
+ all_planes = 0xff;
+ } else {
+ sfb = (unsigned char *) pFfb->sfb32;
+ all_planes = 0xffffff;
+ }
+
+ FFBLOG(("CreatorCopyArea: SFB(%p) s(%p) d(%p) alu(%x) pmsk(%08x) "
+ "src(%08x:%08x) dst(%08x:%08x)\n",
+ sfb, sptr, dptr, pGC->alu, pGC->planemask,
+ srcx, srcy, dstx, dsty));
+ if (((pGC->planemask & all_planes) != all_planes || pGC->alu != GXcopy) &&
+ dptr != sfb) {
+ if(sptr == sfb) {
+ WindowPtr pWin = (WindowPtr) pSrcDrawable;
+
+ FFB_ATTR_SFB_VAR_WIN(pFfb, pGC->planemask, pGC->alu, pWin);
+ FFBWait(pFfb, ffb);
+ }
+ if (pSrcDrawable->bitsPerPixel == 8)
+ return cfbCopyArea (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ else
+ return cfb32CopyArea (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ }
+
+ /* Try to use hw VSCROLL if possible */
+ if (!pFfb->disable_vscroll && /* must not be ffb1 in hires */
+ pGC->alu == GXcopy && /* it must be a copy */
+ dstx == srcx && /* X must be unchanging */
+ dsty != srcy && /* Y must be changing */
+ sptr == dptr && /* src and dst must be the framebuffer */
+ dptr == sfb) {
+ WindowPtr pWin = (WindowPtr) pSrcDrawable;
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ unsigned int fbc = pFfbPrivWin->fbc_base;
+ int same_buffer;
+
+ /* One last check, the read buffer and the write buffer
+ * must be the same. VSCROLL only allows to move pixels
+ * within the same buffer.
+ */
+ if (!pFfb->has_double_buffer) {
+ same_buffer = 1;
+ } else {
+ same_buffer = 0;
+ if ((((fbc & FFB_FBC_WB_MASK) == FFB_FBC_WB_A) &&
+ ((fbc & FFB_FBC_RB_MASK) == FFB_FBC_RB_A)) ||
+ (((fbc & FFB_FBC_WB_MASK) == FFB_FBC_WB_B) &&
+ ((fbc & FFB_FBC_RB_MASK) == FFB_FBC_RB_B)))
+ same_buffer = 1;
+ }
+
+ if (same_buffer != 0) {
+ FFB_ATTR_VSCROLL_WIN(pFfb, pGC->planemask, pWin);
+ if (pSrcDrawable->bitsPerPixel == 8)
+ ret = cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height,
+ dstx, dsty,
+ (void (*)())CreatorDoVertBitblt, 0);
+ else
+ ret = cfb32BitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height,
+ dstx, dsty,
+ (void (*)())CreatorDoVertBitblt, 0);
+ FFBLOG(("CreatorCopyArea: Done, returning %p\n", ret));
+ return ret;
+ }
+ }
+
+ /* OK, we have to use GCOPY. */
+
+ /* Even when we are only reading from the framebuffer, we must
+ * set the SFB_VAR attributes to handle double-buffering correctly.
+ */
+ if(dptr == sfb || sptr == sfb) {
+ WindowPtr pWin;
+
+ if (dptr == sfb)
+ pWin = (WindowPtr) pDstDrawable;
+ else
+ pWin = (WindowPtr) pSrcDrawable;
+ FFB_ATTR_SFB_VAR_WIN(pFfb, pGC->planemask, pGC->alu, pWin);
+ FFBWait(pFfb, ffb);
+ }
+ if (pSrcDrawable->bitsPerPixel == 8)
+ ret = cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height,
+ dstx, dsty, (void (*)())CreatorDoBitblt, 0);
+ else
+ ret = cfb32BitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height,
+ dstx, dsty, (void (*)())CreatorDoBitblt, 0);
+
+ FFBLOG(("CreatorCopyArea: Done, returning %p\n", ret));
+ return ret;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_checks.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_checks.c
new file mode 100644
index 000000000..d809aa639
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_checks.c
@@ -0,0 +1,288 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - stipple/tile/line-pattern
+ * verification.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_checks.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+int
+CreatorCheckTile (PixmapPtr pPixmap, CreatorStipplePtr stipple, int ox, int oy, int ph)
+{
+ unsigned int *sbits;
+ unsigned int fg = 0, bg = 0;
+ int fgset = 0, bgset = 0;
+ unsigned int *tilebitsLine, *tilebits, tilebit;
+ unsigned int sbit, mask;
+ int nbwidth;
+ int h, w;
+ int x, y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 32 || (h & (h - 1)))
+ return FALSE;
+
+ w = pPixmap->drawable.width;
+ if (w > 32 || (w & (w - 1)))
+ return FALSE;
+
+ stipple->patalign = (oy << 16) | ox;
+ sbits = stipple->bits;
+ tilebitsLine = (unsigned int *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind / sizeof(unsigned int);
+
+ for (y = 0; y < h; y++) {
+ tilebits = tilebitsLine;
+ tilebitsLine += nbwidth;
+ sbit = 0;
+ mask = 1 << 31;
+ for (x = 0; x < w; x++) {
+ tilebit = *tilebits++;
+ if (fgset && tilebit == fg)
+ sbit |= mask;
+ else if (!bgset || tilebit != bg) {
+ if (!fgset) {
+ fgset = 1;
+ fg = tilebit;
+ sbit |= mask;
+ } else if (!bgset) {
+ bgset = 1;
+ bg = tilebit;
+ } else {
+ return FALSE;
+ }
+ }
+ mask >>= 1;
+ }
+ for (s_x = w; s_x < 32; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ sbit = (sbit >> ox) | (sbit << (32 - ox));
+ for (s_y = y; s_y < 32; s_y += h)
+ sbits[(s_y + oy) & 31] = sbit;
+ }
+ stipple->pagable = 1;
+ for(y = 0; y < (32 - ph); y++) {
+ if(sbits[y] != sbits[(y+ph) & (32 - 1)]) {
+ stipple->pagable = 0;
+ break;
+ }
+ }
+ stipple->fg = fg;
+ stipple->bg = bg;
+ stipple->inhw = 0;
+ return TRUE;
+}
+
+int
+CreatorCheckStipple (PixmapPtr pPixmap, CreatorStipplePtr stipple, int ox, int oy, int ph)
+{
+ unsigned int *sbits;
+ unsigned int *stippleBits;
+ unsigned int sbit, mask, nbwidth;
+ int h, w;
+ int y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 32 || (h & (h - 1)))
+ return FALSE;
+
+ w = pPixmap->drawable.width;
+ if (w > 32 || (w & (w - 1)))
+ return FALSE;
+
+ stipple->patalign = (oy << 16) | ox;
+ sbits = stipple->bits;
+ stippleBits = (unsigned int *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind / sizeof(unsigned int);
+ mask = ~0 << (32 - w);
+ for (y = 0; y < h; y++) {
+ sbit = (*stippleBits) & mask;
+ stippleBits += nbwidth;
+ for (s_x = w; s_x < 32; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ sbit = (sbit >> ox) | (sbit << (32 - ox));
+ for (s_y = y; s_y < 32; s_y += h)
+ sbits[(s_y + oy) & 31] = sbit;
+ }
+ stipple->pagable = 1;
+ for(y = 0; y < (32 - ph); y++) {
+ if(sbits[y] != sbits[(y+ph) & (32 - 1)]) {
+ stipple->pagable = 0;
+ break;
+ }
+ }
+ stipple->inhw = 0;
+ return TRUE;
+}
+
+int
+CreatorCheckLinePattern(GCPtr pGC, CreatorPrivGCPtr gcPriv)
+{
+ unsigned int linepat = 0;
+ unsigned char *dashp = (unsigned char *)pGC->dash;
+ int ndash = pGC->numInDashList;
+ int doff = (int) pGC->dashOffset;
+ int smallest_dashlen;
+ int i, nbits = 0;
+
+ for(i = 0; i < ndash; i++)
+ nbits += dashp[i];
+ if(nbits <= 16) {
+ /* We can do it simply, so don't try to use all of
+ * the hair below.
+ */
+ nbits = 0;
+ for(i = 0; i < ndash; i++) {
+ int this_bits = dashp[i];
+ if((i & 1) == 0) {
+ int x;
+
+ for(x = 0; x < this_bits; x++)
+ linepat |= (1<<(nbits + x));
+ }
+ nbits += this_bits;
+ }
+ smallest_dashlen = 1;
+ } else {
+ /* Iteratively find a usable line pattern bitmap and
+ * assosciated scale. This is slow, but it works.
+ * Feel free to come up with something more efficient. -DaveM
+ */
+ smallest_dashlen = 0;
+ while(smallest_dashlen++ < 16) {
+ int bits_so_far = 0;
+
+ for(i = 0; i < ndash; i++) {
+ if((dashp[i] % smallest_dashlen) != 0)
+ break;
+ bits_so_far += dashp[i] / smallest_dashlen;
+ if(bits_so_far >= 16)
+ return FALSE;
+ }
+ if(i == ndash)
+ break;
+ }
+ if(smallest_dashlen == 16)
+ return FALSE;
+
+ /* Compute the final scaled line pattern. */
+ nbits = 0;
+ for(i = 0; i < ndash; i++) {
+ int this_bits = dashp[i] / smallest_dashlen;
+
+ nbits += this_bits;
+ if((i & 1) != 0)
+ continue;
+ while(this_bits--)
+ linepat |= (1<<(nbits - this_bits - 1));
+ }
+ }
+
+ /* We're golden... */
+ linepat = ((linepat << FFB_LPAT_PATTERN_SHIFT) |
+ (smallest_dashlen << FFB_LPAT_SCALEVAL_SHIFT) |
+ ((nbits & 0xf) << FFB_LPAT_PATLEN_SHIFT) |
+ (((doff / smallest_dashlen) & 0xf) << FFB_LPAT_PATPTR_SHIFT) |
+ (((doff % smallest_dashlen) & 0xf) << FFB_LPAT_SCALEPTR_SHIFT));
+ gcPriv->linepat = linepat;
+ return TRUE;
+}
+
+/* cache one stipple; figuring out if we can use the stipple is as hard as
+ * computing it, so we just use this one and leave it here if it
+ * can't be used this time
+ */
+
+CreatorStipplePtr FFB_tmpStipple;
+
+int
+CreatorCheckFill (GCPtr pGC, DrawablePtr pDrawable)
+{
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ CreatorStipplePtr stipple;
+ unsigned int alu;
+ int xrot, yrot, ph = FFB_FFPARMS(pFfb).pagefill_height;
+
+ if (pGC->fillStyle == FillSolid) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return TRUE;
+ }
+ if (!(stipple = gcPriv->stipple)) {
+ if (!FFB_tmpStipple) {
+ FFB_tmpStipple = (CreatorStipplePtr) xalloc (sizeof *FFB_tmpStipple);
+ if (!FFB_tmpStipple)
+ return FALSE;
+ }
+ stipple = FFB_tmpStipple;
+ }
+ xrot = (pGC->patOrg.x + pDrawable->x) & 31;
+ yrot = (pGC->patOrg.y + pDrawable->y) & 31;
+ alu = pGC->alu;
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ if (!CreatorCheckTile (pGC->tile.pixmap, stipple, xrot, yrot, ph)) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ break;
+ case FillStippled:
+ alu |= FFB_ROP_EDIT_BIT;
+ case FillOpaqueStippled:
+ if (!CreatorCheckStipple (pGC->stipple, stipple, xrot, yrot, ph)) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ stipple->fg = pGC->fgPixel;
+ stipple->bg = pGC->bgPixel;
+ break;
+ }
+ stipple->alu = alu;
+ gcPriv->stipple = stipple;
+ if (stipple == FFB_tmpStipple)
+ FFB_tmpStipple = 0;
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_circle.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_circle.c
new file mode 100644
index 000000000..5c46b01ce
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_circle.c
@@ -0,0 +1,210 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Circle rops.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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 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/drivers/sunffb/ffb_circle.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "cfb8_32wid.h"
+
+#include "mi.h"
+#include "mifillarc.h"
+
+/* Wheee, circles... */
+static void
+CreatorFillEllipseSolid(DrawablePtr pDrawable, GCPtr pGC, xArc *arc)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ ffb_fbcPtr ffb = pFfb->regs;
+ miFillArcRec info;
+ int x, y, e, yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+
+ /* Get the RP ready. */
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ FFB_DRAWOP_RECTANGLE);
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+
+ /* Start computing the rects. */
+ miFillArcSetup(arc, &info);
+ MIFILLARCSETUP();
+ if(pGC->miTranslate) {
+ xorg += pDrawable->x;
+ yorg += pDrawable->y;
+ }
+ while(y > 0) {
+ MIFILLARCSTEP(slw);
+ if(slw > 0) {
+ /* Render. */
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, yorg - y, xorg - x);
+ FFB_WRITE64_2(&ffb->bh, 1, slw);
+ if(miFillArcLower(slw)) {
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, yorg + y + dy, xorg - x);
+ FFB_WRITE64_2(&ffb->bh, 1, slw);
+ }
+ }
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+#define ADDSPAN(l,r) \
+ if (r >= l) { \
+ FFBFifo(pFfb, 4); \
+ FFB_WRITE64(&ffb->by, ya, l); \
+ FFB_WRITE64_2(&ffb->bh, 1, r - l + 1); \
+ }
+
+#define ADDSLICESPANS(flip) \
+ if (!flip) \
+ { \
+ ADDSPAN(xl, xr); \
+ } \
+ else \
+ { \
+ xc = xorg - x; \
+ ADDSPAN(xc, xr); \
+ xc += slw - 1; \
+ ADDSPAN(xl, xc); \
+ }
+
+static void
+CreatorFillArcSliceSolid(DrawablePtr pDrawable, GCPtr pGC, xArc *arc)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ ffb_fbcPtr ffb = pFfb->regs;
+ miFillArcRec info;
+ miArcSliceRec slice;
+ int x, y, e, yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+ int ya, xl, xr, xc;
+
+ /* Get the RP ready. */
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ FFB_DRAWOP_RECTANGLE);
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ FFB_WRITE_FBC(pFfb, ffb, FFB_FBC_WIN(pWin));
+ }
+ 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 += pDrawable->x;
+ yorg += pDrawable->y;
+ slice.edge1.x += pDrawable->x;
+ slice.edge2.x += pDrawable->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);
+ }
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+void
+CreatorPolyFillArcSolid (DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
+{
+ RegionPtr cclip;
+ xArc *arc;
+ BoxRec box;
+ int i, x2, y2;
+
+ FFBLOG(("CreatorPolyFillArcSolid: narcs(%d)\n", narcs));
+ cclip = cfbGetCompositeClip(pGC);
+ for(arc = parcs, i = narcs; --i >= 0; arc++) {
+ if(miFillArcEmpty(arc))
+ continue;
+ if(miCanFillArc(arc)) {
+ box.x1 = arc->x + pDrawable->x;
+ box.y1 = arc->y + pDrawable->y;
+ box.x2 = x2 = box.x1 + (int)arc->width + 1;
+ box.y2 = y2 = box.y1 + (int)arc->height + 1;
+ if((x2 & ~0x7ff) == 0 &&
+ (y2 & ~0x7ff) == 0 &&
+ (RECT_IN_REGION(pDrawable->pScreen, cclip, &box) == rgnIN)) {
+ if(arc->angle2 >= FULLCIRCLE ||
+ arc->angle2 <= -FULLCIRCLE)
+ CreatorFillEllipseSolid(pDrawable, pGC, arc);
+ else
+ CreatorFillArcSliceSolid(pDrawable, pGC, arc);
+ continue;
+ }
+ }
+ /* Use slow mi code if we can't handle it simply. */
+ miPolyFillArc(pDrawable, pGC, 1, arc);
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.c
new file mode 100644
index 000000000..2369381c6
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.c
@@ -0,0 +1,103 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - clip setting.
+ *
+ * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_clip.c,v 1.1 2000/05/18 23:21:36 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_clip.h"
+
+unsigned int
+FFBSetClip(FFBPtr pFfb, ffb_fbcPtr ffb, RegionPtr pClip, int numRects)
+{
+ unsigned int xy1, xy2;
+
+ if (numRects == 1) {
+ xy1 = (pClip->extents.y1 << 16) | pClip->extents.x1;
+ xy2 = ((pClip->extents.y2 - 1) << 16) | (pClip->extents.x2 - 1);
+ if (pFfb->clips[0] == xy1 && pFfb->clips[1] == xy2)
+ return FFB_PPC_VCE_2D|FFB_PPC_ACE_DISABLE;
+ FFBFifo(pFfb, 2);
+ FFB_WRITE64(&ffb->vclipmin, xy1, xy2);
+ pFfb->clips[0] = xy1;
+ pFfb->clips[1] = xy2;
+ return FFB_PPC_VCE_2D|FFB_PPC_ACE_DISABLE;
+ } else if (numRects <= 5) {
+ ffb_auxclipPtr auxclip;
+ BoxPtr pBox = REGION_RECTS(pClip);
+ int i, j;
+ unsigned int xy3, xy4;
+
+ xy1 = (pBox->y1 << 16) | pBox->x1;
+ xy2 = ((pBox->y2 - 1) << 16) | (pBox->x2 - 1);
+ if (pFfb->clips[0] == xy1 && pFfb->clips[1] == xy2) {
+ j = 0;
+ for (i = 1; i < numRects; i++) {
+ xy3 = (pBox[i].y1 << 16) | pBox[i].x1;
+ xy4 = ((pBox[i].y2 - 1) << 16) | (pBox[i].x2 - 1);
+ if (j || xy3 != pFfb->clips[2*i] || xy4 != pFfb->clips[2*i+1]) {
+ j = 1;
+ pFfb->clips[2*i] = xy3;
+ pFfb->clips[2*i+1] = xy4;
+ }
+ }
+ for (; i < 5; i++) {
+ if (j || pFfb->clips[2*i] != 1 || pFfb->clips[2*i+1]) {
+ j = 1;
+ pFfb->clips[2*i] = 1;
+ pFfb->clips[2*i+1] = 0;
+ }
+ }
+ if (!j)
+ return FFB_PPC_VCE_2D|FFB_PPC_ACE_AUX_ADD;
+ FFBFifo(pFfb, 8);
+ auxclip = ffb->auxclip;
+ for (i = 1; i < 5; i++, auxclip++)
+ FFB_WRITE64P(&auxclip->min, &pFfb->clips[2*i]);
+ return FFB_PPC_VCE_2D|FFB_PPC_ACE_AUX_ADD;
+ }
+ FFBFifo(pFfb, 10);
+ FFB_WRITE64(&ffb->vclipmin, xy1, xy2);
+ pFfb->clips[0] = xy1;
+ pFfb->clips[1] = xy2;
+ auxclip = ffb->auxclip;
+ pBox++;
+ for (i = 1; i < numRects; i++, auxclip++, pBox++) {
+ xy3 = (pBox->y1 << 16) | pBox->x1;
+ xy4 = ((pBox->y2 - 1) << 16) | (pBox->x2 - 1);
+ FFB_WRITE64(&auxclip->min, xy3, xy4);
+ pFfb->clips[2*i] = xy3;
+ pFfb->clips[2*i+1] = xy4;
+ }
+ for (; i < 5; i++, auxclip++) {
+ FFB_WRITE64(&auxclip->min, 1, 0);
+ pFfb->clips[2*i] = 1;
+ pFfb->clips[2*i+1] = 0;
+ }
+ return FFB_PPC_VCE_2D|FFB_PPC_ACE_AUX_ADD;
+ }
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.h
new file mode 100644
index 000000000..b90655b61
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_clip.h
@@ -0,0 +1,49 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - clipping defines.
+ *
+ * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_clip.h,v 1.1 2000/05/18 23:21:36 dawes Exp $ */
+
+#ifndef FFBCLIP_H
+#define FFBCLIP_H
+
+extern unsigned int FFBSetClip(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ RegionPtr pClip,
+ int numRects);
+static __inline__ void
+FFBSet1Clip(FFBPtr pFfb, ffb_fbcPtr ffb, BoxPtr extents)
+{
+ unsigned int xy1, xy2;
+
+ xy1 = (extents->y1 << 16) | extents->x1;
+ xy2 = ((extents->y2 - 1) << 16) | (extents->x2 - 1);
+ if (pFfb->clips[0] == xy1 && pFfb->clips[1] == xy2)
+ return;
+ FFBFifo(pFfb, 2);
+ FFB_WRITE64(&ffb->vclipmin, xy1, xy2);
+ pFfb->clips[0] = xy1;
+ pFfb->clips[1] = xy2;
+}
+
+#endif /* FFBCLIP_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cplane.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cplane.c
new file mode 100644
index 000000000..a94b37393
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cplane.c
@@ -0,0 +1,393 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Plane copies.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_cplane.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "cfbmskbits.h"
+#include "mi.h"
+
+/* Blatantly stolen from mach64 driver. */
+#define mfbmaskbits(x, w, startmask, endmask, nlw) \
+ startmask = starttab[(x)&0x1f]; \
+ endmask = endtab[((x)+(w)) & 0x1f]; \
+ if (startmask) \
+ nlw = (((w) - (32 - ((x)&0x1f))) >> 5); \
+ else \
+ nlw = (w) >> 5;
+
+#define mfbmaskpartialbits(x, w, mask) \
+ mask = partmasks[(x)&0x1f][(w)&0x1f];
+
+#define LeftMost 0
+#define StepBit(bit, inc) ((bit) += (inc))
+
+
+#define GetBits(psrc, nBits, curBit, bitPos, bits) {\
+ bits = 0; \
+ while (nBits--) { \
+ bits |= ((*psrc++ >> bitPos) & 1) << curBit; \
+ StepBit (curBit, 1); \
+ } \
+}
+
+static void
+CreatorCopyPlane32to1 (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int rop, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask, unsigned long bitPlane)
+{
+ int srcx, srcy, dstx, dsty, width, height;
+ unsigned long *psrcBase;
+ unsigned long *pdstBase;
+ int widthSrc, widthDst;
+ unsigned int *psrcLine;
+ unsigned int *pdstLine;
+ register unsigned int *psrc;
+ register int i;
+ register int curBit;
+ register int bitPos;
+ register unsigned int bits;
+ register unsigned int *pdst;
+ unsigned int startmask, endmask;
+ int niStart = 0, niEnd = 0;
+ int bitStart = 0, bitEnd = 0;
+ int nl, nlMiddle;
+ int nbox;
+ BoxPtr pbox;
+ int result;
+
+ extern int starttab[32], endtab[32];
+ extern unsigned int partmasks[32][32];
+
+ if (!(planemask & 1))
+ return;
+
+ /* must explicitly ask for "int" widths, as code below expects it */
+ /* on some machines (Sparc64), "long" and "int" are not the same size */
+ cfbGetTypedWidthAndPointer (pSrcDrawable, widthSrc, psrcBase, int, unsigned long)
+ cfbGetTypedWidthAndPointer (pDstDrawable, widthDst, pdstBase, int, unsigned long)
+
+ bitPos = ffs (bitPlane) - 1;
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+ while (nbox--) {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ width = pbox->x2 - pbox->x1;
+ height = pbox->y2 - pbox->y1;
+ pbox++;
+ pptSrc++;
+ psrcLine = (unsigned int *)psrcBase + srcy * widthSrc + srcx;
+ pdstLine = (unsigned int *)pdstBase + dsty * widthDst + (dstx >> 5);
+ if (dstx + width <= 32) {
+ mfbmaskpartialbits(dstx, width, startmask);
+ nlMiddle = 0;
+ endmask = 0;
+ } else {
+ mfbmaskbits (dstx, width, startmask, endmask, nlMiddle);
+ }
+ if (startmask) {
+ niStart = 32 - (dstx & 0x1f);
+ bitStart = LeftMost;
+ StepBit (bitStart, (dstx & 0x1f));
+ }
+ if (endmask) {
+ niEnd = (dstx + width) & 0x1f;
+ bitEnd = LeftMost;
+ }
+ if (rop == GXcopy) {
+ while (height--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ if (startmask) {
+ i = niStart;
+ curBit = bitStart;
+ GetBits (psrc, i, curBit, bitPos, bits);
+
+ *pdst = (*pdst & ~startmask) | bits;
+ pdst++;
+ }
+ nl = nlMiddle;
+
+ while (nl--) {
+ i = 32;
+ curBit = LeftMost;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ *pdst++ = bits;
+ }
+ if (endmask) {
+ i = niEnd;
+ curBit = bitEnd;
+ GetBits (psrc, i, curBit, bitPos, bits);
+
+ *pdst = (*pdst & ~endmask) | bits;
+ }
+ }
+ } else {
+ while (height--) {
+ psrc = psrcLine;
+ pdst = pdstLine;
+ psrcLine += widthSrc;
+ pdstLine += widthDst;
+ if (startmask) {
+ i = niStart;
+ curBit = bitStart;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ DoRop (result, rop, bits, *pdst);
+
+ *pdst = (*pdst & ~startmask) | (result & startmask);
+ pdst++;
+ }
+ nl = nlMiddle;
+ while (nl--) {
+ i = 32;
+ curBit = LeftMost;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ DoRop (result, rop, bits, *pdst);
+ *pdst = result;
+ ++pdst;
+ }
+ if (endmask) {
+ i = niEnd;
+ curBit = bitEnd;
+ GetBits (psrc, i, curBit, bitPos, bits);
+ DoRop (result, rop, bits, *pdst);
+
+ *pdst = (*pdst & ~endmask) | (result & endmask);
+ }
+ }
+ }
+ }
+}
+
+static unsigned int copyPlaneFG, copyPlaneBG;
+
+static void
+CreatorCopyPlane1toFbBpp (DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, int alu, RegionPtr prgnDst, DDXPointPtr pptSrc, unsigned long planemask, unsigned long bitPlane)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDstDrawable->pScreen);
+ WindowPtr pWin = (WindowPtr) pDstDrawable;
+ ffb_fbcPtr ffb = pFfb->regs;
+ int srcx, srcy, dstx, dsty, width, height;
+ int xoffSrc, widthSrc;
+ unsigned int *psrcBase, *psrc, *psrcStart;
+ unsigned int w, tmp, i;
+ int nbox;
+ BoxPtr pbox;
+
+ {
+ unsigned int ppc = (FFB_PPC_APE_DISABLE | FFB_PPC_TBE_OPAQUE |
+ FFB_PPC_CS_CONST);
+ unsigned int ppc_mask = (FFB_PPC_APE_MASK | FFB_PPC_TBE_MASK |
+ FFB_PPC_CS_MASK);
+ unsigned int rop = (FFB_ROP_EDIT_BIT | alu) | (FFB_ROP_NEW << 8);
+ unsigned int fbc = FFB_FBC_WIN(pWin);
+
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+
+ if((pFfb->ppc_cache & ppc_mask) != ppc ||
+ pFfb->fg_cache != copyPlaneFG ||
+ pFfb->fbc_cache != fbc ||
+ pFfb->rop_cache != rop ||
+ pFfb->pmask_cache != planemask ||
+ pFfb->bg_cache != copyPlaneBG) {
+ pFfb->ppc_cache &= ~ppc_mask;
+ pFfb->ppc_cache |= ppc;
+ pFfb->fg_cache = copyPlaneFG;
+ pFfb->fbc_cache = fbc;
+ pFfb->rop_cache = rop;
+ pFfb->pmask_cache = planemask;
+ pFfb->bg_cache = copyPlaneBG;
+ pFfb->rp_active = 1;
+ FFBFifo(pFfb, 6);
+ ffb->ppc = ppc;
+ ffb->fg = copyPlaneFG;
+ ffb->fbc = fbc;
+ ffb->rop = rop;
+ ffb->pmask = planemask;
+ ffb->bg = copyPlaneBG;
+ }
+ }
+
+ cfbGetTypedWidthAndPointer (pSrcDrawable, widthSrc, psrcBase, unsigned int, unsigned int)
+
+ nbox = REGION_NUM_RECTS(prgnDst);
+ pbox = REGION_RECTS(prgnDst);
+ while (nbox--) {
+ dstx = pbox->x1;
+ dsty = pbox->y1;
+ srcx = pptSrc->x;
+ srcy = pptSrc->y;
+ width = pbox->x2 - dstx;
+ height = pbox->y2 - dsty;
+ pbox++;
+ pptSrc++;
+ if (!width)
+ continue;
+ psrc = psrcBase + srcy * widthSrc + (srcx >> 5);
+ for (xoffSrc = srcx & 0x1f; height--; psrc = psrcStart + widthSrc) {
+ w = width;
+ psrcStart = psrc;
+ FFBFifo(pFfb, (1 + (xoffSrc != 0)));
+ ffb->fontxy = ((dsty++ << 16) | (dstx & 0xffff));
+ if (xoffSrc) {
+ tmp = 32 - xoffSrc;
+ if (tmp > w)
+ tmp = w;
+ FFB_WRITE_FONTW(pFfb, ffb, tmp);
+ FFB_WRITE_FONTINC(pFfb, ffb, tmp);
+ ffb->font = *psrc++ << xoffSrc;
+ w -= tmp;
+ }
+ if (!w)
+ continue;
+ FFB_WRITE_FONTW(pFfb, ffb, 32);
+ FFB_WRITE_FONTINC(pFfb, ffb, 32);
+ while (w >= 256) {
+ FFBFifo(pFfb, 8);
+ for (i = 0; i < 8; i++)
+ ffb->font = *psrc++;
+ w -= 256;
+ }
+ while (w >= 32) {
+ FFBFifo(pFfb, 1);
+ ffb->font = *psrc++;
+ w -= 32;
+ }
+ if (w) {
+ FFB_WRITE_FONTW(pFfb, ffb, w);
+ FFBFifo(pFfb, 1);
+ ffb->font = *psrc++;
+ }
+ }
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+RegionPtr CreatorCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pSrcDrawable->pScreen);
+ WindowPtr pWin = (WindowPtr) pDstDrawable;
+ ffb_fbcPtr ffb = pFfb->regs;
+ RegionPtr ret;
+
+ FFBLOG(("CreatorCopyPlane: sbpp(%d) dbpp(%d) src[%08x:%08x] dst[%08x:%08x] bplane(%08x)\n",
+ pSrcDrawable->bitsPerPixel, pDstDrawable->bitsPerPixel,
+ srcx, srcy, dstx, dsty, bitPlane));
+ if (pSrcDrawable->bitsPerPixel == 1 &&
+ (pDstDrawable->bitsPerPixel == 32 || pDstDrawable->bitsPerPixel == 8)) {
+ if (bitPlane == 1) {
+ copyPlaneFG = pGC->fgPixel;
+ copyPlaneBG = pGC->bgPixel;
+ ret = cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height,
+ dstx, dsty, CreatorCopyPlane1toFbBpp, bitPlane);
+ } else
+ ret = miHandleExposures (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+ } else if ((pSrcDrawable->bitsPerPixel == 32 || pSrcDrawable->bitsPerPixel == 8)
+ && pDstDrawable->bitsPerPixel == 1) {
+ extern int InverseAlu[16];
+ int oldalu;
+
+ oldalu = pGC->alu;
+ if ((pGC->fgPixel & 1) == 0 && (pGC->bgPixel&1) == 1)
+ pGC->alu = InverseAlu[pGC->alu];
+ else if ((pGC->fgPixel & 1) == (pGC->bgPixel & 1))
+ pGC->alu = mfbReduceRop(pGC->alu, pGC->fgPixel);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pSrcDrawable->bitsPerPixel == 32) {
+ ret = cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ CreatorCopyPlane32to1, bitPlane);
+ } else {
+ ret = cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ cfbCopyPlane8to1, bitPlane);
+ }
+ pGC->alu = oldalu;
+ } else {
+ PixmapPtr pBitmap;
+ ScreenPtr pScreen = pSrcDrawable->pScreen;
+ GCPtr pGC1;
+
+ pBitmap = (*pScreen->CreatePixmap) (pScreen, width, height, 1);
+ if (!pBitmap)
+ return NULL;
+ pGC1 = GetScratchGC (1, pScreen);
+ if (!pGC1) {
+ (*pScreen->DestroyPixmap) (pBitmap);
+ return NULL;
+ }
+ /*
+ * don't need to set pGC->fgPixel,bgPixel as copyPlane{8,32}to1
+ * ignores pixel values, expecting the rop to "do the
+ * right thing", which GXcopy will.
+ */
+ ValidateGC ((DrawablePtr) pBitmap, pGC1);
+ /* no exposures here, scratch GC's don't get graphics expose */
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pSrcDrawable->bitsPerPixel == 32) {
+ cfbBitBlt (pSrcDrawable, (DrawablePtr) pBitmap,
+ pGC1, srcx, srcy, width, height, 0, 0,
+ CreatorCopyPlane32to1, bitPlane);
+ } else {
+ cfbBitBlt (pSrcDrawable, (DrawablePtr) pBitmap,
+ pGC1, srcx, srcy, width, height, 0, 0,
+ cfbCopyPlane8to1, bitPlane);
+ }
+ copyPlaneFG = pGC->fgPixel;
+ copyPlaneBG = pGC->bgPixel;
+ cfbBitBlt ((DrawablePtr) pBitmap, pDstDrawable, pGC,
+ 0, 0, width, height, dstx, dsty, CreatorCopyPlane1toFbBpp, 1);
+ FreeScratchGC (pGC1);
+ (*pScreen->DestroyPixmap) (pBitmap);
+ /* compute resultant exposures */
+ ret = miHandleExposures (pSrcDrawable, pDstDrawable, pGC,
+ srcx, srcy, width, height,
+ dstx, dsty, bitPlane);
+ }
+ return ret;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cursor.c
new file mode 100644
index 000000000..3fc22926b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cursor.c
@@ -0,0 +1,139 @@
+/*
+ * Hardware cursor support for Creator, Creator 3D and Elite 3D
+ *
+ * Copyright 2000 by Jakub Jelinek <jakub@redhat.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 of Jakub
+ * Jelinek not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Jakub Jelinek makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL JAKUB JELINEK 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_cursor.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+
+/* This file just performs cursor software state management. The
+ * actual programming is done by calls into the DAC layer.
+ */
+
+static void FFBLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void FFBShowCursor(ScrnInfoPtr pScrn);
+static void FFBHideCursor(ScrnInfoPtr pScrn);
+static void FFBSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void FFBSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+
+static void
+FFBLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ unsigned int *data = (unsigned int *)src;
+ int x, y;
+
+ pFfb->CursorData = src;
+ x = pFfb->CursorShiftX;
+ y = pFfb->CursorShiftY;
+ if (x >= 64 || y >= 64)
+ y = 64;
+ FFBDacCursorLoadBitmap(pFfb, x, y, data);
+}
+
+static void
+FFBShowCursor(ScrnInfoPtr pScrn)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ FFBDacCursorEnableDisable(pFfb, 1);
+}
+
+static void
+FFBHideCursor(ScrnInfoPtr pScrn)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ FFBDacCursorEnableDisable(pFfb, 0);
+ pFfb->CursorData = NULL;
+}
+
+static void
+FFBSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ int CursorShiftX = 0, CursorShiftY = 0;
+
+ if (x < 0) {
+ CursorShiftX = -x;
+ x = 0;
+ if (CursorShiftX > 64)
+ CursorShiftX = 64;
+ }
+ if (y < 0) {
+ CursorShiftY = -y;
+ y = 0;
+ if (CursorShiftY > 64)
+ CursorShiftY = 64;
+ }
+ if ((CursorShiftX != pFfb->CursorShiftX ||
+ CursorShiftY != pFfb->CursorShiftY) &&
+ pFfb->CursorData != NULL) {
+ pFfb->CursorShiftX = CursorShiftX;
+ pFfb->CursorShiftY = CursorShiftY;
+ FFBLoadCursorImage(pScrn, pFfb->CursorData);
+ }
+
+ FFBDacLoadCursorPos(pFfb, x, y);
+}
+
+static void
+FFBSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ FFBDacLoadCursorColor(pFfb, fg, bg);
+}
+
+Bool
+FFBHWCursorInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ FFBPtr pFfb;
+ xf86CursorInfoPtr infoPtr;
+
+ pFfb = GET_FFB_FROM_SCRN(pScrn);
+ pFfb->CursorShiftX = 0;
+ pFfb->CursorShiftY = 0;
+ pFfb->CursorData = NULL;
+
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ pFfb->CursorInfoRec = infoPtr;
+
+ infoPtr->MaxWidth = 64;
+ infoPtr->MaxHeight = 64;
+ infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+
+ infoPtr->SetCursorColors = FFBSetCursorColors;
+ infoPtr->SetCursorPosition = FFBSetCursorPosition;
+ infoPtr->LoadCursorImage = FFBLoadCursorImage;
+ infoPtr->HideCursor = FFBHideCursor;
+ infoPtr->ShowCursor = FFBShowCursor;
+ infoPtr->UseHWCursor = NULL;
+
+ return xf86InitCursor(pScreen, infoPtr);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.c
new file mode 100644
index 000000000..aded7f96f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.c
@@ -0,0 +1,491 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - DAC programming.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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/drivers/sunffb/ffb_dac.c,v 1.2 2000/06/30 17:15:16 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86DDC.h"
+
+/* Cursor programming */
+
+void
+FFBDacLoadCursorPos(FFBPtr pFfb, int x, int y)
+{
+ ffb_dacPtr dac = pFfb->dac;
+ int posval;
+
+ posval = ((y & 0xffff) << 16) | (x & 0xffff);
+ posval &= (FFBDAC_CUR_POS_Y_SIGN |
+ FFBDAC_CUR_POS_Y |
+ FFBDAC_CUR_POS_X_SIGN |
+ FFBDAC_CUR_POS_X);
+
+ DACCUR_WRITE(dac, FFBDAC_CUR_POS, posval);
+}
+
+void
+FFBDacLoadCursorColor(FFBPtr pFfb, int fg, int bg)
+{
+ ffb_dacPtr dac = pFfb->dac;
+
+ dac->cur = FFBDAC_CUR_COLOR1;
+ dac->curdata = bg;
+ dac->curdata = fg;
+}
+
+void
+FFBDacCursorEnableDisable(FFBPtr pFfb, int enable)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ int val;
+
+ val = 0;
+ if (!enable)
+ val = (FFBDAC_CUR_CTRL_P0 | FFBDAC_CUR_CTRL_P1);
+
+ /* PAC1 ramdacs with manufacturing revision less than
+ * '3' invert these control bits, wheee...
+ */
+ if (p->flags & FFB_DAC_ICURCTL)
+ val ^= (FFBDAC_CUR_CTRL_P0 | FFBDAC_CUR_CTRL_P1);
+
+ DACCUR_WRITE(dac, FFBDAC_CUR_CTRL, val);
+}
+
+void
+FFBDacCursorLoadBitmap(FFBPtr pFfb, int xshift, int yshift, unsigned int *bitmap)
+{
+ ffb_dacPtr dac = pFfb->dac;
+ int i, j;
+
+ dac->cur = FFBDAC_CUR_BITMAP_P0;
+ for (j = 0; j < 2; j++) {
+ bitmap += yshift * 2;
+ if (!xshift) {
+ for (i = yshift * 2; i < 128; i++)
+ dac->curdata = *bitmap++;
+ } else if (xshift < 32) {
+ for (i = yshift; i < 64; i++, bitmap += 2) {
+ dac->curdata = (bitmap[0] << xshift) |
+ (bitmap[1] >> (32 - xshift));
+ dac->curdata = bitmap[1] << xshift;
+ }
+ } else {
+ for (i = yshift; i < 64; i++, bitmap += 2) {
+ dac->curdata = bitmap[1] << (xshift - 32);
+ dac->curdata = 0;
+ }
+ }
+
+ for (i = 0; i < yshift * 2; i++)
+ dac->curdata = 0;
+ }
+}
+
+/* Config space programming */
+
+/* XF86 LoadPalette callback. */
+
+void
+FFBDacLoadPalette(ScrnInfoPtr pScrn, int ncolors, int *indices, LOCO *colors, VisualPtr pVisual)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int *cluts;
+ int i, index, palette;
+
+ if ((pVisual->nplanes != 8 && pVisual->class != DirectColor) ||
+ (pVisual->nplanes == 8 && pVisual->class == StaticGray))
+ return;
+
+ palette = 0;
+ if (p->flags & FFB_DAC_PAC2) {
+ if (pVisual->class == PseudoColor)
+ palette = 0;
+ if (pVisual->class == GrayScale)
+ palette = 1;
+ if (pVisual->class == DirectColor)
+ palette = 2;
+ }
+
+ cluts = &p->x_dac_state.clut[256 * palette];
+ for (i = 0; i < ncolors; i++) {
+ unsigned int regval;
+
+ index = indices[i];
+ if (pVisual->class == GrayScale) {
+ regval = cluts[index] =
+ ((colors[index].red << FFBDAC_COLOR_RED_SHFT) |
+ (colors[index].red << FFBDAC_COLOR_GREEN_SHFT) |
+ (colors[index].red << FFBDAC_COLOR_BLUE_SHFT));
+ } else {
+ regval = cluts[index] =
+ ((colors[index].red << FFBDAC_COLOR_RED_SHFT) |
+ (colors[index].green << FFBDAC_COLOR_GREEN_SHFT) |
+ (colors[index].blue << FFBDAC_COLOR_BLUE_SHFT));
+ }
+
+ FFBLOG(("FFBDacLoadPalette: visclass(%d) index(%d) val[%08x]\n",
+ pVisual->class, index, regval));
+
+ /* Now update the hardware copy. */
+ dac->cfg = FFBDAC_CFG_CLUP(palette) + index;
+ dac->cfgdata = regval;
+ }
+}
+
+/* WARNING: Very dangerous function, use with extreme care. */
+static void
+dac_stop(FFBPtr pFfb)
+{
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int tgctrl;
+
+ tgctrl = DACCFG_READ(dac, FFBDAC_CFG_TGEN);
+ if (tgctrl & FFBDAC_CFG_TGEN_TGE) {
+ long limit = 1000000;
+
+ /* We try to shut off the timing generation
+ * precisely at the beginning of a vertical
+ * retrace. This is really just to make it
+ * look nice, it's not a functional necessity.
+ *
+ * The limit is so that malfunctioning hardware
+ * does not end up hanging the server.
+ */
+ while (limit--) {
+ unsigned int vctr = DACCFG_READ(dac, FFBDAC_CFG_TGVC);
+
+ if (vctr == 0)
+ break;
+ }
+
+ DACCFG_WRITE(dac, FFBDAC_CFG_TGEN, 0);
+ }
+}
+
+/* This is made slightly complex because the ordering matters
+ * between several operations. We have to stop the DAC while
+ * restoring the timing registers so that some intermediate
+ * state does not emit wild retrace signals to the monitor.
+ *
+ * Another further complication is that we need to mess with
+ * some portions of the FFB framebuffer config registers to
+ * do this all properly.
+ */
+static void
+dac_state_restore(FFBPtr pFfb, ffb_dac_hwstate_t *state)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ ffb_fbcPtr ffb = pFfb->regs;
+ int i, nluts;
+
+ /* Step 1: Shut off all pixel timing generation. */
+ dac_stop(pFfb);
+ ffb->fbcfg0 = 0;
+
+ /* Step 2: Restore timing settings. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_VBNP, state->vbnp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_VBAP, state->vbap);
+ DACCFG_WRITE(dac, FFBDAC_CFG_VSNP, state->vsnp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_VSAP, state->vsap);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HSNP, state->hsnp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HBNP, state->hbnp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HBAP, state->hbap);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HSYNCNP, state->hsyncnp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HSYNCAP, state->hsyncap);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HSCENNP, state->hscennp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_HSCENAP, state->hscenap);
+ DACCFG_WRITE(dac, FFBDAC_CFG_EPNP, state->epnp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_EINP, state->einp);
+ DACCFG_WRITE(dac, FFBDAC_CFG_EIAP, state->eiap);
+
+ /* Step 3: Restore rest of DAC hw state. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_PPLLCTRL, state->ppllctrl);
+ DACCFG_WRITE(dac, FFBDAC_CFG_GPLLCTRL, state->gpllctrl);
+ DACCFG_WRITE(dac, FFBDAC_CFG_PFCTRL, state->pfctrl);
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL, state->uctrl);
+
+ nluts = (p->flags & FFB_DAC_PAC1) ? 256 : (4 * 256);
+ dac->cfg = FFBDAC_CFG_CLUP_BASE;
+ for (i = 0; i < nluts; i++)
+ dac->cfgdata = state->clut[i];
+
+ if (p->flags & FFB_DAC_PAC2) {
+ dac->cfg = FFBDAC_PAC2_AOVWLUT0;
+ for (i = 0; i < 4; i++)
+ dac->cfgdata = state->ovluts[i];
+ }
+
+ DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL, state->wtctrl);
+ DACCFG_WRITE(dac, FFBDAC_CFG_TMCTRL, state->tmctrl);
+ DACCFG_WRITE(dac, FFBDAC_CFG_TCOLORKEY, state->tcolorkey);
+ if (p->flags & FFB_DAC_PAC2)
+ DACCFG_WRITE(dac, FFBDAC_CFG_WAMASK, state->wamask);
+
+ if (p->flags & FFB_DAC_PAC1) {
+ dac->cfg = FFBDAC_PAC1_APWLUT_BASE;
+ for (i = 0; i < 32; i++)
+ dac->cfgdata = state->pwluts[i];
+ } else {
+ dac->cfg = FFBDAC_PAC2_APWLUT_BASE;
+ for (i = 0; i < 64; i++)
+ dac->cfgdata = state->pwluts[i];
+ }
+
+ DACCFG_WRITE(dac, FFBDAC_CFG_DACCTRL, state->dacctrl);
+
+ /* Step 4: Restore FFB framebuffer config state. */
+ if (pFfb->ffb_type == ffb2_vertical_plus ||
+ pFfb->ffb_type == ffb2_horizontal_plus ||
+ pFfb->ffb_type == afb_m3 ||
+ pFfb->ffb_type == afb_m6)
+ ffb->passin = p->ffb_passin_ctrl;
+ ffb->fbcfg0 = p->ffbcfg0;
+ ffb->fbcfg2 = p->ffbcfg2;
+
+ /* Step 5: Restore the timing generator control reg. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_TGEN, state->tgen);
+
+ /* Step 6: Pause for a bit. */
+ for (i = 0; i < 100; i++)
+ (void) DACCFG_READ(dac, FFBDAC_CFG_TGVC);
+}
+
+static void
+dac_state_save(FFBPtr pFfb, ffb_dac_hwstate_t *state)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ int i, nluts;
+
+ state->ppllctrl = DACCFG_READ(dac, FFBDAC_CFG_PPLLCTRL);
+ state->gpllctrl = DACCFG_READ(dac, FFBDAC_CFG_GPLLCTRL);
+ state->pfctrl = DACCFG_READ(dac, FFBDAC_CFG_PFCTRL);
+ state->uctrl = DACCFG_READ(dac, FFBDAC_CFG_UCTRL);
+
+ nluts = (p->flags & FFB_DAC_PAC1) ? 256 : (4 * 256);
+ dac->cfg = FFBDAC_CFG_CLUP_BASE;
+ for (i = 0; i < nluts; i++)
+ state->clut[i] = dac->cfgdata;
+
+ if (p->flags & FFB_DAC_PAC2) {
+ dac->cfg = FFBDAC_PAC2_AOVWLUT0;
+ for (i = 0; i < 4; i++)
+ state->ovluts[i] = dac->cfgdata;
+ }
+
+ state->wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
+ state->tmctrl = DACCFG_READ(dac, FFBDAC_CFG_TMCTRL);
+ state->tcolorkey = DACCFG_READ(dac, FFBDAC_CFG_TCOLORKEY);
+ if (p->flags & FFB_DAC_PAC2)
+ state->wamask = DACCFG_READ(dac, FFBDAC_CFG_WAMASK);
+
+ if (p->flags & FFB_DAC_PAC1) {
+ dac->cfg = FFBDAC_PAC1_APWLUT_BASE;
+ for (i = 0; i < 32; i++)
+ state->pwluts[i] = dac->cfgdata;
+ } else {
+ dac->cfg = FFBDAC_PAC2_APWLUT_BASE;
+ for (i = 0; i < 64; i++)
+ state->pwluts[i] = dac->cfgdata;
+ }
+
+ state->dacctrl = DACCFG_READ(dac, FFBDAC_CFG_DACCTRL);
+
+ state->tgen = DACCFG_READ(dac, FFBDAC_CFG_TGEN);
+ state->vbnp = DACCFG_READ(dac, FFBDAC_CFG_VBNP);
+ state->vbap = DACCFG_READ(dac, FFBDAC_CFG_VBAP);
+ state->vsnp = DACCFG_READ(dac, FFBDAC_CFG_VSNP);
+ state->vsap = DACCFG_READ(dac, FFBDAC_CFG_VSAP);
+ state->hsnp = DACCFG_READ(dac, FFBDAC_CFG_HSNP);
+ state->hbnp = DACCFG_READ(dac, FFBDAC_CFG_HBNP);
+ state->hbap = DACCFG_READ(dac, FFBDAC_CFG_HBAP);
+ state->hsyncnp = DACCFG_READ(dac, FFBDAC_CFG_HSYNCNP);
+ state->hsyncap = DACCFG_READ(dac, FFBDAC_CFG_HSYNCAP);
+ state->hscennp = DACCFG_READ(dac, FFBDAC_CFG_HSCENNP);
+ state->hscenap = DACCFG_READ(dac, FFBDAC_CFG_HSCENAP);
+ state->epnp = DACCFG_READ(dac, FFBDAC_CFG_EPNP);
+ state->einp = DACCFG_READ(dac, FFBDAC_CFG_EINP);
+ state->eiap = DACCFG_READ(dac, FFBDAC_CFG_EIAP);
+}
+
+static void
+init_dac_flags(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int did, manuf_rev, partnum;
+ char *device;
+
+ /* For AFB, assume it is PAC2 which also implies not having
+ * the inverted cursor control attribute.
+ */
+ if (pFfb->ffb_type == afb_m3 || pFfb->ffb_type == afb_m6) {
+ p->flags = FFB_DAC_PAC2;
+ manuf_rev = 4;
+ } else {
+ p->flags = 0;
+
+ did = DACCFG_READ(dac, FFBDAC_CFG_DID);
+
+ manuf_rev = DACCFG_READ(dac, FFBDAC_CFG_UCTRL);
+ manuf_rev = (manuf_rev & FFBDAC_UCTRL_MANREV) >> 8;
+
+ partnum = ((did & FFBDAC_CFG_DID_PNUM) >> 12);
+ if (partnum == 0x236e)
+ p->flags |= FFB_DAC_PAC2;
+ else
+ p->flags |= FFB_DAC_PAC1;
+ }
+
+ device = pFfb->psdp->device;
+ if ((p->flags & FFB_DAC_PAC1) != 0) {
+ if (manuf_rev < 3) {
+ p->flags |= FFB_DAC_ICURCTL;
+ xf86Msg(X_INFO, "%s: BT9068 (PAC1) ramdac detected (with "
+ "inverted cursor control)\n", device);
+ } else {
+ xf86Msg(X_INFO, "%s: BT9068 (PAC1) ramdac detected (with "
+ "normal cursor control)\n", device);
+ }
+ } else {
+ xf86Msg(X_INFO, "%s: BT498 (PAC2) ramdac detected\n", device);
+ }
+}
+
+/* The registers of the chip must be mapped, and the FFB/AFB
+ * board type must be probed before this is invoked.
+ */
+Bool
+FFBDacInit(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ init_dac_flags(pFfb);
+
+ p->ffbcfg0 = ffb->fbcfg0;
+ p->ffbcfg2 = ffb->fbcfg2;
+ if (pFfb->ffb_type == ffb2_vertical_plus ||
+ pFfb->ffb_type == ffb2_horizontal_plus ||
+ pFfb->ffb_type == afb_m3 ||
+ pFfb->ffb_type == afb_m6)
+ p->ffb_passin_ctrl = ffb->passin;
+
+ /* Save the kernel DAC state. We also save to the
+ * X server state here as well even though we have
+ * not modified anything yet.
+ */
+ dac_state_save(pFfb, &p->kern_dac_state);
+ dac_state_save(pFfb, &p->x_dac_state);
+
+ /* Fire up the WID layer. */
+ FFBWidPoolInit(pFfb);
+
+ return TRUE;
+}
+
+/* We need to reset the A buffer X planes to the value 0xff
+ * when giving the hardware back to the kernel too, thus...
+ * Also need to do this for the B buffer X planes when double
+ * buffering is available.
+ */
+static void
+restore_kernel_xchannel(FFBPtr pFfb)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int fbc, ppc, ppc_mask, drawop;
+
+ if (pFfb->has_double_buffer)
+ fbc = FFB_FBC_WB_AB;
+ else
+ fbc = FFB_FBC_WB_A;
+
+ fbc |= (FFB_FBC_WM_COMBINED | FFB_FBC_RB_A | FFB_FBC_SB_BOTH |
+ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF |
+ FFB_FBC_XE_ON | FFB_FBC_RGBE_MASK);
+
+ ppc = (FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | FFB_PPC_XS_WID);
+ ppc_mask = (FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK);
+
+ drawop = FFB_DRAWOP_RECTANGLE;
+
+ FFB_ATTR_RAW(pFfb, ppc, ppc_mask, ~0,
+ (FFB_ROP_EDIT_BIT | GXcopy)|(FFB_ROP_NEW<<8),
+ drawop, 0x0, fbc, 0xff);
+
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, 0, 0);
+ FFB_WRITE64_2(&ffb->bh, pFfb->psdp->height, pFfb->psdp->width);
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, ffb);
+}
+
+void
+FFBDacFini(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+
+ /* Just restore the kernel ramdac/x-channel state. */
+ dac_state_restore(pFfb, &p->kern_dac_state);
+ restore_kernel_xchannel(pFfb);
+}
+
+
+/* Restore X server DAC state. */
+void
+FFBDacEnterVT(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+
+ /* Save kernel DAC state. */
+ dac_state_save(pFfb, &p->kern_dac_state);
+
+ /* Restore X DAC state. */
+ dac_state_restore(pFfb, &p->x_dac_state);
+}
+
+/* Restore kernel DAC state. */
+void
+FFBDacLeaveVT(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+
+ /* Save X DAC state. */
+ dac_state_save(pFfb, &p->x_dac_state);
+
+ /* Restore kernel DAC and x-channel state. */
+ dac_state_restore(pFfb, &p->kern_dac_state);
+ restore_kernel_xchannel(pFfb);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.h
new file mode 100644
index 000000000..cc2911b41
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dac.h
@@ -0,0 +1,363 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - DAC register layout.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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/drivers/sunffb/ffb_dac.h,v 1.1 2000/05/23 04:47:44 dawes Exp $ */
+
+#ifndef _FFB_DAC_H
+#define _FFB_DAC_H
+
+/* FFB utilizes two different ramdac chips:
+ *
+ * 1) BT9068 "Pacifica1", used in all FFB1 and
+ * FFB2 boards.
+ *
+ * 2) BT498(a) "Pacifica2", used in FFB2+ and
+ * AFB boards.
+ *
+ * They are mostly equivalent, except in a few key areas:
+ *
+ * 1) WID register layout
+ * 2) Number of CLUT tables
+ * 3) Presence of Window Address Mask register
+ * 4) Method of GAMMA correction support
+ */
+
+/* NOTE: All addresses described in this file are DAC
+ * indirect addresses.
+ */
+
+/* DAC color values are in the following format. */
+#define FFBDAC_COLOR_BLUE 0x00ff0000
+#define FFBDAC_COLOR_BLUE_SHFT 16
+#define FFBDAC_COLOR_GREEN 0x0000ff00
+#define FFBDAC_COLOR_GREEN_SHFT 8
+#define FFBDAC_COLOR_RED 0x000000ff
+#define FFBDAC_COLOR_RED_SHFT 0
+
+/* Cursor DAC register addresses. */
+#define FFBDAC_CUR_BITMAP_P0 0x000 /* Plane 0 cursor bitmap */
+#define FFBDAC_CUR_BITMAP_P1 0x080 /* Plane 1 cursor bitmap */
+#define FFBDAC_CUR_CTRL 0x100 /* Cursor control */
+#define FFBDAC_CUR_COLOR0 0x101 /* Cursor Color 0 */
+#define FFBDAC_CUR_COLOR1 0x102 /* Cursor Color 1 (bg) */
+#define FFBDAC_CUR_COLOR2 0x103 /* Cursor Color 2 (fg) */
+#define FFBDAC_CUR_POS 0x104 /* Active cursor position */
+
+/* Cursor control register.
+ * WARNING: Be careful, reverse logic on these bits.
+ */
+#define FFBDAC_CUR_CTRL_P0 0x00000001 /* Plane0 display disable */
+#define FFBDAC_CUR_CTRL_P1 0x00000002 /* Plane1 display disable */
+
+/* Active cursor position register */
+#define FFBDAC_CUR_POS_Y_SIGN 0x80000000 /* Sign of Y position */
+#define FFBDAC_CUR_POS_Y 0x0fff0000 /* Y position */
+#define FFBDAC_CUR_POS_X_SIGN 0x00008000 /* Sign of X position */
+#define FFBDAC_CUR_POS_X 0x00000fff /* X position */
+
+/* Configuration and Palette DAC register addresses. */
+#define FFBDAC_CFG_PPLLCTRL 0x0000 /* Pixel PLL Control */
+#define FFBDAC_CFG_GPLLCTRL 0x0001 /* General Purpose PLL Control */
+#define FFBDAC_CFG_PFCTRL 0x1000 /* Pixel Format Control */
+#define FFBDAC_CFG_UCTRL 0x1001 /* User Control */
+#define FFBDAC_CFG_CLUP_BASE 0x2000 /* Color Lookup Palette */
+#define FFBDAC_CFG_CLUP(entry) (FFBDAC_CFG_CLUP_BASE + ((entry) * 0x100))
+#define FFBDAC_PAC2_SOVWLUT0 0x3100 /* Shadow Overlay Window Lookup 0*/
+#define FFBDAC_PAC2_SOVWLUT1 0x3101 /* Shadow Overlay Window Lookup 1*/
+#define FFBDAC_PAC2_SOVWLUT2 0x3102 /* Shadow Overlay Window Lookup 2*/
+#define FFBDAC_PAC2_SOVWLUT3 0x3103 /* Shadow Overlay Window Lookup 3*/
+#define FFBDAC_PAC2_AOVWLUT0 0x3210 /* Active Overlay Window Lookup 0*/
+#define FFBDAC_PAC2_AOVWLUT1 0x3211 /* Active Overlay Window Lookup 1*/
+#define FFBDAC_PAC2_AOVWLUT2 0x3212 /* Active Overlay Window Lookup 2*/
+#define FFBDAC_PAC2_AOVWLUT3 0x3213 /* Active Overlay Window Lookup 3*/
+#define FFBDAC_CFG_WTCTRL 0x3150 /* Window Transfer Control */
+#define FFBDAC_CFG_TMCTRL 0x3151 /* Transparent Mask Control */
+#define FFBDAC_CFG_TCOLORKEY 0x3152 /* Transparent Color Key */
+#define FFBDAC_CFG_WAMASK 0x3153 /* Window Address Mask (PAC2 only) */
+#define FFBDAC_PAC1_SPWLUT_BASE 0x3100 /* Shadow Primary Window Lookups */
+#define FFBDAC_PAC1_SPWLUT(entry) (FFBDAC_PAC1_SPWLUT_BASE + (entry))
+#define FFBDAC_PAC1_APWLUT_BASE 0x3120 /* Active Primary Window Lookups */
+#define FFBDAC_PAC1_APWLUT(entry) (FFBDAC_PAC1_APWLUT_BASE + (entry))
+#define FFBDAC_PAC2_SPWLUT_BASE 0x3200 /* Shadow Primary Window Lookups */
+#define FFBDAC_PAC2_SPWLUT(entry) (FFBDAC_PAC2_SPWLUT_BASE + (entry))
+#define FFBDAC_PAC2_APWLUT_BASE 0x3240 /* Active Primary Window Lookups */
+#define FFBDAC_PAC2_APWLUT(entry) (FFBDAC_PAC2_APWLUT_BASE + (entry))
+#define FFBDAC_CFG_SANAL 0x5000 /* Signature Analysis Control */
+#define FFBDAC_CFG_DACCTRL 0x5001 /* DAC Control */
+#define FFBDAC_CFG_TGEN 0x6000 /* Timing Generator Control */
+#define FFBDAC_CFG_VBNP 0x6001 /* Vertical Blank Negation Point */
+#define FFBDAC_CFG_VBAP 0x6002 /* Vertical Blank Assertion Point*/
+#define FFBDAC_CFG_VSNP 0x6003 /* Vertical Sync Negation Point */
+#define FFBDAC_CFG_VSAP 0x6004 /* Vertical Sync Assertion Point */
+#define FFBDAC_CFG_HSNP 0x6005 /* Horz Serration Negation Point */
+#define FFBDAC_CFG_HBNP 0x6006 /* Horz Blank Negation Point */
+#define FFBDAC_CFG_HBAP 0x6007 /* Horz Blank Assertion Point */
+#define FFBDAC_CFG_HSYNCNP 0x6008 /* Horz Sync Negation Point */
+#define FFBDAC_CFG_HSYNCAP 0x6009 /* Horz Sync Assertion Point */
+#define FFBDAC_CFG_HSCENNP 0x600A /* Horz SCEN Negation Point */
+#define FFBDAC_CFG_HSCENAP 0x600B /* Horz SCEN Assertion Point */
+#define FFBDAC_CFG_EPNP 0x600C /* Eql'zing Pulse Negation Point */
+#define FFBDAC_CFG_EINP 0x600D /* Eql'zing Intvl Negation Point */
+#define FFBDAC_CFG_EIAP 0x600E /* Eql'zing Intvl Assertion Point*/
+#define FFBDAC_CFG_TGVC 0x600F /* Timing Generator Vert Counter */
+#define FFBDAC_CFG_TGHC 0x6010 /* Timing Generator Horz Counter */
+#define FFBDAC_CFG_DID 0x8000 /* Device Identification */
+#define FFBDAC_CFG_MPDATA 0x8001 /* Monitor Port Data */
+#define FFBDAC_CFG_MPSENSE 0x8002 /* Monitor Port Sense */
+
+/* Pixel PLL Control Register */
+#define FFBDAC_CFG_PPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */
+#define FFBDAC_CFG_PPLLCTRL_D 0x00000780 /* PLL VCO Divisor */
+#define FFBDAC_CFG_PPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */
+#define FFBDAC_CFG_PPLLCTRL_EN 0x00004000 /* Enable PLL as pixel clock src */
+
+/* General Purpose PLL Control Register */
+#define FFBDAC_CFG_GPLLCTRL_M 0x0000007f /* PLL VCO Multiplicand */
+#define FFBDAC_CFG_GPLLCTRL_D 0x00000780 /* PLL VCO Divisor */
+#define FFBDAC_CFG_GPLLCTRL_PFD 0x00001800 /* Post VCO Frequency Divider */
+#define FFBDAC_CFG_GPLLCTRL_EN 0x00004000 /* Enable PLL as Gen. Purpose clk*/
+
+/* Pixel Format Control Register */
+#define FFBDAC_CFG_PFCTRL_2_1 0x00000000 /* 2:1 pixel interleave format */
+#define FFBDAC_CFG_PFCTRL_4_1 0x00000001 /* 4:1 pixel interleave format */
+#define FFBDAC_CFG_PFCTRL_42_1 0x00000002 /* 4/2:1 pixel interleave format */
+#define FFBDAC_CFG_PFCTRL_82_1 0x00000003 /* 8/2:1 pixel interleave format */
+
+/* User Control Register */
+#define FFBDAC_UCTRL_IPDISAB 0x00000001 /* Disable input pullup resistors*/
+#define FFBDAC_UCTRL_ABLANK 0x00000002 /* Asynchronous Blank */
+#define FFBDAC_UCTRL_DBENAB 0x00000004 /* Double-Buffer Enable */
+#define FFBDAC_UCTRL_OVENAB 0x00000008 /* Overlay Enable */
+#define FFBDAC_UCTRL_WMODE 0x00000030 /* Window Mode */
+#define FFBDAC_UCTRL_WM_COMB 0x00000000 /* Window Mode = Combined */
+#define FFBDAC_UCTRL_WM_S4 0x00000010 /* Window Mode = Seperate_4 */
+#define FFBDAC_UCTRL_WM_S8 0x00000020 /* Window Mode = Seperate_8 */
+#define FFBDAC_UCTRL_WM_RESV 0x00000030 /* Window Mode = reserved */
+#define FFBDAC_UCTRL_MANREV 0x00000f00 /* 4-bit Manufacturing Revision */
+
+/* Overlay Window Lookup Registers (PAC2 only) */
+#define FFBDAC_CFG_OVWLUT_PSEL 0x0000000f /* Palette Section, Seperate_4 */
+#define FFBDAC_CFG_OVWLUT_PTBL 0x00000030 /* Palette Table */
+#define FFBDAC_CFG_OVWLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */
+#define FFBDAC_CFG_OVWLUT_OTYP 0x00000c00 /* Overlay Type */
+#define FFBDAC_CFG_OVWLUT_O_N 0x00000000 /* Overlay Type - None */
+#define FFBDAC_CFG_OVWLUT_O_T 0x00000400 /* Overlay Type - Transparent */
+#define FFBDAC_CFG_OVWLUT_O_O 0x00000800 /* Overlay Type - Opaque */
+#define FFBDAC_CFG_OVWLUT_O_R 0x00000c00 /* Overlay Type - Reserved */
+#define FFBDAC_CFG_OVWLUT_PCS 0x00003000 /* Psuedocolor Src */
+#define FFBDAC_CFG_OVWLUT_P_XO 0x00000000 /* Psuedocolor Src - XO[7:0] */
+#define FFBDAC_CFG_OVWLUT_P_R 0x00001000 /* Psuedocolor Src - R[7:0] */
+#define FFBDAC_CFG_OVWLUT_P_G 0x00002000 /* Psuedocolor Src - G[7:0] */
+#define FFBDAC_CFG_OVWLUT_P_B 0x00003000 /* Psuedocolor Src - B[7:0] */
+
+/* Window Transfer Control Register */
+#define FFBDAC_CFG_WTCTRL_DS 0x00000001 /* Device Status, 1 = Busy */
+#define FFBDAC_CFG_WTCTRL_TCMD 0x00000002 /* Transfer Command
+ * 1 = Transfer, 0 = No Action
+ */
+#define FFBDAC_CFG_WTCTRL_TE 0x00000004 /* Transfer Event
+ * 1 = Next Frame, 0 = Next Field
+ */
+#define FFBDAC_CFG_WTCTRL_DRD 0x00000008 /* Drawing Data
+ * 1 = Local Drawing Active
+ * 0 = Local Drawing Idle
+ */
+#define FFBDAC_CFG_WTCTRL_DRS 0x00000010 /* Drawing Status
+ * 1 = Network Drawing Active
+ * 0 = Network Drawing Idle
+ */
+
+/* Transparent Mask Control Register */
+#define FFBDAC_CFG_TMCTRL_OMSK 0x000000ff /* Overlay Mask */
+
+/* Transparent Color Key Register */
+#define FFBDAC_CFG_TCOLORKEY_K 0x000000ff /* Overlay Color Key */
+
+/* Window Address Mask Register (PAC2 only) */
+#define FFBDAC_CFG_WAMASK_PMSK 0x0000003f /* PWLUT select PMASK */
+#define FFBDAC_CFG_WAMASK_OMSK 0x00000300 /* OWLUT control OMASK */
+
+/* (non-Overlay) Window Lookup Table Registers, PAC1 format */
+#define FFBDAC_PAC1_WLUT_DB 0x00000020 /* 0 = Buffer A, 1 = Buffer B */
+#define FFBDAC_PAC1_WLUT_C 0x0000001c /* C: Color Model Selection */
+#define FFBDAC_PAC1_WLUT_C_8P 0x00000000 /* C: 8bpp Pseudocolor */
+#define FFBDAC_PAC1_WLUT_C_8LG 0x00000004 /* C: 8bpp Linear Grey */
+#define FFBDAC_PAC1_WLUT_C_8NG 0x00000008 /* C: 8bpp Non-Linear Grey */
+#define FFBDAC_PAC1_WLUT_C_24D 0x00000010 /* C: 24bpp Directcolor */
+#define FFBDAC_PAC1_WLUT_C_24LT 0x00000014 /* C: 24bpp Linear Truecolor */
+#define FFBDAC_PAC1_WLUT_C_24NT 0x00000018 /* C: 24bpp Non-Linear Truecolor */
+#define FFBDAC_PAC1_WLUT_PCS 0x00000003 /* Pseudocolor Src */
+#define FFBDAC_PAC1_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */
+#define FFBDAC_PAC1_WLUT_P_R 0x00000001 /* Pseudocolor Src - R[7:0] */
+#define FFBDAC_PAC1_WLUT_P_G 0x00000002 /* Pseudocolor Src - G[7:0] */
+#define FFBDAC_PAC1_WLUT_P_B 0x00000003 /* Pseudocolor Src - B[7:0] */
+
+/* (non-Overlay) Window Lookup Table Registers, PAC2 format */
+#define FFBDAC_PAC2_WLUT_PTBL 0x00000030 /* Palette Table Entry */
+#define FFBDAC_PAC2_WLUT_LKUP 0x00000100 /* 1 = Use palette, 0 = Bypass */
+#define FFBDAC_PAC2_WLUT_PCS 0x00003000 /* Pseudocolor Src */
+#define FFBDAC_PAC2_WLUT_P_XO 0x00000000 /* Pseudocolor Src - XO[7:0] */
+#define FFBDAC_PAC2_WLUT_P_R 0x00001000 /* Pseudocolor Src - R[7:0] */
+#define FFBDAC_PAC2_WLUT_P_G 0x00002000 /* Pseudocolor Src - G[7:0] */
+#define FFBDAC_PAC2_WLUT_P_B 0x00003000 /* Pseudocolor Src - B[7:0] */
+#define FFBDAC_PAC2_WLUT_DEPTH 0x00004000 /* 0 = Pseudocolor, 1 = Truecolor*/
+#define FFBDAC_PAC2_WLUT_DB 0x00008000 /* 0 = Buffer A, 1 = Buffer B */
+
+/* Signature Analysis Control Register */
+#define FFBDAC_CFG_SANAL_SRR 0x000000ff /* DAC Seed/Result for Red */
+#define FFBDAC_CFG_SANAL_SRG 0x0000ff00 /* DAC Seed/Result for Green */
+#define FFBDAC_CFG_SANAL_SRB 0x00ff0000 /* DAC Seed/Result for Blue */
+#define FFBDAC_CFG_SANAL_RQST 0x01000000 /* Signature Capture Request */
+#define FFBDAC_CFG_SANAL_BSY 0x02000000 /* Signature Analysis Busy */
+#define FFBDAC_CFG_SANAL_DSM 0x04000000 /* Data Strobe Mode
+ * 0 = Signature Analysis Mode
+ * 1 = Data Strobe Mode
+ */
+
+/* DAC Control Register */
+#define FFBDAC_CFG_DACCTRL_O2 0x00000003 /* Operand 2 Select
+ * 00 = Normal Operation
+ * 01 = Select 145mv Reference
+ * 10 = Select Blue DAC Output
+ * 11 = Reserved
+ */
+#define FFBDAC_CFG_DACCTRL_O1 0x0000000c /* Operand 1 Select
+ * 00 = Normal Operation
+ * 01 = Select Green DAC Output
+ * 10 = Select Red DAC Output
+ * 11 = Reserved
+ */
+#define FFBDAC_CFG_DACCTRL_CR 0x00000010 /* Comparator Result
+ * 0 = operand1 < operand2
+ * 1 = operand1 > operand2
+ */
+#define FFBDAC_CFG_DACCTRL_SGE 0x00000020 /* Sync-on-Green Enable */
+#define FFBDAC_CFG_DACCTRL_PE 0x00000040 /* Pedestal Enable */
+#define FFBDAC_CFG_DACCTRL_VPD 0x00000080 /* VSYNC* Pin Disable */
+#define FFBDAC_CFG_DACCTRL_SPB 0x00000100 /* Sync Polarity Bit
+ * 0 = VSYNC* and CSYNC* active low
+ * 1 = VSYNC* and CSYNC* active high
+ */
+
+/* Timing Generator Control Register */
+#define FFBDAC_CFG_TGEN_VIDE 0x00000001 /* Video Enable */
+#define FFBDAC_CFG_TGEN_TGE 0x00000002 /* Timing Generator Enable */
+#define FFBDAC_CFG_TGEN_HSD 0x00000004 /* HSYNC* Disabled */
+#define FFBDAC_CFG_TGEN_VSD 0x00000008 /* VSYNC* Disabled */
+#define FFBDAC_CFG_TGEN_EQD 0x00000010 /* Equalization Disabled */
+#define FFBDAC_CFG_TGEN_MM 0x00000020 /* 0 = Slave, 1 = Master */
+#define FFBDAC_CFG_TGEN_IM 0x00000040 /* 1 = Interlaced Mode */
+
+/* Device Identification Register, should be 0xA236E1AD for FFB bt497/bt498 */
+#define FFBDAC_CFG_DID_ONE 0x00000001 /* Always set */
+#define FFBDAC_CFG_DID_MANUF 0x00000ffe /* Manufacturer ID */
+#define FFBDAC_CFG_DID_PNUM 0x0ffff000 /* Device Part Number */
+#define FFBDAC_CFG_DID_REV 0xf0000000 /* Device Revision */
+
+/* Monitor Port Data Register */
+#define FFBDAC_CFG_MPDATA_SCL 0x00000001 /* SCL Data */
+#define FFBDAC_CFG_MPDATA_SDA 0x00000002 /* SDA Data */
+
+/* Monitor Port Sense Register */
+#define FFBDAC_CFG_MPSENSE_SCL 0x00000001 /* SCL Sense */
+#define FFBDAC_CFG_MPSENSE_SDA 0x00000002 /* SDA Sense */
+
+/* DAC register access shorthands. */
+#define DACCUR_READ(DAC, ADDR) ((DAC)->cur = (ADDR), (DAC)->curdata)
+#define DACCUR_WRITE(DAC, ADDR, VAL) ((DAC)->cur = (ADDR), (DAC)->curdata = (VAL))
+#define DACCFG_READ(DAC, ADDR) ((DAC)->cfg = (ADDR), (DAC)->cfgdata)
+#define DACCFG_WRITE(DAC, ADDR, VAL) ((DAC)->cfg = (ADDR), (DAC)->cfgdata = (VAL))
+
+typedef struct ffb_dac_hwstate {
+ unsigned int ppllctrl;
+ unsigned int gpllctrl;
+ unsigned int pfctrl;
+ unsigned int uctrl;
+ unsigned int clut[256 * 4]; /* One 256 entry clut on PAC1, 4 on PAC2 */
+ unsigned int ovluts[4]; /* Overlay WLUTS, PAC2 only */
+ unsigned int wtctrl;
+ unsigned int tmctrl;
+ unsigned int tcolorkey;
+ unsigned int wamask;
+ unsigned int pwluts[64];
+ unsigned int dacctrl;
+ unsigned int tgen;
+ unsigned int vbnp;
+ unsigned int vbap;
+ unsigned int vsnp;
+ unsigned int vsap;
+ unsigned int hsnp;
+ unsigned int hbnp;
+ unsigned int hbap;
+ unsigned int hsyncnp;
+ unsigned int hsyncap;
+ unsigned int hscennp;
+ unsigned int hscenap;
+ unsigned int epnp;
+ unsigned int einp;
+ unsigned int eiap;
+} ffb_dac_hwstate_t;
+
+typedef struct {
+ Bool InUse;
+
+ /* The following fields are undefined unless InUse is TRUE. */
+ int refcount;
+ Bool canshare;
+ unsigned int wlut_regval;
+ int buffer; /* 0 = Buffer A, 1 = Buffer B */
+ int depth; /* 8 or 32 bpp */
+ int greyscale; /* 1 = greyscale, 0 = color */
+ int linear; /* 1 = linear, 0 = non-linear */
+ int direct; /* 1 = 24bpp directcolor */
+ int channel; /* 0 = X, 1 = R, 2 = G, 3 = B */
+ int palette; /* Only PAC2 has multiple CLUTs */
+} ffb_wid_info_t;
+
+#define FFB_MAX_PWIDS 64
+typedef struct {
+ int num_wids;
+ int wid_shift; /* To get X channel value */
+ ffb_wid_info_t wid_pool[FFB_MAX_PWIDS];
+} ffb_wid_pool_t;
+
+typedef struct ffb_dac_info {
+ unsigned int flags;
+#define FFB_DAC_PAC1 0x00000001 /* Pacifica1 DAC, BT9068 */
+#define FFB_DAC_PAC2 0x00000002 /* Pacifica2 DAC, BT498 */
+#define FFB_DAC_ICURCTL 0x00000004 /* Inverted CUR_CTRL bits */
+
+ /* These registers need to be modified when changing DAC
+ * timing state, so at init time we capture their values.
+ */
+ unsigned int ffbcfg0;
+ unsigned int ffbcfg2;
+ unsigned int ffb_passin_ctrl; /* FFB2+/AFB only */
+
+ ffb_dac_hwstate_t kern_dac_state;
+ ffb_dac_hwstate_t x_dac_state;
+
+ ffb_wid_pool_t wid_table;
+} ffb_dac_info_t;
+
+#endif /* _FFB_DAC_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dbe.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dbe.c
new file mode 100644
index 000000000..b5d7bc4f1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dbe.c
@@ -0,0 +1,901 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Dbe Acceleration.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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/drivers/sunffb/ffb_dbe.c,v 1.1 2000/05/23 04:47:44 dawes Exp $ */
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "os.h"
+#include "windowstr.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "extnsionst.h"
+#include "dixstruct.h"
+#include "resource.h"
+#include "opaque.h"
+#include "dbestruct.h"
+#include "regionstr.h"
+#include "gcstruct.h"
+#include "inputstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "xf86_ansic.h"
+#include "xf86.h"
+
+#include "ffb.h"
+#include "ffb_fifo.h"
+#include "ffb_rcache.h"
+
+static int FFBDbePrivPrivGeneration = 0;
+static int FFBDbeWindowPrivPrivIndex = -1;
+static RESTYPE dbeDrawableResType;
+static RESTYPE dbeWindowPrivResType;
+static int dbeScreenPrivIndex = -1;
+static int dbeWindowPrivIndex = -1;
+
+#define FFB_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv) \
+ (((FFBDbeWindowPrivPrivIndex < 0) || (!pDbeWindowPriv)) ? \
+ NULL : \
+ ((FFBDbeWindowPrivPrivPtr) \
+ ((pDbeWindowPriv)->devPrivates[FFBDbeWindowPrivPrivIndex].ptr)))
+
+#define FFB_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin) \
+ FFB_DBE_WINDOW_PRIV_PRIV(DBE_WINDOW_PRIV(pWin))
+
+typedef struct _FFBDbeWindowPrivPrivRec {
+ int HwAccelerated;
+ int HwCurrentBuf; /* 0 = buffer A, 1 = buffer B */
+
+ /* We need also what midbe would use in case we must
+ * revert to unaccelerated dbe.
+ */
+ PixmapPtr pBackBuffer;
+ PixmapPtr pFrontBuffer;
+
+ /* Back pointer to generic DBE layer window private. */
+ DbeWindowPrivPtr pDbeWindowPriv;
+} FFBDbeWindowPrivPrivRec, *FFBDbeWindowPrivPrivPtr;
+
+static Bool
+FFBDbeGetVisualInfo(ScreenPtr pScreen, XdbeScreenVisualInfo *pScrVisInfo)
+{
+ XdbeVisualInfo *visInfo;
+ DepthPtr pDepth;
+ int i, j, k, count;
+
+ /* XXX Should check for double-buffer presence. But even if
+ * XXX the double-buffer is not present we can still play
+ * XXX tricks with GetWindowPixmap in 8bpp mode, ie. double
+ * XXX buffer between the R and G planes of buffer A. -DaveM
+ */
+
+ /* Determine number of visuals for this screen. */
+ for (i = 0, count = 0; i < pScreen->numDepths; i++)
+ count += pScreen->allowedDepths[i].numVids;
+
+ /* Allocate an array of XdbeVisualInfo items. */
+ if (!(visInfo = (XdbeVisualInfo *)xalloc(count * sizeof(XdbeVisualInfo))))
+ return FALSE;
+
+ for (i = 0, k = 0; i < pScreen->numDepths; i++) {
+ /* For each depth of this screen, get visual information. */
+ pDepth = &pScreen->allowedDepths[i];
+ for (j = 0; j < pDepth->numVids; j++) {
+ /* For each visual for this depth of this screen, get visual ID
+ * and visual depth. For now, we will always return
+ * the same performance level for all visuals (0). A higher
+ * performance level value indicates higher performance.
+ */
+ visInfo[k].visual = pDepth->vids[j];
+ visInfo[k].depth = pDepth->depth;
+
+ /* XXX We should set this appropriately... -DaveM */
+ visInfo[k].perflevel = 0;
+ k++;
+ }
+ }
+
+ /* Record the number of visuals and point visual_depth to
+ * the array of visual info.
+ */
+ pScrVisInfo->count = count;
+ pScrVisInfo->visinfo = visInfo;
+
+ return TRUE;
+}
+
+static void
+FFBDbeUpdateWidPlane(WindowPtr pWin, GCPtr pGC)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen);
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ RegionPtr prgnClip;
+ BoxPtr pboxClipped, pboxClippedBase;
+ unsigned int fbc;
+ int numRects;
+ int x, y, w, h;
+
+ x = pWin->drawable.x;
+ y = pWin->drawable.y;
+ w = pWin->drawable.width;
+ h = pWin->drawable.height;
+
+ fbc = pFfbPrivWin->fbc_base;
+ fbc = (fbc & ~FFB_FBC_WB_MASK) | FFB_FBC_WB_AB;
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_ON;
+ fbc = (fbc & ~FFB_FBC_RGBE_MASK) | FFB_FBC_RGBE_OFF;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS (prgnClip);
+ pboxClippedBase = (BoxPtr) ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+
+ pboxClipped = pboxClippedBase;
+ {
+ int x1, y1, x2, y2, bx2, by2;
+ BoxRec box;
+ BoxPtr pextent;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+
+ if ((box.x1 = x) < x1)
+ box.x1 = x1;
+
+ if ((box.y1 = y) < y1)
+ box.y1 = y1;
+
+ bx2 = (int) x + (int) w;
+ if (bx2 > x2)
+ bx2 = x2;
+ box.x2 = bx2;
+
+ by2 = (int) y + (int) h;
+ if (by2 > y2)
+ by2 = y2;
+ box.y2 = by2;
+
+ if ((box.x1 < box.x2) && (box.y1 < box.y2)) {
+ int n = REGION_NUM_RECTS (prgnClip);
+ BoxPtr 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) {
+ ffb_fbcPtr ffb = pFfb->regs;
+ int num = (pboxClipped - pboxClippedBase);
+
+ FFB_ATTR_RAW(pFfb,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | FFB_PPC_XS_WID,
+ FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK,
+ pGC->planemask,
+ ((FFB_ROP_EDIT_BIT | pGC->alu) | (FFB_ROP_NEW << 8)),
+ FFB_DRAWOP_RECTANGLE,
+ pGC->fgPixel,
+ fbc, pFfbPrivWin->wid);
+
+ pboxClipped = pboxClippedBase;
+ while (num--) {
+ int xx, yy, ww, hh;
+
+ xx = pboxClipped->x1;
+ yy = pboxClipped->y1;
+ ww = (pboxClipped->x2 - xx);
+ hh = (pboxClipped->y2 - yy);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, yy, xx);
+ FFB_WRITE64_2(&ffb->bh, hh, ww);
+ }
+ }
+
+ DEALLOCATE_LOCAL (pboxClippedBase);
+}
+
+static int
+FFBDbeAllocBackBufferName(WindowPtr pWin, XID bufId, int swapAction)
+{
+ ScreenPtr pScreen;
+ FFBPtr pFfb;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ FFBDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ GCPtr pGC;
+ xRectangle clearRect;
+
+ pScreen = pWin->drawable.pScreen;
+ pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
+ pFfb = GET_FFB_FROM_SCREEN(pScreen);
+
+ pDbeWindowPrivPriv = FFB_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+ if (pDbeWindowPriv->nBufferIDs == 0) {
+ /* There is no buffer associated with the window.
+ * We have to create the window priv priv. Remember, the window
+ * priv was created at the DIX level, so all we need to do is
+ * create the priv priv and attach it to the priv.
+ */
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ /* Setup the window priv priv. */
+ pDbeWindowPrivPriv->pDbeWindowPriv = pDbeWindowPriv;
+
+ if (!pFfb->NoAccel && pFfb->has_double_buffer) {
+ CreatorPrivWinPtr pFfbPrivWin;
+ unsigned int wid, fbc;
+
+ /* We just render directly into the hardware, all
+ * that is needed is to swap the rendering attributes
+ * and the WID settings during a swap.
+ */
+ if (!AddResource(bufId, dbeDrawableResType,
+ (pointer)&pWin->drawable)) {
+ /* Free the buffer and the drawable resource. */
+ FreeResource(bufId, RT_NONE);
+ return BadAlloc;
+ }
+
+ pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ wid = FFBWidUnshare(pFfb, pFfbPrivWin->wid);
+ if (wid == (unsigned int)-1)
+ return BadAlloc;
+
+ pFfbPrivWin->wid = wid;
+
+ /* Attach the priv priv to the priv. */
+ pDbeWindowPriv->devPrivates[FFBDbeWindowPrivPrivIndex].ptr =
+ (pointer)pDbeWindowPrivPriv;
+
+ /* Indicate we are doing hw acceleration. */
+ pDbeWindowPrivPriv->HwAccelerated = 1;
+
+ /* Start rendering into buffer B. */
+ pDbeWindowPrivPriv->HwCurrentBuf = 1;
+
+ /* No back/front temporary pixmaps. */
+ pDbeWindowPrivPriv->pFrontBuffer = NULL;
+ pDbeWindowPrivPriv->pBackBuffer = NULL;
+
+ /* Switch to writing into buffer B. */
+ fbc = pFfbPrivWin->fbc_base;
+ fbc &= ~(FFB_FBC_WB_MASK | FFB_FBC_RB_MASK);
+ fbc |= (FFB_FBC_WB_B | FFB_FBC_RB_B);
+ pFfbPrivWin->fbc_base = fbc;
+
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+
+ /* Fill X plane of front and back buffers. */
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ ValidateGC(&pWin->drawable, pGC);
+ FFBDbeUpdateWidPlane(pWin, pGC);
+ }
+
+ /* Clear out buffer B. */
+ clearRect.x = clearRect.y = 0;
+ clearRect.width = pWin->drawable.width;
+ clearRect.height = pWin->drawable.height;
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ ValidateGC(&pWin->drawable, pGC);
+ (*pGC->ops->PolyFillRect)(&pWin->drawable, pGC, 1, &clearRect);
+ }
+
+ FreeScratchGC(pGC);
+ } else {
+ /* Get a front pixmap. */
+ if (!(pDbeWindowPrivPriv->pFrontBuffer =
+ (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
+ pDbeWindowPriv->height,
+ pWin->drawable.depth)))
+ return BadAlloc;
+
+ /* Get a back pixmap. */
+ if (!(pDbeWindowPrivPriv->pBackBuffer =
+ (*pScreen->CreatePixmap)(pScreen, pDbeWindowPriv->width,
+ pDbeWindowPriv->height,
+ pWin->drawable.depth))) {
+ (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
+ return BadAlloc;
+ }
+
+
+ /* Make the back pixmap a DBE drawable resource. */
+ if (!AddResource(bufId, dbeDrawableResType,
+ (pointer)pDbeWindowPrivPriv->pBackBuffer)) {
+ /* Free the buffer and the drawable resource. */
+ FreeResource(bufId, RT_NONE);
+ return(BadAlloc);
+ }
+
+ /* Attach the priv priv to the priv. */
+ pDbeWindowPriv->devPrivates[FFBDbeWindowPrivPrivIndex].ptr =
+ (pointer)pDbeWindowPrivPriv;
+
+ /* Indicate we are doing this non-accelerated. */
+ pDbeWindowPrivPriv->HwAccelerated = 0;
+
+ /* Clear the back buffer. */
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC);
+ clearRect.x = clearRect.y = 0;
+ clearRect.width = pDbeWindowPrivPriv->pBackBuffer->drawable.width;
+ clearRect.height = pDbeWindowPrivPriv->pBackBuffer->drawable.height;
+ (*pGC->ops->PolyFillRect)(
+ (DrawablePtr)pDbeWindowPrivPriv->pBackBuffer, pGC, 1,
+ &clearRect);
+ }
+ FreeScratchGC(pGC);
+ }
+ } else {
+ pointer cookie;
+
+ /* A buffer is already associated with the window.
+ * Place the new buffer ID information at the head of the ID list.
+ */
+ if (pDbeWindowPrivPriv->HwAccelerated != 0)
+ cookie = (pointer)&pWin->drawable;
+ else
+ cookie = (pointer)pDbeWindowPrivPriv->pBackBuffer;
+
+ /* Associate the new ID with an existing pixmap. */
+ if (!AddResource(bufId, dbeDrawableResType, cookie))
+ return BadAlloc;
+ }
+
+ return Success;
+}
+
+static void
+FFBDbeAliasBuffers(DbeWindowPrivPtr pDbeWindowPriv)
+{
+ FFBDbeWindowPrivPrivPtr pDbeWindowPrivPriv =
+ FFB_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+ pointer cookie;
+ int i;
+
+ if (pDbeWindowPrivPriv->HwAccelerated != 0)
+ cookie = (pointer) &pDbeWindowPriv->pWindow->drawable;
+ else
+ cookie = (pointer) pDbeWindowPrivPriv->pBackBuffer;
+
+ for (i = 0; i < pDbeWindowPriv->nBufferIDs; i++)
+ ChangeResourceValue(pDbeWindowPriv->IDs[i], dbeDrawableResType, cookie);
+}
+
+static int
+FFBDbeSwapBuffers(ClientPtr client, int *pNumWindows, DbeSwapInfoPtr swapInfo)
+{
+ FFBDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ PixmapPtr pTmpBuffer;
+ xRectangle clearRect;
+ WindowPtr pWin;
+ GCPtr pGC;
+
+ pWin = swapInfo[0].pWindow;
+ pDbeScreenPriv = DBE_SCREEN_PRIV_FROM_WINDOW(pWin);
+ pDbeWindowPrivPriv = FFB_DBE_WINDOW_PRIV_PRIV_FROM_WINDOW(pWin);
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+
+ if (pDbeWindowPrivPriv->HwAccelerated != 0) {
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen);
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ unsigned int fbc;
+ int visible;
+
+ /* Unfortunately, this is necessary for correctness. */
+ FFBWait(pFfb, pFfb->regs);
+
+ /* Flip front/back in the WID. */
+ visible = 0;
+ if (pWin->viewable &&
+ pWin->visibility != VisibilityFullyObscured)
+ visible = 1;
+ FFBWidChangeBuffer(pFfb, pFfbPrivWin->wid, visible);
+
+ /* Indicate where we are rendering now. */
+ pDbeWindowPrivPriv->HwCurrentBuf ^= 1;
+
+ /* Update framebuffer controls. */
+ fbc = pFfbPrivWin->fbc_base;
+ fbc &= ~(FFB_FBC_WB_MASK | FFB_FBC_RB_MASK);
+ if (pDbeWindowPrivPriv->HwCurrentBuf == 0)
+ fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
+ else
+ fbc |= FFB_FBC_WB_B | FFB_FBC_RB_B;
+
+ /* For XdbeUndefined we do not have to do anything.
+ * This is true for XdbeUntouched as well because we
+ * do in fact retain the unobscured contents of the
+ * front buffer while it is being displayed, thus now
+ * when it has become the back buffer it is still holding
+ * those contents.
+ *
+ * The XdbeUntouched case is important because most apps
+ * using dbe use this type of swap.
+ */
+
+ if (swapInfo[0].swapAction == XdbeCopied) {
+ unsigned int fbc_front_to_back;
+
+ /* Do a GCOPY, front to back. */
+ fbc_front_to_back = fbc & ~FFB_FBC_RB_MASK;
+ if (pDbeWindowPrivPriv->HwCurrentBuf == 0)
+ fbc_front_to_back |= FFB_FBC_RB_B;
+ else
+ fbc_front_to_back |= FFB_FBC_RB_A;
+
+ pFfbPrivWin->fbc_base = fbc_front_to_back;
+ ValidateGC(&pWin->drawable, pGC);
+ (*pGC->ops->CopyArea)(&pWin->drawable,
+ &pWin->drawable,
+ pGC,
+ 0, 0,
+ pWin->drawable.width,
+ pWin->drawable.height,
+ 0, 0);
+ } else if (swapInfo[0].swapAction == XdbeBackground) {
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ ValidateGC(&pWin->drawable, pGC);
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width = pWin->drawable.width;
+ clearRect.height = pWin->drawable.height;
+ (*pGC->ops->PolyFillRect)(&pWin->drawable, pGC,
+ 1, &clearRect);
+ }
+ }
+
+ /* Ok, now render with these fb controls. */
+ pFfbPrivWin->fbc_base = fbc;
+ } else {
+ if (swapInfo[0].swapAction == XdbeUntouched) {
+ ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer, pGC);
+ (*pGC->ops->CopyArea)((DrawablePtr)pWin,
+ (DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
+ pGC, 0, 0, pWin->drawable.width,
+ pWin->drawable.height, 0, 0);
+ }
+
+ ValidateGC((DrawablePtr)pWin, pGC);
+ (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ (DrawablePtr)pWin, pGC, 0, 0,
+ pWin->drawable.width, pWin->drawable.height,
+ 0, 0);
+
+ if (swapInfo[0].swapAction == XdbeBackground) {
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ ValidateGC((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ pGC);
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width =
+ pDbeWindowPrivPriv->pBackBuffer->drawable.width;
+ clearRect.height =
+ pDbeWindowPrivPriv->pBackBuffer->drawable.height;
+ (*pGC->ops->PolyFillRect)(
+ (DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ pGC, 1, &clearRect);
+ }
+ } else if (swapInfo[0].swapAction == XdbeUntouched) {
+ /* Swap pixmap pointers. */
+ pTmpBuffer = pDbeWindowPrivPriv->pBackBuffer;
+ pDbeWindowPrivPriv->pBackBuffer =
+ pDbeWindowPrivPriv->pFrontBuffer;
+ pDbeWindowPrivPriv->pFrontBuffer = pTmpBuffer;
+ FFBDbeAliasBuffers(pDbeWindowPrivPriv->pDbeWindowPriv);
+ }
+ }
+
+ /* Remove the swapped window from the swap information array and decrement
+ * pNumWindows to indicate to the DIX level how many windows were actually
+ * swapped.
+ */
+ if (*pNumWindows > 1) {
+ /* We were told to swap more than one window, but we only swapped the
+ * first one. Remove the first window in the list by moving the last
+ * window to the beginning.
+ */
+ swapInfo[0].pWindow = swapInfo[*pNumWindows - 1].pWindow;
+ swapInfo[0].swapAction = swapInfo[*pNumWindows - 1].swapAction;
+
+ /* Clear the last window information just to be safe. */
+ swapInfo[*pNumWindows - 1].pWindow = (WindowPtr)NULL;
+ swapInfo[*pNumWindows - 1].swapAction = 0;
+ } else {
+ /* Clear the window information just to be safe. */
+ swapInfo[0].pWindow = (WindowPtr)NULL;
+ swapInfo[0].swapAction = 0;
+ }
+
+ (*pNumWindows)--;
+
+ FreeScratchGC(pGC);
+
+ return Success;
+}
+
+static void
+FFBDbeWinPrivDelete(DbeWindowPrivPtr pDbeWindowPriv, XID bufId)
+{
+ WindowPtr pWin = pDbeWindowPriv->pWindow;
+ FFBDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+
+ if (pDbeWindowPriv->nBufferIDs != 0) {
+ /* We still have at least one more buffer ID associated with this
+ * window.
+ */
+ return;
+ }
+
+ /* We have no more buffer IDs associated with this window. We need to
+ * free some stuff.
+ */
+ pDbeWindowPrivPriv = FFB_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+
+ /* If we were accelerating we need to restore the framebuffer
+ * attributes. We need to also free up the Dbe WID and go
+ * back to using the shared one.
+ */
+ if (pDbeWindowPrivPriv->HwAccelerated != 0) {
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pWin->drawable.pScreen);
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ xRectangle clearRect;
+ unsigned int fbc;
+ GCPtr pGC;
+
+ pFfbPrivWin->wid = FFBWidReshare(pFfb, pFfbPrivWin->wid);
+
+ /* Go back to using buffer A. */
+ fbc = pFfbPrivWin->fbc_base;
+ fbc &= ~(FFB_FBC_WB_MASK | FFB_FBC_RB_MASK);
+ fbc |= FFB_FBC_WB_A | FFB_FBC_RB_A;
+
+ /* Now fixup the WID channel. */
+ pFfbPrivWin->fbc_base =
+ (fbc & ~FFB_FBC_RGBE_MASK) | FFB_FBC_RGBE_OFF;
+
+ pGC = GetScratchGC(pWin->drawable.depth, pWin->drawable.pScreen);
+ clearRect.x = clearRect.y = 0;
+ clearRect.width = pWin->drawable.width;
+ clearRect.height = pWin->drawable.height;
+ ValidateGC(&pWin->drawable, pGC);
+ FFBDbeUpdateWidPlane(pWin, pGC);
+ (*pGC->ops->PolyFillRect)(&pWin->drawable, pGC, 1, &clearRect);
+ FreeScratchGC(pGC);
+
+ pFfbPrivWin->fbc_base = fbc;
+ } else {
+ /* Destroy the front and back pixmaps. */
+ if (pDbeWindowPrivPriv->pFrontBuffer)
+ (*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)(
+ pDbeWindowPrivPriv->pFrontBuffer);
+ if (pDbeWindowPrivPriv->pBackBuffer)
+ (*pDbeWindowPriv->pWindow->drawable.pScreen->DestroyPixmap)(
+ pDbeWindowPrivPriv->pBackBuffer);
+ }
+}
+
+static Bool
+FFBDbePositionWindow(WindowPtr pWin, int x, int y)
+{
+ ScreenPtr pScreen;
+ DbeScreenPrivPtr pDbeScreenPriv;
+ DbeWindowPrivPtr pDbeWindowPriv;
+ FFBDbeWindowPrivPrivPtr pDbeWindowPrivPriv;
+ int width, height;
+ int dx, dy, dw, dh;
+ int sourcex, sourcey;
+ int destx, desty;
+ int savewidth, saveheight;
+ PixmapPtr pFrontBuffer;
+ PixmapPtr pBackBuffer;
+ Bool clear;
+ GCPtr pGC;
+ xRectangle clearRect;
+ Bool ret;
+
+ /* 1. Unwrap the member routine. */
+ pScreen = pWin->drawable.pScreen;
+ pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+ pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
+
+ /* 2. Do any work necessary before the member routine is called.
+ *
+ * In this case we do not need to do anything.
+ */
+
+ /* 3. Call the member routine, saving its result if necessary. */
+ ret = (*pScreen->PositionWindow)(pWin, x, y);
+
+ /* 4. Rewrap the member routine, restoring the wrapper value first in case
+ * the wrapper (or something that it wrapped) change this value.
+ */
+ pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = FFBDbePositionWindow;
+
+ /* 5. Do any work necessary after the member routine has been called. */
+ if (!(pDbeWindowPriv = DBE_WINDOW_PRIV(pWin)))
+ return ret;
+
+ if (pDbeWindowPriv->width == pWin->drawable.width &&
+ pDbeWindowPriv->height == pWin->drawable.height)
+ return ret;
+
+ width = pWin->drawable.width;
+ height = pWin->drawable.height;
+
+ dx = pWin->drawable.x - pDbeWindowPriv->x;
+ dy = pWin->drawable.y - pDbeWindowPriv->y;
+ dw = width - pDbeWindowPriv->width;
+ dh = height - pDbeWindowPriv->height;
+
+ GravityTranslate (0, 0, -dx, -dy, dw, dh, pWin->bitGravity, &destx, &desty);
+
+ clear = ((pDbeWindowPriv->width < (unsigned short)width ) ||
+ (pDbeWindowPriv->height < (unsigned short)height) ||
+ (pWin->bitGravity == ForgetGravity));
+
+ sourcex = 0;
+ sourcey = 0;
+ savewidth = pDbeWindowPriv->width;
+ saveheight = pDbeWindowPriv->height;
+
+ /* Clip rectangle to source and destination. */
+ if (destx < 0) {
+ savewidth += destx;
+ sourcex -= destx;
+ destx = 0;
+ }
+
+ if (destx + savewidth > width)
+ savewidth = width - destx;
+
+ if (desty < 0) {
+ saveheight += desty;
+ sourcey -= desty;
+ desty = 0;
+ }
+
+ if (desty + saveheight > height)
+ saveheight = height - desty;
+
+ pDbeWindowPriv->width = width;
+ pDbeWindowPriv->height = height;
+ pDbeWindowPriv->x = pWin->drawable.x;
+ pDbeWindowPriv->y = pWin->drawable.y;
+
+ pGC = GetScratchGC (pWin->drawable.depth, pScreen);
+
+ if (clear) {
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width = width;
+ clearRect.height = height;
+ } else {
+ clear = FALSE;
+ }
+ }
+
+ pDbeWindowPrivPriv = FFB_DBE_WINDOW_PRIV_PRIV(pDbeWindowPriv);
+ if (pDbeWindowPrivPriv->HwAccelerated != 0) {
+ /* If we're hw accelerating, things are much easier. */
+ ValidateGC(&pWin->drawable, pGC);
+ FFBDbeUpdateWidPlane(pWin, pGC);
+ if (clear) {
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ unsigned int fbc, orig_fbc;
+
+ ValidateGC(&pWin->drawable, pGC);
+ (*pGC->ops->PolyFillRect)(&pWin->drawable, pGC,
+ 1, &clearRect);
+
+ orig_fbc = fbc = pFfbPrivWin->fbc_base;
+ fbc &= ~(FFB_FBC_WB_MASK);
+ if (pDbeWindowPrivPriv->HwCurrentBuf == 0)
+ fbc |= FFB_FBC_WB_B;
+ else
+ fbc |= FFB_FBC_WB_A;
+
+ pFfbPrivWin->fbc_base = fbc;
+
+ if ((*pDbeScreenPriv->SetupBackgroundPainter)(pWin, pGC)) {
+ ValidateGC(&pWin->drawable, pGC);
+ clearRect.x = 0;
+ clearRect.y = 0;
+ clearRect.width = width;
+ clearRect.height = height;
+ (*pGC->ops->PolyFillRect)(&pWin->drawable, pGC,
+ 1, &clearRect);
+ }
+
+ pFfbPrivWin->fbc_base = orig_fbc;
+ }
+
+ FreeScratchGC(pGC);
+ } else {
+ /* Create DBE buffer pixmaps equal to size of resized window. */
+ pFrontBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
+ pWin->drawable.depth);
+
+ pBackBuffer = (*pScreen->CreatePixmap)(pScreen, width, height,
+ pWin->drawable.depth);
+
+ if (!pFrontBuffer || !pBackBuffer) {
+ /* We failed at creating 1 or 2 of the pixmaps. */
+ if (pFrontBuffer)
+ (*pScreen->DestroyPixmap)(pFrontBuffer);
+ if (pBackBuffer)
+ (*pScreen->DestroyPixmap)(pBackBuffer);
+
+ /* Destroy all buffers for this window. */
+ while (pDbeWindowPriv) {
+ /* DbeWindowPrivDelete() will free the window private
+ * if there no more buffer IDs associated with this
+ * window.
+ */
+ FreeResource(pDbeWindowPriv->IDs[0], RT_NONE);
+ pDbeWindowPriv = DBE_WINDOW_PRIV(pWin);
+ }
+ FreeScratchGC(pGC);
+ return FALSE;
+ } else {
+ /* Clear out the new DBE buffer pixmaps. */
+ ValidateGC((DrawablePtr)pFrontBuffer, pGC);
+
+ /* I suppose this could avoid quite a bit of work if
+ * it computed the minimal area required.
+ */
+ if (clear) {
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pFrontBuffer, pGC, 1,
+ &clearRect);
+ (*pGC->ops->PolyFillRect)((DrawablePtr)pBackBuffer , pGC, 1,
+ &clearRect);
+ }
+
+ /* Copy the contents of the old DBE pixmaps to the new pixmaps. */
+ if (pWin->bitGravity != ForgetGravity) {
+ (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pFrontBuffer,
+ (DrawablePtr)pFrontBuffer, pGC,
+ sourcex, sourcey,
+ savewidth, saveheight,
+ destx, desty);
+ (*pGC->ops->CopyArea)((DrawablePtr)pDbeWindowPrivPriv->pBackBuffer,
+ (DrawablePtr)pBackBuffer, pGC,
+ sourcex, sourcey,
+ savewidth, saveheight, destx, desty);
+ }
+
+ /* Destroy the old pixmaps, and point the DBE window priv to the new
+ * pixmaps.
+ */
+ (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pFrontBuffer);
+ (*pScreen->DestroyPixmap)(pDbeWindowPrivPriv->pBackBuffer);
+
+ pDbeWindowPrivPriv->pFrontBuffer = pFrontBuffer;
+ pDbeWindowPrivPriv->pBackBuffer = pBackBuffer;
+
+ /* Make sure all XID are associated with the new back pixmap. */
+ FFBDbeAliasBuffers(pDbeWindowPriv);
+
+ FreeScratchGC(pGC);
+ }
+ }
+
+ return ret;
+}
+
+static void
+FFBDbeResetProc(ScreenPtr pScreen)
+{
+ DbeScreenPrivPtr pDbeScreenPriv = DBE_SCREEN_PRIV(pScreen);
+
+ /* Unwrap wrappers */
+ pScreen->PositionWindow = pDbeScreenPriv->PositionWindow;
+}
+
+static Bool
+FFBDbeInit(ScreenPtr pScreen, DbeScreenPrivPtr pDbeScreenPriv)
+{
+ ScrnInfoPtr pScrn;
+ FFBPtr pFfb;
+
+ pScrn = xf86Screens[pScreen->myNum];
+ pFfb = GET_FFB_FROM_SCRN(pScrn);
+ xf86Msg(X_INFO, "%s: Setting up double-buffer acceleration.\n",
+ pFfb->psdp->device);
+
+ /* Copy resource types created by DIX */
+ dbeDrawableResType = pDbeScreenPriv->dbeDrawableResType;
+ dbeWindowPrivResType = pDbeScreenPriv->dbeWindowPrivResType;
+
+ /* Copy private indices created by DIX */
+ dbeScreenPrivIndex = pDbeScreenPriv->dbeScreenPrivIndex;
+ dbeWindowPrivIndex = pDbeScreenPriv->dbeWindowPrivIndex;
+
+ /* Reset the window priv privs if generations do not match. */
+ if (FFBDbePrivPrivGeneration != serverGeneration) {
+ /* Allocate the window priv priv. */
+ FFBDbeWindowPrivPrivIndex = (*pDbeScreenPriv->AllocWinPrivPrivIndex)();
+
+ if (!(*pDbeScreenPriv->AllocWinPrivPriv)(pScreen,
+ FFBDbeWindowPrivPrivIndex,
+ sizeof(FFBDbeWindowPrivPrivRec)))
+ return FALSE;
+
+ /* Make sure we only do this code once. */
+ FFBDbePrivPrivGeneration = serverGeneration;
+ }
+
+ /* Wrap functions. */
+ pDbeScreenPriv->PositionWindow = pScreen->PositionWindow;
+ pScreen->PositionWindow = FFBDbePositionWindow;
+
+ /* Initialize the per-screen DBE function pointers. */
+ pDbeScreenPriv->GetVisualInfo = FFBDbeGetVisualInfo;
+ pDbeScreenPriv->AllocBackBufferName = FFBDbeAllocBackBufferName;
+ pDbeScreenPriv->SwapBuffers = FFBDbeSwapBuffers;
+ pDbeScreenPriv->BeginIdiom = 0;
+ pDbeScreenPriv->EndIdiom = 0;
+ pDbeScreenPriv->ResetProc = FFBDbeResetProc;
+ pDbeScreenPriv->WinPrivDelete = FFBDbeWinPrivDelete;
+
+ /* The FFB implementation doesn't need buffer validation. */
+ pDbeScreenPriv->ValidateBuffer = (void (*)())NoopDDA;
+
+ return TRUE;
+}
+
+extern Bool DbeRegisterFunction(ScreenPtr pScreen, Bool (*funct)(ScreenPtr, DbeScreenPrivPtr));
+
+Bool
+FFBDbePreInit(ScreenPtr pScreen)
+{
+ return DbeRegisterFunction(pScreen, FFBDbeInit);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_ddc.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_ddc.c
new file mode 100644
index 000000000..6d1a312d5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_ddc.c
@@ -0,0 +1,195 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - DDC support.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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/drivers/sunffb/ffb_ddc.c,v 1.1 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+
+#include "ffb_dac.h"
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+#include "xf86DDC.h"
+
+/* XXX This needs a lot more work. Only an attempt at the PAC2 version
+ * XXX is below, and that is untested. The BT498 manual is unclear about
+ * XXX several details and I must figure them out by trial and error.
+ */
+
+/* Wait for the next VSYNC. */
+static void
+WaitForVSYNC(ffb_dacPtr dac)
+{
+ unsigned int vsap = DACCFG_READ(dac, FFBDAC_CFG_VSAP);
+ unsigned int vcnt;
+
+ vcnt = DACCFG_READ(dac, FFBDAC_CFG_TGVC);
+ while (vcnt > vsap)
+ vcnt = DACCFG_READ(dac, FFBDAC_CFG_TGVC);
+ while (vcnt <= vsap)
+ vcnt = DACCFG_READ(dac, FFBDAC_CFG_TGVC);
+
+}
+
+/* The manual seems to imply this is needed, but it's really clumsy
+ * so we can test if it really is a requirement with this.
+ */
+#define MDATA_NEEDS_BLANK
+
+/* DDC1/DDC2 support */
+static unsigned int
+FFBDacDdc1Read(ScrnInfoPtr pScrn)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int val;
+#ifdef MDATA_NEEDS_BLANK
+ unsigned int uctrl;
+#endif
+
+#ifdef MDATA_NEEDS_BLANK
+ /* Force a blank of the screen. */
+ uctrl = DACCFG_READ(dac, FFBDAC_CFG_UCTRL);
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL,
+ (uctrl | FFBDAC_UCTRL_ABLANK));
+#endif
+
+ /* Tristate SCL pin. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_MPDATA,
+ FFBDAC_CFG_MPDATA_SCL);
+
+ /* Pause until VSYNC is hit. */
+ WaitForVSYNC(dac);
+
+ /* Read the sense line to see what the monitor is driving
+ * it at.
+ */
+ val = DACCFG_READ(dac, FFBDAC_CFG_MPSENSE);
+ val = (val & FFBDAC_CFG_MPSENSE_SCL) ? 1 : 0;
+
+ /* Stop tristating the SCL pin. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_MPDATA, 0);
+
+#ifdef MDATA_NEEDS_BLANK
+ /* Restore UCTRL to unblank the screen. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL, uctrl);
+#endif
+
+ /* Return the result and we're done. */
+ return val;
+}
+
+static void
+FFBI2CGetBits(I2CBusPtr b, int *clock, int *data)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(xf86Screens[b->scrnIndex]);
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int val;
+#ifdef MDATA_NEEDS_BLANK
+ unsigned int uctrl;
+#endif
+
+#ifdef MDATA_NEEDS_BLANK
+ /* Force a blank of the screen. */
+ uctrl = DACCFG_READ(dac, FFBDAC_CFG_UCTRL);
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL,
+ (uctrl | FFBDAC_UCTRL_ABLANK));
+#endif
+
+ /* Tristate SCL+SDA pins. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_MPDATA,
+ (FFBDAC_CFG_MPDATA_SCL | FFBDAC_CFG_MPDATA_SDA));
+
+ /* Read the sense line to see what the monitor is driving
+ * them at.
+ */
+ val = DACCFG_READ(dac, FFBDAC_CFG_MPSENSE);
+ *clock = (val & FFBDAC_CFG_MPSENSE_SCL) ? 1 : 0;
+ *data = (val & FFBDAC_CFG_MPSENSE_SDA) ? 1 : 0;
+
+ /* Stop tristating the SCL pin. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_MPDATA, 0);
+
+#ifdef MDATA_NEEDS_BLANK
+ /* Restore UCTRL to unblank the screen. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL, uctrl);
+#endif
+}
+
+static void
+FFBI2CPutBits(I2CBusPtr b, int clock, int data)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(xf86Screens[b->scrnIndex]);
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int val;
+#ifdef MDATA_NEEDS_BLANK
+ unsigned int uctrl;
+#endif
+
+ val = 0;
+ if (clock)
+ val |= FFBDAC_CFG_MPDATA_SCL;
+ if (data)
+ val |= FFBDAC_CFG_MPDATA_SDA;
+
+#ifdef MDATA_NEEDS_BLANK
+ /* Force a blank of the screen. */
+ uctrl = DACCFG_READ(dac, FFBDAC_CFG_UCTRL);
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL,
+ (uctrl | FFBDAC_UCTRL_ABLANK));
+#endif
+
+ /* Tristate requested pins. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_MPDATA, val);
+
+#ifdef MDATA_NEEDS_BLANK
+ /* Restore UCTRL to unblank the screen. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_UCTRL, uctrl);
+#endif
+}
+
+Bool
+FFBi2cInit(ScrnInfoPtr pScrn)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ I2CBusPtr I2CPtr;
+
+ I2CPtr = xf86CreateI2CBusRec();
+ if (!I2CPtr)
+ return FALSE;
+
+ pFfb->I2C = I2CPtr;
+
+ I2CPtr->BusName = "DDC";
+ I2CPtr->scrnIndex = pScrn->scrnIndex;
+ I2CPtr->I2CPutBits = FFBI2CPutBits;
+ I2CPtr->I2CGetBits = FFBI2CGetBits;
+ I2CPtr->AcknTimeout = 5;
+
+ if (!xf86I2CBusInit(I2CPtr))
+ return FALSE;
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c
new file mode 100644
index 000000000..5729c5e31
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c
@@ -0,0 +1,280 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - DGA support.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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/drivers/sunffb/ffb_dga.c,v 1.1 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "dgaproc.h"
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+#include "ffb_loops.h"
+
+static Bool FFB_OpenFramebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem,
+ int *size, int *offset, int *extra);
+static void FFB_CloseFramebuffer(ScrnInfoPtr pScrn);
+static Bool FFB_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode);
+static void FFB_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags);
+static int FFB_GetViewport(ScrnInfoPtr pScrn);
+static void FFB_Flush(ScrnInfoPtr pScrn);
+
+/* Have to disable all this stuff for now until I figure out where
+ * we should get the WID values from... ho hum... -DaveM
+ */
+#if 0
+static void FFB_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color);
+
+#ifdef USE_VIS
+static void FFB_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h,
+ int dstx, int dsty);
+#else
+#define FFB_BlitRect NULL
+#endif
+#else
+#define FFB_FillRect NULL
+#define FFB_BlitRect NULL
+#endif
+
+static DGAFunctionRec FFB_DGAFuncs = {
+ FFB_OpenFramebuffer,
+ FFB_CloseFramebuffer,
+ FFB_SetMode,
+ FFB_SetViewport,
+ FFB_GetViewport,
+ FFB_Flush,
+ FFB_FillRect,
+ FFB_BlitRect,
+ NULL
+};
+
+void FFB_InitDGA(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ FFBPtr pFfb;
+ DGAModePtr mode;
+ Bool result;
+
+ pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ mode = xnfcalloc(sizeof(DGAModeRec), 1);
+ if (!mode) {
+ xf86Msg(X_WARNING, "%s: DGA init failed, cannot alloc DGAMode.\n",
+ pFfb->psdp->device);
+ return;
+ }
+
+ mode->num = 0;
+ mode->mode = pScrn->modes;
+
+ /* Hmmm, what does concurrent access really mean? -DaveM */
+ mode->flags = (DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE | DGA_FILL_RECT);
+
+#ifdef USE_VIS
+ mode->flags |= DGA_BLIT_RECT;
+#endif
+
+ mode->imageWidth = 2048;
+ mode->imageHeight = 2048;
+ mode->pixmapWidth = 2048;
+ mode->pixmapHeight = 2048;
+
+ /* XXX I would imagine that this value states how many bytes
+ * XXX you add to advance exactly one full horizontal line in
+ * XXX the framebuffer addressing, but the way we set the pScrn
+ * XXX mode values do not match that definition.
+ * XXX
+ * XXX Ask Jakub what is going on here. -DaveM
+ */
+#if 1
+ mode->bytesPerScanline = pScrn->modes->HDisplay * 4;
+#else
+ mode->bytesPerScanline = (2048 * 4);
+#endif
+
+ mode->byteOrder = pScrn->imageByteOrder;
+ mode->depth = 32;
+ mode->bitsPerPixel = 32;
+ mode->red_mask = 0xff;
+ mode->green_mask = 0xff00;
+ mode->blue_mask = 0xff0000;
+ mode->visualClass = TrueColor;
+ mode->viewportWidth = pScrn->modes->HDisplay;
+ mode->viewportHeight = pScrn->modes->VDisplay;
+
+ /* Do these values even matter if we do not support
+ * viewports? -DaveM
+ */
+ mode->xViewportStep = 0;
+ mode->yViewportStep = 0;
+ mode->maxViewportX = 0;
+ mode->maxViewportY = 0;
+
+ mode->viewportFlags = 0;
+ mode->offset = 0;
+
+ result = DGAInit(pScreen, &FFB_DGAFuncs, mode, 1);
+ if (result == FALSE) {
+ xf86Msg(X_WARNING,
+ "%s: DGA init failed, DGAInit returns FALSE.\n",
+ pFfb->psdp->device);
+ } else {
+ xf86Msg(X_INFO, "%s: DGA support initialized.\n",
+ pFfb->psdp->device);
+ }
+}
+
+static Bool FFB_OpenFramebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem,
+ int *size, int *offset, int *extra)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ *name = &pFfb->psdp->device;
+
+ /* We give the user the dumb frame buffer. */
+ *mem = (unsigned char *)FFB_DFB24_VOFF;
+ *size = 0x1000000;
+ *offset = 0;
+ *extra = 0;
+
+ return TRUE;
+}
+
+static void FFB_CloseFramebuffer(ScrnInfoPtr pScrn)
+{
+}
+
+static Bool FFB_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
+{
+ /* Nothing to do, we currently only support one mode
+ * and we are always in it.
+ */
+ return TRUE;
+}
+
+static void FFB_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
+{
+ /* We don't support viewports, so... */
+}
+
+static int FFB_GetViewport(ScrnInfoPtr pScrn)
+{
+ /* No viewports, none pending... */
+ return 0;
+}
+
+static void FFB_Flush(ScrnInfoPtr pScrn)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBWait(pFfb, ffb);
+}
+
+#if 0
+
+extern void CreatorFillBoxSolid (DrawablePtr pDrawable, int nBox,
+ BoxPtr pBox, unsigned long pixel);
+
+static void FFB_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color)
+{
+ DrawableRec draw;
+ BoxRec box;
+
+ draw.pScreen = pScrn->pScreen;
+ box.x1 = x;
+ box.y1 = y;
+ box.x2 = x + w;
+ box.y2 = y + h;
+
+ CreatorFillBoxSolid(&draw, 1, &box, color);
+}
+
+#ifdef USE_VIS
+extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long);
+extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long);
+
+static void FFB_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy,
+ int w, int h, int dstx, int dsty)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ if (!pFfb->disable_vscroll &&
+ dstx == srcx &&
+ dsty != dsty) {
+ FFB_WRITE_ATTRIBUTES_VSCROLL(pFfb, 0x00ffffff);
+ FFBFifo(pFfb, 7);
+ ffb->drawop = FFB_DRAWOP_VSCROLL;
+ FFB_WRITE64(&ffb->by, srcy, srcx);
+ FFB_WRITE64_2(&ffb->dy, dsty, dstx);
+ FFB_WRITE64_3(&ffb->bh, h, w);
+ pFfb->rp_active = 1;
+ } else {
+ unsigned char *base = (unsigned char *)pFfb->fb;
+ int use_prefetch = pFfb->use_blkread_prefetch;
+
+ FFB_WRITE_ATTRIBUTES_SFB_VAR(pFfb, 0x00ffffff, GXcopy);
+ FFBWait(pFfb, ffb);
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ ffb->mer = FFB_MER_EIRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, ffb);
+ }
+ if (srcx < dstx) {
+ VISmoveImageRL((base +
+ ((srcy + h - 1) * (2048 * 4)) +
+ (srcx * (32 / 8))),
+ (base +
+ ((dsty + h - 1) * (2048 * 4)) +
+ (dstx * (32 / 8))),
+ (w * (32 / 8)),
+ h,
+ -(2048 * 4), - (2048 * 4));
+ } else {
+ VISmoveImageLR((base +
+ ((srcy + h - 1) * (2048 * 4)) +
+ (srcx * (32 / 8))),
+ (base +
+ ((dsty + h - 1) * (2048 * 4)) +
+ (dstx * (32 / 8))),
+ (w * (32 / 8)),
+ h,
+ -(2048 * 4), - (2048 * 4));
+ }
+ if (use_prefetch) {
+ FFBFifo(pFfb, 1);
+ ffb->mer = FFB_MER_DRA;
+ pFfb->rp_active = 1;
+ FFBWait(pFfb, pFfb->regs);
+ }
+ }
+}
+#endif
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dri.c
new file mode 100644
index 000000000..b10dd018d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dri.c
@@ -0,0 +1,488 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dri.c,v 1.4 2000/06/23 23:43:44 alanh Exp $
+ * Acceleration for the Creator and Creator3D framebuffer - DRI/DRM support.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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.
+ *
+ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Priv.h"
+
+#include "xf86PciInfo.h"
+#include "xf86Pci.h"
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb32.h"
+
+#include "miline.h"
+
+#include "GL/glxtokens.h"
+
+#include "xf86drm.h"
+#include "sarea.h"
+#define _XF86DRI_SERVER_
+#include "xf86dri.h"
+#include "dri.h"
+#include "dristruct.h"
+
+#include "GL/glxint.h"
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_fifo.h"
+#include "ffb_rcache.h"
+
+static char FFBKernelDriverName[] = "ffb";
+static char FFBClientDriverName[] = "ffb";
+
+/* Forward declarations. */
+static Bool FFBDRICreateContext(ScreenPtr, VisualPtr, drmContext,
+ void *, DRIContextType);
+static void FFBDRIDestroyContext(ScreenPtr, drmContext, DRIContextType);
+
+static void FFBDRIInitBuffers(WindowPtr, RegionPtr, CARD32);
+static void FFBDRIMoveBuffers(WindowPtr, DDXPointRec, RegionPtr, CARD32);
+
+static void FFBDRISetDrawableIndex(WindowPtr, CARD32);
+
+/* XXX Why isn't this in a header somewhere? XXX */
+extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
+ void **configprivs);
+
+static Bool
+FFBDRIInitVisualConfigs(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ __GLXvisualConfig *pConfigs;
+ FFBConfigPrivPtr pFfbConfigs;
+ FFBConfigPrivPtr *pFfbConfigPtrs;
+
+ pConfigs = (__GLXvisualConfig *)
+ xnfcalloc(sizeof(__GLXvisualConfig), 1);
+ if (!pConfigs)
+ return FALSE;
+
+ pFfbConfigs = (FFBConfigPrivPtr)
+ xnfcalloc(sizeof(FFBConfigPrivRec), 1);
+ if (!pFfbConfigs) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+
+ pFfbConfigPtrs = (FFBConfigPrivPtr *)
+ xnfcalloc(sizeof(FFBConfigPrivPtr), 1);
+ if (!pFfbConfigPtrs) {
+ xfree(pConfigs);
+ xfree(pFfbConfigs);
+ return FALSE;
+ }
+
+ pFfbConfigPtrs[0] = &pFfbConfigs[0];
+
+ pConfigs->vid = -1;
+ pConfigs->class = -1;
+ pConfigs->rgba = TRUE;
+ pConfigs->redSize = 8;
+ pConfigs->greenSize = 8;
+ pConfigs->blueSize = 8;
+ pConfigs->alphaSize = 0;
+ pConfigs->redMask = 0x000000ff;
+ pConfigs->greenMask = 0x0000ff00;
+ pConfigs->blueMask = 0x00ff0000;
+ pConfigs->alphaMask = 0;
+ pConfigs->accumRedSize = 0;
+ pConfigs->accumGreenSize = 0;
+ pConfigs->accumBlueSize = 0;
+ pConfigs->accumAlphaSize = 0;
+ pConfigs->doubleBuffer = TRUE;
+ pConfigs->stereo = FALSE;
+ pConfigs->bufferSize = 32;
+ pConfigs->depthSize = 16;
+ pConfigs->stencilSize = 0;
+ pConfigs->auxBuffers = 0;
+ pConfigs->level = 0;
+ pConfigs->visualRating = 0;
+ pConfigs->transparentPixel = 0;
+ pConfigs->transparentRed = 0;
+ pConfigs->transparentGreen = 0;
+ pConfigs->transparentBlue = 0;
+ pConfigs->transparentAlpha = 0;
+ pConfigs->transparentIndex = 0;
+
+ pFfb->numVisualConfigs = 1;
+ pFfb->pVisualConfigs = pConfigs;
+ pFfb->pVisualConfigsPriv = pFfbConfigs;
+
+ GlxSetVisualConfigs(1, pConfigs, (void **)pFfbConfigPtrs);
+
+ return TRUE;
+}
+
+static void
+init_ffb_sarea(FFBPtr pFfb, ffb_dri_state_t *pFfbSarea)
+{
+ int i;
+
+ pFfbSarea->flags = 0;
+
+ switch (pFfb->ffb_type) {
+ case ffb2_prototype:
+ case ffb2_vertical:
+ case ffb2_vertical_plus:
+ case ffb2_horizontal:
+ case ffb2_horizontal_plus:
+ pFfbSarea->flags |= FFB_DRI_FFB2;
+ break;
+
+ default:
+ break;
+ };
+
+ if (pFfb->ffb_type == ffb2_vertical_plus ||
+ pFfb->ffb_type == ffb2_horizontal_plus)
+ pFfbSarea->flags |= FFB_DRI_FFB2PLUS;
+
+ if (pFfb->dac_info.flags & FFB_DAC_PAC1)
+ pFfbSarea->flags |= FFB_DRI_PAC1;
+
+ if (pFfb->dac_info.flags & FFB_DAC_PAC2)
+ pFfbSarea->flags |= FFB_DRI_PAC2;
+
+ for (i = 0; i < FFB_DRI_NWIDS; i++)
+ pFfbSarea->wid_table[i] = 0;
+}
+
+#define FFB_DFB24_POFF 0x02000000UL
+#define FFB_DFB24_SIZE 0x01000000UL
+
+#define FFB_FBC_REGS_POFF 0x00600000UL
+#define FFB_FBC_REGS_SIZE 0x00002000UL
+
+#define FFB_DAC_POFF 0x00400000UL
+#define FFB_DAC_SIZE 0x00002000UL
+
+#define FFB_SFB8R_POFF 0x04000000UL
+#define FFB_SFB8R_SIZE 0x00400000UL
+
+#define FFB_SFB32_POFF 0x05000000UL
+#define FFB_SFB32_SIZE 0x01000000UL
+
+#define FFB_SFB64_POFF 0x06000000UL
+#define FFB_SFB64_SIZE 0x02000000UL
+
+Bool
+FFBDRIScreenInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ DRIInfoPtr pDRIInfo;
+ FFBDRIPtr pFfbDRI;
+
+ /* Check that the GLX, DRI, and DRM modules have been loaded by testing
+ * for canonical symbols in each module.
+ */
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs"))
+ return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit"))
+ return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable"))
+ return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "FFBDRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+
+ pDRIInfo = DRICreateInfoRec();
+ if (pDRIInfo == NULL)
+ return FALSE;
+
+ pFfb->pDRIInfo = pDRIInfo;
+
+ pDRIInfo->drmDriverName = FFBKernelDriverName;
+ pDRIInfo->clientDriverName = FFBClientDriverName;
+
+ pDRIInfo->ddxDriverMajorVersion = 0;
+ pDRIInfo->ddxDriverMinorVersion = 0;
+ pDRIInfo->ddxDriverPatchVersion = 1;
+
+ pDRIInfo->busIdString = xalloc(64); /* Freed in DRIDestroyInfoRec */
+ sprintf(pDRIInfo->busIdString, "SBUS:%s", pFfb->psdp->device);
+
+ /* Dumb rendering port for now... */
+ pDRIInfo->frameBufferPhysicalAddress = FFB_DFB24_POFF;
+ pDRIInfo->frameBufferSize = FFB_DFB24_SIZE;
+ pDRIInfo->frameBufferStride = (2048 * 4);
+
+ /* XXX */
+ pDRIInfo->ddxDrawableTableEntry = 15;
+ pDRIInfo->maxDrawableTableEntry = 15;
+ pDRIInfo->SAREASize = (SAREA_MAX + (0x2000 - 1)) & ~(0x2000 - 1);
+
+ pFfbDRI = (FFBDRIPtr) xnfcalloc(sizeof(FFBDRIRec), 1);
+ if (pFfbDRI == NULL) {
+ DRIDestroyInfoRec(pFfb->pDRIInfo);
+ return FALSE;
+ }
+
+ pDRIInfo->devPrivate = pFfbDRI;
+ pDRIInfo->devPrivateSize = sizeof(*pFfbDRI);
+ pDRIInfo->contextSize = 0; /* kernel does ctx swaps */
+
+ pDRIInfo->CreateContext = FFBDRICreateContext;
+ pDRIInfo->DestroyContext = FFBDRIDestroyContext;
+ pDRIInfo->InitBuffers = FFBDRIInitBuffers;
+ pDRIInfo->MoveBuffers = FFBDRIMoveBuffers;
+ pDRIInfo->SetDrawableIndex = FFBDRISetDrawableIndex;
+
+ /* Our InitBuffers depends heavily on this setting. */
+ pDRIInfo->bufferRequests = DRI_3D_WINDOWS_ONLY;
+
+ if (!DRIScreenInit(pScreen, pDRIInfo, &(pFfb->drmSubFD))) {
+ DRIDestroyInfoRec(pFfb->pDRIInfo);
+ xfree(pFfbDRI);
+ return FALSE;
+ }
+
+ pFfb->pFfbSarea = DRIGetSAREAPrivate(pScreen);
+ init_ffb_sarea(pFfb, pFfb->pFfbSarea);
+
+ /* Setup device specific direct rendering memory maps. */
+ if (drmAddMap(pFfb->drmSubFD,
+ FFB_FBC_REGS_POFF, FFB_FBC_REGS_SIZE,
+ DRM_REGISTERS, 0, &pFfbDRI->hFbcRegs) < 0) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ pFfbDRI->sFbcRegs = FFB_FBC_REGS_SIZE;
+ pFfbDRI->mFbcRegs = 0;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] FBC Register handle = 0x%08x\n",
+ pFfbDRI->hFbcRegs);
+
+ if (drmAddMap(pFfb->drmSubFD,
+ FFB_DAC_POFF, FFB_DAC_SIZE,
+ DRM_REGISTERS, 0, &pFfbDRI->hDacRegs) < 0) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ pFfbDRI->sDacRegs = FFB_DAC_SIZE;
+ pFfbDRI->mDacRegs = 0;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] DAC Register handle = 0x%08x\n",
+ pFfbDRI->hDacRegs);
+
+ /* Now add maps for the "Smart" views of the framebuffer. */
+ if (drmAddMap(pFfb->drmSubFD,
+ FFB_SFB8R_POFF, FFB_SFB8R_SIZE,
+ DRM_REGISTERS, 0, &pFfbDRI->hSfb8r) < 0) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ pFfbDRI->sSfb8r = FFB_SFB8R_SIZE;
+ pFfbDRI->mSfb8r = 0;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] SFB8R handle = 0x%08x\n",
+ pFfbDRI->hSfb8r);
+
+ if (drmAddMap(pFfb->drmSubFD,
+ FFB_SFB32_POFF, FFB_SFB32_SIZE,
+ DRM_REGISTERS, 0, &pFfbDRI->hSfb32) < 0) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ pFfbDRI->sSfb32 = FFB_SFB32_SIZE;
+ pFfbDRI->mSfb32 = 0;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] SFB32 handle = 0x%08x\n",
+ pFfbDRI->hSfb32);
+
+ if (drmAddMap(pFfb->drmSubFD,
+ FFB_SFB64_POFF, FFB_SFB64_SIZE,
+ DRM_REGISTERS, 0, &pFfbDRI->hSfb64) < 0) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+ pFfbDRI->sSfb64 = FFB_SFB64_SIZE;
+ pFfbDRI->mSfb64 = 0;
+
+ xf86DrvMsg(pScreen->myNum, X_INFO,
+ "[drm] SFB64 handle = 0x%08x\n",
+ pFfbDRI->hSfb64);
+
+ /* Setup visual configurations. */
+ if (!FFBDRIInitVisualConfigs(pScreen)) {
+ DRICloseScreen(pScreen);
+ return FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "[drm] Visual configs initialized\n");
+
+ return TRUE;
+}
+
+void
+FFBDRICloseScreen(ScreenPtr pScreen)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+
+ DRICloseScreen(pScreen);
+
+ if (pFfb->pDRIInfo) {
+ DRIInfoPtr pDRIInfo = pFfb->pDRIInfo;
+
+ if (pDRIInfo->devPrivate)
+ xfree(pDRIInfo->devPrivate);
+ DRIDestroyInfoRec(pDRIInfo);
+ pFfb->pDRIInfo = NULL;
+ }
+
+ if (pFfb->pVisualConfigs) {
+ xfree(pFfb->pVisualConfigs);
+ pFfb->pVisualConfigs = NULL;
+ }
+ if (pFfb->pVisualConfigsPriv) {
+ xfree(pFfb->pVisualConfigsPriv);
+ pFfb->pVisualConfigsPriv = NULL;
+ }
+}
+
+static Bool
+FFBDRICreateContext(ScreenPtr pScreen, VisualPtr visual, drmContext hwContext,
+ void *pVisualConfigPriv, DRIContextType context)
+{
+ /* Nothing to do... */
+ return TRUE;
+}
+
+static void
+FFBDRIDestroyContext(ScreenPtr pScreen, drmContext hwContext, DRIContextType context)
+{
+ /* Nothing to do... */
+}
+
+Bool
+FFBDRIFinishScreenInit(ScreenPtr pScreen)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ DRIInfoPtr pDRIInfo = pFfb->pDRIInfo;
+ FFBDRIPtr pFfbDRI = (FFBDRIPtr) pDRIInfo->devPrivate;
+ int i;
+
+ /* This belongs in the kernel. I'm sorry, the rest
+ * of the current DRI switching mechanisms just suck.
+ */
+ pDRIInfo->driverSwapMethod = DRI_KERNEL_SWAP;
+
+ /* Copy over the fast/page filling parameters now that
+ * acceleration has been fully setup.
+ */
+ pFfbDRI->disable_pagefill = pFfb->disable_pagefill;
+ pFfbDRI->fastfill_small_area = FFB_FFPARMS(pFfb).fastfill_small_area;
+ pFfbDRI->pagefill_small_area = FFB_FFPARMS(pFfb).pagefill_small_area;
+ pFfbDRI->fastfill_height = FFB_FFPARMS(pFfb).fastfill_height;
+ pFfbDRI->fastfill_width = FFB_FFPARMS(pFfb).fastfill_width;
+ pFfbDRI->pagefill_height = FFB_FFPARMS(pFfb).pagefill_height;
+ pFfbDRI->pagefill_width = FFB_FFPARMS(pFfb).pagefill_width;
+ for (i = 0; i < 0x800; i++)
+ pFfbDRI->Pf_AlignTab[i] = pFfb->Pf_AlignTab[i];
+
+ return DRIFinishScreenInit(pScreen);
+}
+
+static void
+FFBDRIInitBuffers(WindowPtr pWin, RegionPtr prgn, CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int fbc;
+ BoxPtr pBox;
+ int nBox;
+
+ fbc = pFfbPrivWin->fbc_base;
+ fbc = (fbc & ~FFB_FBC_WB_MASK) | FFB_FBC_WB_AB;
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_ON;
+ fbc = (fbc & ~FFB_FBC_RGBE_MASK) | FFB_FBC_RGBE_OFF;
+
+ pBox = REGION_RECTS(prgn);
+ nBox = (int) REGION_NUM_RECTS(prgn);
+ FFB_WRITE_ROP(pFfb, ffb, (FFB_ROP_NEW | (FFB_ROP_NEW << 8)));
+ FFB_WRITE_PPC(pFfb, ffb,
+ (FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST | FFB_PPC_XS_WID),
+ (FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK));
+ FFB_WRITE_PMASK(pFfb, ffb, ~0);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ FFB_WRITE_WID(pFfb, ffb, FFB_WID_WIN(pWin));
+
+ while(nBox--) {
+ register int x, y, w, h;
+
+ x = pBox->x1;
+ y = pBox->y1;
+ w = (pBox->x2 - x);
+ h = (pBox->y2 - y);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, h, w);
+ pBox++;
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+static void
+FFBDRIMoveBuffers(WindowPtr pParent, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc, CARD32 index)
+{
+}
+
+static void
+FFBDRISetDrawableIndex(WindowPtr pWin, CARD32 index)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pScreen);
+ CreatorPrivWinPtr pFfbPrivWin = CreatorGetWindowPrivate(pWin);
+ unsigned int wid;
+
+ if (FFBWidIsShared(pFfb, pFfbPrivWin->wid)) {
+ wid = FFBWidUnshare(pFfb, pFfbPrivWin->wid);
+ if (wid == (unsigned int) -1)
+ return;
+
+ ErrorF("FFB: Allocated WID %x for DRI window.\n", wid);
+ pFfbPrivWin->wid = wid;
+
+ /* Now update the SAREA. */
+ pFfb->pFfbSarea->wid_table[index] = wid;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_drishare.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_drishare.h
new file mode 100644
index 000000000..501dd5b21
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_drishare.h
@@ -0,0 +1,53 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_drishare.h,v 1.2 2000/06/21 00:47:37 dawes Exp $ */
+
+#ifndef _FFB_DRISHARE_H
+#define _FFB_DRISHARE_H
+
+typedef struct ffb_dri_state {
+ int flags;
+#define FFB_DRI_FFB2 0x00000001
+#define FFB_DRI_FFB2PLUS 0x00000002
+#define FFB_DRI_PAC1 0x00000004
+#define FFB_DRI_PAC2 0x00000008
+
+ /* Indexed by DRI drawable id. */
+#define FFB_DRI_NWIDS 64
+ unsigned int wid_table[FFB_DRI_NWIDS];
+} ffb_dri_state_t;
+
+#define FFB_DRISHARE(SAREA) \
+ ((ffb_dri_state_t *) (((char *)(SAREA)) + sizeof(XF86DRISAREARec)))
+
+typedef struct {
+ drmHandle hFbcRegs;
+ drmSize sFbcRegs;
+ drmAddress mFbcRegs;
+
+ drmHandle hDacRegs;
+ drmSize sDacRegs;
+ drmAddress mDacRegs;
+
+ drmHandle hSfb8r;
+ drmSize sSfb8r;
+ drmAddress mSfb8r;
+
+ drmHandle hSfb32;
+ drmSize sSfb32;
+ drmAddress mSfb32;
+
+ drmHandle hSfb64;
+ drmSize sSfb64;
+ drmAddress mSfb64;
+
+ /* Fastfill/Pagefill parameters. */
+ unsigned char disable_pagefill;
+ int fastfill_small_area;
+ int pagefill_small_area;
+ int fastfill_height;
+ int fastfill_width;
+ int pagefill_height;
+ int pagefill_width;
+ short Pf_AlignTab[0x800];
+} FFBDRIRec, *FFBDRIPtr;
+
+#endif /* !(_FFB_DRISHARE_H) */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c
new file mode 100644
index 000000000..21115a100
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c
@@ -0,0 +1,1090 @@
+/*
+ * Creator, Creator3D and Elite3D framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_driver.c,v 1.5 2000/06/30 17:15:16 dawes Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "cfb8_32wid.h"
+
+#include "xf86cmap.h"
+
+#include "ffb.h"
+
+static OptionInfoPtr FFBAvailableOptions(int chipid, int busid);
+static void FFBIdentify(int flags);
+static Bool FFBProbe(DriverPtr drv, int flags);
+static Bool FFBPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool FFBScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool FFBEnterVT(int scrnIndex, int flags);
+static void FFBLeaveVT(int scrnIndex, int flags);
+static Bool FFBCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool FFBSaveScreen(ScreenPtr pScreen, int mode);
+
+/* Required if the driver supports mode switching */
+static Bool FFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void FFBAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void FFBFreeScreen(int scrnIndex, int flags);
+static int FFBValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+/* ffb_dga.c */
+extern void FFB_InitDGA(ScreenPtr pScreen);
+
+void FFBSync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define FFB_NAME "SUNFFB"
+#define FFB_DRIVER_NAME "sunffb"
+#define FFB_MAJOR_VERSION 1
+#define FFB_MINOR_VERSION 0
+#define FFB_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNFFB = {
+ VERSION,
+ FFB_DRIVER_NAME,
+ FFBIdentify,
+ FFBProbe,
+ FFBAvailableOptions,
+ NULL,
+ 0
+};
+
+typedef enum {
+ OPTION_SW_CURSOR,
+ OPTION_HW_CURSOR,
+ OPTION_NOACCEL
+} FFBOpts;
+
+static OptionInfoRec FFBOptions[] = {
+ { OPTION_SW_CURSOR, "SWcursor", 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 }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(ffbSetup);
+
+static XF86ModuleVersionInfo sunffbVersRec =
+{
+ "sunffb",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ FFB_MAJOR_VERSION, FFB_MINOR_VERSION, FFB_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData sunffbModuleData = { &sunffbVersRec, ffbSetup, NULL };
+
+pointer
+ffbSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNFFB, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+FFBGetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an FFBRec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(FFBRec), 1);
+ return TRUE;
+}
+
+static void
+FFBFreeRec(ScrnInfoPtr pScrn)
+{
+ FFBPtr pFfb;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+FFBAvailableOptions(int chipid, int busid)
+{
+ return FFBOptions;
+}
+
+/* Mandatory */
+static void
+FFBIdentify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for Creator, Creator 3D and Elite 3D\n", FFB_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+FFBProbe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(FFB_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(FFB_NAME, SBUS_DEVICE_FFB,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = FFB_DRIVER_NAME;
+ pScrn->name = FFB_NAME;
+ pScrn->Probe = FFBProbe;
+ pScrn->PreInit = FFBPreInit;
+ pScrn->ScreenInit = FFBScreenInit;
+ pScrn->SwitchMode = FFBSwitchMode;
+ pScrn->AdjustFrame = FFBAdjustFrame;
+ pScrn->EnterVT = FFBEnterVT;
+ pScrn->LeaveVT = FFBLeaveVT;
+ pScrn->FreeScreen = FFBFreeScreen;
+ pScrn->ValidMode = FFBValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+FFBPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ FFBPtr pFfb;
+ sbusDevicePtr psdp;
+ MessageType from;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the FFBRec driverPrivate */
+ if (!FFBGetRec(pScrn))
+ return FALSE;
+
+ pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* FFB is purely UPA (but we handle it as SBUS) */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pFfb->psdp = psdp;
+ } else
+ return FALSE;
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 24, 0, 32, Support32bppFb)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 24:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ /* Collect all of the relevant option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+ /* Process the options */
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, FFBOptions);
+
+ /*
+ * This must happen after pScrn->display has been set because
+ * xf86SetWeight references it.
+ */
+ if (pScrn->depth > 8) {
+ rgb weight = {8, 8, 8};
+ rgb mask = {0xff, 0xff00, 0xff0000};
+
+ if (!xf86SetWeight(pScrn, weight, mask)) {
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* Set the bits per RGB for 8bpp mode */
+ from = X_DEFAULT;
+
+ /* determine whether we use hardware or software cursor */
+
+ pFfb->HWCursor = TRUE;
+ if (xf86GetOptValBool(FFBOptions, OPTION_HW_CURSOR, &pFfb->HWCursor))
+ from = X_CONFIG;
+ if (xf86ReturnOptValBool(FFBOptions, OPTION_SW_CURSOR, FALSE)) {
+ from = X_CONFIG;
+ pFfb->HWCursor = FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+ pFfb->HWCursor ? "HW" : "SW");
+
+ if (xf86ReturnOptValBool(FFBOptions, OPTION_NOACCEL, FALSE)) {
+ pFfb->NoAccel = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
+ }
+
+ if (xf86LoadSubModule(pScrn, "xf8_32wid") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (xf86LoadSubModule(pScrn, "cfb32") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (xf86LoadSubModule(pScrn, "cfb") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (pFfb->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (xf86LoadSubModule(pScrn, "dbe") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+
+#ifdef XF86DRI
+ if (xf86LoadSubModule(pScrn, "drm") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (xf86LoadSubModule(pScrn, "dri") == NULL) {
+ FFBFreeRec(pScrn);
+ return FALSE;
+ }
+#endif
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "FFB does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pFfb->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Determine the FFB/AFB board type. We need this information even
+ * if acceleration is disabled because the ramdac support layer needs
+ * to know what kind of FFB/AFB this is.
+ */
+static void
+FFBProbeBoardType(FFBPtr pFfb)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+ volatile unsigned int *afb_fem;
+ unsigned int val;
+
+ afb_fem = ((volatile unsigned int *) ((char *)ffb + 0x1540));
+ val = *afb_fem;
+ val &= 0x7f;
+
+ xf86Msg(X_INFO, "%s: ", pFfb->psdp->device);
+ if (val == 0x3f || val == 0x07 || val == 0x01) {
+ /* When firmware has not been loaded onto AFB we
+ * just assume it is an M6 board.
+ */
+ if (val == 0x3f || val != 0x07) {
+ pFfb->ffb_type = afb_m6;
+ ErrorF("AFB: Detected Elite3D/M6.\n");
+ } else {
+ pFfb->ffb_type = afb_m3;
+ ErrorF("AFB: Detected Elite3D/M3.\n");
+ }
+
+ /* These attributes are invariant on AFB. */
+ pFfb->has_double_res = 0;
+ pFfb->has_z_buffer = 1;
+ pFfb->has_double_buffer = 1;
+ } else {
+ unsigned char sbits;
+
+ /* Read the board strapping bits twice, because sometimes
+ * the strapping pins can get misrouted to the bus interface
+ * on the first attempt. The second attempt will get the
+ * correct value.
+ */
+ sbits = *((volatile unsigned char *)pFfb->strapping_bits);
+ sbits = *((volatile unsigned char *)pFfb->strapping_bits);
+ switch (sbits & 0x78) {
+ case (0x0 << 5) | (0x0 << 3):
+ pFfb->ffb_type = ffb1_prototype;
+ ErrorF("Detected FFB1 pre-FCS prototype, ");
+ break;
+ case (0x0 << 5) | (0x1 << 3):
+ pFfb->ffb_type = ffb1_standard;
+ ErrorF("Detected FFB1, ");
+ break;
+ case (0x0 << 5) | (0x3 << 3):
+ pFfb->ffb_type = ffb1_speedsort;
+ ErrorF("Detected FFB1-SpeedSort, ");
+ break;
+ case (0x1 << 5) | (0x0 << 3):
+ pFfb->ffb_type = ffb2_prototype;
+ ErrorF("Detected FFB2/vertical pre-FCS prototype, ");
+ break;
+ case (0x1 << 5) | (0x1 << 3):
+ pFfb->ffb_type = ffb2_vertical;
+ ErrorF("Detected FFB2/vertical, ");
+ break;
+ case (0x1 << 5) | (0x2 << 3):
+ pFfb->ffb_type = ffb2_vertical_plus;
+ ErrorF("Detected FFB2+/vertical, ");
+ break;
+ case (0x2 << 5) | (0x0 << 3):
+ pFfb->ffb_type = ffb2_horizontal;
+ ErrorF("Detected FFB2/horizontal, ");
+ break;
+ case (0x2 << 5) | (0x2 << 3):
+ pFfb->ffb_type = ffb2_horizontal;
+ ErrorF("Detected FFB2+/horizontal, ");
+ break;
+ default:
+ pFfb->ffb_type = ffb2_vertical;
+ ErrorF("Unknown boardID[%08x], assuming FFB2, ", sbits);
+ break;
+ };
+
+ if (sbits & (1 << 2)) {
+ ErrorF("DoubleRES, ");
+ pFfb->has_double_res = 1;
+ } else {
+ pFfb->has_double_res = 0;
+ }
+ if (sbits & (1 << 1)) {
+ ErrorF("Z-buffer, ");
+ pFfb->has_z_buffer = 1;
+ } else {
+ pFfb->has_z_buffer = 0;
+ }
+ if (sbits & (1 << 0)) {
+ ErrorF("Double-buffered.\n");
+
+ /* This state really means to the driver that the double
+ * buffers are available for hw accelerate Dbe. When the
+ * FFB is in high-resolution mode, the buffers are combined
+ * into one single large framebuffer. So in high-resolution
+ * hw accelerated double-buffering is not available.
+ */
+ if ((ffb->fbcfg0 & FFB_FBCFG0_RES_MASK) != FFB_FBCFG0_RES_HIGH)
+ pFfb->has_double_buffer = 1;
+ else
+ pFfb->has_double_buffer = 1;
+ } else {
+ ErrorF("Single-buffered.\n");
+ pFfb->has_double_buffer = 0;
+ }
+ }
+}
+
+static unsigned long CreatorUnaccelGeneration = 0;
+static int CreatorUnaccelWindowPrivateIndex;
+
+#define CreatorUnaccelGetWid(w) \
+ ((w)->devPrivates[CreatorUnaccelWindowPrivateIndex].val)
+#define CreatorUnaccelSetWid(w,wid) \
+ (((w)->devPrivates[CreatorUnaccelWindowPrivateIndex].val) = (wid))
+
+static unsigned int
+CreatorWidGet(WindowPtr pWin)
+{
+ return CreatorUnaccelGetWid(pWin);
+}
+
+static Bool
+CreatorWidAlloc(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ unsigned int wid;
+ int i, visual, visclass;
+
+ visual = wVisual(pWin);
+ visclass = 0;
+ for (i = 0; i < pScreen->numVisuals; i++) {
+ if (pScreen->visuals[i].vid == visual) {
+ visclass = pScreen->visuals[i].class;
+ break;
+ }
+ }
+
+ wid = FFBWidAlloc(pFfb, visclass, wColormap(pWin), TRUE);
+ if (wid == (unsigned int) -1)
+ return FALSE;
+
+ CreatorUnaccelSetWid(pWin, wid);
+
+ return TRUE;
+}
+
+static void
+CreatorWidFree(WindowPtr pWin)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pWin->drawable.pScreen->myNum];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+ unsigned int wid = CreatorUnaccelGetWid(pWin);
+
+ FFBWidFree(pFfb, wid);
+}
+
+static cfb8_32WidOps CreatorUnaccelWidOps = {
+ CreatorWidGet,
+ CreatorWidAlloc,
+ CreatorWidFree,
+ NULL,
+ NULL
+};
+
+static Bool
+CreatorUnaccelWidInit(ScreenPtr pScreen)
+{
+ if (serverGeneration != CreatorUnaccelGeneration) {
+ CreatorUnaccelWindowPrivateIndex =
+ AllocateWindowPrivateIndex();
+ if (CreatorUnaccelWindowPrivateIndex == -1)
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+FFBScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ FFBPtr pFfb;
+ int ret;
+ unsigned int afb_fem;
+ VisualPtr visual;
+
+ /* Add in our Dbe hook. */
+ if (!FFBDbePreInit(pScreen))
+ return FALSE;
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ /* Map the FFB framebuffer, for each view. */
+
+ /* 24-bit RGB Dumb view */
+ pFfb->fb = pFfb->dfb24 =
+ xf86MapSbusMem (pFfb->psdp, FFB_DFB24_VOFF, 0x1000000);
+
+ if (! pFfb->dfb24)
+ return FALSE;
+
+ /* 8-bit R Dumb view */
+ pFfb->dfb8r =
+ xf86MapSbusMem (pFfb->psdp, FFB_DFB8R_VOFF, 0x400000);
+
+ if (! pFfb->dfb8r)
+ return FALSE;
+
+ /* 8-bit X Dumb view */
+ pFfb->dfb8x =
+ xf86MapSbusMem (pFfb->psdp, FFB_DFB8X_VOFF, 0x400000);
+
+ if (! pFfb->dfb8x)
+ return FALSE;
+
+ /* 32-bit RGB Smart view */
+ pFfb->sfb32 =
+ xf86MapSbusMem (pFfb->psdp, FFB_SFB32_VOFF, 0x1000000);
+
+ if (!pFfb->sfb32)
+ return FALSE;
+
+ /* 8-bit R Smart view */
+ pFfb->sfb8r =
+ xf86MapSbusMem(pFfb->psdp, FFB_SFB8R_VOFF, 0x400000);
+
+ if (!pFfb->sfb8r)
+ return FALSE;
+
+ /* 8-bit X Smart view */
+ pFfb->sfb8x =
+ xf86MapSbusMem(pFfb->psdp, FFB_SFB8X_VOFF, 0x400000);
+
+ if (!pFfb->sfb8x)
+ return FALSE;
+
+ /* Map the rendering pipeline */
+ pFfb->regs =
+ xf86MapSbusMem (pFfb->psdp, FFB_FBC_REGS_VOFF, 16384);
+
+ if (! pFfb->regs)
+ return FALSE;
+
+ /* Map the ramdac */
+ pFfb->dac =
+ xf86MapSbusMem (pFfb->psdp, FFB_DAC_VOFF, 8192);
+
+ if (! pFfb->dac)
+ return FALSE;
+
+ /* Map the board strapping bits */
+ pFfb->strapping_bits = (volatile unsigned int *)
+ xf86MapSbusMem(pFfb->psdp, FFB_EXP_VOFF, 8192);
+
+ if (! pFfb->strapping_bits)
+ return FALSE;
+
+ /* Probe for the type of FFB/AFB we have. */
+ FFBProbeBoardType(pFfb);
+
+ /* Now that we have the board type, we can init the ramdac layer. */
+ if (FFBDacInit(pFfb) == FALSE)
+ return FALSE;
+
+ /* OK, a fun gross hack to detect if this is
+ * AFB and if so whether the correct firmware
+ * has been loaded. The machine will flatline
+ * if you try to use certain acceleration features
+ * without the full firmware loaded.
+ *
+ * The bootup Elite3D/AFB firmware is minimal, and
+ * will leave the FloatEnableMask register at a
+ * value of 0x01. Creator{,3D} lacks the FEM register
+ * and will return a "nonsense" value on attempts to
+ * read this location. After experimentation, an
+ * appropriate definition for "nonsense" seems to
+ * be anything with all low 7 bits not 0x3f, 0x07,
+ * of 0x01.
+ *
+ * If the FEM register is non-zero and is some value
+ * other than 0x1 (usually 0x3f or 0x7 depending upon
+ * whether the card has 3 or 6 floats) we can assume
+ * the correct firmware has been loaded. -DaveM
+ */
+ afb_fem = *(unsigned int *)((char *)pFfb->regs + 0x1540);
+ if ((afb_fem & 0x7f) != 0x3f &&
+ (afb_fem & 0x7f) != 0x07 &&
+ (afb_fem & 0x7f) != 0x01)
+ xf86Msg(X_INFO, "%s: Detected Creator/Creator3D\n", pFfb->psdp->device);
+ else {
+ xf86Msg(X_INFO, "%s: Detected Elite3D M3/M6, checking firmware...\n", pFfb->psdp->device);
+ if (afb_fem == 0x1) {
+ xf86Msg(X_INFO, "%s: ... AFB firmware not loaded\n", pFfb->psdp->device);
+ if (!pFfb->NoAccel) {
+ xf86Msg(X_WARNING, "%s: Forcing no acceleration on Elite3D M3/M6\n", pFfb->psdp->device);
+ pFfb->NoAccel = TRUE;
+ }
+ } else
+ xf86Msg(X_INFO, "%s: ... AFB firmware is loaded\n", pFfb->psdp->device);
+ }
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ FFBSaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ if (pFfb->NoAccel == TRUE) {
+ if (!CreatorUnaccelWidInit(pScreen))
+ return FALSE;
+ }
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Setup the visuals we support. */
+ if (!miSetVisualTypes(24, TrueColorMask | DirectColorMask,
+ pScrn->rgbBits, TrueColor))
+ return FALSE;
+ if (!miSetVisualTypes(8, PseudoColorMask | GrayScaleMask | StaticGrayMask,
+ pScrn->rgbBits, PseudoColor))
+ return FALSE;
+
+#ifdef XF86DRI
+ if (pFfb->ffb_type != afb_m3 && pFfb->ffb_type != afb_m6) {
+ pFfb->dri_enabled = FFBDRIScreenInit(pScreen);
+ if (pFfb->dri_enabled == TRUE)
+ xf86Msg(X_INFO, "%s: DRM initialized\n",
+ pFfb->psdp->device);
+ else
+ xf86Msg(X_INFO, "%s: DRM setup failed\n",
+ pFfb->psdp->device);
+ } else {
+ pFfb->dri_enabled = FALSE;
+ }
+#endif
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+ if (pFfb->NoAccel == TRUE) {
+ ret = cfb8_32WidScreenInit(pScreen, pFfb->dfb24, pFfb->dfb8r, pFfb->dfb8x,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ 2048, 2048, 2048, 8,
+ &CreatorUnaccelWidOps);
+ } else {
+ /* Use smart framebuffer aperture for cfb8/cfb32. */
+ ret = cfb8_32WidScreenInit(pScreen, pFfb->sfb32, pFfb->sfb8r, pFfb->dfb8x,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ 2048, 2048, 2048, 8,
+ &CreatorUnaccelWidOps);
+ }
+
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ 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 (!pFfb->NoAccel) {
+ if (!FFBAccelInit(pScreen, pFfb))
+ return FALSE;
+ xf86Msg(X_INFO, "%s: Using acceleration\n", pFfb->psdp->device);
+ }
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialize HW cursor layer.
+ * Must follow software cursor initialization.
+ */
+ if (pFfb->HWCursor) {
+ if(!FFBHWCursorInit(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed\n");
+ return(FALSE);
+ }
+ xf86SbusHideOsHwCursor(pFfb->psdp);
+ }
+
+ /* Initialise default colourmap. */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ /* Initialize colormap layer.
+ * Must follow initialization of the default colormap.
+ */
+ if (!xf86HandleColormaps(pScreen, 256, 8,
+ FFBDacLoadPalette, NULL,
+#if 0
+ CMAP_PALETTED_TRUECOLOR |
+#endif
+ CMAP_LOAD_EVEN_IF_OFFSCREEN |
+ CMAP_RELOAD_ON_MODE_SWITCH))
+ return FALSE;
+
+ /* Setup DGA support. */
+ FFB_InitDGA(pScreen);
+
+#ifdef XF86DRI
+ if (pFfb->dri_enabled) {
+ /* Now that mi, cfb, drm and others have done their thing,
+ * complete the DRI setup.
+ */
+ pFfb->dri_enabled = FFBDRIFinishScreenInit(pScreen);
+ if (pFfb->dri_enabled)
+ xf86Msg(X_INFO, "%s: DRM finish setup complete\n",
+ pFfb->psdp->device);
+ else
+ xf86Msg(X_INFO, "%s: DRM finish setup failed\n",
+ pFfb->psdp->device);
+ }
+#endif
+
+ pFfb->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = FFBCloseScreen;
+ pScreen->SaveScreen = FFBSaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ FFBSaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+FFBSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+FFBAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+FFBEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ if (!pFfb->NoAccel)
+ CreatorVtChange (pScrn->pScreen, TRUE);
+ if (pFfb->HWCursor)
+ xf86SbusHideOsHwCursor (pFfb->psdp);
+
+ FFBDacEnterVT(pFfb);
+
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+FFBLeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+ FFBDacLeaveVT(pFfb);
+
+ if (!pFfb->NoAccel)
+ CreatorVtChange (pScrn->pScreen, FALSE);
+ return;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+FFBCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
+
+#ifdef XF86DRI
+ if (pFfb->dri_enabled)
+ FFBDRICloseScreen(pScreen);
+#endif
+
+ /* Restore kernel ramdac state before we unmap registers. */
+ FFBDacFini(pFfb);
+
+ pScrn->vtSema = FALSE;
+
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb24, 0x1000000);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb8r, 0x400000);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->dfb8x, 0x400000);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb32, 0x1000000);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb8r, 0x400000);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->sfb8x, 0x400000);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->regs, 16384);
+ xf86UnmapSbusMem(pFfb->psdp, pFfb->dac, 8192);
+ xf86UnmapSbusMem(pFfb->psdp, (void *)pFfb->strapping_bits, 8192);
+
+ pScreen->CloseScreen = pFfb->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+FFBFreeScreen(int scrnIndex, int flags)
+{
+ FFBFreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+FFBValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+FFBSaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+FFBSync(ScrnInfoPtr pScrn)
+{
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fifo.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fifo.h
new file mode 100644
index 000000000..0957e84f3
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fifo.h
@@ -0,0 +1,69 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - fifo macros.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_fifo.h,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#ifndef FFBFIFO_H
+#define FFBFIFO_H
+
+#include "ffb.h"
+
+/* This is the smallest FFB fifo size I know of. -DaveM */
+#define FFB_FIFO_MIN 124
+
+#define FFBFifo(__fpriv, __n) \
+do { int __cur_slots = (__fpriv)->fifo_cache; \
+ if((__cur_slots - (__n)) < 0) { \
+ ffb_fbcPtr __ffb = pFfb->regs; \
+ do { __cur_slots = (((int)__ffb->ucsr & FFB_UCSR_FIFO_MASK) - 4); \
+ } while((__cur_slots - (__n)) < 0); \
+ } (__fpriv)->fifo_cache = (__cur_slots - (__n)); \
+} while(0)
+
+/* While we are polling for the raster processor to idle, cache the
+ * fifo count as well.
+ */
+#define FFBWait(__fpriv, __ffb) \
+if ((__fpriv)->rp_active != 0) { \
+ unsigned int __regval = (__ffb)->ucsr; \
+ while((__regval & FFB_UCSR_RP_BUSY) != 0) { \
+ __regval = (__ffb)->ucsr; \
+ } \
+ (__fpriv)->fifo_cache = ((int)(__regval & FFB_UCSR_FIFO_MASK)) - 4; \
+ (__fpriv)->rp_active = 0; \
+} while(0)
+
+/* DEBUGGING: You can use this if you suspect corruption is occuring
+ * because someone is touching the framebuffer while the
+ * raster processor is active. If you enable this and the
+ * problem goes away, odds are your suspicions are correct.
+ */
+#undef FORCE_WAIT_EVERY_ROP
+#ifdef FORCE_WAIT_EVERY_ROP
+#define FFBSync(__fpriv, __ffb) FFBWait(__fpriv, __ffb)
+#else
+#define FFBSync(__fpriv, __ffb) do { } while(0)
+#endif
+
+#endif /* FFBFIFO_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_frect.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_frect.c
new file mode 100644
index 000000000..4ad5f744e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_frect.c
@@ -0,0 +1,709 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Rectangle filling.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb_frect.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+#include "ffb_loops.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#define PAGEFILL_DISABLED(pFfb) ((pFfb)->disable_pagefill != 0)
+#define FASTFILL_AP_DISABLED(pFfb) ((pFfb)->disable_fastfill_ap != 0)
+
+void
+CreatorFillBoxStipple (DrawablePtr pDrawable, int nBox, BoxPtr pBox, CreatorStipplePtr stipple)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int bits[32];
+ unsigned int newalign;
+
+ FFBLOG(("CreatorFillBoxStipple: nbox(%d)\n", nBox));
+ newalign = ((pDrawable->y & 31) << 16) | (pDrawable->x & 31);
+ if (stipple->patalign != newalign) {
+ int x, y, i;
+
+ x = (pDrawable->x - (stipple->patalign & 0xffff)) & 31;
+ y = (pDrawable->y - (stipple->patalign >> 16)) & 31;
+ if (x | y) {
+ memcpy(bits, stipple->bits, sizeof(bits));
+ for (i = 0; i < 32; i++)
+ stipple->bits[(i + y) & 31] =
+ (bits[i] >> x) | (bits[i] << (32 - x));
+ stipple->inhw = 0;
+ }
+ stipple->patalign = newalign;
+ }
+
+ FFBSetStipple(pFfb, ffb, stipple,
+ FFB_PPC_APE_DISABLE|FFB_PPC_CS_CONST|FFB_PPC_XS_WID,
+ FFB_PPC_APE_MASK|FFB_PPC_CS_MASK|FFB_PPC_XS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, ~0);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ FFB_WRITE_FBC(pFfb, ffb, FFB_FBC_WIN(pWin));
+ FFB_WRITE_WID(pFfb, ffb, FFB_WID_WIN(pWin));
+
+ while(nBox--) {
+ register int x, y, w, h;
+
+ x = pBox->x1;
+ y = pBox->y1;
+ w = (pBox->x2 - x);
+ h = (pBox->y2 - y);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, h, w);
+ pBox++;
+ }
+
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+enum ffb_fillrect_method { fillrect_page,
+ fillrect_fast, fillrect_fast_opaque,
+ fillrect_normal };
+
+#define BOX_AREA(__w, __h) ((int)(__w) * (int)(__h))
+
+/* Compute the page aligned box for a page mode fast fill.
+ * In 'ework' this returns greater than zero if there are some odd
+ * edges to take care of which are outside of the page aligned area.
+ * It will place less than zero there if the box is too small,
+ * indicating that a different method must be used to fill it.
+ */
+#define CreatorPageFillParms(pFfb, ffp, x, y, w, h, px, py, pw, ph, ework) \
+do { int xdiff, ydiff; \
+ int pf_bh = ffp->pagefill_height; \
+ int pf_bw = ffp->pagefill_width; \
+ py = ((y + (pf_bh - 1)) & ~(pf_bh - 1)); \
+ ydiff = py - y; \
+ px = pFfb->Pf_AlignTab[x + (pf_bw - 1)]; \
+ xdiff = px - x; \
+ ph = ((h - ydiff) & ~(pf_bh - 1)); \
+ if(ph <= 0) \
+ ework = -1; \
+ else { \
+ pw = pFfb->Pf_AlignTab[w - xdiff]; \
+ if(pw <= 0) { \
+ ework = -1; \
+ } else { \
+ ework = (((xdiff > 0) || \
+ (ydiff > 0) || \
+ ((w - pw) > 0) || \
+ ((h - ph) > 0))) ? 1 : 0; \
+ } \
+ } \
+} while(0);
+
+/* Compute fixups of non-page aligned areas after a page fill.
+ * Return the number of fixups needed.
+ */
+static __inline__ int
+CreatorComputePageFillFixups(xRectangle *fixups,
+ int x, int y, int w, int h,
+ int paligned_x, int paligned_y,
+ int paligned_w, int paligned_h)
+{
+ int nfixups = 0;
+
+ /* FastFill Left */
+ if(paligned_x != x) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = paligned_y;
+ fixups[nfixups].width = paligned_x - x;
+ fixups[nfixups].height = paligned_h;
+ nfixups++;
+ }
+ /* FastFill Top */
+ if(paligned_y != y) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = y;
+ fixups[nfixups].width = w;
+ fixups[nfixups].height = paligned_y - y;
+ nfixups++;
+ }
+ /* FastFill Right */
+ if((x+w) != (paligned_x+paligned_w)) {
+ fixups[nfixups].x = (paligned_x+paligned_w);
+ fixups[nfixups].y = paligned_y;
+ fixups[nfixups].width = (x+w) - fixups[nfixups].x;
+ fixups[nfixups].height = paligned_h;
+ nfixups++;
+ }
+ /* FastFill Bottom */
+ if((y+h) != (paligned_y+paligned_h)) {
+ fixups[nfixups].x = x;
+ fixups[nfixups].y = (paligned_y+paligned_h);
+ fixups[nfixups].width = w;
+ fixups[nfixups].height = (y+h) - fixups[nfixups].y;
+ nfixups++;
+ }
+ return nfixups;
+}
+
+/* Fill a set of boxes, pagefill and fastfill not allowed. */
+static void
+CreatorBoxFillNormal(FFBPtr pFfb,
+ int nbox, BoxPtr pbox)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBLOG(("BFNormal: "));
+ if(nbox)
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ while(nbox--) {
+ register int x, y, w, h;
+
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - x);
+ h = (pbox->y2 - y);
+ pbox++;
+ FFBLOG(("[%08x:%08x:%08x:%08x] ", x, y, w, h));
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, h, w);
+ }
+ FFBLOG(("\n"));
+}
+
+/* Fill a set of boxes, only non-pagemode fastfill is allowed. */
+static void
+CreatorBoxFillFast(FFBPtr pFfb,
+ int nbox, BoxPtr pbox)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBLOG(("BFFast: "));
+ while(nbox--) {
+ struct fastfill_parms *ffp = &FFB_FFPARMS(pFfb);
+ register int x, y, w, h;
+
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - x);
+ h = (pbox->y2 - y);
+ pbox++;
+ if(BOX_AREA(w, h) < ffp->fastfill_small_area) {
+ /* Too small for fastfill to be useful. */
+ FFBLOG(("NRM(%08x:%08x:%08x:%08x) ",
+ x, y, w, h));
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, h, w);
+ } else {
+ FFBLOG(("FST(%08x:%08x:%08x:%08x:[%08x:%08x]) ",
+ x, y, w, h,
+ (w + (x & (ffp->fastfill_width - 1))),
+ (h + (y & (ffp->fastfill_height - 1)))));
+ if (pFfb->ffb_res == ffb_res_high &&
+ ((x & 7) != 0 || (w & 7) != 0)) {
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ if ((x & 7) != 0) {
+ register int nx = x;
+ register int nw;
+
+ nw = 8 - (nx & 7);
+ if (nw > w)
+ nw = w;
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, nx);
+ FFB_WRITE64_2(&ffb->bh, h, nw);
+ x += nw;
+ w -= nw;
+ }
+ if ((w & 7) != 0) {
+ register int nx, nw;
+
+ nw = (w & 7);
+ nx = x + (w - nw);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, nx);
+ FFB_WRITE64_2(&ffb->bh, h, nw);
+ w -= nw;
+ }
+ if (w <= 0)
+ goto next_rect;
+ }
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_FASTFILL);
+ FFBFifo(pFfb, 10);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ FFB_WRITE64(&ffb->dy, 0, 0);
+ FFB_WRITE64_2(&ffb->bh,
+ ffp->fastfill_height,
+ (ffp->fastfill_width * 4));
+ FFB_WRITE64_3(&ffb->dy, y, x);
+ ffb->bh = (h + (y & (ffp->fastfill_height - 1)));
+ FFB_WRITE64(&ffb->by, FFB_FASTFILL_BLOCK,
+ (w + (x & (ffp->fastfill_width - 1))));
+ }
+ next_rect:
+ ;
+ }
+ FFBLOG(("\n"));
+}
+
+/* Fill a set of boxes, any fastfill method is allowed. */
+static void
+CreatorBoxFillPage(FFBPtr pFfb,
+ int nbox, BoxPtr pbox)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBLOG(("BFPage: "));
+ while(nbox--) {
+ struct fastfill_parms *ffp = &FFB_FFPARMS(pFfb);
+ register int x, y, w, h;
+
+ x = pbox->x1;
+ y = pbox->y1;
+ w = (pbox->x2 - x);
+ h = (pbox->y2 - y);
+ pbox++;
+ if(BOX_AREA(w, h) < ffp->fastfill_small_area) {
+ /* Too small for fastfill or page fill to be useful. */
+ FFBLOG(("NRM(%08x:%08x:%08x:%08x) ",
+ x, y, w, h));
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, h, w);
+ } else {
+ int paligned_y, paligned_x;
+ int paligned_h, paligned_w = 0;
+ int extra_work;
+
+ if (pFfb->ffb_res == ffb_res_high &&
+ ((x & 7) != 0 || (w & 7) != 0)) {
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ if ((x & 7) != 0) {
+ register int nx = x;
+ register int nw;
+
+ nw = 8 - (nx & 7);
+ if (nw > w)
+ nw = w;
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, nx);
+ FFB_WRITE64_2(&ffb->bh, h, nw);
+ x += nw;
+ w -= nw;
+ }
+ if ((w & 7) != 0) {
+ register int nx, nw;
+
+ nw = (w & 7);
+ nx = x + (w - nw);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, nx);
+ FFB_WRITE64_2(&ffb->bh, h, nw);
+ w -= nw;
+ }
+ if (w <= 0)
+ goto next_rect;
+ }
+
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_FASTFILL);
+ if((w < (ffp->pagefill_width<<1)) ||
+ (h < (ffp->pagefill_height<<1)))
+ goto do_fastfill;
+
+ CreatorPageFillParms(pFfb, ffp,
+ x, y, w, h,
+ paligned_x, paligned_y,
+ paligned_w, paligned_h, extra_work);
+
+ /* See if the aligned area is large enough for
+ * page fill to be worthwhile.
+ */
+ if(extra_work < 0 ||
+ BOX_AREA(paligned_w, paligned_h) < ffp->pagefill_small_area) {
+ do_fastfill:
+ FFBLOG(("FST(%08x:%08x:%08x:%08x:[%08x:%08x]) ",
+ x, y, w, h,
+ (w + (x & (ffp->fastfill_width - 1))),
+ (h + (y & (ffp->fastfill_height - 1)))));
+ FFBFifo(pFfb, 10);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ FFB_WRITE64(&ffb->dy, 0, 0);
+ FFB_WRITE64_2(&ffb->bh,
+ ffp->fastfill_height,
+ (ffp->fastfill_width * 4));
+ FFB_WRITE64_3(&ffb->dy, y, x);
+ ffb->bh = (h + (y & (ffp->fastfill_height - 1)));
+ FFB_WRITE64(&ffb->by, FFB_FASTFILL_BLOCK,
+ (w + (x & (ffp->fastfill_width - 1))));
+ } else {
+ /* Ok, page fill is worth it, let it rip. */
+ FFBLOG(("PAG(%08x:%08x:%08x:%08x) ",
+ paligned_x, paligned_y, paligned_w, paligned_h));
+ FFBFifo(pFfb, 15);
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ FFB_WRITE64(&ffb->dy, 0, 0);
+ FFB_WRITE64_2(&ffb->bh, ffp->fastfill_height, (ffp->fastfill_width * 4));
+ ffb->by = FFB_FASTFILL_BLOCK_X;
+ FFB_WRITE64(&ffb->dy, 0, 0);
+ FFB_WRITE64_2(&ffb->bh, ffp->pagefill_height, (ffp->pagefill_width * 4));
+ FFB_WRITE64_3(&ffb->dy, paligned_y, paligned_x);
+ ffb->bh = paligned_h;
+ FFB_WRITE64(&ffb->by, FFB_FASTFILL_PAGE, paligned_w);
+
+ if(extra_work) {
+ register int nfixups;
+
+ /* Ok, we're going to do at least one fixup. */
+ nfixups = CreatorComputePageFillFixups(pFfb->Pf_Fixups,
+ x, y, w, h,
+ paligned_x, paligned_y,
+ paligned_w, paligned_h);
+
+ /* NOTE: For the highres case we have already
+ * aligned the outermost X and W coordinates.
+ * Therefore we can be assured that the fixup
+ * X and W coordinates below will be 8 pixel
+ * aligned as well. Do the math, it works. -DaveM
+ */
+
+ FFBFifo(pFfb, 5 + (nfixups * 5));
+ ffb->by = FFB_FASTFILL_COLOR_BLK;
+ FFB_WRITE64(&ffb->dy, 0, 0);
+ FFB_WRITE64_2(&ffb->bh, ffp->fastfill_height, (ffp->fastfill_width * 4));
+
+ while(--nfixups >= 0) {
+ register int xx, yy, ww, hh;
+
+ xx = pFfb->Pf_Fixups[nfixups].x;
+ yy = pFfb->Pf_Fixups[nfixups].y;
+ FFB_WRITE64(&ffb->dy, yy, xx);
+ ww = (pFfb->Pf_Fixups[nfixups].width +
+ (xx & (ffp->fastfill_width - 1)));
+ hh = (pFfb->Pf_Fixups[nfixups].height +
+ (yy & (ffp->fastfill_height - 1)));
+ FFBLOG(("FIXUP(%08x:%08x:%08x:%08x) ",
+ xx, yy, ww, hh));
+ if(nfixups != 0) {
+ ffb->by = FFB_FASTFILL_BLOCK;
+ FFB_WRITE64_2(&ffb->bh, hh, ww);
+ } else {
+ ffb->bh = hh;
+ FFB_WRITE64(&ffb->by, FFB_FASTFILL_BLOCK, ww);
+ }
+ }
+ }
+ }
+ }
+ next_rect:
+ ;
+ }
+ FFBLOG(("\n"));
+}
+
+void
+CreatorFillBoxSolid (DrawablePtr pDrawable, int nBox, BoxPtr pBox, unsigned long pixel)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ WindowPtr pWin = (WindowPtr) pDrawable;
+
+ FFBLOG(("CreatorFillBoxSolid: nbox(%d)\n", nBox));
+ FFB_ATTR_FFWIN(pFfb, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ pixel);
+ if (PAGEFILL_DISABLED(pFfb))
+ CreatorBoxFillNormal(pFfb, nBox, pBox);
+ else
+ CreatorBoxFillPage(pFfb, nBox, pBox);
+
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+static void
+FFBSetStippleFast(FFBPtr pFfb, ffb_fbcPtr ffb,
+ CreatorStipplePtr stipple,
+ unsigned int ppc, unsigned int ppc_mask)
+{
+ ppc |= FFB_PPC_APE_ENABLE | FFB_PPC_TBE_TRANSPARENT | FFB_PPC_XS_WID;
+ ppc_mask |= FFB_PPC_APE_MASK | FFB_PPC_TBE_MASK | FFB_PPC_XS_MASK;
+ FFB_WRITE_PPC(pFfb, ffb, ppc, ppc_mask);
+ FFB_WRITE_ROP(pFfb, ffb, (FFB_ROP_EDIT_BIT|stipple->alu)|(FFB_ROP_NEW<<8));
+ FFB_WRITE_FG(pFfb, ffb, stipple->fg);
+ FFBFifo(pFfb, 32);
+ FFB_STIPPLE_LOAD(&ffb->pattern[0], &stipple->bits[0]);
+}
+
+static void
+FFBSetStippleFastIdentity(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ CreatorStipplePtr stipple)
+{
+ int i;
+
+ FFB_WRITE_FG(pFfb, ffb, stipple->bg);
+ FFBFifo(pFfb, 32);
+ for(i = 0; i < 32; i++)
+ ffb->pattern[i] = ~stipple->bits[i];
+ stipple->inhw = 0;
+ pFfb->laststipple = NULL;
+}
+
+void
+CreatorPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ register BoxPtr pboxClipped;
+ BoxPtr pboxClippedBase;
+ BoxPtr pextent;
+ CreatorPrivGCPtr gcPriv;
+ int numRects;
+ int n;
+ int xorg, yorg;
+
+ /* No garbage please. */
+ if (nrectFill <= 0)
+ return;
+
+ gcPriv = CreatorGetGCPrivate (pGC);
+ FFBLOG(("CreatorPolyFillRect: nrect(%d) ALU(%x) STIP(%p) pmsk(%08x)\n",
+ nrectFill, pGC->alu, gcPriv->stipple, pGC->planemask));
+ prgnClip = cfbGetCompositeClip(pGC);
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while (n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+ numRects = REGION_NUM_RECTS (prgnClip) * nrectFill;
+ if (numRects > 64) {
+ pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ if (!pboxClippedBase)
+ return;
+ } else
+ pboxClippedBase = pFfb->ClippedBoxBuf;
+
+ 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++;
+ }
+ }
+ }
+ /* Now fill the pre-clipped boxes. */
+ if(pboxClipped != pboxClippedBase) {
+ enum ffb_fillrect_method how = fillrect_page;
+ int num = (pboxClipped - pboxClippedBase);
+ int f_w = pboxClippedBase->x2 - pboxClippedBase->x1;
+ int f_h = pboxClippedBase->y2 - pboxClippedBase->y1;
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ unsigned int fbc = FFB_FBC_WIN(pWin);
+ unsigned int drawop = FFB_DRAWOP_FASTFILL;
+
+ if (PAGEFILL_DISABLED(pFfb) ||
+ pGC->alu != GXcopy ||
+ BOX_AREA(f_w, f_h) < 128) {
+ drawop = FFB_DRAWOP_RECTANGLE;
+ how = fillrect_normal;
+ } else if (gcPriv->stipple != NULL) {
+ if (FASTFILL_AP_DISABLED(pFfb)) {
+ drawop = FFB_DRAWOP_RECTANGLE;
+ how = fillrect_normal;
+ } else {
+ if ((gcPriv->stipple->alu & FFB_ROP_EDIT_BIT) != 0)
+ how = fillrect_fast;
+ else
+ how = fillrect_fast_opaque;
+ }
+ } else {
+ int all_planes;
+
+ /* Plane masks are not controllable with page fills. */
+ if (pGC->depth == 8)
+ all_planes = 0xff;
+ else
+ all_planes = 0xffffff;
+ if ((pGC->planemask & all_planes) != all_planes)
+ how = fillrect_fast;
+ }
+
+ if (how == fillrect_page) {
+ fbc &= ~(FFB_FBC_XE_MASK | FFB_FBC_RGBE_MASK);
+ fbc |= FFB_FBC_XE_ON | FFB_FBC_RGBE_ON;
+ }
+
+ /* In the high-resolution modes, the Creator3D transforms
+ * the framebuffer such that the dual-buffers present become
+ * one large single buffer. As such you need to enable both
+ * A and B write buffers for page/fast fills to work properly
+ * under this configuration. -DaveM
+ */
+ if (pFfb->ffb_res == ffb_res_high)
+ fbc |= FFB_FBC_WB_B;
+
+ /* Setup the attributes. */
+ if (gcPriv->stipple == NULL) {
+ FFB_ATTR_RAW(pFfb,
+ FFB_PPC_APE_DISABLE|FFB_PPC_CS_CONST|FFB_PPC_XS_WID,
+ FFB_PPC_APE_MASK|FFB_PPC_CS_MASK|FFB_PPC_XS_MASK,
+ pGC->planemask,
+ ((FFB_ROP_EDIT_BIT|pGC->alu)|(FFB_ROP_NEW<<8)),
+ drawop,
+ pGC->fgPixel,
+ fbc, FFB_WID_WIN(pWin));
+ } else {
+ if (how == fillrect_fast_opaque) {
+ FFBSetStippleFast(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST|FFB_PPC_XS_WID,
+ FFB_PPC_CS_MASK|FFB_PPC_XS_MASK);
+ } else {
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST|FFB_PPC_XS_WID,
+ FFB_PPC_CS_MASK|FFB_PPC_XS_MASK);
+ }
+ FFB_WRITE_DRAWOP(pFfb, ffb, drawop);
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ FFB_WRITE_WID(pFfb, ffb, FFB_WID_WIN(pWin));
+ }
+
+ /* Now render. */
+ if(how == fillrect_normal)
+ CreatorBoxFillNormal(pFfb, num, pboxClippedBase);
+ else if(how == fillrect_fast || how == fillrect_fast_opaque)
+ CreatorBoxFillFast(pFfb, num, pboxClippedBase);
+ else
+ CreatorBoxFillPage(pFfb, num, pboxClippedBase);
+
+ if(how == fillrect_fast_opaque) {
+ FFBSetStippleFastIdentity(pFfb, ffb, gcPriv->stipple);
+ CreatorBoxFillFast(pFfb, num, pboxClippedBase);
+ }
+
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+ }
+ if (pboxClippedBase != pFfb->ClippedBoxBuf)
+ DEALLOCATE_LOCAL (pboxClippedBase);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fspans.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fspans.c
new file mode 100644
index 000000000..45990151b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_fspans.c
@@ -0,0 +1,121 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Fill spans.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_fspans.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+#include "ffb_loops.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "mi.h"
+#include "mispans.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+void
+CreatorFillSpans (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ int *pwidthFree;
+ DDXPointPtr pptFree;
+ RegionPtr clip = cfbGetCompositeClip(pGC);
+ int nTmp = n * miFindMaxBand(clip);
+
+ FFBLOG(("CreatorFillSpans: n(%d) fsorted(%d)\n", n, fSorted));
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(clip,
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ FFB_DRAWOP_BRLINEOPEN);
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_BRLINEOPEN);
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+ FFBFifo(pFfb, 1);
+ ffb->lpat = 0;
+
+ if (pFfb->has_brline_bug) {
+ while(n--) {
+ register int x, y, w;
+
+ x = ppt->x;
+ y = ppt->y;
+ w = *pwidth++;
+ FFBFifo(pFfb, 5);
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, y, (x + w));
+ ppt++;
+ }
+ } else {
+ while(n--) {
+ register int x, y, w;
+
+ x = ppt->x;
+ y = ppt->y;
+ w = *pwidth++;
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, y, (x + w));
+ ppt++;
+ }
+ }
+
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c
new file mode 100644
index 000000000..eb357fac5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.c
@@ -0,0 +1,752 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - GC implementation.
+ *
+ * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb_gc.c,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_loops.h"
+#include "ffb_gc.h"
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "migc.h"
+#include "mi.h"
+#include "mispans.h"
+
+GCOps CreatorTEOps1Rect8 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfbPutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorPolylines,
+ CreatorPolySegment,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ CreatorTEGlyphBlt,
+ CreatorPolyTEGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorTEOps1Rect32 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfb32PutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorPolylines,
+ CreatorPolySegment,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ CreatorTEGlyphBlt,
+ CreatorPolyTEGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorTEOps8 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfbPutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorLineSSStub,
+ CreatorSegmentSSStub,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ CreatorTEGlyphBlt,
+ CreatorPolyTEGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorTEOps32 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfb32PutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorLineSSStub,
+ CreatorSegmentSSStub,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ CreatorTEGlyphBlt,
+ CreatorPolyTEGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorNonTEOps1Rect8 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfbPutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorPolylines,
+ CreatorPolySegment,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ CreatorPolyGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorNonTEOps1Rect32 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfb32PutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorPolylines,
+ CreatorPolySegment,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ CreatorPolyGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorNonTEOps8 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfbPutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorLineSSStub,
+ CreatorSegmentSSStub,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ CreatorPolyGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps CreatorNonTEOps32 = {
+ CreatorFillSpans,
+ CreatorSetSpans,
+ cfb32PutImage,
+ CreatorCopyArea,
+ CreatorCopyPlane,
+ CreatorPolyPoint,
+ CreatorLineSSStub,
+ CreatorSegmentSSStub,
+ miPolyRectangle,
+ CreatorZeroPolyArc,
+ CreatorFillPolygon,
+ CreatorPolyFillRect,
+ CreatorPolyFillArcSolid,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ miImageGlyphBlt,
+ CreatorPolyGlyphBlt,
+ miPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+#define FONTWIDTH(font) (FONTMAXBOUNDS(font,rightSideBearing) - \
+ FONTMINBOUNDS(font,leftSideBearing))
+#define FONTHEIGHT(font) (FONTMAXBOUNDS(font,ascent) + \
+ FONTMINBOUNDS(font,descent))
+
+static GCOps *
+CreatorMatchCommon (GCPtr pGC, cfbPrivGCPtr devPriv)
+{
+ int depth = pGC->depth;
+
+ 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 &&
+ FONTWIDTH (pGC->font) <= 32 &&
+ FONTHEIGHT (pGC->font) <= 100 &&
+ FONTMINBOUNDS(pGC->font,characterWidth) >= 0) {
+ if (TERMINALFONT(pGC->font)) {
+ if (devPriv->oneRect) {
+ return (depth == 8 ?
+ &CreatorTEOps1Rect8 :
+ &CreatorTEOps1Rect32);
+ } else {
+ return (depth == 8 ?
+ &CreatorTEOps8 :
+ &CreatorTEOps32);
+ }
+ } else {
+ if (devPriv->oneRect) {
+ return (depth == 8 ?
+ &CreatorNonTEOps1Rect8 :
+ &CreatorNonTEOps1Rect32);
+ } else {
+ return (depth == 8 ?
+ &CreatorNonTEOps8 :
+ &CreatorNonTEOps32);
+ }
+ }
+ }
+ return 0;
+}
+
+static void
+CreatorDestroyGC (GCPtr pGC)
+{
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+
+ if (gcPriv->stipple)
+ xfree (gcPriv->stipple);
+ miDestroyGC (pGC);
+}
+
+static __inline__ void
+CreatorNewLine(GCPtr pGC, cfbPrivGCPtr devPriv, CreatorPrivGCPtr gcPriv, int accel)
+{
+ pGC->ops->FillPolygon = miFillPolygon;
+ pGC->ops->PolyRectangle = miPolyRectangle;
+ if (pGC->lineWidth == 0)
+ pGC->ops->PolyArc = miZeroPolyArc;
+ else
+ pGC->ops->PolyArc = miPolyArc;
+ if (accel) {
+ pGC->ops->FillPolygon = CreatorFillPolygon;
+ if (pGC->lineWidth == 0 && pGC->capStyle != CapNotLast)
+ pGC->ops->PolyArc = CreatorZeroPolyArc;
+ }
+ pGC->ops->PolySegment = miPolySegment;
+ gcPriv->linepat = 0;
+
+ /* Segment and Line ops are only accelerated if there is
+ * one clipping region.
+ */
+ if (accel && !devPriv->oneRect)
+ accel = 0;
+
+ if (pGC->lineStyle == LineSolid) {
+ if(pGC->lineWidth == 0) {
+ if (pGC->fillStyle == FillSolid) {
+ pGC->ops->Polylines = CreatorLineSSStub;
+ pGC->ops->PolySegment = CreatorSegmentSSStub;
+ } else
+ pGC->ops->Polylines = miZeroLine;
+ if (accel) {
+ gcPriv->PolySegment = pGC->ops->PolySegment;
+ gcPriv->Polylines = pGC->ops->Polylines;
+ pGC->ops->PolySegment = CreatorPolySegment;
+ pGC->ops->Polylines = CreatorPolylines;
+ }
+ } else {
+ pGC->ops->Polylines = miWideLine;
+ }
+ } else if(pGC->lineStyle == LineOnOffDash) {
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) {
+ pGC->ops->Polylines = CreatorLineSDStub;
+ pGC->ops->PolySegment = CreatorSegmentSDStub;
+ if(accel &&
+ CreatorCheckLinePattern(pGC, gcPriv)) {
+ gcPriv->PolySegment = pGC->ops->PolySegment;
+ gcPriv->Polylines = pGC->ops->Polylines;
+ pGC->ops->PolySegment = CreatorPolySegment;
+ pGC->ops->Polylines = CreatorPolylines;
+ }
+ } else {
+ pGC->ops->Polylines = miWideDash;
+ }
+ } else if(pGC->lineStyle == LineDoubleDash) {
+ if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) {
+ pGC->ops->Polylines = CreatorLineSDStub;
+ pGC->ops->PolySegment = CreatorSegmentSDStub;
+ } else {
+ pGC->ops->Polylines = miWideDash;
+ }
+ }
+}
+
+static __inline__ void
+CreatorNewGlyph(GCPtr pGC, CreatorPrivGCPtr gcPriv)
+{
+ if (FONTWIDTH(pGC->font) > 32 ||
+ FONTHEIGHT(pGC->font) > 100 ||
+ FONTMINBOUNDS(pGC->font,characterWidth) < 0) {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ } else {
+ if (pGC->fillStyle == FillSolid) {
+ if (TERMINALFONT (pGC->font)) {
+ pGC->ops->PolyGlyphBlt = CreatorPolyTEGlyphBlt;
+ } else {
+ pGC->ops->PolyGlyphBlt = CreatorPolyGlyphBlt;
+ }
+ } else {
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+ }
+
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+ if (TERMINALFONT(pGC->font))
+ pGC->ops->ImageGlyphBlt = CreatorTEGlyphBlt;
+ else
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+}
+
+static __inline__ void
+CreatorNewFillSpans(GCPtr pGC, cfbPrivGCPtr devPriv, CreatorPrivGCPtr gcPriv, int accel)
+{
+ if (pGC->fillStyle == FillSolid) {
+ pGC->ops->FillSpans = CreatorSolidSpansGeneralStub;
+ } else if(pGC->fillStyle == FillTiled) {
+ if (pGC->pRotatedPixmap) {
+ int pmsk = (pGC->depth == 8 ? 0xff : 0xffffff);
+ if (pGC->alu == GXcopy && (pGC->planemask & pmsk) == pmsk)
+ pGC->ops->FillSpans = CreatorTile32FSCopyStub;
+ else
+ pGC->ops->FillSpans = CreatorTile32FSGeneralStub;
+ } else
+ pGC->ops->FillSpans = CreatorUnnaturalTileFSStub;
+ } else if(pGC->fillStyle == FillStippled) {
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = Creator8Stipple32FSStub;
+ else
+ pGC->ops->FillSpans = CreatorUnnaturalStippleFSStub;
+ } else if(pGC->fillStyle == FillOpaqueStippled) {
+ if (pGC->pRotatedPixmap)
+ pGC->ops->FillSpans = Creator8OpaqueStipple32FSStub;
+ else
+ pGC->ops->FillSpans = CreatorUnnaturalStippleFSStub;
+ } else
+ FatalError("CreatorValidateGC: illegal fillStyle\n");
+ if (accel)
+ pGC->ops->FillSpans = CreatorFillSpans;
+}
+
+static __inline__ void
+CreatorNewFillArea(GCPtr pGC, cfbPrivGCPtr devPriv, CreatorPrivGCPtr gcPriv, int accel)
+{
+ if (accel) {
+ pGC->ops->PolyFillRect = CreatorPolyFillRect;
+ pGC->ops->PolyFillArc = CreatorPolyFillArcSolid;
+ } else {
+ pGC->ops->PolyFillRect = miPolyFillRect;
+ if(pGC->fillStyle == FillSolid || pGC->fillStyle == FillTiled)
+ pGC->ops->PolyFillRect = CreatorPolyFillRectStub;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ }
+ pGC->ops->PushPixels = mfbPushPixels;
+}
+
+void
+CreatorValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
+{
+ int mask; /* stateChanges */
+ int new_rrop;
+ int new_line, new_text, new_fillspans, new_fillarea;
+ int new_rotate;
+ int xrot, yrot;
+ /* flags for changing the proc vector */
+ cfbPrivGCPtr devPriv;
+ CreatorPrivGCPtr gcPriv;
+ int oneRect;
+ int accel, drawableChanged;
+
+ gcPriv = CreatorGetGCPrivate (pGC);
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ if (gcPriv->type == DRAWABLE_WINDOW) {
+ extern GCOps cfbNonTEOps;
+ extern GCOps cfb32NonTEOps;
+
+ miDestroyGCOps (pGC->ops);
+
+ if (pGC->depth == 8)
+ pGC->ops = &cfbNonTEOps;
+ else
+ pGC->ops = &cfb32NonTEOps;
+
+ changes = (1 << (GCLastBit+1)) - 1;
+ pGC->stateChanges = changes;
+ gcPriv->type = pDrawable->type;
+ }
+ if (pGC->depth == 8)
+ cfbValidateGC (pGC, changes, pDrawable);
+ else
+ cfb32ValidateGC (pGC, changes, pDrawable);
+
+ /* Our high speed VIS copyarea can
+ * be used on pixmaps too.
+ * But don't clobber someones ops prototype!!
+ */
+ if (!pGC->ops->devPrivate.val) {
+ pGC->ops = miCreateGCOps(pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+ pGC->ops->CopyArea = CreatorCopyArea;
+ return;
+ }
+
+ if (gcPriv->type != DRAWABLE_WINDOW) {
+ changes = (1 << (GCLastBit+1)) - 1;
+ gcPriv->type = DRAWABLE_WINDOW;
+ }
+
+ new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
+ pGC->lastWinOrg.y != pDrawable->y;
+ if(new_rotate != 0) {
+ 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;
+
+ drawableChanged = (pDrawable->serialNumber !=
+ (pGC->serialNumber & (DRAWABLE_SERIAL_BITS)));
+#define CLIP_BITS (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)
+ /* 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 & CLIP_BITS) != 0 || drawableChanged) {
+ miComputeCompositeClip(pGC, pDrawable);
+ oneRect = REGION_NUM_RECTS(cfbGetCompositeClip(pGC)) == 1;
+ if (oneRect != devPriv->oneRect) {
+ new_line = TRUE;
+ devPriv->oneRect = oneRect;
+ }
+ }
+
+ /* A while loop with a switch statement inside? No thanks. -DaveM */
+ mask = changes;
+ if((mask & (GCFunction | GCForeground | GCBackground | GCPlaneMask)) != 0)
+ new_rrop = TRUE;
+ if((mask & (GCPlaneMask | GCFillStyle | GCFont)) != 0)
+ new_text = TRUE;
+ if((mask & (GCLineStyle | GCLineWidth | GCFillStyle | GCCapStyle)) != 0)
+ new_line = TRUE;
+ if((mask & (GCFillStyle | GCTile | GCStipple)) != 0)
+ new_fillspans = new_fillarea = TRUE;
+ if(new_rotate == FALSE &&
+ (mask & (GCTileStipXOrigin | GCTileStipYOrigin)) != 0)
+ new_rotate = TRUE;
+ if((mask & GCStipple) != 0) {
+ if(pGC->stipple) {
+ int width = pGC->stipple->drawable.width;
+ PixmapPtr nstipple;
+
+ if ((width <= 32) && !(width & (width - 1))) {
+ int depth = pGC->depth;
+ nstipple = (depth == 8 ?
+ cfbCopyPixmap(pGC->stipple) :
+ cfb32CopyPixmap(pGC->stipple));
+ if (nstipple) {
+ if (depth == 8)
+ cfbPadPixmap(nstipple);
+ else
+ cfb32PadPixmap(nstipple);
+ (*pGC->pScreen->DestroyPixmap)(pGC->stipple);
+ pGC->stipple = nstipple;
+ }
+ }
+ }
+ }
+
+ /* If the drawable has changed, check its depth and ensure suitable
+ * entries are in the proc vector.
+ */
+ if (drawableChanged)
+ new_fillspans = TRUE; /* deal with FillSpans later */
+
+ if (new_rotate || new_fillspans) {
+ Bool new_pix = FALSE;
+
+ xrot = pGC->patOrg.x + pDrawable->x;
+ yrot = pGC->patOrg.y + pDrawable->y;
+ if (!CreatorCheckFill (pGC, pDrawable)) {
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ if (!pGC->tileIsPixel)
+ {
+ int width = pGC->tile.pixmap->drawable.width;
+
+ if (pGC->depth == 8)
+ width *= 8;
+ else
+ width *= 32;
+
+ if ((width <= 32) && !(width & (width - 1))) {
+ if (pGC->depth == 8)
+ cfbCopyRotatePixmap(pGC->tile.pixmap,
+ &pGC->pRotatedPixmap,
+ xrot, yrot);
+ else
+ cfb32CopyRotatePixmap(pGC->tile.pixmap,
+ &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+ case FillStippled:
+ case FillOpaqueStippled:
+ {
+ int width = pGC->stipple->drawable.width;
+
+ if ((width <= 32) && !(width & (width - 1)))
+ {
+ mfbCopyRotatePixmap(pGC->stipple,
+ &pGC->pRotatedPixmap, xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+ }
+ }
+ if (!new_pix && pGC->pRotatedPixmap) {
+ (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ }
+ }
+
+ if (new_rrop) {
+ int old_rrop;
+
+ if (gcPriv->stipple) {
+ if (pGC->fillStyle == FillStippled)
+ gcPriv->stipple->alu = pGC->alu | FFB_ROP_EDIT_BIT;
+ else
+ gcPriv->stipple->alu = pGC->alu;
+ if (pGC->fillStyle != FillTiled) {
+ gcPriv->stipple->fg = pGC->fgPixel;
+ gcPriv->stipple->bg = pGC->bgPixel;
+ }
+ }
+
+ old_rrop = devPriv->rop;
+ if (pGC->depth == 8)
+ devPriv->rop = cfbReduceRasterOp (pGC->alu, pGC->fgPixel,
+ pGC->planemask,
+ &devPriv->and, &devPriv->xor);
+ else
+ devPriv->rop = cfb32ReduceRasterOp (pGC->alu, pGC->fgPixel,
+ pGC->planemask,
+ &devPriv->and, &devPriv->xor);
+ if (old_rrop == devPriv->rop)
+ new_rrop = FALSE;
+ else {
+ new_line = TRUE;
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ }
+ }
+
+ if (new_rrop || new_fillspans || new_text || new_fillarea || new_line) {
+ GCOps *newops;
+ int using_creator_ops = 0;
+
+ if ((newops = CreatorMatchCommon (pGC, devPriv))) {
+ if (pGC->ops->devPrivate.val)
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = newops;
+ new_rrop = new_line = new_fillspans = new_text = new_fillarea = 0;
+ using_creator_ops = 1;
+ } else {
+ if (!pGC->ops->devPrivate.val) {
+ pGC->ops = miCreateGCOps (pGC->ops);
+ pGC->ops->devPrivate.val = 1;
+ }
+
+ /* We have to make sure the copyarea op always
+ * points to our special routine as it maintains the
+ * synchronization between the raster processor and direct
+ * access to the frame buffer.
+ */
+ pGC->ops->CopyArea = CreatorCopyArea;
+ }
+ if (pGC->depth == 8)
+ newops = cfbMatchCommon(pGC, devPriv);
+ else
+ newops = cfb32MatchCommon(pGC, devPriv);
+
+ if (newops) {
+ gcPriv->PolySegment = newops->PolySegment;
+ gcPriv->Polylines = newops->Polylines;
+
+ if (using_creator_ops) {
+ /* Fixup line/segment backup ops. */
+ if (pGC->ops->PolySegment == CreatorPolySegment)
+ gcPriv->PolySegment = CreatorSegmentSSStub;
+ if (pGC->ops->Polylines == CreatorPolylines)
+ gcPriv->Polylines = CreatorLineSSStub;
+ }
+ }
+ }
+
+ accel = pGC->fillStyle == FillSolid || gcPriv->stipple;
+
+ /* deal with the changes we've collected */
+ if (new_line)
+ CreatorNewLine(pGC, devPriv, gcPriv, accel);
+
+ if (new_text && pGC->font)
+ CreatorNewGlyph(pGC, gcPriv);
+
+ if (new_fillspans)
+ CreatorNewFillSpans(pGC, devPriv, gcPriv, accel);
+
+ if (new_fillarea)
+ CreatorNewFillArea(pGC, devPriv, gcPriv, accel);
+}
+
+GCFuncs CreatorGCFuncs = {
+ CreatorValidateGC,
+ miChangeGC,
+ miCopyGC,
+ CreatorDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip
+};
+
+Bool
+CreatorCreateGC (GCPtr pGC)
+{
+ CreatorPrivGCPtr gcPriv;
+
+ if (pGC->depth == 1)
+ return mfbCreateGC(pGC);
+
+ if (pGC->depth == 8) {
+ if (!cfbCreateGC(pGC))
+ return FALSE;
+ } else {
+ if (!cfb32CreateGC(pGC))
+ return FALSE;
+ }
+
+ if (pGC->depth == 8)
+ pGC->ops = &CreatorNonTEOps8;
+ else
+ pGC->ops = &CreatorNonTEOps32;
+
+ pGC->funcs = &CreatorGCFuncs;
+ gcPriv = CreatorGetGCPrivate(pGC);
+ gcPriv->type = DRAWABLE_WINDOW;
+ gcPriv->linepat = 0;
+ gcPriv->stipple = 0;
+ gcPriv->PolySegment = CreatorSegmentSSStub;
+ gcPriv->Polylines = CreatorLineSSStub;
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.h
new file mode 100644
index 000000000..3e6226965
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gc.h
@@ -0,0 +1,151 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Accel func declarations.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb_gc.h,v 1.2 2000/05/23 04:47:44 dawes Exp $ */
+
+#ifndef FFBGC_H
+#define FFBGC_H
+
+extern void CreatorDoBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask);
+
+extern void CreatorDoVertBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask);
+
+extern RegionPtr CreatorCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty);
+
+extern RegionPtr CreatorCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane);
+
+extern void CreatorFillBoxSolid (DrawablePtr pDrawable, int nBox,
+ BoxPtr pBox, unsigned long pixel);
+
+extern void CreatorFillBoxStipple (DrawablePtr pDrawable,
+ int nBox, BoxPtr pBox, CreatorStipplePtr stipple);
+
+extern void CreatorPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+
+extern void CreatorFillSpans (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted);
+
+extern void CreatorPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, xPoint *pptInit);
+
+extern void CreatorPolySegment (DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSeg);
+
+extern void CreatorFillPolygon (DrawablePtr pDrawable, GCPtr pGC,
+ int shape, int mode, int count, DDXPointPtr ppt);
+
+extern void CreatorPolylines (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt);
+
+extern void CreatorPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase);
+
+extern void CreatorTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase);
+
+extern void CreatorPolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase);
+
+extern void CreatorPolyFillArcSolid (DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs);
+
+extern void CreatorZeroPolyArc(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs);
+
+extern int CreatorCheckTile (PixmapPtr pPixmap, CreatorStipplePtr stipple,
+ int ox, int oy, int ph);
+
+extern int CreatorCheckStipple (PixmapPtr pPixmap, CreatorStipplePtr stipple,
+ int ox, int oy, int ph);
+
+extern int CreatorCheckLinePattern(GCPtr pGC, CreatorPrivGCPtr gcPriv);
+
+extern int CreatorCheckFill (GCPtr pGC, DrawablePtr pDrawable);
+
+extern void CreatorSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pcharsrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted);
+
+/* Stuff still not accelerated fully. */
+extern void CreatorSegmentSSStub (DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSeg);
+
+extern void CreatorLineSSStub (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt);
+
+extern void CreatorSegmentSDStub (DrawablePtr pDrawable, GCPtr pGC,
+ int nseg, xSegment *pSeg);
+
+extern void CreatorLineSDStub (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt);
+
+extern void CreatorSolidSpansGeneralStub (DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void CreatorPolyGlyphBlt8Stub (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph, CharInfoPtr *ppci,
+ pointer pglyphBase);
+
+extern void CreatorImageGlyphBlt8Stub (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase);
+
+extern void CreatorTile32FSCopyStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void CreatorTile32FSGeneralStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void CreatorUnnaturalTileFSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void Creator8Stipple32FSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void CreatorUnnaturalStippleFSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void Creator8OpaqueStipple32FSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted);
+
+extern void CreatorPolyFillRectStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+
+#endif /* FFBGC_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_glyph.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_glyph.c
new file mode 100644
index 000000000..76668e3fc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_glyph.c
@@ -0,0 +1,380 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Glyph rops.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb_glyph.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_loops.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+void
+CreatorPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ FontPtr pfont = pGC->font;
+ RegionPtr clip = cfbGetCompositeClip(pGC);
+ BoxPtr pbox = REGION_RECTS(clip);
+ int nbox = REGION_NUM_RECTS(clip);
+ int skippix, skipglyph, width, n, i;
+ int Left, Right, Top, Bottom, LeftEdge, RightEdge;
+
+ FFBLOG(("CreatorPolyGlyphBlt: xy[%08x:%08x] nglyph(%d)\n", x, y, nglyph));
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ width = 0;
+ for(i = 0; i < (nglyph - 1); i++)
+ width += (ppci[i])->metrics.characterWidth;
+
+ Left = x + (ppci[0])->metrics.leftSideBearing;
+ Right = x + (width + (ppci[nglyph - 1])->metrics.rightSideBearing);
+ Top = y - FONTMAXBOUNDS(pfont, ascent);
+ Bottom = y + FONTMAXBOUNDS(pfont, descent);
+
+ while(nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ if(!nbox || Bottom < pbox->y1)
+ return;
+
+ /* Ok, setup the chip. */
+ {
+ unsigned int ppc = (FFB_PPC_APE_DISABLE | FFB_PPC_TBE_TRANSPARENT |
+ FFB_PPC_CS_CONST);
+ unsigned int ppc_mask = (FFB_PPC_APE_MASK | FFB_PPC_TBE_MASK |
+ FFB_PPC_CS_MASK);
+ unsigned int pmask = pGC->planemask;
+ unsigned int rop = (FFB_ROP_EDIT_BIT | pGC->alu) | (FFB_ROP_NEW << 8);
+ unsigned int fg = pGC->fgPixel;
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ unsigned int fbc = FFB_FBC_WIN(pWin);
+
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+
+ if((pFfb->ppc_cache & ppc_mask) != ppc ||
+ pFfb->fg_cache != fg ||
+ pFfb->fbc_cache != fbc ||
+ pFfb->rop_cache != rop ||
+ pFfb->pmask_cache != pmask ||
+ pFfb->fontinc_cache != ((1<<16) | 0)) {
+ pFfb->ppc_cache &= ~ppc_mask;
+ pFfb->ppc_cache |= ppc;
+ pFfb->fg_cache = fg;
+ pFfb->fbc_cache = fbc;
+ pFfb->rop_cache = rop;
+ pFfb->pmask_cache = pmask;
+ pFfb->fontinc_cache = ((1<<16) | 0);
+ pFfb->rp_active = 1;
+ FFBFifo(pFfb, 6);
+ ffb->ppc = ppc;
+ ffb->fg = fg;
+ ffb->fbc = fbc;
+ ffb->rop = rop;
+ ffb->pmask = pmask;
+ ffb->fontinc = ((1 << 16) | 0);
+ }
+ }
+
+ while(nbox && (Bottom >= pbox->y1)) {
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+ if(RightEdge > LeftEdge) {
+ int walk, x_start;
+
+ skippix = LeftEdge - x;
+ skipglyph = walk = 0;
+ while(skippix >= (walk + (ppci[skipglyph])->metrics.rightSideBearing)) {
+ walk += (ppci[skipglyph])->metrics.characterWidth;
+ skipglyph++;
+ }
+ x_start = x + walk;
+ skippix = RightEdge - x;
+ n = 0;
+ i = skipglyph;
+ while((i < nglyph) &&
+ (skippix > (walk + (ppci[i])->metrics.leftSideBearing))) {
+ walk += (ppci[i])->metrics.characterWidth;
+ i++;
+ n++;
+ }
+ if(n) {
+ CharInfoPtr *ppci_iter = ppci + skipglyph;
+ CharInfoPtr pci;
+ unsigned int *bits;
+ int w, h, x0, y0, xskip, yskip;
+
+ while(n--) {
+ pci = *ppci_iter++;
+ w = GLYPHWIDTHPIXELS(pci);
+ h = GLYPHHEIGHTPIXELS(pci);
+ if(!w || !h)
+ goto next_glyph;
+
+ x0 = x_start + pci->metrics.leftSideBearing;
+ y0 = y - pci->metrics.ascent;
+ bits = (unsigned int *) pci->bits;
+
+ /* Now clip it to the bits we should actually
+ * render.
+ */
+ xskip = yskip = 0;
+ if(pbox->x1 > x0) {
+ xskip = pbox->x1 - x0;
+ w -= xskip;
+ x0 = pbox->x1;
+ if(w <= 0)
+ goto next_glyph;
+ }
+ if(pbox->y1 > y0) {
+ yskip = pbox->y1 - y0;
+ h -= yskip;
+ y0 = pbox->y1;
+ if(h <= 0)
+ goto next_glyph;
+ }
+ if(pbox->x2 < (x0 + w)) {
+ w = pbox->x2 - x0;
+ if(w <= 0)
+ goto next_glyph;
+ }
+ if(pbox->y2 < (y0 + h)) {
+ h = pbox->y2 - y0;
+ if(h <= 0)
+ goto next_glyph;
+ }
+
+ FFB_WRITE_FONTW(pFfb, ffb, w);
+ FFBFifo(pFfb, 1 + h);
+ ffb->fontxy = ((y0 << 16) | x0);
+ for(i = 0; i < h; i++)
+ ffb->font = bits[yskip + i] << xskip;
+
+ next_glyph:
+ x_start += pci->metrics.characterWidth;
+ }
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+void
+CreatorTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ RegionPtr clip = cfbGetCompositeClip(pGC);
+ int nbox = REGION_NUM_RECTS(clip);
+ BoxPtr pbox = REGION_RECTS(clip);
+ FontPtr pfont = pGC->font;
+ int glyphWidth = FONTMAXBOUNDS(pfont, characterWidth);
+ int skippix, skipglyphs, Left, Right, Top, Bottom;
+ int LeftEdge, RightEdge, ytop, ybot, h, w;
+
+ FFBLOG(("CreatorTEGlyphBlt: xy[%08x:%08x] nglyph(%d) pgbase(%p)\n",
+ x, y, nglyph, pGlyphBase));
+
+ Left = x + pDrawable->x;
+ Right = Left + (glyphWidth * nglyph);
+ y += pDrawable->y;
+ Top = y - FONTASCENT(pfont);
+ Bottom = y + FONTDESCENT(pfont);
+
+ while(nbox && (Top >= pbox->y2)) {
+ pbox++;
+ nbox--;
+ }
+
+ if(!nbox || Bottom <= pbox->y1)
+ return;
+
+ /* Ok, setup the chip. */
+ {
+ unsigned int ppc = FFB_PPC_APE_DISABLE|FFB_PPC_CS_CONST;
+ unsigned int ppc_mask = FFB_PPC_APE_MASK|FFB_PPC_TBE_MASK|FFB_PPC_CS_MASK;
+ unsigned int pmask = pGC->planemask;
+ unsigned int rop;
+ unsigned int fg = pGC->fgPixel;
+ unsigned int bg = pGC->bgPixel;
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ unsigned int fbc = FFB_FBC_WIN(pWin);
+
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+
+ if(pGlyphBase) {
+ ppc |= FFB_PPC_TBE_TRANSPARENT;
+ rop = FFB_ROP_EDIT_BIT | pGC->alu;
+ } else {
+ ppc |= FFB_PPC_TBE_OPAQUE;
+ rop = FFB_ROP_EDIT_BIT | GXcopy;
+ }
+ rop |= (FFB_ROP_NEW << 8);
+ if((pFfb->ppc_cache & ppc_mask) != ppc ||
+ pFfb->fg_cache != fg ||
+ pFfb->fbc_cache != fbc ||
+ pFfb->rop_cache != rop ||
+ pFfb->pmask_cache != pmask ||
+ pFfb->fontinc_cache != ((1<<16) | 0) ||
+ (!pGlyphBase && pFfb->bg_cache != bg)) {
+ pFfb->ppc_cache &= ~ppc_mask;
+ pFfb->ppc_cache |= ppc;
+ pFfb->fg_cache = fg;
+ pFfb->fbc_cache = fbc;
+ pFfb->rop_cache = rop;
+ pFfb->pmask_cache = pmask;
+ pFfb->fontinc_cache = ((1<<16) | 0);
+ if(!pGlyphBase)
+ pFfb->bg_cache = bg;
+ FFBFifo(pFfb, (!pGlyphBase ? 7 : 6));
+ ffb->ppc = ppc;
+ ffb->fg = fg;
+ ffb->fbc = fbc;
+ ffb->rop = rop;
+ ffb->pmask = pmask;
+ ffb->fontinc = ((1 << 16) | 0);
+ if(!pGlyphBase)
+ ffb->bg = bg;
+ }
+ }
+
+ while(nbox && (Bottom > pbox->y1)) {
+ LeftEdge = max(Left, pbox->x1);
+ RightEdge = min(Right, pbox->x2);
+
+ if(RightEdge > LeftEdge) {
+ ytop = max(Top, pbox->y1);
+ ybot = min(Bottom, pbox->y2);
+
+ if((skippix = LeftEdge - Left)) {
+ skipglyphs = skippix / glyphWidth;
+ skippix %= glyphWidth;
+ } else
+ skipglyphs = 0;
+ w = RightEdge - LeftEdge;
+
+ /* Get aligned onto a character. */
+ if(skippix) {
+ unsigned int *gbits = (unsigned int *) ppci[skipglyphs++]->bits;
+ int chunk_size = (glyphWidth - skippix);
+
+ if (chunk_size > w)
+ chunk_size = w;
+
+ FFB_WRITE_FONTW(pFfb, ffb, chunk_size);
+ FFBFifo(pFfb, 1 + (ybot - ytop));
+ ffb->fontxy = ((ytop << 16) | LeftEdge);
+ for(h = (ytop - Top); h < (ybot - Top); h++)
+ ffb->font = gbits[h] << skippix;
+ LeftEdge += chunk_size;
+ w -= chunk_size;
+ }
+ /* And now blit the rest with unrolled loops. */
+#define LoopIt(chunkW, loadup, fetch) \
+ FFB_WRITE_FONTW(pFfb, ffb, chunkW); \
+ while (w >= chunkW) { \
+ loadup \
+ FFBFifo(pFfb, 1 + (ybot - ytop)); \
+ ffb->fontxy = ((ytop << 16) | LeftEdge); \
+ for(h = (ytop - Top); h < (ybot - Top); h++) \
+ ffb->font = fetch; \
+ LeftEdge += chunkW; \
+ w -= chunkW; \
+ }
+ if(glyphWidth <= 8) {
+ int chunk_size = glyphWidth << 2;
+ LoopIt(chunk_size,
+ unsigned int *char1 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);
+ unsigned int *char2 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);
+ unsigned int *char3 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);
+ unsigned int *char4 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);,
+ (*char1++ | ((*char2++ | ((*char3++ | (*char4++ >> glyphWidth))
+ >> glyphWidth))
+ >> glyphWidth)))
+ } else if(glyphWidth <= 10) {
+ int chunk_size = (glyphWidth << 1) + glyphWidth;
+ LoopIt(chunk_size,
+ unsigned int *char1 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);
+ unsigned int *char2 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);
+ unsigned int *char3 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);,
+ (*char1++ | ((*char2++ | (*char3++ >> glyphWidth)) >> glyphWidth)));
+ } else if(glyphWidth <= 16) {
+ int chunk_size = glyphWidth << 1;
+ LoopIt(chunk_size,
+ unsigned int *char1 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);
+ unsigned int *char2 = ((unsigned int *)ppci[skipglyphs++]->bits)+(ytop-Top);,
+ (*char1++ | (*char2++ >> glyphWidth)));
+ }
+#undef LoopIt
+ /* Take care of any final glyphs. */
+ while(w > 0) {
+ unsigned int *gbits = (unsigned int *) ppci[skipglyphs++]->bits;
+ int pix = glyphWidth;
+
+ if(w < pix)
+ pix = w;
+ FFB_WRITE_FONTW(pFfb, ffb, pix);
+ FFBFifo(pFfb, 1 + (ybot - ytop));
+ ffb->fontxy = ((ytop << 16) | LeftEdge);
+ for(h = (ytop - Top); h < (ybot - Top); h++)
+ ffb->font = gbits[h];
+ LeftEdge += pix;
+ w -= pix;
+ }
+ }
+ nbox--;
+ pbox++;
+ }
+
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
+
+void
+CreatorPolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ CreatorTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (char *) 1);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gspans.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gspans.c
new file mode 100644
index 000000000..5c00cb728
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_gspans.c
@@ -0,0 +1,130 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Get spans.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_gspans.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+void
+CreatorGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
+ int *pwidth, int nspans, char *pchardstStart)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ char *addrp;
+
+ FFBLOG(("CreatorGetSpans: wmax(%d) nspans(%d)\n", wMax, nspans));
+
+ /* Punt early for this case. */
+ if(pDrawable->bitsPerPixel == 1) {
+ mfbGetSpans(pDrawable, wMax, ppt, pwidth,
+ nspans, pchardstStart);
+ return;
+ }
+
+ /* This code only works when sucking bits directly from
+ * the framebuffer.
+ */
+ if(pDrawable->type != DRAWABLE_WINDOW) {
+ if (pDrawable->bitsPerPixel == 8)
+ cfbGetSpans(pDrawable, wMax, ppt, pwidth,
+ nspans, pchardstStart);
+ else
+ cfb32GetSpans(pDrawable, wMax, ppt, pwidth,
+ nspans, pchardstStart);
+ return;
+ }
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!cfbDrawableEnabled(pDrawable))
+ return;
+
+ /* We're just reading pixels from SFB, but we could be using
+ * a different read buffer when double-buffering.
+ */
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0x00ffffff, GXcopy, (WindowPtr)pDrawable);
+ FFBWait(pFfb, ffb);
+
+ if (pDrawable->bitsPerPixel == 32) {
+ unsigned int *pdst = (unsigned int *)pchardstStart;
+
+ addrp = (char *) pFfb->sfb32;
+
+ if ((nspans == 1) && (*pwidth == 1)) {
+ *pdst = *(unsigned int *)(addrp + (ppt->y << 13) + (ppt->x << 2));
+ return;
+ }
+
+ while(nspans--) {
+ int w = min(ppt->x + *pwidth, 2048) - ppt->x;
+ unsigned int *psrc = (unsigned int *) (addrp +
+ (ppt->y << 13) +
+ (ppt->x << 2));
+ unsigned int *pdstNext = pdst + w;
+
+ while (w--)
+ *psrc++ = *pdst++;
+ pdst = pdstNext;
+ ppt++;
+ pwidth++;
+ }
+ } else {
+ unsigned char *pdst = (unsigned char *)pchardstStart;
+
+ addrp = (char *) pFfb->sfb8r;
+
+ if ((nspans == 1) && (*pwidth == 1)) {
+ *pdst = *(unsigned char *)(addrp + (ppt->y << 11) + (ppt->x << 0));
+ return;
+ }
+
+ while(nspans--) {
+ int w = min(ppt->x + *pwidth, 2048) - ppt->x;
+ unsigned char *psrc = (unsigned char *) (addrp +
+ (ppt->y << 11) +
+ (ppt->x << 0));
+ unsigned char *pdstNext = pdst + w;
+
+ while (w--)
+ *psrc++ = *pdst++;
+ pdst = pdstNext;
+ ppt++;
+ pwidth++;
+ }
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_line.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_line.c
new file mode 100644
index 000000000..e94fd0300
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_line.c
@@ -0,0 +1,195 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Line rops.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_line.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "miline.h"
+
+/* The scheme here is similar as for segments, except that
+ * if there are any out of range coordinate, we fully punt
+ * and do all of the pieces in software. This is as to
+ * avoid complexity in final line capping, sloped lines, line
+ * patterns etc.
+ */
+#define IN_RANGE(_extent, _x, _y) \
+ ((_x) >= (_extent)->x1 && (_x) < (_extent)->x2 && \
+ (_y) >= (_extent)->y1 && (_y) < (_extent)->y2)
+
+
+void
+CreatorPolylines (DrawablePtr pDrawable, GCPtr pGC, int mode, int nptInit, DDXPointPtr pptInit)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ DDXPointPtr ppt;
+ BoxPtr extent;
+ int x, y, xorg, yorg, npt, capLast;
+
+ npt = nptInit;
+ if (npt <= 1)
+ return;
+ ppt = pptInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ x = ppt->x + xorg;
+ y = ppt->y + yorg;
+ extent = REGION_RECTS(cfbGetCompositeClip(pGC));
+ if (!IN_RANGE(extent, x, y))
+ goto punt_rest;
+ ppt++;
+ while(npt--) {
+ if (mode == CoordModeOrigin) {
+ x = ppt->x + xorg;
+ y = ppt->y + yorg;
+ } else {
+ x += ppt->x;
+ y += ppt->y;
+ }
+ if (!IN_RANGE(extent, x, y))
+ goto punt_rest;
+ ppt++;
+ }
+ FFBLOG(("CreatorPolylines: npt(%d) lpat(%08x) alu(%x) pmsk(%08x)\n",
+ npt, gcPriv->linepat, pGC->alu, pGC->planemask));
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ FFB_DRAWOP_BRLINEOPEN);
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_BRLINEOPEN);
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+ pFfb->rp_active = 1;
+
+ ppt = pptInit;
+ npt = nptInit;
+ x = ppt->x + xorg;
+ y = ppt->y + yorg;
+
+ FFBFifo(pFfb, 3);
+ ffb->lpat = gcPriv->linepat;
+ ffb->by = y;
+ ffb->bx = x;
+ ppt++;
+ npt--;
+ capLast = pGC->capStyle != CapNotLast;
+ if (mode == CoordModeOrigin) {
+ if (capLast)
+ npt--;
+ if (pFfb->has_brline_bug) {
+ while (npt--) {
+ x = ppt->x + xorg;
+ y = ppt->y + yorg;
+ ppt++;
+ FFBFifo(pFfb, 3);
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->bh, y, x);
+ }
+ } else {
+ while (npt--) {
+ x = ppt->x + xorg;
+ y = ppt->y + yorg;
+ ppt++;
+ FFBFifo(pFfb, 2);
+ FFB_WRITE64(&ffb->bh, y, x);
+ }
+ }
+ if (capLast) {
+ register int x2, y2;
+
+ x2 = ppt->x + xorg;
+ y2 = ppt->y + yorg;
+
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_BRLINECAP);
+ FFBFifo(pFfb, 5);
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, y2, x2);
+ }
+ } else {
+ if (capLast)
+ npt--;
+ if (pFfb->has_brline_bug) {
+ while (npt--) {
+ x += ppt->x;
+ y += ppt->y;
+ ppt++;
+
+ FFBFifo(pFfb, 3);
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->bh, y, x);
+ }
+ } else {
+ while (npt--) {
+ x += ppt->x;
+ y += ppt->y;
+ ppt++;
+
+ FFBFifo(pFfb, 2);
+ FFB_WRITE64(&ffb->bh, y, x);
+ }
+ }
+ if (capLast) {
+ register int x2, y2;
+
+ x2 = x + ppt->x;
+ y2 = y + ppt->y;
+
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_BRLINECAP);
+ FFBFifo(pFfb, 5);
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, y2, x2);
+ }
+ }
+ FFBSync(pFfb, ffb);
+ return;
+
+punt_rest:
+ gcPriv->Polylines(pDrawable, pGC, mode, nptInit, pptInit);
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_loops.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_loops.h
new file mode 100644
index 000000000..efb14c391
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_loops.h
@@ -0,0 +1,212 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - fast inner loops.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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 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/drivers/sunffb/ffb_loops.h,v 1.1 2000/05/18 23:21:37 dawes Exp $ */
+
+#ifndef FFBLOOPS_H
+#define FFBLOOPS_H
+
+#ifdef USE_VIS
+extern void FFB_STIPPLE_LOAD(volatile unsigned int *d,
+ unsigned int *s);
+
+extern void FFB_PPT_BOX_LOOP(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ BoxPtr pbox, BoxPtr pbox_last,
+ DDXPointPtr ppt);
+
+extern void FFB_BOX_LOOP(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ BoxPtr pbox,
+ BoxPtr pbox_last);
+
+extern void FFB_RECT_LOOP(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ xRectangle *prect,
+ xRectangle *prect_last,
+ int xOrg, int yOrg);
+
+extern void FFB_PPT_WIDTH_LOOP(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int *pwidth);
+
+extern DDXPointPtr FFB_PPT_LOOP1(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int xOrg, int yOrg);
+
+extern DDXPointPtr FFB_PPT_LOOP2(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int x, int y);
+
+extern DDXPointPtr FFB_LINE_LOOP1(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int xOrg, int yOrg);
+
+extern DDXPointPtr FFB_LINE_LOOP2(FFBPtr ffbpriv,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int *x, int *y);
+
+#else /* !USE_VIS */
+
+#define FFB_STIPPLE_LOAD(_d,_s) \
+do { \
+ volatile unsigned int *d = (_d); \
+ unsigned int *s = (_s); \
+ int i; \
+ \
+ for (i = 0; i < (32 / 2); i++, d+=2, s+=2) \
+ FFB_WRITE64(d, s[0], s[1]); \
+} while (0)
+
+#define FFB_PPT_BOX_LOOP(pFfb, ffb, pbox, _pbox_last, ppt) \
+do { \
+ BoxPtr pbox_last = (BoxPtr)(_pbox_last); \
+ while (pbox <= pbox_last) { \
+ FFBFifo(pFfb, 7); \
+ ffb->drawop = FFB_DRAWOP_VSCROLL; \
+ FFB_WRITE64(&ffb->by, ppt->y, ppt->x); \
+ FFB_WRITE64_2(&ffb->dy, pbox->y1, pbox->x1); \
+ FFB_WRITE64_3(&ffb->bh, (pbox->y2 - pbox->y1), (pbox->x2 - pbox->x1)); \
+ pbox++; ppt++; \
+ } \
+} while (0)
+
+#define FFB_BOX_LOOP(pFfb, ffb, pbox, _pbox_last) \
+do { \
+ BoxPtr pbox_last = (BoxPtr)(_pbox_last); \
+ while (pbox <= pbox_last) { \
+ FFBFifo(pFfb, 4); \
+ FFB_WRITE64(&ffb->by, pbox->y1, pbox->x1); \
+ FFB_WRITE64_2(&ffb->bh, (pbox->y2 - pbox->y1), (pbox->x2 - pbox->x1)); \
+ pbox++; \
+ } \
+} while (0)
+
+#define FFB_RECT_LOOP(pFfb, ffb, prect, _prect_last, xOrg, yOrg) \
+do { \
+ xRectangle *prect_last = (xRectangle *)(_prect_last); \
+ for (; prect <= prect_last; prect++) { \
+ register int x, y, w, h; \
+ x = prect->x + xOrg; \
+ y = prect->y + yOrg; \
+ w = prect->width; \
+ h = prect->height; \
+ if (extents->x2 <= x || \
+ extents->x1 >= x + w || \
+ extents->y2 <= y || \
+ extents->y1 >= y + h) \
+ continue; \
+ FFBFifo(pFfb, 4); \
+ FFB_WRITE64(&ffb->by, y, x); \
+ FFB_WRITE64_2(&ffb->bh, h, w); \
+ } \
+} while (0)
+
+#define FFB_PPT_WIDTH_LOOP(pFfb, ffb, ppt, _ppt_last, pwidth) \
+do { \
+ DDXPointPtr ppt_last = (DDXPointPtr)(_ppt_last); \
+ while (ppt <= ppt_last) { \
+ register int x, y, w; \
+ x = ppt->x; \
+ y = ppt->y; \
+ w = *pwidth++; \
+ FFBFifo(pFfb, 5); \
+ ffb->ppc = 0; \
+ FFB_WRITE64(&ffb->by, y, x); \
+ FFB_WRITE64_2(&ffb->bh, y, (x + w)); \
+ ppt++; \
+ } \
+} while (0)
+
+static __inline__ DDXPointPtr FFB_PPT_LOOP1(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int xOrg, int yOrg)
+{
+ while (ppt <= ppt_last) {
+ FFBFifo(pFfb, 2);
+ FFB_WRITE64_2(&ffb->bh, (ppt->y + yOrg), (ppt->x + xOrg));
+ ppt++;
+ }
+ return ppt;
+}
+
+static __inline__ DDXPointPtr FFB_PPT_LOOP2(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int x, int y)
+{
+ register int __x = x, __y = y;
+ while (ppt <= ppt_last) {
+ FFBFifo(pFfb, 2);
+ __x += ppt->x;
+ __y += ppt->y;
+ FFB_WRITE64_2(&ffb->bh, __y, __x);
+ ppt++;
+ }
+ return ppt;
+}
+
+static __inline__ DDXPointPtr FFB_LINE_LOOP1(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int xOrg, int yOrg)
+{
+ while (ppt <= ppt_last) {
+ FFBFifo(pFfb, 3);
+ ffb->ppc = 0;
+ FFB_WRITE64_2(&ffb->bh, (ppt->y + yOrg), (ppt->x + xOrg));
+ ppt++;
+ }
+ return ppt;
+}
+
+static __inline__ DDXPointPtr FFB_LINE_LOOP2(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ DDXPointPtr ppt, DDXPointPtr ppt_last,
+ int *x, int *y)
+{
+ register int __x = *x, __y = *y;
+ while (ppt <= ppt_last) {
+ FFBFifo(pFfb, 3);
+ ffb->ppc = 0;
+ __x += ppt->x;
+ __y += ppt->y;
+ FFB_WRITE64_2(&ffb->bh, __y, __x);
+ ppt++;
+ }
+ *x = __x;
+ *y = __y;
+ return ppt;
+}
+
+#endif /* !USE_VIS */
+
+#endif /* FFBLOOPS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_plygon.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_plygon.c
new file mode 100644
index 000000000..933b15f05
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_plygon.c
@@ -0,0 +1,167 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Polygon rops.
+ *
+ * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_plygon.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "mi.h"
+
+void
+CreatorFillPolygon (DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr ppt)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ BoxRec box;
+ int lx, rx, ty, by;
+ int t, b, i, j, k, l, tt;
+ int xy[12] FFB_ALIGN64;
+ int xOrg, yOrg;
+
+ FFBLOG(("CreatorFillPolygon: ALU(%x) PMSK(%08x) shape(%d) mode(%d) count(%d)\n",
+ pGC->alu, pGC->planemask, shape, mode, count));
+ if (count < 3)
+ return;
+
+ if (shape != Convex && count > 3) {
+ miFillPolygon (pDrawable, pGC, shape, mode, count, ppt);
+ return;
+ }
+
+ xOrg = pDrawable->x;
+ yOrg = pDrawable->y;
+
+ ppt->x += xOrg;
+ ppt->y += yOrg;
+ lx = ppt->x;
+ rx = ppt->x;
+ ty = ppt->y;
+ by = ppt->y;
+ t = b = 0;
+ tt = 1;
+ for (i = 1; i < count; i++) {
+ if (mode == CoordModeOrigin) {
+ ppt[i].x += xOrg;
+ ppt[i].y += yOrg;
+ } else {
+ ppt[i].x += ppt[i-1].x;
+ ppt[i].y += ppt[i-1].y;
+ }
+ if (ppt[i].x < lx)
+ lx = ppt[i].x;
+ if (ppt[i].x > rx)
+ rx = ppt[i].x;
+ if (ppt[i].y < ty) {
+ ty = ppt[i].y;
+ t = i;
+ tt = 1;
+ } else if (ppt[i].y == ty)
+ tt++;
+ if (ppt[i].y > by) {
+ by = ppt[i].y;
+ b = i;
+ }
+ }
+ if (tt > 2) {
+ miFillConvexPoly(pDrawable, pGC, count, ppt);
+ return;
+ } else if (tt == 2) {
+ i = t - 1;
+ if (i < 0)
+ i = count - 1;
+ if (ppt[i].y == ppt[t].y)
+ t = i;
+ }
+ box.x1 = lx;
+ box.x2 = rx + 1;
+ box.y1 = ty;
+ box.y2 = by + 1;
+
+ switch (RECT_IN_REGION(pGC->pScreen, cfbGetCompositeClip(pGC), &box)) {
+ case rgnPART:
+ miFillConvexPoly(pDrawable, pGC, count, ppt);
+ case rgnOUT:
+ return;
+ }
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ FFB_DRAWOP_POLYGON);
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_POLYGON);
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+ xy[0] = ppt[t].y;
+ xy[1] = ppt[t].x;
+ j = t + 1;
+ if (j == count) j = 0;
+ xy[2] = ppt[j].y;
+ xy[3] = ppt[j].x;
+ j = t + 2;
+ if (j >= count)
+ j -= count;
+ for (i = 2 * count - 4; i; i -= k) {
+ b = 2;
+ for (k = 0; k < i && k < 8; k+=2) {
+ xy[4 + k] = ppt[j].y;
+ xy[4 + k + 1] = ppt[j].x;
+ if (xy[4 + k] > xy[b])
+ b = 4 + k;
+ j++; if (j == count) j = 0;
+ }
+ FFBFifo(pFfb, 4 + k);
+ for (l = 0; l < b - 2; l+=2)
+ FFB_WRITE64P(&ffb->by, &xy[l]);
+ FFB_WRITE64P(&ffb->bh, &xy[l]);
+ for (l+=2; l <= k; l+=2)
+ FFB_WRITE64P(&ffb->by, &xy[l]);
+ FFB_WRITE64P(&ffb->ebyi, &xy[l]);
+ xy[2] = xy[l];
+ xy[3] = xy[l+1];
+ }
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_point.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_point.c
new file mode 100644
index 000000000..407f22cde
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_point.c
@@ -0,0 +1,108 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Point rops.
+ *
+ * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_point.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_loops.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+void
+CreatorPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode,
+ int npt, xPoint *pptInit)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ ffb_fbcPtr ffb = pFfb->regs;
+ RegionPtr clip;
+ int numRects;
+ register int off, c1, c2;
+ register char *addrp;
+ register int *ppt, pt, i;
+ BoxPtr pbox;
+ xPoint *pptPrev;
+
+ FFBLOG(("CreatorPolyPoint: ALU(%x) PMSK(%08x) mode(%d) npt(%d)\n",
+ pGC->alu, pGC->planemask, mode, npt));
+
+ if (pGC->alu == GXnoop)
+ return;
+
+ clip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS(clip);
+ off = *(int *)&pDrawable->x;
+ off -= (off & 0x8000) << 1;
+ if (mode == CoordModePrevious && npt > 1) {
+ for (pptPrev = pptInit + 1, i = npt - 1; --i >= 0; pptPrev++) {
+ pptPrev->x += pptPrev[-1].x;
+ pptPrev->y += pptPrev[-1].y;
+ }
+ }
+
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ pFfb->drawop_cache);
+ FFBWait(pFfb, ffb);
+
+ if (pGC->depth == 8) {
+ addrp = (char *)pFfb->sfb8r + (pDrawable->y << 11) + (pDrawable->x << 0);
+ pbox = REGION_RECTS(clip);
+ while (numRects--) {
+ c1 = *(int *)&pbox->x1 - off;
+ c2 = *(int *)&pbox->x2 - off - 0x00010001;
+ for (ppt = (int *)pptInit, i = npt; --i >= 0; ) {
+ pt = *ppt++;
+ if (!(((pt - c1) | (c2 - pt)) & 0x80008000))
+ *(unsigned char *)(addrp + ((pt << 11) & 0x3ff800) +
+ ((pt >> 16) & 0x07ff)) = 0;
+ }
+ pbox++;
+ }
+ } else {
+ addrp = (char *)pFfb->sfb32 + (pDrawable->y << 13) + (pDrawable->x << 2);
+ pbox = REGION_RECTS(clip);
+ while (numRects--) {
+ c1 = *(int *)&pbox->x1 - off;
+ c2 = *(int *)&pbox->x2 - off - 0x00010001;
+ for (ppt = (int *)pptInit, i = npt; --i >= 0; ) {
+ pt = *ppt++;
+ if (!(((pt - c1) | (c2 - pt)) & 0x80008000))
+ *(unsigned int *)(addrp + ((pt << 13) & 0xffe000) +
+ ((pt >> 14) & 0x1ffc)) = 0;
+ }
+ pbox++;
+ }
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h
new file mode 100644
index 000000000..5beb23ea4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rcache.h
@@ -0,0 +1,333 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - register caching.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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 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/drivers/sunffb/ffb_rcache.h,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#ifndef FFBRCACHE_H
+#define FFBRCACHE_H
+
+/* We only need to write the bits which actually change,
+ * writing unnessary bits causes the operation to go more
+ * slowly. -DaveM
+ *
+ * We used to have some hairy code here which tried to
+ * avoid writing attribute bits unnecessarily. It has been
+ * removed because various two bit fields have different
+ * semantics. For example, for some the higher bit is the
+ * edit bit, for others there are three state patterns
+ * and zero is a special "no edit" value. Ho hum, it was
+ * a nice idea...
+ */
+#define FFB_WRITE_PPC(__fpriv, __ffb, __val, __chg_mask) \
+do { unsigned int oldval = (__fpriv)->ppc_cache; \
+ unsigned int __t; \
+ __t = (oldval & (__chg_mask)) ^ (__val); \
+ if (__t) { \
+ unsigned int newval = oldval & ~(__chg_mask); \
+ newval |= (__val); \
+ (__fpriv)->ppc_cache = newval; \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->ppc = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_PMASK(__fpriv, __ffb, __val) \
+do { if((__fpriv)->pmask_cache != (__val)) { \
+ (__fpriv)->pmask_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->pmask = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_ROP(__fpriv, __ffb, __val) \
+do { if((__fpriv)->rop_cache != (__val)) { \
+ (__fpriv)->rop_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->rop = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_DRAWOP(__fpriv, __ffb, __val) \
+do { if((__fpriv)->drawop_cache != (__val)) { \
+ (__fpriv)->drawop_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->drawop = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_FG(__fpriv, __ffb, __val) \
+do { if((__fpriv)->fg_cache != (__val)) { \
+ (__fpriv)->fg_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->fg = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_BG(__fpriv, __ffb, __val) \
+do { if((__fpriv)->bg_cache != (__val)) { \
+ (__fpriv)->bg_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->bg = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_FONTW(__fpriv, __ffb, __val) \
+do { if((__fpriv)->fontw_cache != (__val)) { \
+ (__fpriv)->fontw_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->fontw = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_FONTINC(__fpriv, __ffb, __val) \
+do { if((__fpriv)->fontinc_cache != (__val)) { \
+ (__fpriv)->fontinc_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->fontinc = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_FBC(__fpriv, __ffb, __val) \
+do { if((__fpriv)->fbc_cache != (__val)) { \
+ (__fpriv)->fbc_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->fbc = (__val); \
+ } \
+} while(0)
+
+#define FFB_WRITE_WID(__fpriv, __ffb, __val) \
+do { if((__fpriv)->wid_cache != (__val)) { \
+ (__fpriv)->wid_cache = (__val); \
+ FFBFifo((__fpriv), 1); \
+ (__ffb)->wid = (__val); \
+ } \
+} while(0)
+
+extern void __FFB_Attr_Raw(FFBPtr pFfb,
+ unsigned int ppc,
+ unsigned int ppc_mask,
+ unsigned int pmask,
+ unsigned int rop,
+ int drawop, int fg,
+ unsigned int fbc,
+ unsigned int wid);
+
+#define FFB_ATTR_RAW(__fpriv, __ppc, __ppc_mask, __pmask, __rop, __drawop, __fg, __fbc, __wid) \
+ if((((__fpriv)->ppc_cache & (__ppc_mask)) != (__ppc)) || \
+ ((__fpriv)->pmask_cache != (__pmask)) || \
+ ((__fpriv)->rop_cache != (__rop)) || \
+ (((__drawop) != -1) && ((__fpriv)->drawop_cache != (__drawop))) || \
+ ((__fpriv)->fg_cache != (__fg)) || \
+ ((__fpriv)->fbc_cache != (__fbc)) || \
+ ((__fpriv)->wid_cache != (__wid))) \
+ __FFB_Attr_Raw((__fpriv), (__ppc), (__ppc_mask), (__pmask), \
+ (__rop), (__drawop), (__fg), (__fbc), (__wid))
+
+#define FFB_PPC_GCMASK (FFB_PPC_APE_MASK | FFB_PPC_CS_MASK)
+
+/* This is for loading the FFB attributes for the case where
+ * where most of the values come directly from the graphics
+ * context and only the PPC and DRAWOP are variable.
+ */
+extern void __FFB_Attr_GC(FFBPtr pFfb, GCPtr pGC, WindowPtr pWin,
+ unsigned int ppc, int drawop);
+
+#define FFB_ATTR_GC(__fpriv, __pgc, __pwin, __ppc, __drawop) \
+do { CreatorPrivWinPtr __winpriv = CreatorGetWindowPrivate(__pwin); \
+ unsigned int __rop = ((__pgc)->alu | FFB_ROP_EDIT_BIT); \
+ unsigned int __fbc = ((__winpriv)->fbc_base); \
+ __fbc &= ~FFB_FBC_XE_MASK; \
+ __fbc |= FFB_FBC_XE_OFF; \
+ __rop |= (FFB_ROP_NEW << 8); \
+ if ((((__fpriv)->ppc_cache & FFB_PPC_GCMASK) != (__ppc))|| \
+ ((__fpriv)->pmask_cache != ((__pgc)->planemask)) || \
+ ((__fpriv)->rop_cache != (__rop)) || \
+ ((__fpriv)->drawop_cache != (__drawop)) || \
+ ((__fpriv)->fg_cache != ((__pgc)->fgPixel)) || \
+ ((__fpriv)->fbc_cache != __fbc)) \
+ __FFB_Attr_GC(__fpriv, __pgc, __pwin, __ppc, __drawop); \
+} while(0)
+
+#define FFB_PPC_WINMASK (FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK)
+
+extern void __FFB_Attr_FastfillWin(FFBPtr pFfb, WindowPtr pWin,
+ unsigned int ppc, unsigned int pixel);
+
+#define FFB_ATTR_FFWIN(__fpriv, __pwin, __ppc, __pixel) \
+do { CreatorPrivWinPtr __winpriv = CreatorGetWindowPrivate(__pwin); \
+ unsigned int ___ppc = (__ppc) | FFB_PPC_XS_WID; \
+ unsigned int fbc = (__winpriv)->fbc_base; \
+ unsigned int rop = (FFB_ROP_NEW|(FFB_ROP_NEW<<8)); \
+ if((__fpriv)->has_double_buffer) { \
+ fbc &= ~FFB_FBC_WB_MASK; \
+ fbc |= FFB_FBC_WB_AB; \
+ } \
+ fbc &= ~(FFB_FBC_XE_MASK | FFB_FBC_RGBE_MASK); \
+ fbc |= FFB_FBC_XE_ON | FFB_FBC_RGBE_ON; \
+ if (pFfb->ffb_res == ffb_res_high) \
+ fbc |= FFB_FBC_WB_B; \
+ if ((((__fpriv)->ppc_cache & FFB_PPC_WINMASK) != (___ppc))|| \
+ ((__fpriv)->pmask_cache != 0x00ffffff) || \
+ ((__fpriv)->rop_cache!= rop) || \
+ ((__fpriv)->drawop_cache != FFB_DRAWOP_FASTFILL) || \
+ ((__fpriv)->fg_cache != (__pixel)) || \
+ ((__fpriv)->fbc_cache != fbc) || \
+ ((__fpriv)->wid_cache != ((__winpriv)->wid))) \
+ __FFB_Attr_FastfillWin(__fpriv, __pwin, ___ppc, __pixel);\
+} while (0)
+
+/* We have to be careful when copying windows around. For that
+ * case we will use either VIS copies or hw accelerated VSCROLL.
+ * All of the planes needs to be copied in the framebuffer from
+ * src to dst in order to handle child windows using different WIDs
+ * than the parent window being copied.
+ */
+
+/* Setup to access the smart frame buffer (SFB) directly where the
+ * pixel color comes from the cpu on writes.
+ */
+#define FFB_PPC_WINCOPY (FFB_PPC_APE_DISABLE | FFB_PPC_XS_VAR | FFB_PPC_CS_VAR)
+#define FFB_PPC_WINCOPY_MASK (FFB_PPC_APE_MASK | FFB_PPC_XS_MASK | FFB_PPC_CS_MASK)
+#define FFB_FBC_WINCOPY (FFB_FBC_WB_A | FFB_FBC_WM_COMBINED | FFB_FBC_WE_FORCEON | \
+ FFB_FBC_RB_A | FFB_FBC_SB_BOTH | FFB_FBC_XE_ON | \
+ FFB_FBC_ZE_OFF | FFB_FBC_YE_OFF | FFB_FBC_RGBE_ON)
+
+#define FFB_ATTR_SFB_VAR_WINCOPY(__fpriv) \
+do { unsigned int ppc = FFB_PPC_WINCOPY; \
+ unsigned int ppc_mask = FFB_PPC_WINCOPY_MASK; \
+ unsigned int rop = FFB_ROP_NEW|(FFB_ROP_NEW<<8); \
+ unsigned int fbc = FFB_FBC_WINCOPY; \
+ if((__fpriv)->has_double_buffer) { \
+ fbc &= ~FFB_FBC_WB_MASK; \
+ fbc |= FFB_FBC_WB_AB; \
+ } \
+ if (((__fpriv)->ppc_cache & ppc_mask) != ppc || \
+ (__fpriv)->fbc_cache != fbc || \
+ (__fpriv)->rop_cache != rop || \
+ (__fpriv)->pmask_cache != 0xffffffff) { \
+ ffb_fbcPtr __ffb = (__fpriv)->regs; \
+ (__fpriv)->ppc_cache &= ~ppc_mask; \
+ (__fpriv)->ppc_cache |= ppc; \
+ (__fpriv)->fbc_cache = fbc; \
+ (__fpriv)->rop_cache = rop; \
+ (__fpriv)->pmask_cache = 0xffffffff; \
+ (__fpriv)->rp_active = 1; \
+ FFBFifo(__fpriv, 4); \
+ (__ffb)->ppc = ppc; \
+ (__ffb)->fbc = fbc; \
+ (__ffb)->rop = rop; \
+ (__ffb)->pmask = 0xffffffff; \
+ (__fpriv)->rp_active = 1; \
+ } \
+} while(0)
+
+extern void __FFB_Attr_SFB_VAR(FFBPtr pFfb, unsigned int ppc, unsigned int ppc_mask, unsigned int fbc,
+ unsigned int wid, unsigned int rop, unsigned int pmask);
+
+#define FFB_ATTR_SFB_VAR_WIN(__fpriv, __pmask, __alu, __pwin) \
+do { unsigned int ppc = FFB_PPC_APE_DISABLE | FFB_PPC_CS_VAR | FFB_PPC_XS_WID; \
+ unsigned int ppc_mask = FFB_PPC_APE_MASK | FFB_PPC_CS_MASK | FFB_PPC_XS_MASK; \
+ unsigned int rop = (FFB_ROP_EDIT_BIT | (__alu))|(FFB_ROP_NEW<<8); \
+ unsigned int fbc = FFB_FBC_WIN(__pwin); \
+ if((__fpriv)->has_double_buffer) { \
+ fbc &= ~FFB_FBC_WB_MASK; \
+ fbc |= FFB_FBC_WB_AB; \
+ } \
+ if(((__fpriv)->ppc_cache & ppc_mask) != ppc || \
+ (__fpriv)->fbc_cache != fbc || \
+ (__fpriv)->wid_cache != FFB_WID_WIN(__pwin) || \
+ (__fpriv)->rop_cache != rop || \
+ (__fpriv)->pmask_cache != (__pmask)) \
+ __FFB_Attr_SFB_VAR(__fpriv, ppc, ppc_mask, fbc, \
+ FFB_WID_WIN(__pwin), rop, (__pmask)); \
+} while(0)
+
+/* VSCROLL Attributes:
+ *
+ * PPC) VCE_DISABLE must be set, all other attributes are effectively
+ * ignored since this drawop just copies pixels within the ram
+ * chips and bypasses the pixel processor entirely. So you
+ * end up with a PPC color source behavior of {ZS,YS,XS,CS}_VAR.
+ * FBC) all options are allowed, but the SRC/DST buffers are determined
+ * solely by the WB_* setting, that is, the RB_* setting is effectively
+ * ignored since the pixels are copied directly through the write buffer
+ * ROP) must be FFB_ROP_OLD (even for the X plane!)
+ * PMASK) all options allowed
+ */
+#define FFB_ATTR_VSCROLL_WINCOPY(__fpriv) \
+do { unsigned int rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \
+ unsigned int fbc = FFB_FBC_WINCOPY; \
+ if((__fpriv)->has_double_buffer) { \
+ fbc &= ~FFB_FBC_WB_MASK; \
+ fbc |= FFB_FBC_WB_AB; \
+ } \
+ if((__fpriv)->fbc_cache != fbc || \
+ (__fpriv)->rop_cache != rop || \
+ (__fpriv)->pmask_cache != 0xffffffff || \
+ (__fpriv)->drawop_cache != FFB_DRAWOP_VSCROLL) { \
+ ffb_fbcPtr __ffb = (__fpriv)->regs; \
+ (__fpriv)->fbc_cache = fbc; \
+ (__fpriv)->rop_cache = rop; \
+ (__fpriv)->pmask_cache = 0xffffffff; \
+ (__fpriv)->drawop_cache = FFB_DRAWOP_VSCROLL; \
+ (__fpriv)->rp_active = 1; \
+ FFBFifo(__fpriv, 4); \
+ (__ffb)->fbc = fbc; \
+ (__ffb)->rop = rop; \
+ (__ffb)->pmask = 0xffffffff; \
+ (__ffb)->drawop = FFB_DRAWOP_VSCROLL; \
+ (__fpriv)->rp_active = 1; \
+ } \
+} while(0)
+
+#define FFB_ATTR_VSCROLL_WIN(__fpriv, __pmask, __pwin) \
+do { unsigned int rop = (FFB_ROP_OLD | (FFB_ROP_OLD << 8)); \
+ unsigned int fbc = FFB_FBC_WIN(__pwin); \
+ if((__fpriv)->has_double_buffer) { \
+ fbc &= ~FFB_FBC_WB_MASK; \
+ fbc |= FFB_FBC_WB_AB; \
+ } \
+ if((__fpriv)->fbc_cache != fbc || \
+ (__fpriv)->rop_cache != rop || \
+ (__fpriv)->pmask_cache != (__pmask) || \
+ (__fpriv)->drawop_cache != FFB_DRAWOP_VSCROLL) { \
+ ffb_fbcPtr __ffb = (__fpriv)->regs; \
+ (__fpriv)->fbc_cache = fbc; \
+ (__fpriv)->rop_cache = rop; \
+ (__fpriv)->pmask_cache = (__pmask); \
+ (__fpriv)->drawop_cache = FFB_DRAWOP_VSCROLL; \
+ (__fpriv)->rp_active = 1; \
+ FFBFifo(__fpriv, 4); \
+ (__ffb)->fbc = fbc; \
+ (__ffb)->rop = rop; \
+ (__ffb)->pmask = (__pmask); \
+ (__ffb)->drawop = FFB_DRAWOP_VSCROLL; \
+ } \
+} while(0)
+
+#define FFB_FBC_WIN(pWin) CreatorGetWindowPrivate(pWin)->fbc_base
+#define FFB_WID_WIN(pWin) CreatorGetWindowPrivate(pWin)->wid
+
+#endif /* FFBRCACHE_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rect.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rect.c
new file mode 100644
index 000000000..30ef01529
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_rect.c
@@ -0,0 +1,207 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Non-filled rects.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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
+ * 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/drivers/sunffb/ffb_rect.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#define PSZ 32
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_loops.h"
+#include "ffb_clip.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+
+#error If we start using this again, need to fixup FFB_WRITE_ATTRIBUTES for wids -DaveM
+
+/* Heavily derived from mipolyrect.c code, see there for authors. */
+
+/* This about it, capping makes not a single difference ever,
+ * always the upper left corner coordinate will be pixelated.
+ */
+void
+CreatorPolyRectangle(DrawablePtr pDrawable, GCPtr pGC,
+ int nrects, xRectangle *pRects)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ ffb_fbcPtr ffb = pFfb->regs;
+ xRectangle *pR = pRects;
+ RegionPtr clip;
+ unsigned int ppc, line_drawop;
+ int bound_tmp, i, numRects;
+
+ if(nrects <= 0)
+ return;
+ clip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ numRects = REGION_NUM_RECTS(clip);
+ if (!numRects)
+ return;
+ if(!(ppc = FFBSetClip(pFfb, ffb, clip, numRects))) {
+ miPolyRectangle(pDrawable, pGC, nrects, pRects);
+ return;
+ }
+ if(pGC->lineStyle == LineDoubleDash)
+ line_drawop = FFB_DRAWOP_DDLINE;
+ else
+ line_drawop = FFB_DRAWOP_BRLINECAP;
+ if(gcPriv->stipple == NULL) {
+ FFB_WRITE_ATTRIBUTES(pFfb,
+ ppc|FFB_PPC_APE_DISABLE|FFB_PPC_TBE_OPAQUE|
+ FFB_PPC_XS_CONST|FFB_PPC_YS_CONST|FFB_PPC_ZS_CONST|FFB_PPC_CS_CONST,
+ FFB_PPC_VCE_MASK|FFB_PPC_ACE_MASK|FFB_PPC_APE_MASK|FFB_PPC_TBE_MASK|
+ FFB_PPC_XS_MASK|FFB_PPC_YS_MASK|FFB_PPC_ZS_MASK|FFB_PPC_CS_MASK,
+ pGC->planemask,
+ FFB_ROP_EDIT_BIT|pGC->alu,
+ -1, pGC->fgPixel,
+ FFB_FBC_DEFAULT);
+ if(pGC->lineStyle == LineDoubleDash)
+ FFB_WRITE_BG(pFfb, ffb, pGC->bgPixel);
+ } else {
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ ppc|
+ FFB_PPC_XS_CONST|FFB_PPC_YS_CONST|FFB_PPC_ZS_CONST|FFB_PPC_CS_CONST,
+ FFB_PPC_VCE_MASK|FFB_PPC_ACE_MASK|
+ FFB_PPC_XS_MASK|FFB_PPC_YS_MASK|FFB_PPC_ZS_MASK|FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_FBC(pFfb, ffb, FFB_FBC_DEFAULT);
+ }
+
+#define MINBOUND(dst,eqn) bound_tmp = eqn; \
+ if (bound_tmp < -32768) \
+ bound_tmp = -32768; \
+ dst = bound_tmp;
+
+#define MAXBOUND(dst,eqn) bound_tmp = eqn; \
+ if (bound_tmp > 32767) \
+ bound_tmp = 32767; \
+ dst = bound_tmp;
+
+#define MAXUBOUND(dst,eqn) bound_tmp = eqn; \
+ if (bound_tmp > 65535) \
+ bound_tmp = 65535; \
+ dst = bound_tmp;
+
+ if (pGC->lineStyle == LineSolid &&
+ pGC->joinStyle == JoinMiter &&
+ pGC->lineWidth != 0) {
+ int ntmp;
+ int offset1, offset2, offset3;
+ int x, y, width, height;
+ int tx, ty, tw, th;
+
+ ntmp = (nrects << 2);
+ offset2 = pGC->lineWidth;
+ offset1 = offset2 >> 1;
+ offset3 = offset2 - offset1;
+ for (i = 0; i < nrects; i++) {
+ x = pR->x;
+ y = pR->y;
+ width = pR->width;
+ height = pR->height;
+ pR++;
+ if (width == 0 && height == 0) {
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_DOT);
+ FFBFifo(pFfb, 2);
+ FFB_WRITE64(&ffb->bh, y + pDrawable->y, x + pDrawable->x);
+ continue;
+ }
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ if (height < offset2 || width < offset1) {
+ if (height == 0) {
+ tx = x;
+ tw = width;
+ } else {
+ MINBOUND (tx, x - offset1);
+ MAXUBOUND (tw, width + offset2);
+ }
+ if (width == 0) {
+ ty = y;
+ th = height;
+ } else {
+ MINBOUND (ty, y - offset1);
+ MAXUBOUND (th, height + offset2);
+ }
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, ty + pDrawable->y, tx + pDrawable->x);
+ FFB_WRITE64_2(&ffb->bh, th, tw);
+ } else {
+ MINBOUND(tx, x - offset1);
+ MINBOUND(ty, y - offset1);
+ MAXUBOUND(tw, width + offset2);
+ th = offset2;
+ FFBFifo(pFfb, 13);
+ FFB_WRITE64(&ffb->by, ty + pDrawable->y, tx + pDrawable->x);
+ FFB_WRITE64_2(&ffb->bh, th, tw);
+ MAXBOUND(ty, y + offset3);
+ tw = offset2;
+ th = height - offset2;
+ ffb->by = ty + pDrawable->y;
+ FFB_WRITE64_2(&ffb->bh, th, tw);
+ MAXBOUND(tx, x + width - offset1);
+ ffb->bx = tx + pDrawable->x;
+ ffb->bw = tw;
+ MINBOUND(tx, x - offset1);
+ MAXBOUND(ty, y + height - offset1);
+ MAXUBOUND(tw, width + offset2);
+ th = offset2;
+ FFB_WRITE64(&ffb->by, ty + pDrawable->y, tx + pDrawable->x);
+ FFB_WRITE64_2(&ffb->bh, th, tw);
+ }
+ }
+ } else {
+ int xOrg = pDrawable->x;
+ int yOrg = pDrawable->y;
+ unsigned int linepat = gcPriv->linepat;
+
+ FFB_WRITE_DRAWOP(pFfb, ffb, line_drawop);
+ if(linepat == 0) {
+ FFBFifo(pFfb, 1);
+ ffb->lpat = 0;
+ }
+ for (i=0; i < nrects; i++) {
+ register int x0, xCoord, y0, yCoord;
+
+ x0 = xCoord = pR->x;
+ y0 = yCoord = pR->y;
+ FFBFifo(pFfb, 11);
+ if(linepat)
+ ffb->lpat = linepat;
+ else
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->by, (yCoord + yOrg), (xCoord + xOrg));
+ MAXBOUND(xCoord, pR->x + (int) pR->width);
+ FFB_WRITE64(&ffb->bh, (yCoord + yOrg), (xCoord + xOrg));
+ MAXBOUND(yCoord, pR->y + (int) pR->height);
+ FFB_WRITE64_2(&ffb->bh, (yCoord + yOrg), (xCoord + xOrg));
+ FFB_WRITE64_3(&ffb->bh, (yCoord + yOrg), (x0 + xOrg));
+ FFB_WRITE64(&ffb->bh, (y0 + yOrg), (x0 + xOrg));
+ pR++;
+ }
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h
new file mode 100644
index 000000000..7f383d38d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_regs.h
@@ -0,0 +1,509 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - register layout.
+ *
+ * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1998 Michal Rehacek (majkl@iname.com)
+ * Copyright (C) 1999 David S. Miller (davem@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, MICHAL REHACEK, 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/drivers/sunffb/ffb_regs.h,v 1.1 2000/05/18 23:21:37 dawes Exp $ */
+
+#ifndef FFBREGS_H
+#define FFBREGS_H
+
+/* Auxilliary clips. */
+typedef struct {
+ volatile unsigned int min;
+ volatile unsigned int max;
+} ffb_auxclip, *ffb_auxclipPtr;
+
+/* FFB register set. */
+typedef struct _ffb_fbc {
+ /* Next vertex registers, on the right we list which drawops
+ * use said register and the logical name the register has in
+ * that context.
+ */ /* DESCRIPTION DRAWOP(NAME) */
+/*0x00*/unsigned int pad1[3]; /* Reserved */
+/*0x0c*/volatile unsigned int alpha; /* ALPHA Transparency */
+/*0x10*/volatile unsigned int red; /* RED */
+/*0x14*/volatile unsigned int green; /* GREEN */
+/*0x18*/volatile unsigned int blue; /* BLUE */
+/*0x1c*/volatile unsigned int z; /* DEPTH */
+/*0x20*/volatile unsigned int y; /* Y triangle(DOYF) */
+ /* aadot(DYF) */
+ /* ddline(DYF) */
+ /* aaline(DYF) */
+/*0x24*/volatile unsigned int x; /* X triangle(DOXF) */
+ /* aadot(DXF) */
+ /* ddline(DXF) */
+ /* aaline(DXF) */
+/*0x28*/unsigned int pad2[2]; /* Reserved */
+/*0x30*/volatile unsigned int ryf; /* Y (alias to DOYF) ddline(RYF) */
+ /* aaline(RYF) */
+ /* triangle(RYF) */
+/*0x34*/volatile unsigned int rxf; /* X ddline(RXF) */
+ /* aaline(RXF) */
+ /* triangle(RXF) */
+/*0x38*/unsigned int pad3[2]; /* Reserved */
+/*0x40*/volatile unsigned int dmyf; /* Y (alias to DOYF) triangle(DMYF) */
+/*0x44*/volatile unsigned int dmxf; /* X triangle(DMXF) */
+/*0x48*/unsigned int pad4[2]; /* Reserved */
+/*0x50*/volatile unsigned int ebyi; /* Y (alias to RYI) polygon(EBYI) */
+/*0x54*/volatile unsigned int ebxi; /* X polygon(EBXI) */
+/*0x58*/unsigned int pad5[2]; /* Reserved */
+/*0x60*/volatile unsigned int by; /* Y brline(RYI) */
+ /* fastfill(OP) */
+ /* polygon(YI) */
+ /* rectangle(YI) */
+ /* bcopy(SRCY) */
+ /* vscroll(SRCY) */
+/*0x64*/volatile unsigned int bx; /* X brline(RXI) */
+ /* polygon(XI) */
+ /* rectangle(XI) */
+ /* bcopy(SRCX) */
+ /* vscroll(SRCX) */
+ /* fastfill(GO) */
+/*0x68*/volatile unsigned int dy; /* destination Y fastfill(DSTY) */
+ /* bcopy(DSRY) */
+ /* vscroll(DSRY) */
+/*0x6c*/volatile unsigned int dx; /* destination X fastfill(DSTX) */
+ /* bcopy(DSTX) */
+ /* vscroll(DSTX) */
+/*0x70*/volatile unsigned int bh; /* Y (alias to RYI) brline(DYI) */
+ /* dot(DYI) */
+ /* polygon(ETYI) */
+ /* Height fastfill(H) */
+ /* bcopy(H) */
+ /* vscroll(H) */
+ /* Y count fastfill(NY) */
+/*0x74*/volatile unsigned int bw; /* X dot(DXI) */
+ /* brline(DXI) */
+ /* polygon(ETXI) */
+ /* fastfill(W) */
+ /* bcopy(W) */
+ /* vscroll(W) */
+ /* fastfill(NX) */
+/*0x78*/unsigned int pad6[2]; /* Reserved */
+/*0x80*/unsigned int pad7[32]; /* Reserved */
+
+ /* Setup Unit's vertex state register */
+/*100*/ volatile unsigned int suvtx;
+/*104*/ unsigned int pad8[63]; /* Reserved */
+
+ /* Frame Buffer Control Registers */
+/*200*/ volatile unsigned int ppc; /* Pixel Processor Control */
+/*204*/ volatile unsigned int wid; /* Current WID */
+/*208*/ volatile unsigned int fg; /* FG data */
+/*20c*/ volatile unsigned int bg; /* BG data */
+/*210*/ volatile unsigned int consty; /* Constant Y */
+/*214*/ volatile unsigned int constz; /* Constant Z */
+/*218*/ volatile unsigned int xclip; /* X Clip */
+/*21c*/ volatile unsigned int dcss; /* Depth Cue Scale Slope */
+/*220*/ volatile unsigned int vclipmin; /* Viewclip XY Min Bounds */
+/*224*/ volatile unsigned int vclipmax; /* Viewclip XY Max Bounds */
+/*228*/ volatile unsigned int vclipzmin; /* Viewclip Z Min Bounds */
+/*22c*/ volatile unsigned int vclipzmax; /* Viewclip Z Max Bounds */
+/*230*/ volatile unsigned int dcsf; /* Depth Cue Scale Front Bound */
+/*234*/ volatile unsigned int dcsb; /* Depth Cue Scale Back Bound */
+/*238*/ volatile unsigned int dczf; /* Depth Cue Z Front */
+/*23c*/ volatile unsigned int dczb; /* Depth Cue Z Back */
+/*240*/ unsigned int pad9; /* Reserved */
+/*244*/ volatile unsigned int blendc; /* Alpha Blend Control */
+/*248*/ volatile unsigned int blendc1; /* Alpha Blend Color 1 */
+/*24c*/ volatile unsigned int blendc2; /* Alpha Blend Color 2 */
+/*250*/ volatile unsigned int fbramitc; /* FB RAM Interleave Test Control */
+/*254*/ volatile unsigned int fbc; /* Frame Buffer Control */
+/*258*/ volatile unsigned int rop; /* Raster OPeration */
+/*25c*/ volatile unsigned int cmp; /* Frame Buffer Compare */
+/*260*/ volatile unsigned int matchab; /* Buffer AB Match Mask */
+/*264*/ volatile unsigned int matchc; /* Buffer C(YZ) Match Mask */
+/*268*/ volatile unsigned int magnab; /* Buffer AB Magnitude Mask */
+/*26c*/ volatile unsigned int magnc; /* Buffer C(YZ) Magnitude Mask */
+/*270*/ volatile unsigned int fbcfg0; /* Frame Buffer Config 0 */
+/*274*/ volatile unsigned int fbcfg1; /* Frame Buffer Config 1 */
+/*278*/ volatile unsigned int fbcfg2; /* Frame Buffer Config 2 */
+/*27c*/ volatile unsigned int fbcfg3; /* Frame Buffer Config 3 */
+/*280*/ volatile unsigned int ppcfg; /* Pixel Processor Config */
+/*284*/ volatile unsigned int pick; /* Picking Control */
+/*288*/ volatile unsigned int fillmode; /* FillMode */
+/*28c*/ volatile unsigned int fbramwac; /* FB RAM Write Address Control */
+/*290*/ volatile unsigned int pmask; /* RGB PlaneMask */
+/*294*/ volatile unsigned int xpmask; /* X PlaneMask */
+/*298*/ volatile unsigned int ypmask; /* Y PlaneMask */
+/*29c*/ volatile unsigned int zpmask; /* Z PlaneMask */
+/*2a0*/ ffb_auxclip auxclip[4]; /* Auxilliary Viewport Clip */
+
+ /* New 3dRAM III support regs */
+/*2c0*/ volatile unsigned int rawblend2;
+/*2c4*/ volatile unsigned int rawpreblend;
+/*2c8*/ volatile unsigned int rawstencil;
+/*2cc*/ volatile unsigned int rawstencilctl;
+/*2d0*/ volatile unsigned int threedram1;
+/*2d4*/ volatile unsigned int threedram2;
+/*2d8*/ volatile unsigned int passin;
+/*2dc*/ volatile unsigned int rawclrdepth;
+/*2e0*/ volatile unsigned int rawpmask;
+/*2e4*/ volatile unsigned int rawcsrc;
+/*2e8*/ volatile unsigned int rawmatch;
+/*2ec*/ volatile unsigned int rawmagn;
+/*2f0*/ volatile unsigned int rawropblend;
+/*2f4*/ volatile unsigned int rawcmp;
+/*2f8*/ volatile unsigned int rawwac;
+/*2fc*/ volatile unsigned int fbramid;
+
+/*300*/ volatile unsigned int drawop; /* Draw OPeration */
+/*304*/ unsigned int pad10[2]; /* Reserved */
+/*30c*/ volatile unsigned int lpat; /* Line Pattern control */
+/*310*/ unsigned int pad11; /* Reserved */
+/*314*/ volatile unsigned int fontxy; /* XY Font coordinate */
+/*318*/ volatile unsigned int fontw; /* Font Width */
+/*31c*/ volatile unsigned int fontinc; /* Font Increment */
+/*320*/ volatile unsigned int font; /* Font bits */
+/*324*/ unsigned int pad12[3]; /* Reserved */
+/*330*/ volatile unsigned int blend2;
+/*334*/ volatile unsigned int preblend;
+/*338*/ volatile unsigned int stencil;
+/*33c*/ volatile unsigned int stencilctl;
+
+/*340*/ unsigned int pad13[4]; /* Reserved */
+/*350*/ volatile unsigned int dcss1; /* Depth Cue Scale Slope 1 */
+/*354*/ volatile unsigned int dcss2; /* Depth Cue Scale Slope 2 */
+/*358*/ volatile unsigned int dcss3; /* Depth Cue Scale Slope 3 */
+/*35c*/ volatile unsigned int widpmask;
+/*360*/ volatile unsigned int dcs2;
+/*364*/ volatile unsigned int dcs3;
+/*368*/ volatile unsigned int dcs4;
+/*36c*/ unsigned int pad14; /* Reserved */
+/*370*/ volatile unsigned int dcd2;
+/*374*/ volatile unsigned int dcd3;
+/*378*/ volatile unsigned int dcd4;
+/*37c*/ unsigned int pad15; /* Reserved */
+/*380*/ volatile unsigned int pattern[32]; /* area Pattern */
+/*400*/ unsigned int pad16[8]; /* Reserved */
+/*420*/ volatile unsigned int reset; /* chip RESET */
+/*424*/ unsigned int pad17[247]; /* Reserved */
+/*800*/ volatile unsigned int devid; /* Device ID */
+/*804*/ unsigned int pad18[63]; /* Reserved */
+/*900*/ volatile unsigned int ucsr; /* User Control & Status Register */
+/*904*/ unsigned int pad19[31]; /* Reserved */
+/*980*/ volatile unsigned int mer; /* Mode Enable Register */
+/*984*/ unsigned int pad20[1439]; /* Reserved */
+} ffb_fbc, *ffb_fbcPtr;
+
+/* Draw operations */
+#define FFB_DRAWOP_DOT 0x00
+#define FFB_DRAWOP_AADOT 0x01
+#define FFB_DRAWOP_BRLINECAP 0x02
+#define FFB_DRAWOP_BRLINEOPEN 0x03
+#define FFB_DRAWOP_DDLINE 0x04
+#define FFB_DRAWOP_AALINE 0x05
+#define FFB_DRAWOP_TRIANGLE 0x06
+#define FFB_DRAWOP_POLYGON 0x07
+#define FFB_DRAWOP_RECTANGLE 0x08
+#define FFB_DRAWOP_FASTFILL 0x09
+#define FFB_DRAWOP_BCOPY 0x0a /* Not implemented in any FFB, VIS is faster */
+#define FFB_DRAWOP_VSCROLL 0x0b /* Up to 12x faster than BCOPY, 3-4x faster than VIS */
+
+/* FastFill operation codes. */
+#define FFB_FASTFILL_PAGE 0x01
+#define FFB_FASTFILL_BLOCK 0x02
+#define FFB_FASTFILL_COLOR_BLK 0x03
+#define FFB_FASTFILL_BLOCK_X 0x04
+
+/* Spanfill Unit Line Pattern */
+#define FFB_LPAT_SCALEPTR 0xf0000000
+#define FFB_LPAT_SCALEPTR_SHIFT 28
+#define FFB_LPAT_PATPTR 0x0f000000
+#define FFB_LPAT_PATPTR_SHIFT 24
+#define FFB_LPAT_SCALEVAL 0x00f00000
+#define FFB_LPAT_SCALEVAL_SHIFT 20
+#define FFB_LPAT_PATLEN 0x000f0000
+#define FFB_LPAT_PATLEN_SHIFT 16
+#define FFB_LPAT_PATTERN 0x0000ffff
+#define FFB_LPAT_PATTERN_SHIFT 0
+
+/* Pixel processor control */
+/* Force WID */
+#define FFB_PPC_FW_DISABLE 0x800000
+#define FFB_PPC_FW_ENABLE 0xc00000
+#define FFB_PPC_FW_MASK 0xc00000
+/* Auxiliary clip */
+#define FFB_PPC_ACE_DISABLE 0x040000
+#define FFB_PPC_ACE_AUX_SUB 0x080000
+#define FFB_PPC_ACE_AUX_ADD 0x0c0000
+#define FFB_PPC_ACE_MASK 0x0c0000
+/* Depth cue */
+#define FFB_PPC_DCE_DISABLE 0x020000
+#define FFB_PPC_DCE_ENABLE 0x030000
+#define FFB_PPC_DCE_MASK 0x030000
+/* Alpha blend */
+#define FFB_PPC_ABE_DISABLE 0x008000
+#define FFB_PPC_ABE_ENABLE 0x00c000
+#define FFB_PPC_ABE_MASK 0x00c000
+/* View clip */
+#define FFB_PPC_VCE_DISABLE 0x001000
+#define FFB_PPC_VCE_2D 0x002000
+#define FFB_PPC_VCE_3D 0x003000
+#define FFB_PPC_VCE_MASK 0x003000
+/* Area pattern */
+#define FFB_PPC_APE_DISABLE 0x000800
+#define FFB_PPC_APE_ENABLE 0x000c00
+#define FFB_PPC_APE_MASK 0x000c00
+/* Transparent background */
+#define FFB_PPC_TBE_OPAQUE 0x000200
+#define FFB_PPC_TBE_TRANSPARENT 0x000300
+#define FFB_PPC_TBE_MASK 0x000300
+/* Z source */
+#define FFB_PPC_ZS_VAR 0x000080
+#define FFB_PPC_ZS_CONST 0x0000c0
+#define FFB_PPC_ZS_MASK 0x0000c0
+/* Y source */
+#define FFB_PPC_YS_VAR 0x000020
+#define FFB_PPC_YS_CONST 0x000030
+#define FFB_PPC_YS_MASK 0x000030
+/* X source */
+#define FFB_PPC_XS_WID 0x000004
+#define FFB_PPC_XS_VAR 0x000008
+#define FFB_PPC_XS_CONST 0x00000c
+#define FFB_PPC_XS_MASK 0x00000c
+/* Color (BGR) source */
+#define FFB_PPC_CS_VAR 0x000002
+#define FFB_PPC_CS_CONST 0x000003
+#define FFB_PPC_CS_MASK 0x000003
+
+/* X Clip */
+#define FFB_XCLIP_XREF 0x000000ff
+#define FFB_XCLIP_TEST_MASK 0x00070000
+#define FFB_XCLIP_TEST_ALWAYS 0x00000000
+#define FFB_XCLIP_TEST_GT 0x00010000
+#define FFB_XCLIP_TEST_EQ 0x00020000
+#define FFB_XCLIP_TEST_GE 0x00030000
+#define FFB_XCLIP_TEST_NEVER 0x00040000
+#define FFB_XCLIP_TEST_LE 0x00050000
+#define FFB_XCLIP_TEST_NE 0x00060000
+#define FFB_XCLIP_TEST_LT 0x00070000
+
+/* FB Control register */
+/* Write buffer dest */
+#define FFB_FBC_WB_A 0x20000000
+#define FFB_FBC_WB_B 0x40000000
+#define FFB_FBC_WB_AB 0x60000000
+#define FFB_FBC_WB_C 0x80000000
+#define FFB_FBC_WB_AC 0xa0000000
+#define FFB_FBC_WB_BC 0xc0000000
+#define FFB_FBC_WB_ABC 0xe0000000
+#define FFB_FBC_WB_MASK 0xe0000000
+/* Write enable */
+#define FFB_FBC_WE_FORCEOFF 0x00100000
+#define FFB_FBC_WE_FORCEON 0x00200000
+#define FFB_FBC_WE_USE_WMASK 0x00300000
+#define FFB_FBC_WE_MASK 0x00300000
+/* Write group mode */
+#define FFB_FBC_WM_RSVD 0x00040000
+#define FFB_FBC_WM_COMBINED 0x00080000
+#define FFB_FBC_WM_SEPARATE 0x000c0000
+#define FFB_FBC_WM_MASK 0x000c0000
+/* Read buffer src */
+#define FFB_FBC_RB_A 0x00004000
+#define FFB_FBC_RB_B 0x00008000
+#define FFB_FBC_RB_C 0x0000c000
+#define FFB_FBC_RB_MASK 0x0000c000
+/* Stereo buf dest */
+#define FFB_FBC_SB_LEFT 0x00001000
+#define FFB_FBC_SB_RIGHT 0x00002000
+#define FFB_FBC_SB_BOTH 0x00003000
+#define FFB_FBC_SB_MASK 0x00003000
+/* Z plane group enable */
+#define FFB_FBC_ZE_OFF 0x00000400
+#define FFB_FBC_ZE_ON 0x00000800
+#define FFB_FBC_ZE_MASK 0x00000c00
+/* Y plane group enable */
+#define FFB_FBC_YE_OFF 0x00000100
+#define FFB_FBC_YE_ON 0x00000200
+#define FFB_FBC_YE_MASK 0x00000300
+/* X plane group enable */
+#define FFB_FBC_XE_OFF 0x00000040
+#define FFB_FBC_XE_ON 0x00000080
+#define FFB_FBC_XE_MASK 0x000000c0
+/* B plane group enable */
+#define FFB_FBC_BE_OFF 0x00000010
+#define FFB_FBC_BE_ON 0x00000020
+#define FFB_FBC_BE_MASK 0x00000030
+/* G plane group enable */
+#define FFB_FBC_GE_OFF 0x00000004
+#define FFB_FBC_GE_ON 0x00000008
+#define FFB_FBC_GE_MASK 0x0000000c
+/* R plane group enable */
+#define FFB_FBC_RE_OFF 0x00000001
+#define FFB_FBC_RE_ON 0x00000002
+#define FFB_FBC_RE_MASK 0x00000003
+/* Combined */
+#define FFB_FBC_RGBE_OFF 0x00000015
+#define FFB_FBC_RGBE_ON 0x0000002a
+#define FFB_FBC_RGBE_MASK 0x0000003f
+
+/* Raster OP */
+#define FFB_ROP_YZ_MASK 0x008f0000
+#define FFB_ROP_X_MASK 0x00008f00
+#define FFB_ROP_RGB_MASK 0x0000008f
+
+/* Now the rops themselves which get shifted into the
+ * above fields.
+ */
+#define FFB_ROP_EDIT_BIT 0x80
+#define FFB_ROP_ZERO 0x80
+#define FFB_ROP_NEW_AND_OLD 0x81
+#define FFB_ROP_NEW_AND_NOLD 0x82
+#define FFB_ROP_NEW 0x83
+#define FFB_ROP_NNEW_AND_OLD 0x84
+#define FFB_ROP_OLD 0x85
+#define FFB_ROP_NEW_XOR_OLD 0x86
+#define FFB_ROP_NEW_OR_OLD 0x87
+#define FFB_ROP_NNEW_AND_NOLD 0x88
+#define FFB_ROP_NNEW_XOR_NOLD 0x89
+#define FFB_ROP_NOLD 0x8a
+#define FFB_ROP_NEW_OR_NOLD 0x8b
+#define FFB_ROP_NNEW 0x8c
+#define FFB_ROP_NNEW_OR_OLD 0x8d
+#define FFB_ROP_NNEW_OR_NOLD 0x8e
+#define FFB_ROP_ONES 0x8f
+
+/* FB Compare */
+#define FFB_CMP_MATCHC_MASK 0x8f000000
+#define FFB_CMP_MAGNC_MASK 0x00870000
+#define FFB_CMP_MATCHAB_MASK 0x0000ff00
+#define FFB_CMP_MAGNAB_MASK 0x000000ff
+
+/* Compare Match codes */
+#define FFB_CMP_MATCH_EDIT_BIT 0x80
+#define FFB_CMP_MATCH_ALWAYS 0x80
+#define FFB_CMP_MATCH_NEVER 0x81
+#define FFB_CMP_MATCH_EQ 0x82
+#define FFB_CMP_MATCH_NE 0x83
+#define FFB_CMP_MATCH_A_ALWAYS 0xc0
+#define FFB_CMP_MATCH_B_ALWAYS 0xa0
+
+/* Compare Magnitude codes */
+#define FFB_CMP_MAGN_EDIT_BIT 0x80
+#define FFB_CMP_MAGN_ALWAYS 0x80
+#define FFB_CMP_MAGN_GT 0x81
+#define FFB_CMP_MAGN_EQ 0x82
+#define FFB_CMP_MAGN_GE 0x83
+#define FFB_CMP_MAGN_NEVER 0x84
+#define FFB_CMP_MAGN_LE 0x85
+#define FFB_CMP_MAGN_NE 0x86
+#define FFB_CMP_MAGN_LT 0x87
+#define FFB_CMP_MAGN_A_ALWAYS 0xc0
+#define FFB_CMP_MAGN_B_ALWAYS 0xa0
+
+/* User Control and Status */
+#define FFB_UCSR_FIFO_MASK 0x00000fff
+#define FFB_UCSR_PICK_NO_HIT 0x00020000
+#define FFB_UCSR_PICK_HIT 0x00030000
+#define FFB_UCSR_PICK_DISABLE 0x00080000
+#define FFB_UCSR_PICK_ENABLE 0x000c0000
+#define FFB_UCSR_FB_BUSY 0x01000000
+#define FFB_UCSR_RP_BUSY 0x02000000
+#define FFB_UCSR_ALL_BUSY (FFB_UCSR_RP_BUSY|FFB_UCSR_FB_BUSY)
+#define FFB_UCSR_READ_ERR 0x40000000
+#define FFB_UCSR_FIFO_OVFL 0x80000000
+#define FFB_UCSR_ALL_ERRORS (FFB_UCSR_READ_ERR|FFB_UCSR_FIFO_OVFL)
+
+/* Mode Enable Register */
+#define FFB_MER_EIRA 0x00000080 /* Enable read-ahead, increasing */
+#define FFB_MER_EDRA 0x000000c0 /* Enable read-ahead, decreasing */
+#define FFB_MER_DRA 0x00000040 /* No read-ahead */
+
+/* FBram Config 0 */
+#define FFB_FBCFG0_RFTIME 0xff800000
+#define FFB_FBCFG0_XMAX 0x007c0000
+#define FFB_FBCFG0_YMAX 0x0003ffc0
+#define FFB_FBCFG0_RES_MASK 0x00000030
+#define FFB_FBCFG0_RES_HIGH 0x00000030 /* 1920x1360 */
+#define FFB_FBCFG0_RES_STD 0x00000020 /* 1280x1024 */
+#define FFB_FBCFG0_RES_STEREO 0x00000010 /* 960x580 */
+#define FFB_FBCFG0_RES_PRTRAIT 0x00000000 /* 1280x2048 */
+#define FFB_FBCFG0_ITRLACE 0x00000000
+#define FFB_FBCFG0_SEQUENTIAL 0x00000008
+#define FFB_FBCFG0_DRENA 0x00000004
+#define FFB_FBCFG0_BPMODE 0x00000002
+#define FFB_FBCFG0_RFRSH_RST 0x00000001
+
+typedef struct _ffb_dac {
+ volatile unsigned int cfg;
+ volatile unsigned int cfgdata;
+ volatile unsigned int cur;
+ volatile unsigned int curdata;
+} ffb_dac, *ffb_dacPtr;
+
+/* Writing 2 32-bit registers at a time using 64-bit stores. -DaveM */
+#if defined(__GNUC__) && defined(USE_VIS)
+/* 64-bit register writing support.
+ * Note: "lo" means "low address".
+ */
+#define FFB_WRITE64_COMMON(__regp, __lo32, __hi32, REG0, REG1) \
+do { __extension__ register unsigned int __r0 __asm__(""#REG0); \
+ __extension__ register unsigned int __r1 __asm__(""#REG1); \
+ __r0 = (__lo32); \
+ __r1 = (__hi32); \
+ __asm__ __volatile__ ("sllx\t%0, 32, %%g1\n\t" \
+ "srl\t%1, 0, %1\n\t" \
+ "or\t%%g1, %1, %%g1\n\t" \
+ "stx\t%%g1, %2" \
+ : : "r" (__r0), "r" (__r1), "m" (*(__regp)) : "g1"); \
+} while(0)
+
+#define FFB_WRITE64P(__regp, __srcp) \
+do { __asm__ __volatile__ ("ldx\t%0, %%g2;" \
+ "stx\t%%g2, %1" \
+ : : "m" (*(__srcp)), "m" (*(__regp)) \
+ : "g2"); \
+} while(0)
+
+#define FFB_WRITE64(__regp, __lo32, __hi32) \
+ FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g2, g3)
+#define FFB_WRITE64_2(__regp, __lo32, __hi32) \
+ FFB_WRITE64_COMMON(__regp, __lo32, __hi32, g4, g5)
+#define FFB_WRITE64_3(__regp, __lo32, __hi32) \
+ FFB_WRITE64_COMMON(__regp, __lo32, __hi32, o4, o5)
+
+#else /* Do not use 64-bit writes. */
+
+#define FFB_WRITE64(__regp, __lo32, __hi32) \
+do { volatile unsigned int *__p = (__regp); \
+ *__p = (__lo32); \
+ *(__p + 1) = (__hi32); \
+} while(0)
+
+#define FFB_WRITE64P(__regp, __srcp) \
+do { volatile unsigned int *__p = (__regp); \
+ unsigned int *__q = (__srcp); \
+ *__p = *__q; \
+ *(__p + 1) = *(__q + 1); \
+} while(0)
+
+#define FFB_WRITE64_2(__regp, __lo32, __hi32) \
+ FFB_WRITE64(__regp, __lo32, __hi32)
+#define FFB_WRITE64_3(__regp, __lo32, __hi32) \
+ FFB_WRITE64(__regp, __lo32, __hi32)
+#endif
+
+#endif /* FFBREGS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_seg.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_seg.c
new file mode 100644
index 000000000..930632fb3
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_seg.c
@@ -0,0 +1,196 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Segment rops.
+ *
+ * Copyright (C) 1998,1999,2000 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_seg.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_loops.h"
+#include "ffb_stip.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "miline.h"
+
+/* The general strategy is to do the drawing completely in hardware
+ * iff:
+ * 1) Single region rect
+ * 2) Both ends of the segment lie within it
+ */
+#define SEG_DRAWOP(__pgc) ((__pgc)->capStyle == CapNotLast ? \
+ FFB_DRAWOP_BRLINEOPEN : \
+ FFB_DRAWOP_BRLINECAP)
+static void
+ReloadSegmentAttrs(FFBPtr pFfb, CreatorPrivGCPtr gcPriv, GCPtr pGC, WindowPtr pWin)
+{
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ SEG_DRAWOP(pGC));
+ } else {
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, SEG_DRAWOP(pGC));
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+}
+
+void
+CreatorPolySegment (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ BoxPtr extent;
+ int xorg, yorg, lpat;
+
+ if (nseg == 0)
+ return;
+
+ FFBLOG(("CreatorPolySegment: ALU(%x) PMSK(%08x) nseg(%d) lpat(%08x)\n",
+ pGC->alu, pGC->planemask, nseg, gcPriv->linepat));
+
+ if (gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
+ SEG_DRAWOP(pGC));
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, SEG_DRAWOP(pGC));
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+
+ pFfb->rp_active = 1;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ extent = REGION_RECTS(cfbGetCompositeClip(pGC));
+ lpat = gcPriv->linepat;
+
+ if (lpat == 0) {
+ FFBFifo(pFfb, 1);
+ ffb->lpat = 0;
+ if (pFfb->has_brline_bug) {
+ while (nseg--) {
+ register int x1 = pSeg->x1 + xorg;
+ register int y1 = pSeg->y1 + yorg;
+ register int x2 = pSeg->x2 + xorg;
+ register int y2 = pSeg->y2 + yorg;
+
+ if (x1 >= extent->x1 &&
+ x2 >= extent->x1 &&
+ x1 < extent->x2 &&
+ x2 < extent->x2 &&
+ y1 >= extent->y1 &&
+ y2 >= extent->y1 &&
+ y1 < extent->y2 &&
+ y2 < extent->y2) {
+ FFBFifo(pFfb, 5);
+ ffb->ppc = 0;
+ FFB_WRITE64(&ffb->by, y1, x1);
+ FFB_WRITE64_2(&ffb->bh, y2, x2);
+ } else {
+ gcPriv->PolySegment(pDrawable, pGC, 1, pSeg);
+ ReloadSegmentAttrs(pFfb, gcPriv, pGC, pWin);
+ pFfb->rp_active = 1;
+ }
+ pSeg++;
+ }
+ } else {
+ while (nseg--) {
+ register int x1 = pSeg->x1 + xorg;
+ register int y1 = pSeg->y1 + yorg;
+ register int x2 = pSeg->x2 + xorg;
+ register int y2 = pSeg->y2 + yorg;
+
+ if (x1 >= extent->x1 &&
+ x2 >= extent->x1 &&
+ x1 < extent->x2 &&
+ x2 < extent->x2 &&
+ y1 >= extent->y1 &&
+ y2 >= extent->y1 &&
+ y1 < extent->y2 &&
+ y2 < extent->y2) {
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y1, x1);
+ FFB_WRITE64_2(&ffb->bh, y2, x2);
+ } else {
+ gcPriv->PolySegment(pDrawable, pGC, 1, pSeg);
+ ReloadSegmentAttrs(pFfb, gcPriv, pGC, pWin);
+ pFfb->rp_active = 1;
+ }
+ pSeg++;
+ }
+ }
+ } else {
+ /* No reason to optimize the non-brline bug case since
+ * we have to write the line pattern register each loop
+ * anyways.
+ */
+ while (nseg--) {
+ register int x1 = pSeg->x1 + xorg;
+ register int y1 = pSeg->y1 + yorg;
+ register int x2 = pSeg->x2 + xorg;
+ register int y2 = pSeg->y2 + yorg;
+
+ if (x1 >= extent->x1 && x2 >= extent->x1 &&
+ x1 < extent->x2 && x2 < extent->x2 &&
+ y1 >= extent->y1 && y2 >= extent->y1 &&
+ y1 < extent->y2 && y2 < extent->y2) {
+ FFBFifo(pFfb, 5);
+ ffb->lpat = lpat;
+ FFB_WRITE64(&ffb->by, y1, x1);
+ FFB_WRITE64_2(&ffb->bh, y2, x2);
+ } else {
+ gcPriv->PolySegment(pDrawable, pGC, 1, pSeg);
+ ReloadSegmentAttrs(pFfb, gcPriv, pGC, pWin);
+ pFfb->rp_active = 1;
+ }
+ pSeg++;
+ }
+ }
+
+ FFBSync(pFfb, ffb);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_sspans.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_sspans.c
new file mode 100644
index 000000000..3d4b2ae15
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_sspans.c
@@ -0,0 +1,166 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Set spans.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_sspans.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+/* PPC does all of the planemask and ROP'ing on the written pixels,
+ * and we know various other things are constant, so this is easy.
+ */
+static void
+CreatorSetScanline(int y, int xOrigin, int xStart, int xEnd,
+ unsigned int *_psrc, char *sfb, int depth)
+{
+ if (depth == 8) {
+ unsigned char *psrc = (unsigned char *)_psrc;
+ unsigned char *pdst = (unsigned char *)(sfb +
+ (y << 11) +
+ (xStart << 0));
+ int w = xEnd - xStart;
+
+ psrc += (xStart - xOrigin);
+ while(w--)
+ *pdst++ = *psrc++;
+ } else {
+ unsigned int *psrc = (unsigned int *)_psrc;
+ unsigned int *pdst = (unsigned int *)(sfb +
+ (y << 13) +
+ (xStart << 2));
+ int w = xEnd - xStart;
+
+ psrc += (xStart - xOrigin);
+ while(w--)
+ *pdst++ = *psrc++;
+ }
+}
+
+void
+CreatorSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *pcharsrc,
+ DDXPointPtr ppt, int *pwidth, int nspans, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ unsigned int *psrc = (unsigned int *)pcharsrc;
+ BoxPtr pbox, pboxLast, pboxTest;
+ DDXPointPtr pptLast;
+ RegionPtr prgnDst;
+ char *addrp;
+ int xStart, xEnd, yMax;
+
+ if(pDrawable->type != DRAWABLE_WINDOW) {
+ if (pDrawable->bitsPerPixel == 8)
+ cfbSetSpans(pDrawable, pGC, pcharsrc, ppt,
+ pwidth, nspans, fSorted);
+ else
+ cfb32SetSpans(pDrawable, pGC, pcharsrc, ppt,
+ pwidth, nspans, fSorted);
+ return;
+ }
+ FFBLOG(("CreatorSetSpans: ALU(%x) PMSK(%08x) nspans(%d) fsorted(%d)\n",
+ pGC->alu, pGC->planemask, nspans, fSorted));
+ if (pGC->alu == GXnoop)
+ return;
+
+ /* Get SFB ready. */
+ FFB_ATTR_SFB_VAR_WIN(pFfb, pGC->planemask, pGC->alu, pWin);
+ FFBWait(pFfb, ffb);
+
+ if (pGC->depth == 8)
+ addrp = (char *) pFfb->sfb8r;
+ else
+ addrp = (char *) pFfb->sfb32;
+
+ yMax = (int) pDrawable->y + (int) pDrawable->height;
+ prgnDst = cfbGetCompositeClip(pGC);
+ pbox = REGION_RECTS(prgnDst);
+ pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
+ pptLast = ppt + nspans;
+ if(fSorted) {
+ pboxTest = pbox;
+ while(ppt < pptLast) {
+ pbox = pboxTest;
+ if(ppt->y >= yMax)
+ break;
+ while(pbox < pboxLast) {
+ if(pbox->y1 > ppt->y) {
+ break;
+ } else if(pbox->y2 <= ppt->y) {
+ pboxTest = ++pbox;
+ continue;
+ } else if(pbox->x1 > ppt->x + *pwidth) {
+ break;
+ } else if(pbox->x2 <= ppt->x) {
+ pbox++;
+ continue;
+ }
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(ppt->x + *pwidth, pbox->x2);
+ CreatorSetScanline(ppt->y, ppt->x, xStart, xEnd,
+ psrc, addrp, pGC->depth);
+ if(ppt->x + *pwidth <= pbox->x2)
+ break;
+ else
+ pbox++;
+ }
+ ppt++;
+ psrc += *pwidth++;
+ }
+ } else {
+ while(ppt < pptLast) {
+ if(ppt->y >= 0 && ppt->y < yMax) {
+ for(pbox = REGION_RECTS(prgnDst); pbox < pboxLast; pbox++) {
+ if(pbox->y1 > ppt->y) {
+ break;
+ } else if(pbox->y2 <= ppt->y) {
+ pbox++;
+ break;
+ }
+ if(pbox->x1 <= ppt->x + *pwidth &&
+ pbox->x2 > ppt->x) {
+ xStart = max(pbox->x1, ppt->x);
+ xEnd = min(pbox->x2, ppt->x + *pwidth);
+ CreatorSetScanline(ppt->y, ppt->x,
+ xStart, xEnd,
+ psrc, addrp, pGC->depth);
+ }
+ }
+ }
+ ppt++;
+ psrc += *pwidth++;
+ }
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.c
new file mode 100644
index 000000000..d79b2324a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.c
@@ -0,0 +1,64 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - stipple setting.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_stip.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+#include "ffb_loops.h"
+
+void
+FFBSetStipple(FFBPtr pFfb, ffb_fbcPtr ffb,
+ CreatorStipplePtr stipple,
+ unsigned int ppc, unsigned int ppc_mask)
+{
+ int transparent = ((stipple->alu & FFB_ROP_EDIT_BIT) != 0);
+
+ if(transparent)
+ ppc |= FFB_PPC_APE_ENABLE|FFB_PPC_TBE_TRANSPARENT;
+ else
+ ppc |= FFB_PPC_APE_ENABLE|FFB_PPC_TBE_OPAQUE;
+ ppc_mask |= FFB_PPC_APE_MASK|FFB_PPC_TBE_MASK;
+ FFB_WRITE_PPC(pFfb, ffb, ppc, ppc_mask);
+ FFB_WRITE_ROP(pFfb, ffb,
+ (FFB_ROP_EDIT_BIT|stipple->alu)| (FFB_ROP_NEW<<8));
+
+ if (stipple->inhw && pFfb->laststipple == stipple) {
+ FFB_WRITE_FG(pFfb, ffb, stipple->fg);
+ if(!transparent)
+ FFB_WRITE_BG(pFfb, ffb, stipple->bg);
+ return;
+ }
+ FFBFifo(pFfb, 32);
+ FFB_STIPPLE_LOAD(&ffb->pattern[0], &stipple->bits[0]);
+ FFB_WRITE_FG(pFfb, ffb, stipple->fg);
+ if(!transparent)
+ FFB_WRITE_BG(pFfb, ffb, stipple->bg);
+ stipple->inhw = 1;
+ pFfb->laststipple = stipple;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.h b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.h
new file mode 100644
index 000000000..3d490d0c1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stip.h
@@ -0,0 +1,36 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - stipple defines.
+ *
+ * Copyright (C) 1998,1999 Jakub Jelinek (jakub@redhat.com)
+ * Copyright (C) 1999 David S. Miller (davem@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 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/drivers/sunffb/ffb_stip.h,v 1.1 2000/05/18 23:21:38 dawes Exp $ */
+
+#ifndef FFBSTIP_H
+#define FFBSTIP_H
+
+extern void FFBSetStipple(FFBPtr pFfb,
+ ffb_fbcPtr ffb,
+ CreatorStipplePtr stipple,
+ unsigned int ppc, unsigned int ppc_mask);
+
+#endif /* FFBSTIP_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stubs.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stubs.c
new file mode 100644
index 000000000..aa01018ee
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_stubs.c
@@ -0,0 +1,544 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Unaccelerated stuff.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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
+ * 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/drivers/sunffb/ffb_stubs.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+/* CFB is just too clever for it's own good. There are paths
+ * in cfb for 8bpp that just arbitrarily change the ROP of the
+ * GC and assume it just works even without revalidating that
+ * GC. So for now we turn this stuff off. -DaveM
+ */
+#undef USE_SFB_TRICKS
+
+#ifdef USE_SFB_TRICKS
+/* Sorry, have to expose some CFB internals to get the stubs right. -DaveM */
+struct cfb_gcstate {
+ unsigned long pmask;
+ int alu, rop, and, xor;
+};
+
+#define CFB_STATE_SAVE(__statep, __gcp, __privp) \
+do { (__statep)->pmask = (__gcp)->planemask; \
+ (__statep)->alu = (__gcp)->alu; \
+ (__statep)->rop = (__privp)->rop; \
+ (__statep)->and = (__privp)->and; \
+ (__statep)->xor = (__privp)->xor; \
+} while(0)
+
+#define CFB_STATE_RESTORE(__statep, __gcp, __privp) \
+do { (__gcp)->planemask = (__statep)->pmask; \
+ (__gcp)->alu = (__statep)->alu; \
+ (__privp)->rop = (__statep)->rop; \
+ (__privp)->and = (__statep)->and; \
+ (__privp)->xor = (__statep)->xor; \
+} while(0)
+
+#define CFB_STATE_SET_SFB(__gcp, __privp) \
+do { (__gcp)->alu = GXcopy; \
+ (__gcp)->planemask = (((__gcp)->depth==8)?0xff:0xffffff); \
+ (__privp)->rop = GXcopy; \
+ (__privp)->and = 0; \
+ (__privp)->xor = (__gcp)->fgPixel; \
+} while(0)
+#endif
+
+/* Stubs so we can wait for the raster processor to
+ * unbusy itself before we let the cfb code write
+ * directly to the framebuffer.
+ */
+void
+CreatorSolidSpansGeneralStub (DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbSolidSpansGeneral(pDrawable, pGC, nInit, pptInit,
+ pwidthInit, fSorted);
+ else
+ cfb32SolidSpansGeneral(pDrawable, pGC, nInit, pptInit,
+ pwidthInit, fSorted);
+}
+
+void
+CreatorSegmentSSStub (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8) {
+ if (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768)))
+ cfb8SegmentSS1Rect(pDrawable, pGC, nseg, pSeg);
+ else
+ cfbSegmentSS(pDrawable, pGC, nseg, pSeg);
+ } else
+ cfb32SegmentSS(pDrawable, pGC, nseg, pSeg);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8) {
+ if (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768)))
+ cfb8SegmentSS1Rect(pDrawable, pGC, nseg, pSeg);
+ else
+ cfbSegmentSS(pDrawable, pGC, nseg, pSeg);
+ } else
+ cfb32SegmentSS(pDrawable, pGC, nseg, pSeg);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorLineSSStub (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8) {
+ if (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768)))
+ cfb8LineSS1Rect(pDrawable, pGC, mode, npt, ppt);
+ else
+ cfbLineSS(pDrawable, pGC, mode, npt, ppt);
+ } else
+ cfb32LineSS(pDrawable, pGC, mode, npt, ppt);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8) {
+ if (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768)))
+ cfb8LineSS1Rect(pDrawable, pGC, mode, npt, ppt);
+ else
+ cfbLineSS(pDrawable, pGC, mode, npt, ppt);
+ } else
+ cfb32LineSS(pDrawable, pGC, mode, npt, ppt);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorSegmentSDStub (DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSeg)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbSegmentSD(pDrawable, pGC, nseg, pSeg);
+ else
+ cfb32SegmentSD(pDrawable, pGC, nseg, pSeg);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbSegmentSD(pDrawable, pGC, nseg, pSeg);
+ else
+ cfb32SegmentSD(pDrawable, pGC, nseg, pSeg);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorLineSDStub (DrawablePtr pDrawable, GCPtr pGC,
+ int mode, int npt, DDXPointPtr ppt)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbLineSD(pDrawable, pGC, mode, npt, ppt);
+ else
+ cfb32LineSD(pDrawable, pGC, mode, npt, ppt);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbLineSD(pDrawable, pGC, mode, npt, ppt);
+ else
+ cfb32LineSD(pDrawable, pGC, mode, npt, ppt);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorPolyGlyphBlt8Stub (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph, CharInfoPtr *ppci,
+ pointer pglyphBase)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbPolyGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ else
+ cfb32PolyGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbPolyGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ else
+ cfb32PolyGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorImageGlyphBlt8Stub (DrawablePtr pDrawable, GCPtr pGC,
+ int x, int y, unsigned int nglyph,
+ CharInfoPtr *ppci, pointer pglyphBase)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbImageGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ else
+ cfb32ImageGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbImageGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ else
+ cfb32ImageGlyphBlt8(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorTile32FSCopyStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbTile32FSCopy(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32Tile32FSCopy(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbTile32FSCopy(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32Tile32FSCopy(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorTile32FSGeneralStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbTile32FSGeneral(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32Tile32FSGeneral(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbTile32FSGeneral(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32Tile32FSGeneral(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorUnnaturalTileFSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32UnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32UnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+Creator8Stipple32FSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ cfb8Stipple32FS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ cfb8Stipple32FS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorUnnaturalStippleFSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32UnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ else
+ cfb32UnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+Creator8OpaqueStipple32FSStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nInit, DDXPointPtr pptInit,
+ int *pwidthInit, int fSorted)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ cfb8OpaqueStipple32FS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ cfb8OpaqueStipple32FS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
+
+void
+CreatorPolyFillRectStub(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN (pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+#ifdef USE_SFB_TRICKS
+ struct cfb_gcstate cfb_state;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+#endif
+
+ FFBLOG(("STUB(%s:%d)\n", __FILE__, __LINE__));
+#ifndef USE_SFB_TRICKS
+ FFB_ATTR_SFB_VAR_WIN(pFfb, 0xffffffff, GXcopy, pWin);
+ FFBWait(pFfb, ffb);
+ if (pGC->depth == 8)
+ cfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+ else
+ cfb32PolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+#else
+ CFB_STATE_SAVE(&cfb_state, pGC, devPriv);
+ FFB_ATTR_SFB_VAR_WIN(pFfb, cfb_state.pmask, cfb_state.alu, pWin);
+ FFBWait(pFfb, ffb);
+ CFB_STATE_SET_SFB(pGC, devPriv);
+ if (pGC->depth == 8)
+ cfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+ else
+ cfb32PolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+ CFB_STATE_RESTORE(&cfb_state, pGC, devPriv);
+#endif
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c
new file mode 100644
index 000000000..dfc110fdb
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wid.c
@@ -0,0 +1,461 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - WID pool management.
+ *
+ * Copyright (C) 2000 David S. Miller (davem@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
+ * 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/drivers/sunffb/ffb_wid.c,v 1.2 2000/06/20 05:08:48 dawes Exp $ */
+
+#include "ffb.h"
+
+static void
+determine_numwids(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+
+ if (p->flags & FFB_DAC_PAC1)
+ p->wid_table.num_wids = 32;
+ else
+ p->wid_table.num_wids = 64;
+}
+
+static void
+make_wlut_regval(ffb_dac_info_t *p, ffb_wid_info_t *wid)
+{
+ wid->wlut_regval = 0;
+
+ if (p->flags & FFB_DAC_PAC1) {
+ unsigned int color_model_bits;
+
+ /* Pacifica1 format */
+ if (wid->buffer != 0)
+ wid->wlut_regval |= FFBDAC_PAC1_WLUT_DB;
+
+ if (wid->depth == 8) {
+ if (wid->greyscale) {
+ if (wid->linear)
+ color_model_bits = FFBDAC_PAC1_WLUT_C_8LG;
+ else
+ color_model_bits = FFBDAC_PAC1_WLUT_C_8NG;
+ } else {
+ color_model_bits = FFBDAC_PAC1_WLUT_C_8P;
+ }
+ } else {
+ if (wid->direct) {
+ color_model_bits = FFBDAC_PAC1_WLUT_C_24D;
+ } else {
+ if (wid->linear)
+ color_model_bits = FFBDAC_PAC1_WLUT_C_24LT;
+ else
+ color_model_bits = FFBDAC_PAC1_WLUT_C_24NT;
+ }
+ }
+
+ wid->wlut_regval |= color_model_bits;
+
+ switch (wid->channel) {
+ default:
+ case 0:
+ wid->wlut_regval |= FFBDAC_PAC1_WLUT_P_XO;
+ break;
+ case 1:
+ wid->wlut_regval |= FFBDAC_PAC1_WLUT_P_R;
+ break;
+ case 2:
+ wid->wlut_regval |= FFBDAC_PAC1_WLUT_P_G;
+ break;
+ case 3:
+ wid->wlut_regval |= FFBDAC_PAC1_WLUT_P_B;
+ break;
+ };
+ } else {
+ /* Pacifica2 format */
+ if (wid->buffer != 0)
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_DB;
+
+ if (wid->depth == 24)
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_DEPTH;
+
+ switch (wid->channel) {
+ default:
+ case 0:
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_P_XO;
+ break;
+ case 1:
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_P_R;
+ break;
+ case 2:
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_P_G;
+ break;
+ case 3:
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_P_B;
+ break;
+ };
+
+ if ((wid->depth == 8 && wid->greyscale == 0) ||
+ (wid->depth == 24 && wid->direct != 0))
+ wid->wlut_regval |= FFBDAC_PAC2_WLUT_LKUP;
+
+ if (wid->palette != -1)
+ wid->wlut_regval |=
+ ((wid->palette << 4) & FFBDAC_PAC2_WLUT_PTBL);
+ }
+}
+
+static void
+init_wid_table(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int i;
+
+ for (i = 0; i < table->num_wids; i++) {
+ table->wid_pool[i].InUse = FALSE;
+ table->wid_pool[i].buffer = 0;
+ table->wid_pool[i].depth = 24;
+ table->wid_pool[i].greyscale = 0;
+ table->wid_pool[i].linear = 0;
+ table->wid_pool[i].direct = 0;
+ table->wid_pool[i].channel = 0;
+ table->wid_pool[i].palette = -1;
+ make_wlut_regval(p, &table->wid_pool[i]);
+ }
+
+ table->wid_pool[table->num_wids - 1].InUse = TRUE;
+ table->wid_pool[table->num_wids - 1].canshare = FALSE;
+}
+
+static void
+init_hw_wids(FFBPtr pFfb)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int i;
+
+ if (p->flags & FFB_DAC_PAC1)
+ dac->cfg = FFBDAC_PAC1_APWLUT_BASE;
+ else
+ dac->cfg = FFBDAC_PAC2_APWLUT_BASE;
+ for (i = 0; i < table->num_wids; i++)
+ dac->cfgdata = table->wid_pool[i].wlut_regval;
+
+ if (p->flags & FFB_DAC_PAC1)
+ dac->cfg = FFBDAC_PAC1_SPWLUT_BASE;
+ else
+ dac->cfg = FFBDAC_PAC2_SPWLUT_BASE;
+ for (i = 0; i < table->num_wids; i++)
+ dac->cfgdata = table->wid_pool[i].wlut_regval;
+}
+
+static void
+init_hw_widmode(FFBPtr pFfb)
+{
+ ffb_dacPtr dac = pFfb->dac;
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ unsigned int uctrl;
+
+ /* For now we use the Combined WID mode until I figure
+ * out exactly how Seperate4 and Seperate8 work. We
+ * also disable overlays for the time being.
+ */
+ p->wid_table.wid_shift = 0;
+
+ dac->cfg = FFBDAC_CFG_UCTRL;
+ uctrl = dac->cfgdata;
+ uctrl &= ~FFBDAC_UCTRL_WMODE;
+ uctrl |= FFBDAC_UCTRL_WM_COMB;
+ uctrl &= ~FFBDAC_UCTRL_OVENAB;
+ dac->cfg = FFBDAC_CFG_UCTRL;
+ dac->cfgdata = uctrl;
+}
+
+void
+FFBWidPoolInit(FFBPtr pFfb)
+{
+ determine_numwids(pFfb);
+ init_wid_table(pFfb);
+ init_hw_wids(pFfb);
+ init_hw_widmode(pFfb);
+}
+
+static void
+update_wids(FFBPtr pFfb, int index)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_dacPtr dac = pFfb->dac;
+ unsigned int base;
+ int limit;
+
+ if (p->flags & FFB_DAC_PAC1)
+ base = FFBDAC_PAC1_SPWLUT(index);
+ else
+ base = FFBDAC_PAC2_SPWLUT(index);
+ DACCFG_WRITE(dac, base, p->wid_table.wid_pool[index].wlut_regval);
+
+ /* Schedule the window transfer. */
+ DACCFG_WRITE(dac, FFBDAC_CFG_WTCTRL,
+ (FFBDAC_CFG_WTCTRL_TCMD | FFBDAC_CFG_WTCTRL_TE));
+
+ limit = 1000000;
+ while (limit--) {
+ unsigned int wtctrl = DACCFG_READ(dac, FFBDAC_CFG_WTCTRL);
+
+ if ((wtctrl & FFBDAC_CFG_WTCTRL_DS) == 0)
+ break;
+ }
+}
+
+unsigned int
+FFBWidAlloc(FFBPtr pFfb, int visclass, int cmap, Bool canshare)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int i, depth, direct, static_greyscale, palette, channel;
+
+ direct = 0;
+ static_greyscale = 0;
+ switch (visclass) {
+ case StaticGray:
+ static_greyscale = 1;
+ /* Fallthrough... */
+ case StaticColor:
+ case GrayScale:
+ case PseudoColor:
+ depth = 8;
+ channel = 1;
+ break;
+
+ case DirectColor:
+ direct = 1;
+ /* Fallthrough... */
+ case TrueColor:
+ depth = 24;
+ channel = 0;
+ break;
+
+ default:
+ return (unsigned int) -1;
+ };
+
+ palette = -1;
+ if (p->flags & FFB_DAC_PAC1) {
+ if (visclass == PseudoColor ||
+ visclass == GrayScale ||
+ visclass == DirectColor)
+ palette = 0;
+ } else {
+ if (visclass == PseudoColor)
+ palette = 0;
+ if (visclass == GrayScale)
+ palette = 1;
+ if (visclass == DirectColor)
+ palette = 2;
+ }
+
+ if (canshare) {
+ for (i = 0; i < table->num_wids; i++) {
+ if (table->wid_pool[i].InUse == TRUE &&
+ table->wid_pool[i].canshare == TRUE &&
+ table->wid_pool[i].palette == palette &&
+ table->wid_pool[i].direct == direct &&
+ table->wid_pool[i].greyscale == static_greyscale &&
+ table->wid_pool[i].channel == channel &&
+ table->wid_pool[i].depth == depth) {
+ table->wid_pool[i].refcount++;
+ return i << table->wid_shift;
+ }
+ }
+ }
+
+ for (i = 0; i < table->num_wids; i++) {
+ if (table->wid_pool[i].InUse == FALSE)
+ break;
+ }
+
+ if (i != table->num_wids) {
+ table->wid_pool[i].InUse = TRUE;
+ table->wid_pool[i].buffer = 0;
+ table->wid_pool[i].depth = depth;
+ table->wid_pool[i].palette = palette;
+ table->wid_pool[i].direct = direct;
+ table->wid_pool[i].greyscale = static_greyscale;
+ if (depth == 8)
+ table->wid_pool[i].channel = 1;
+ else
+ table->wid_pool[i].channel = 0;
+ table->wid_pool[i].refcount = 1;
+ table->wid_pool[i].canshare = canshare;
+ make_wlut_regval(p, &table->wid_pool[i]);
+ update_wids(pFfb, i);
+ return i << table->wid_shift;
+ }
+
+ return (unsigned int) -1;
+}
+
+void
+FFBWidFree(FFBPtr pFfb, unsigned int wid)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int index = wid >> table->wid_shift;
+
+ if (index < 0 || index >= table->num_wids) {
+ return;
+ }
+
+ if (--table->wid_pool[index].refcount == 0) {
+ table->wid_pool[index].InUse = FALSE;
+ }
+}
+
+/* Double Buffering support. */
+
+unsigned int
+FFBWidUnshare(FFBPtr pFfb, unsigned int wid)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int index = wid >> table->wid_shift;
+ int i;
+
+ if (index < 0 || index >= table->num_wids) {
+ return (unsigned int) -1;
+ }
+
+ for (i = 0; i < table->num_wids; i++) {
+ if (table->wid_pool[i].InUse == FALSE)
+ break;
+ }
+
+ if (i == table->num_wids) {
+ return (unsigned int) -1;
+ }
+
+ table->wid_pool[i].InUse = TRUE;
+ table->wid_pool[i].buffer = 0;
+ table->wid_pool[i].depth = table->wid_pool[index].depth;
+ table->wid_pool[i].palette = table->wid_pool[index].palette;
+ table->wid_pool[i].direct = table->wid_pool[index].direct;
+ table->wid_pool[i].greyscale = table->wid_pool[index].greyscale;
+ table->wid_pool[i].channel = table->wid_pool[index].channel;
+ table->wid_pool[i].refcount = 1;
+ table->wid_pool[i].canshare = FALSE;
+ make_wlut_regval(p, &table->wid_pool[i]);
+ update_wids(pFfb, i);
+
+ /* Now free the original WID. */
+ if (--table->wid_pool[index].refcount == 0) {
+ table->wid_pool[index].InUse = FALSE;
+ }
+
+ return i << table->wid_shift;
+}
+
+unsigned int
+FFBWidReshare(FFBPtr pFfb, unsigned int wid)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int index = wid >> table->wid_shift;
+ int i;
+
+ if (index < 0 || index >= table->num_wids) {
+ return wid;
+ }
+
+ for (i = 0; i < table->num_wids; i++) {
+ if (table->wid_pool[i].InUse == TRUE &&
+ table->wid_pool[i].canshare == TRUE &&
+ table->wid_pool[i].depth == table->wid_pool[index].depth &&
+ table->wid_pool[i].palette == table->wid_pool[index].palette &&
+ table->wid_pool[i].direct == table->wid_pool[index].direct &&
+ table->wid_pool[i].greyscale == table->wid_pool[index].greyscale &&
+ table->wid_pool[i].channel == table->wid_pool[index].channel)
+ break;
+ }
+
+ if (i == table->num_wids) {
+ /* OK, very simple, just make the old one shared. */
+ table->wid_pool[index].canshare = TRUE;
+ table->wid_pool[index].buffer = 0;
+ make_wlut_regval(p, &table->wid_pool[index]);
+ update_wids(pFfb, index);
+ return wid;
+ }
+
+ /* Ok, free the original WID. */
+ if (--table->wid_pool[index].refcount == 0) {
+ table->wid_pool[index].InUse = FALSE;
+ }
+
+ /* And grab a reference to the new one. */
+ table->wid_pool[i].refcount++;
+
+ /* And return the shared one. */
+ return i << table->wid_shift;
+}
+
+void
+FFBWidChangeBuffer(FFBPtr pFfb, unsigned int wid, int visible)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int index = wid >> table->wid_shift;
+ int buffer;
+
+ if (index < 0 || index >= table->num_wids)
+ return;
+
+ buffer = (table->wid_pool[index].buffer ^= 1);
+ if (visible) {
+ unsigned int bit;
+
+ if (p->flags & FFB_DAC_PAC1)
+ bit = FFBDAC_PAC1_WLUT_DB;
+ else
+ bit = FFBDAC_PAC2_WLUT_DB;
+
+ if (buffer)
+ table->wid_pool[index].wlut_regval |= bit;
+ else
+ table->wid_pool[index].wlut_regval &= ~bit;
+
+ update_wids(pFfb, index);
+ }
+}
+
+/* Used by DRI part of driver. */
+Bool
+FFBWidIsShared(FFBPtr pFfb, unsigned int wid)
+{
+ ffb_dac_info_t *p = &pFfb->dac_info;
+ ffb_wid_pool_t *table = &p->wid_table;
+ int index = wid >> table->wid_shift;
+
+ if (index < 0 || index >= table->num_wids)
+ return TRUE;
+
+ if (table->wid_pool[index].canshare == TRUE)
+ return TRUE;
+
+ return FALSE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wline.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wline.c
new file mode 100644
index 000000000..2d194d82e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_wline.c
@@ -0,0 +1,897 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Wide line rops.
+ *
+ * Copyright (C) 1999 David S. Miller (davem@redhat.com)
+ * Copyright (C) 1999 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 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/drivers/sunffb/ffb_wline.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#define PSZ 32
+
+#include <math.h>
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+
+#include "miwideline.h"
+
+#error If we start using this again, need to fixup FFB_WRITE_ATTRIBUTES for wids -DaveM
+
+/* Wheee, wide lines... */
+extern int miPolyBuildEdge();
+
+static int LeftClip, RightClip, TopClip, BottomClip;
+
+#define Y_IN_BOX(y) (((y) >= TopClip) && ((y) <= BottomClip))
+#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; \
+ } \
+}
+
+#define CreatorPointHelper(pFfb, x, y) \
+do { \
+ ffb_fbcPtr ffb = (pFfb)->regs; \
+ FFB_WRITE_DRAWOP((pFfb), ffb, FFB_DRAWOP_DOT); \
+ FFBFifo(pFfb, 2); \
+ FFB_WRITE64(&ffb->bh, (y), (x)); \
+} while (0)
+
+static void CreatorFillRectHelper(FFBPtr pFfb,
+ int x, int y, int dx, int dy)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+ int x2 = x + dx - 1;
+ int y2 = y + dy - 1;
+
+ if(x < LeftClip)
+ x = LeftClip;
+ if(x2 > RightClip)
+ x2 = RightClip;
+ if(y < TopClip)
+ y = TopClip;
+ if(y2 > BottomClip)
+ y2 = BottomClip;
+
+ dx = x2 - x + 1;
+ dy = y2 - y + 1;
+
+ if((dx > 0) && (dy > 0)) {
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x);
+ FFB_WRITE64_2(&ffb->bh, dy, dx);
+ }
+}
+
+/* The span helper does not check for y being clipped, caller beware */
+static void CreatorSpanHelper(FFBPtr pFfb,
+ int x1, int y, int width)
+{
+ ffb_fbcPtr ffb = pFfb->regs;
+ int x2 = x1 + width - 1;
+
+ if(x1 < LeftClip)
+ x1 = LeftClip;
+ if(x2 > RightClip)
+ x2 = RightClip;
+ width = x2 - x1 + 1;
+
+ if(width > 0) {
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_RECTANGLE);
+ FFBFifo(pFfb, 4);
+ FFB_WRITE64(&ffb->by, y, x1);
+ FFB_WRITE64_2(&ffb->bh, 1, width);
+ }
+}
+
+#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
+CreatorFillPolyHelper (DrawablePtr pDrawable, GCPtr pGC,
+ int y, int overall_height,
+ PolyEdgePtr left, PolyEdgePtr right,
+ int left_count, int right_count)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ 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, height;
+ int left_height = 0;
+ int right_height = 0;
+ int xorg = 0;
+
+ if (pGC->miTranslate) {
+ y += pDrawable->y;
+ xorg = pDrawable->x;
+ }
+
+ 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;
+ while (height--) {
+ if((right_x > left_x) && Y_IN_BOX(y))
+ CreatorSpanHelper(pFfb, 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
+CreatorWideSegment (DrawablePtr pDrawable, GCPtr pGC,
+ int x1, int y1, int x2, int y2,
+ Bool projectLeft, Bool projectRight,
+ LineFacePtr leftFace, LineFacePtr rightFace)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ double l, L, r, xa, ya, projectXoff, projectYoff, k, maxy;
+ int x, y, dx, dy, finaly, lefty, righty, topy, bottomy, signdx;
+ PolyEdgePtr left, right, top, bottom;
+ PolyEdgeRec lefts[2], rights[2];
+ LineFacePtr tface;
+ int lw = pGC->lineWidth;
+
+ /* 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;
+ if(pGC->miTranslate) {
+ x += pDrawable->x;
+ y += pDrawable->y;
+ }
+ CreatorFillRectHelper(pFfb, 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;
+ if(pGC->miTranslate) {
+ x += pDrawable->x;
+ y += pDrawable->y;
+ }
+ CreatorFillRectHelper(pFfb, 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;
+
+ if (projectLeft | projectRight) {
+ 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;
+ CreatorFillPolyHelper (pDrawable, pGC, topy,
+ bottom->height + bottomy - topy, lefts, rights, 2, 2);
+ }
+}
+
+static void
+CreatorLineArcI (DrawablePtr pDraw, GCPtr pGC, int xorg, int yorg)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDraw->pScreen);
+ int x, y, e, ex, slw;
+
+ if (pGC->miTranslate) {
+ xorg += pDraw->x;
+ yorg += pDraw->y;
+ }
+
+ slw = pGC->lineWidth;
+ if (slw == 1) {
+ CreatorPointHelper(pFfb, xorg, yorg);
+ return;
+ }
+
+ 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--;
+
+ if(Y_IN_BOX(yorg - y))
+ CreatorSpanHelper(pFfb, xorg - x, yorg - y, slw);
+
+ if ((y != 0) && ((slw > 1) || (e != ex)) && Y_IN_BOX(yorg + y))
+ CreatorSpanHelper(pFfb, xorg - x, yorg + y, slw);
+ }
+}
+
+static void
+CreatorLineArcD (DrawablePtr pDraw, GCPtr pGC,
+ double xorg, double yorg,
+ PolyEdgePtr edge1, int edgey1, Bool edgeleft1,
+ PolyEdgePtr edge2, int edgey2, Bool edgeleft2)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDraw->pScreen);
+ double radius, x0, y0, el, er, yk, xlk, xrk, k;
+ int xbase, ybase, y, boty, xl, xr, xcl, xcr, ymin, ymax, ymin1, ymin2;
+ Bool edge1IsMin, edge2IsMin;
+
+ xbase = floor(xorg);
+ x0 = xorg - xbase;
+ ybase = ICEIL (yorg);
+ y0 = yorg - ybase;
+ if (pGC->miTranslate) {
+ xbase += pDraw->x;
+ ybase += pDraw->y;
+ edge1->x += pDraw->x;
+ edge2->x += pDraw->x;
+ edgey1 += pDraw->y;
+ edgey2 += pDraw->y;
+ }
+
+ 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) && Y_IN_BOX(ybase))
+ CreatorSpanHelper(pFfb, 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) && Y_IN_BOX(ybase))
+ CreatorSpanHelper(pFfb, xcl, ybase, xcr - xcl + 1);
+ }
+}
+
+
+static void
+CreatorLineArc (DrawablePtr pDraw, GCPtr pGC,
+ LineFacePtr leftFace, LineFacePtr rightFace,
+ double xorg, double yorg,
+ Bool isInt)
+{
+ int xorgi, yorgi, edgey1, edgey2;
+ PolyEdgeRec edge1, edge2;
+ Bool edgeleft1, edgeleft2;
+
+ if (isInt) {
+ xorgi = leftFace ? leftFace->x : rightFace->x;
+ yorgi = leftFace ? leftFace->y : rightFace->y;
+ }
+ 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)
+ CreatorLineArcI(pDraw, pGC, xorgi, yorgi);
+ else
+ CreatorLineArcD(pDraw, pGC, xorg, yorg,
+ &edge1, edgey1, edgeleft1,
+ &edge2, edgey2, edgeleft2);
+}
+
+static void
+CreatorLineJoin (DrawablePtr pDrawable, GCPtr pGC, LineFacePtr pLeft, LineFacePtr pRight)
+{
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ double mx, my, denom;
+ PolyVertexRec vertices[4];
+ PolySlopeRec slopes[4];
+ PolyEdgeRec left[4], right[4];
+ int edgecount, nleft, nright, y, height, 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) {
+ if(pGC->miTranslate)
+ CreatorPointHelper(pFfb,
+ pLeft->x + pDrawable->x,
+ pLeft->y + pDrawable->y);
+ else
+ CreatorPointHelper(pFfb, pLeft->x, pLeft->y);
+ return;
+ }
+ } else {
+ if (joinStyle == JoinRound) {
+ CreatorLineArc(pDrawable, 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);
+ CreatorFillPolyHelper(pDrawable, pGC, y, height, left, right, nleft, nright);
+}
+
+void
+CreatorWideLineSolid (DrawablePtr pDrawable, GCPtr pGC, int mode, int npt, DDXPointPtr pPts)
+{
+ int x1, y1, x2, y2, first = TRUE;
+ Bool projectLeft, projectRight, somethingDrawn = FALSE, selfJoin = FALSE;
+ LineFaceRec leftFace, rightFace, prevRightFace, firstFace;
+ cfbPrivGCPtr devPriv = cfbGetGCPrivate(pGC);
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+ RegionPtr clip;
+ int numRects;
+ unsigned int ppc;
+ BoxPtr pbox;
+
+ clip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
+ numRects = REGION_NUM_RECTS(clip);
+ if (!numRects)
+ return;
+ if (!(ppc = FFBSetClip(pFfb, ffb, clip, numRects))) {
+ miWideLine(pDrawable, pGC, mode, npt, pPts);
+ return;
+ }
+
+ LeftClip = 2048; TopClip = 2048;
+ RightClip = 0; BottomClip = 0;
+ for (pbox = REGION_RECTS(clip); numRects; numRects--, pbox++) {
+ if (pbox->x1 < LeftClip) LeftClip = pbox->x1;
+ if (pbox->x2 > RightClip) RightClip = pbox->x2 - 1;
+ if (pbox->y1 < TopClip) TopClip = pbox->y1;
+ if (pbox->y2 > BottomClip) BottomClip = pbox->y2 - 1;
+ }
+
+ FFB_WRITE_ATTRIBUTES(pFfb,
+ ppc|FFB_PPC_APE_DISABLE|FFB_PPC_TBE_OPAQUE|
+ FFB_PPC_XS_CONST|FFB_PPC_YS_CONST|FFB_PPC_ZS_CONST|FFB_PPC_CS_CONST,
+ FFB_PPC_VCE_MASK|FFB_PPC_ACE_MASK|FFB_PPC_APE_MASK|FFB_PPC_TBE_MASK|
+ FFB_PPC_XS_MASK|FFB_PPC_YS_MASK|FFB_PPC_ZS_MASK|FFB_PPC_CS_MASK,
+ pGC->planemask,
+ FFB_ROP_EDIT_BIT|pGC->alu,
+ -1, pGC->fgPixel,
+ FFB_FBC_DEFAULT);
+
+ 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;
+
+ while (--npt) {
+ x1 = x2;
+ y1 = y2;
+ ++pPts;
+ x2 = pPts->x;
+ y2 = pPts->y;
+ if (mode == CoordModePrevious) {
+ x2 += x1;
+ y2 += y1;
+ }
+ if ((x1 != x2) || (y1 != y2)) {
+ somethingDrawn = TRUE;
+ if ((npt == 1) && (pGC->capStyle == CapProjecting) && !selfJoin)
+ projectRight = TRUE;
+ CreatorWideSegment(pDrawable, pGC, x1, y1, x2, y2,
+ projectLeft, projectRight, &leftFace, &rightFace);
+ if (first) {
+ if (selfJoin)
+ firstFace = leftFace;
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ if(pGC->miTranslate)
+ CreatorPointHelper(pFfb,
+ x1 + pDrawable->x,
+ y1 + pDrawable->y);
+ else
+ CreatorPointHelper(pFfb, x1, y1);
+ } else
+ CreatorLineArc(pDrawable, pGC,
+ &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0,
+ TRUE);
+ }
+ } else
+ CreatorLineJoin (pDrawable, pGC, &leftFace, &prevRightFace);
+
+ prevRightFace = rightFace;
+ first = FALSE;
+ projectLeft = FALSE;
+ }
+ if (npt == 1 && somethingDrawn) {
+ if (selfJoin)
+ CreatorLineJoin (pDrawable, pGC, &firstFace, &rightFace);
+ else if (pGC->capStyle == CapRound) {
+ if (pGC->lineWidth == 1) {
+ if(pGC->miTranslate)
+ CreatorPointHelper(pFfb,
+ x2 + pDrawable->x,
+ y2 + pDrawable->y);
+ else
+ CreatorPointHelper(pFfb, x2, y2);
+ } else
+ CreatorLineArc (pDrawable, pGC,
+ (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0,
+ TRUE);
+ }
+ }
+ }
+
+ /* handle crock where all points are coincedent */
+ if (!somethingDrawn) {
+ projectLeft = (pGC->capStyle == CapProjecting);
+ CreatorWideSegment (pDrawable, pGC,
+ x2, y2, x2, y2, projectLeft, projectLeft,
+ &leftFace, &rightFace);
+ if (pGC->capStyle == CapRound) {
+ CreatorLineArc (pDrawable, pGC,
+ &leftFace, (LineFacePtr) NULL,
+ (double)0.0, (double)0.0,
+ TRUE);
+ rightFace.dx = -1; /* sleezy hack to make it work */
+ CreatorLineArc (pDrawable, pGC,
+ (LineFacePtr) NULL, &rightFace,
+ (double)0.0, (double)0.0,
+ TRUE);
+ }
+ }
+ pFfb->rp_active = 1;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_zeroarc.c b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_zeroarc.c
new file mode 100644
index 000000000..86b587678
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_zeroarc.c
@@ -0,0 +1,536 @@
+/*
+ * Acceleration for the Creator and Creator3D framebuffer - Zero arc
+ * rops.
+ *
+ * Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
+ *
+ * Derived from mi/mizerarc.c, see there for authors.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and 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/drivers/sunffb/ffb_zeroarc.c,v 1.2 2000/05/23 04:47:45 dawes Exp $ */
+
+#include "ffb.h"
+#include "ffb_regs.h"
+#include "ffb_rcache.h"
+#include "ffb_fifo.h"
+#include "ffb_stip.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+
+#include "mi.h"
+#include "mizerarc.h"
+
+#define FULLCIRCLE (360 * 64)
+#define OCTANT (45 * 64)
+#define QUADRANT (90 * 64)
+#define HALFCIRCLE (180 * 64)
+#define QUADRANT3 (270 * 64)
+
+typedef struct {
+ int skipStart;
+ int haveStart;
+ DDXPointRec startPt;
+ int haveLast;
+ int skipLast;
+ DDXPointRec endPt;
+ int dashIndex;
+ int dashOffset;
+ int dashIndexInit;
+ int dashOffsetInit;
+} DashInfo;
+
+#define Pixelate(xval,yval,ext) \
+if (((xval)+xoff) >= (ext)->x1 && \
+ ((xval)+xoff) < (ext)->x2 && \
+ ((yval)+yoff) >= (ext)->y1 && \
+ ((yval)+yoff) < (ext)->y2) { \
+ FFBFifo(pFfb, 2); \
+ FFB_WRITE64(&ffb->bh, ((yval)+yoff), ((xval)+xoff)); \
+}
+
+#define Pixelate1(xval,yval,ext) \
+if (((xval)+xoff) >= (ext)->x1 && \
+ ((xval)+xoff) < (ext)->x2 && \
+ ((yval)+yoff) >= (ext)->y1 && \
+ ((yval)+yoff) < (ext)->y2) { \
+ FFBFifo(pFfb, 2); \
+ FFB_WRITE64(&ffb->bh, ((yval)+yoff), ((xval)+xoff)); \
+}
+
+#define DoPix(idx,xval,yval,ext) if (mask & (1 << idx)) Pixelate(xval, yval,ext);
+
+static void
+CreatorZeroArcPts(xArc *arc, DrawablePtr pDrawable, GCPtr pGC, BoxPtr pextent)
+{
+ miZeroArcRec info;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ int xoff, yoff;
+ Bool do360;
+ FFBPtr pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ ffb_fbcPtr ffb = pFfb->regs;
+
+ xoff = 0;
+ yoff = 0;
+ if (pGC->miTranslate) {
+ xoff = pDrawable->x;
+ yoff = pDrawable->y;
+ }
+ do360 = miZeroArcSetup(arc, &info, TRUE);
+ MIARCSETUP();
+ mask = info.initialMask;
+ if (!(arc->width & 1)) {
+ DoPix(1, info.xorgo, info.yorg, pextent);
+ DoPix(3, info.xorgo, info.yorgo, pextent);
+ }
+ if (!info.end.x || !info.end.y) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ if (do360 && (arc->width == arc->height) && !(arc->width & 1)) {
+ int yorgh = info.yorg + info.h;
+ int xorghp = info.xorg + info.h;
+ int xorghn = info.xorg - info.h;
+ int lastx = 0, lasty = 0;
+
+ while (1) {
+ if (a < 0)
+ break;
+ Pixelate1(info.xorg + x, info.yorg + y, pextent);
+ Pixelate1(info.xorg - x, info.yorg + y, pextent);
+ Pixelate1(info.xorg - x, info.yorgo - y, pextent);
+ Pixelate1(info.xorg + x, info.yorgo - y, pextent);
+ Pixelate1(xorghp - y, yorgh - x, pextent);
+ Pixelate1(xorghn + y, yorgh - x, pextent);
+ Pixelate1(xorghn + y, yorgh + x, pextent);
+ lastx = xorghp - y; lasty = yorgh + x;
+ Pixelate1(xorghp - y, yorgh + x, pextent);
+ MIARCCIRCLESTEP(;);
+ }
+ if (x <= 0 || lastx != info.xorg + x || lasty != info.yorg + y) {
+ Pixelate1(info.xorg + x, info.yorg + y, pextent);
+ Pixelate1(info.xorg - x, info.yorg + y, pextent);
+ Pixelate1(info.xorg - x, info.yorgo - y, pextent);
+ Pixelate1(info.xorg + x, info.yorgo - y, pextent);
+ }
+ x = info.w;
+ y = info.h;
+ } else if (do360) {
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(;);
+ Pixelate1(info.xorg + x, info.yorg + y, pextent);
+ Pixelate1(info.xorgo - x, info.yorg + y, pextent);
+ Pixelate1(info.xorgo - x, info.yorgo - y, pextent);
+ Pixelate1(info.xorg + x, info.yorgo - y, pextent);
+ MIARCSTEP(;,;);
+ }
+ } else {
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(;);
+ if ((x == info.start.x) || (y == info.start.y)) {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(0, info.xorg + x, info.yorg + y, pextent);
+ DoPix(1, info.xorgo - x, info.yorg + y, pextent);
+ DoPix(2, info.xorgo - x, info.yorgo - y, pextent);
+ DoPix(3, info.xorg + x, info.yorgo - y, pextent);
+ if (x == info.end.x || y == info.end.y) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(;,;);
+ }
+ }
+ if (x == info.start.x || y == info.start.y)
+ mask = info.start.mask;
+ DoPix(0, info.xorg + x, info.yorg + y, pextent);
+ DoPix(2, info.xorgo - x, info.yorgo - y, pextent);
+ if (arc->height & 1) {
+ DoPix(1, info.xorgo - x, info.yorg + y, pextent);
+ DoPix(3, info.xorg + x, info.yorgo - y, pextent);
+ }
+}
+
+#undef DoPix
+#define DoPix(idx,xval,yval) \
+ if (mask & (1 << idx)) \
+ { \
+ arcPts[idx]->x = xval; \
+ arcPts[idx]->y = yval; \
+ arcPts[idx]++; \
+ }
+
+static void
+CreatorZeroArcDashPts(GCPtr pGC, xArc *arc, DashInfo *dinfo, DDXPointPtr points,
+ int maxPts, DDXPointPtr *evenPts, DDXPointPtr *oddPts)
+{
+ miZeroArcRec info;
+ register int x, y, a, b, d, mask;
+ register int k1, k3, dx, dy;
+ int dashRemaining;
+ DDXPointPtr arcPts[4];
+ DDXPointPtr startPts[5], endPts[5];
+ int deltas[5];
+ DDXPointPtr startPt, pt, lastPt, pts;
+ int i, j, delta, ptsdelta, seg, startseg;
+
+ for (i = 0; i < 4; i++)
+ arcPts[i] = points + (i * maxPts);
+ miZeroArcSetup(arc, &info, FALSE);
+ MIARCSETUP();
+ mask = info.initialMask;
+ startseg = info.startAngle / QUADRANT;
+ startPt = arcPts[startseg];
+ if (!(arc->width & 1)) {
+ DoPix(1, info.xorgo, info.yorg);
+ DoPix(3, info.xorgo, info.yorgo);
+ }
+ if (!info.end.x || !info.end.y) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ while (y < info.h || x < info.w) {
+ MIARCOCTANTSHIFT(;);
+ if ((x == info.firstx) || (y == info.firsty))
+ startPt = arcPts[startseg];
+ if ((x == info.start.x) || (y == info.start.y)) {
+ mask = info.start.mask;
+ info.start = info.altstart;
+ }
+ DoPix(0, info.xorg + x, info.yorg + y);
+ DoPix(1, info.xorgo - x, info.yorg + y);
+ DoPix(2, info.xorgo - x, info.yorgo - y);
+ DoPix(3, info.xorg + x, info.yorgo - y);
+ if (x == info.end.x || y == info.end.y) {
+ mask = info.end.mask;
+ info.end = info.altend;
+ }
+ MIARCSTEP(;,;);
+ }
+ if (x == info.firstx || y == info.firsty)
+ startPt = arcPts[startseg];
+ if (x == info.start.x || y == info.start.y)
+ mask = info.start.mask;
+ DoPix(0, info.xorg + x, info.yorg + y);
+ DoPix(2, info.xorgo - x, info.yorgo - y);
+ if (arc->height & 1) {
+ DoPix(1, info.xorgo - x, info.yorg + y);
+ DoPix(3, info.xorg + x, info.yorgo - y);
+ }
+ for (i = 0; i < 4; i++) {
+ seg = (startseg + i) & 3;
+ pt = points + (seg * maxPts);
+ if (seg & 1) {
+ startPts[i] = pt;
+ endPts[i] = arcPts[seg];
+ deltas[i] = 1;
+ } else {
+ startPts[i] = arcPts[seg] - 1;
+ endPts[i] = pt - 1;
+ deltas[i] = -1;
+ }
+ }
+ startPts[4] = startPts[0];
+ endPts[4] = startPt;
+ startPts[0] = startPt;
+ if (startseg & 1) {
+ if (startPts[4] != endPts[4])
+ endPts[4]--;
+ deltas[4] = 1;
+ } else {
+ if (startPts[0] > startPts[4])
+ startPts[0]--;
+ if (startPts[4] < endPts[4])
+ endPts[4]--;
+ deltas[4] = -1;
+ }
+ if (arc->angle2 < 0) {
+ DDXPointPtr tmps, tmpe;
+ int tmpd;
+
+ tmpd = deltas[0];
+ tmps = startPts[0] - tmpd;
+ tmpe = endPts[0] - tmpd;
+ startPts[0] = endPts[4] - deltas[4];
+ endPts[0] = startPts[4] - deltas[4];
+ deltas[0] = -deltas[4];
+ startPts[4] = tmpe;
+ endPts[4] = tmps;
+ deltas[4] = -tmpd;
+ tmpd = deltas[1];
+ tmps = startPts[1] - tmpd;
+ tmpe = endPts[1] - tmpd;
+ startPts[1] = endPts[3] - deltas[3];
+ endPts[1] = startPts[3] - deltas[3];
+ deltas[1] = -deltas[3];
+ startPts[3] = tmpe;
+ endPts[3] = tmps;
+ deltas[3] = -tmpd;
+ tmps = startPts[2] - deltas[2];
+ startPts[2] = endPts[2] - deltas[2];
+ endPts[2] = tmps;
+ deltas[2] = -deltas[2];
+ }
+ for (i = 0; i < 5 && startPts[i] == endPts[i]; i++);
+ if (i == 5)
+ return;
+ pt = startPts[i];
+ for (j = 4; startPts[j] == endPts[j]; j--);
+ lastPt = endPts[j] - deltas[j];
+ if (dinfo->haveLast &&
+ (pt->x == dinfo->endPt.x) && (pt->y == dinfo->endPt.y)) {
+ startPts[i] += deltas[i];
+ } else {
+ dinfo->dashIndex = dinfo->dashIndexInit;
+ dinfo->dashOffset = dinfo->dashOffsetInit;
+ }
+ if (!dinfo->skipStart && (info.startAngle != info.endAngle)) {
+ dinfo->startPt = *pt;
+ dinfo->haveStart = TRUE;
+ } else if (!dinfo->skipLast && dinfo->haveStart &&
+ (lastPt->x == dinfo->startPt.x) &&
+ (lastPt->y == dinfo->startPt.y) &&
+ (lastPt != startPts[i]))
+ endPts[j] = lastPt;
+ if (info.startAngle != info.endAngle) {
+ dinfo->haveLast = TRUE;
+ dinfo->endPt = *lastPt;
+ }
+ dashRemaining = pGC->dash[dinfo->dashIndex] - dinfo->dashOffset;
+ for (i = 0; i < 5; i++) {
+ pt = startPts[i];
+ lastPt = endPts[i];
+ delta = deltas[i];
+ while (pt != lastPt) {
+ if (dinfo->dashIndex & 1) {
+ pts = *oddPts;
+ ptsdelta = -1;
+ } else {
+ pts = *evenPts;
+ ptsdelta = 1;
+ }
+ while ((pt != lastPt) && --dashRemaining >= 0) {
+ *pts = *pt;
+ pts += ptsdelta;
+ pt += delta;
+ }
+ if (dinfo->dashIndex & 1)
+ *oddPts = pts;
+ else
+ *evenPts = pts;
+ if (dashRemaining <= 0) {
+ if (++(dinfo->dashIndex) == pGC->numInDashList)
+ dinfo->dashIndex = 0;
+ dashRemaining = pGC->dash[dinfo->dashIndex];
+ }
+ }
+ }
+ dinfo->dashOffset = pGC->dash[dinfo->dashIndex] - dashRemaining;
+}
+
+void
+CreatorZeroPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
+{
+ WindowPtr pWin = (WindowPtr) pDrawable;
+ int maxPts = 0;
+ register int n;
+ register xArc *arc;
+ register int i;
+ register int j, k;
+ DDXPointPtr points = NULL, pts, oddPts;
+ int numPts = 0;
+ DashInfo dinfo;
+ FFBPtr pFfb;
+ ffb_fbcPtr ffb;
+ RegionPtr clip;
+ int numRects, ppc;
+ BoxPtr pbox;
+ CreatorPrivGCPtr gcPriv;
+ register int off = 0, c1, c2;
+ register char *addrp = NULL;
+ register int *ppt, pt, pix;
+
+ gcPriv = CreatorGetGCPrivate (pGC);
+ pFfb = GET_FFB_FROM_SCREEN(pDrawable->pScreen);
+ ffb = pFfb->regs;
+ clip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS(clip);
+ if (!numRects)
+ return;
+ if (pGC->lineStyle == LineSolid && numRects != 1) {
+ miZeroPolyArc(pDrawable, pGC, narcs, parcs);
+ return;
+ }
+ FFBLOG(("CreatorZeroPolyArc: ALU(%x) PMSK(%08x) narcs(%d)\n",
+ pGC->alu, pGC->planemask, narcs));
+ if (pGC->lineStyle == LineSolid)
+ for (arc = parcs, i = narcs, j = 0; --i >= 0; arc++) {
+ if (!miCanZeroArc(arc))
+ miPolyArc(pDrawable, pGC, 1, arc);
+ else
+ j++;
+ }
+ else
+ for (arc = parcs, i = narcs, j = 0; --i >= 0; arc++) {
+ if (!miCanZeroArc(arc))
+ miPolyArc(pDrawable, pGC, 1, arc);
+ else {
+ j++;
+ if (arc->width > arc->height)
+ n = arc->width + (arc->height >> 1);
+ else
+ n = arc->height + (arc->width >> 1);
+ if (n > maxPts)
+ maxPts = n;
+ }
+ }
+ if (!j)
+ return;
+
+ if (pGC->lineStyle != LineSolid) {
+ numPts = maxPts << 2;
+ points = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * (numPts + (maxPts << 1)));
+ if (!points) return;
+ dinfo.haveStart = FALSE;
+ dinfo.skipStart = FALSE;
+ dinfo.haveLast = FALSE;
+ dinfo.dashIndexInit = 0;
+ dinfo.dashOffsetInit = 0;
+ miStepDash((int)pGC->dashOffset, &dinfo.dashIndexInit,
+ (unsigned char *) pGC->dash, (int)pGC->numInDashList,
+ &dinfo.dashOffsetInit);
+ off = *(int *)&pDrawable->x;
+ off -= (off & 0x8000) << 1;
+ if (pGC->depth == 8) {
+ addrp = (char *)pFfb->sfb8r +
+ (pDrawable->y << 11) + (pDrawable->x << 0);
+ } else {
+ addrp = (char *)pFfb->sfb32 +
+ (pDrawable->y << 13) + (pDrawable->x << 2);
+ }
+ ppc = FFB_PPC_CS_VAR;
+ } else
+ ppc = FFB_PPC_CS_CONST;
+
+ if(gcPriv->stipple == NULL) {
+ FFB_ATTR_GC(pFfb, pGC, pWin,
+ ppc | FFB_PPC_APE_DISABLE,
+ FFB_DRAWOP_DOT);
+ } else {
+ unsigned int fbc;
+
+ FFBSetStipple(pFfb, ffb, gcPriv->stipple,
+ ppc, FFB_PPC_CS_MASK);
+ FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
+ FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_DOT);
+ fbc = FFB_FBC_WIN(pWin);
+ fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
+ FFB_WRITE_FBC(pFfb, ffb, fbc);
+ }
+ if((ppc & FFB_PPC_CS_MASK) == FFB_PPC_CS_VAR)
+ FFBWait(pFfb, ffb);
+
+ for (arc = parcs, i = narcs; --i >= 0; arc++) {
+ if (miCanZeroArc(arc)) {
+ if (pGC->lineStyle == LineSolid)
+ CreatorZeroArcPts(arc, pDrawable, pGC, REGION_RECTS(clip));
+ else {
+ pts = points;
+ oddPts = &points[(numPts >> 1) - 1];
+ dinfo.skipLast = i;
+ CreatorZeroArcDashPts(pGC, arc, &dinfo,
+ oddPts + 1, maxPts, &pts, &oddPts);
+ dinfo.skipStart = TRUE;
+ n = pts - points;
+ pbox = REGION_RECTS(clip);
+ j = numRects;
+ pix = pGC->fgPixel;
+ if (pGC->depth == 8) {
+ while (j--) {
+ c1 = *(int *)&pbox->x1 - off;
+ c2 = *(int *)&pbox->x2 - off - 0x00010001;
+ for (ppt = (int *)points, k = n; --k >= 0; ) {
+ pt = *ppt++;
+ if (!(((pt - c1) | (c2 - pt)) & 0x80008000))
+ *(unsigned char *)(addrp + ((pt << 11) & 0x3ff800) + ((pt >> 16) & 0x07ff)) = pix;
+ }
+ pbox++;
+ }
+ } else {
+ while (j--) {
+ c1 = *(int *)&pbox->x1 - off;
+ c2 = *(int *)&pbox->x2 - off - 0x00010001;
+ for (ppt = (int *)points, k = n; --k >= 0; ) {
+ pt = *ppt++;
+ if (!(((pt - c1) | (c2 - pt)) & 0x80008000))
+ *(unsigned int *)(addrp + ((pt << 13) & 0xffe000) + ((pt >> 14) & 0x1ffc)) = pix;
+ }
+ pbox++;
+ }
+ }
+ if (pGC->lineStyle != LineDoubleDash)
+ continue;
+ if ((pGC->fillStyle == FillSolid) || (pGC->fillStyle == FillStippled))
+ pix = pGC->bgPixel;
+ pts = &points[numPts >> 1];
+ oddPts++;
+ n = pts - oddPts;
+ pbox = REGION_RECTS(clip);
+ j = numRects;
+ if (pGC->depth == 8) {
+ while (j--) {
+ c1 = *(int *)&pbox->x1 - off;
+ c2 = *(int *)&pbox->x2 - off - 0x00010001;
+ for (ppt = (int *)oddPts, k = n; --k >= 0; ) {
+ pt = *ppt++;
+ if (!(((pt - c1) | (c2 - pt)) & 0x80008000))
+ *(unsigned char *)(addrp + ((pt << 11) & 0x3ff800) + ((pt >> 16) & 0x07ff)) = pix;
+ }
+ pbox++;
+ }
+ } else {
+ while (j--) {
+ c1 = *(int *)&pbox->x1 - off;
+ c2 = *(int *)&pbox->x2 - off - 0x00010001;
+ for (ppt = (int *)oddPts, k = n; --k >= 0; ) {
+ pt = *ppt++;
+ if (!(((pt - c1) | (c2 - pt)) & 0x80008000))
+ *(unsigned int *)(addrp + ((pt << 13) & 0xffe000) + ((pt >> 14) & 0x1ffc)) = pix;
+ }
+ pbox++;
+ }
+ }
+ }
+ }
+ }
+ if (pGC->lineStyle != LineSolid) {
+ DEALLOCATE_LOCAL(points);
+ } else {
+ pFfb->rp_active = 1;
+ FFBSync(pFfb, ffb);
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp
new file mode 100644
index 000000000..1db2ea525
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/sunffb.cpp,v 1.2 2000/06/14 02:13:14 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH FFB __drivermansuffix__ "Version 4.0.1" "XFree86"
+.SH NAME
+ffb \- SUNFFB video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsunffb\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B ffb
+is an XFree86 driver for Sun Creator, Creator 3D and Elite 3D video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B ffb
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>, David S. Miller <davem@redhat.com>, Michal Rehacek <majkl@iname.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/Imakefile
new file mode 100644
index 000000000..b58f9f8c2
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/Imakefile
@@ -0,0 +1,42 @@
+XCOMM
+XCOMM This is an Imakefile for the leo driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/Imakefile,v 1.1 2000/05/18 23:21:38 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = leo_driver.c leo_accel.c leo_bcopy.c leo_checks.c leo_frect.c \
+ leo_frectsp.c leo_fspans.c leo_fspanssp.c leo_gc.c leo_glyph.c \
+ leo_stubs.c leo_cursor.c
+OBJS = leo_driver.o leo_accel.o leo_bcopy.o leo_checks.o leo_frect.o \
+ leo_frectsp.o leo_fspans.o leo_fspanssp.o leo_gc.o leo_glyph.o \
+ leo_stubs.o leo_cursor.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \
+ -I$(XF86SRC)/ramdac \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(sunleo,$(OBJS))
+
+InstallObjectModule(sunleo,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(sunleo,)
+InstallModuleManPage(sunleo)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h
new file mode 100644
index 000000000..46ca45162
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h
@@ -0,0 +1,106 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - defines.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo.h,v 1.2 2000/06/30 17:15:16 dawes Exp $ */
+
+#ifndef LEO_H
+#define LEO_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "leo_regs.h"
+#include "xf86sbusBus.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define LEO_FB0_VOFF 0x00000000
+#define LEO_LC0_VOFF 0x00800000
+#define LEO_LD0_VOFF 0x00801000
+#define LEO_LX0_CURSOR_VOFF 0x00802000
+#define LEO_FB1_VOFF 0x00803000
+#define LEO_LC1_VOFF 0x01003000
+#define LEO_LD1 0x01004000
+#define LEO_LX0_VERT_VOFF 0x01005000
+#define LEO_LX_KRN_VOFF 0x01006000
+#define LEO_LC0_KRN_VOFF 0x01007000
+#define LEO_LC1_KRN_VOFF 0x01008000
+#define LEO_LD_GBL_VOFF 0x01009000
+
+typedef struct {
+ unsigned int fg, bg; /* FG/BG colors for stipple */
+ unsigned int patalign; /* X/Y alignment of bits */
+ unsigned int alu; /* Transparent/Opaque + rop */
+ unsigned int bits[32]; /* The stipple bits themselves */
+} LeoStippleRec, *LeoStipplePtr;
+
+typedef struct {
+ int type;
+ LeoStipplePtr stipple;
+} LeoPrivGCRec, *LeoPrivGCPtr;
+
+typedef struct {
+ LeoCommand0 *lc0;
+ LeoDraw *ld0;
+ LeoCursor *dac;
+ unsigned *fb;
+ int vclipmax;
+ int width;
+ int height;
+ /* cache one stipple; figuring out if we can use the stipple is as hard as
+ * computing it, so we just use this one and leave it here if it
+ * can't be used this time
+ */
+ LeoStipplePtr tmpStipple;
+
+ sbusDevicePtr psdp;
+ Bool HWCursor;
+ Bool NoAccel;
+ CloseScreenProcPtr CloseScreen;
+ xf86CursorInfoPtr CursorInfoRec;
+ unsigned char CursorShiftX, CursorShiftY;
+ unsigned char *CursorData;
+} LeoRec, *LeoPtr;
+
+extern int LeoScreenPrivateIndex;
+extern int LeoGCPrivateIndex;
+extern int LeoWindowPrivateIndex;
+
+#define GET_LEO_FROM_SCRN(p) ((LeoPtr)((p)->driverPrivate))
+
+#define LeoGetScreenPrivate(s) \
+((LeoPtr) (s)->devPrivates[LeoScreenPrivateIndex].ptr)
+
+#define LeoGetGCPrivate(g) \
+((LeoPrivGCPtr) (g)->devPrivates [LeoGCPrivateIndex].ptr)
+
+#define LeoGetWindowPrivate(w) \
+((LeoStipplePtr) (w)->devPrivates[LeoWindowPrivateIndex].ptr)
+
+#define LeoSetWindowPrivate(w,p) \
+((w)->devPrivates[LeoWindowPrivateIndex].ptr = (pointer) p)
+
+extern int leoRopTable[];
+
+#endif /* LEO_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c
new file mode 100644
index 000000000..cbe010ca9
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c
@@ -0,0 +1,195 @@
+/*
+ * Acceleration for the LEO (ZX) framebuffer.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_accel.c,v 1.1 2000/05/18 23:21:38 dawes Exp $ */
+
+#define PSZ 32
+#include <asm/types.h>
+#include <math.h>
+
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "regionstr.h"
+#include "mistruct.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+#include "cfb.h"
+#include "cfbmskbits.h"
+#include "cfb8bit.h"
+#include "mibstore.h"
+#include "mifillarc.h"
+#include "miwideline.h"
+#include "fastblt.h"
+#include "mergerop.h"
+#include "migc.h"
+#include "mi.h"
+
+#include "leo.h"
+#include "leo_gc.h"
+
+int LeoScreenPrivateIndex;
+int LeoGCPrivateIndex;
+int LeoWindowPrivateIndex;
+int LeoGeneration;
+
+int leoRopTable[16] = {
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_ZERO, /* GXclear */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_OLD, /* GXand */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_AND_NOLD, /* GXandReverse */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW, /* GXcopy */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_OLD, /* GXandInverted */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_OLD, /* GXnoop */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_XOR_OLD, /* GXxor */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_OLD, /* GXor */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_AND_NOLD, /* GXnor */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_XOR_NOLD, /* GXequiv */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NOLD, /* GXinvert */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW_OR_NOLD, /* GXorReverse */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW, /* GXcopyInverted */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_OLD, /* GXorInverted */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_NNEW_OR_NOLD, /* GXnand */
+ LEO_ATTR_RGBE_ENABLE|LEO_ROP_ONES /* GXset */
+};
+
+static void
+LeoCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ DDXPointPtr pptSrc;
+ DDXPointPtr ppt;
+ RegionPtr prgnDst;
+ BoxPtr pbox;
+ int dx, dy;
+ int i, nbox;
+ WindowPtr pwinRoot;
+ extern WindowPtr *WindowTable;
+
+ dx = ptOldOrg.x - pWin->drawable.x;
+ dy = ptOldOrg.y - pWin->drawable.y;
+
+ pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
+
+ prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
+
+ REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
+ REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip, prgnSrc);
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+ if(!(pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec))))
+ return;
+ ppt = pptSrc;
+
+ for (i = nbox; --i >= 0; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ LeoDoBitblt ((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot,
+ GXcopy, prgnDst, pptSrc, ~0L);
+ DEALLOCATE_LOCAL(pptSrc);
+ REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
+}
+
+void LeoVtChange (ScreenPtr pScreen, int enter)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+
+ ld0->wid = 1;
+ ld0->widclip = 0;
+ ld0->wmask = 0xffff;
+ ld0->planemask = 0xffffff;
+ ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
+ ld0->fg = 0;
+ ld0->vclipmin = 0;
+ ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
+ lc0->fill = 0;
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+}
+
+extern Bool LeoCreateGC (GCPtr pGC);
+
+Bool LeoAccelInit (ScreenPtr pScreen, LeoPtr pLeo)
+{
+ LeoCommand0 *lc0;
+ LeoDraw *ld0;
+
+ if (serverGeneration != LeoGeneration) {
+ LeoScreenPrivateIndex = AllocateScreenPrivateIndex ();
+ if (LeoScreenPrivateIndex == -1) return FALSE;
+ LeoGCPrivateIndex = AllocateGCPrivateIndex ();
+ LeoWindowPrivateIndex = AllocateWindowPrivateIndex ();
+ LeoGeneration = serverGeneration;
+ }
+
+ /* Allocate private structures holding pointer to both videoRAM and control registers.
+ We do not have to map these by ourselves, because the XServer did it for us; we
+ only copy the pointers to out structures. */
+ if (!AllocateGCPrivate(pScreen, LeoGCPrivateIndex, sizeof(LeoPrivGCRec))) return FALSE;
+ if (!AllocateWindowPrivate(pScreen, LeoWindowPrivateIndex, 0)) return FALSE;
+ pScreen->devPrivates[LeoScreenPrivateIndex].ptr = pLeo;
+ pLeo->lc0 = lc0 = (LeoCommand0 *) ((char *)pLeo->fb + LEO_LC0_VOFF);
+ pLeo->ld0 = ld0 = (LeoDraw *) ((char *)pLeo->fb + LEO_LD0_VOFF);
+
+ if (!pLeo->NoAccel) {
+ /* Replace various screen functions. */
+ pScreen->CreateGC = LeoCreateGC;
+ pScreen->CopyWindow = LeoCopyWindow;
+ }
+
+ /* We will now clear the screen: we'll draw a rectangle covering all the
+ * viewscreen, using a 'blackness' ROP.
+ */
+ ld0->wid = 1;
+ ld0->widclip = 0;
+ ld0->wmask = 0xffff;
+ ld0->planemask = 0xffffff;
+ ld0->rop = LEO_ATTR_WE_ENABLE|LEO_ATTR_RGBE_ENABLE|LEO_ATTR_FORCE_WID;
+ ld0->fg = 0;
+ ld0->vclipmin = 0;
+ ld0->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
+ pLeo->vclipmax = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 16);
+ pLeo->width = pLeo->psdp->width;
+ pLeo->height = pLeo->psdp->height;
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->extent = (pLeo->psdp->width - 1) | ((pLeo->psdp->height - 1) << 11);
+ lc0->fill = 0;
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+
+ /* Success */
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_bcopy.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_bcopy.c
new file mode 100644
index 000000000..360a04924
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_bcopy.c
@@ -0,0 +1,178 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Bit-blit copies.
+ *
+ * Copyright (C) 1999 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_bcopy.c,v 1.1 2000/05/18 23:21:39 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+#include "leo_regs.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+
+void
+LeoDoBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDst->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ BoxPtr pboxTmp;
+ DDXPointPtr pptTmp;
+ int nbox;
+ BoxPtr pboxNext, pboxBase, pbox;
+
+ pbox = REGION_RECTS(prgnDst);
+ nbox = REGION_NUM_RECTS(prgnDst);
+
+ pptTmp = pptSrc;
+ pboxTmp = pbox;
+
+ ld0->rop = leoRopTable[alu];
+
+ if (pptSrc->y < pbox->y1) {
+ if (pptSrc->x < pbox->x1) {
+ /* reverse order of bands and rects in each band */
+ pboxTmp=pbox+nbox;
+ pptTmp=pptSrc+nbox;
+
+ while (nbox--){
+ pboxTmp--;
+ pptTmp--;
+ if (pptTmp->y <= pboxTmp->y2) {
+ lc0->extent = 0x80000000 | (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = (pptTmp->x + pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pptTmp->y + pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->copy = (pboxTmp->x2 - 1) | ((pboxTmp->y2 - 1) << 11);
+ } else {
+ lc0->extent = (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = pptTmp->x | (pptTmp->y << 11);
+ lc0->copy = pboxTmp->x1 | (pboxTmp->y1 << 11);
+ }
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ } else {
+ /* keep ordering in each band, reverse order of bands */
+ pboxBase = pboxNext = pbox+nbox-1;
+
+ while (pboxBase >= pbox) { /* for each band */
+
+ /* find first box in band */
+ while (pboxNext >= pbox &&
+ pboxBase->y1 == pboxNext->y1)
+ pboxNext--;
+
+ pboxTmp = pboxNext+1; /* first box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* first point in band */
+
+ while (pboxTmp <= pboxBase) { /* for each box in band */
+ if (pptTmp->y <= pboxTmp->y2) {
+ lc0->extent = 0x80000000 | (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = (pptTmp->x + pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pptTmp->y + pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->copy = (pboxTmp->x2 - 1) | ((pboxTmp->y2 - 1) << 11);
+ } else {
+ lc0->extent = (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = pptTmp->x | (pptTmp->y << 11);
+ lc0->copy = pboxTmp->x1 | (pboxTmp->y1 << 11);
+ }
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ ++pboxTmp;
+ ++pptTmp;
+ }
+ pboxBase = pboxNext;
+
+ }
+ }
+ } else {
+ if (pptSrc->x < pbox->x1) {
+ /* reverse order of rects in each band */
+
+ pboxBase = pboxNext = pbox;
+
+ while (pboxBase < pbox+nbox) { /* for each band */
+
+ /* find last box in band */
+ while (pboxNext < pbox+nbox &&
+ pboxNext->y1 == pboxBase->y1)
+ pboxNext++;
+
+ pboxTmp = pboxNext; /* last box in band */
+ pptTmp = pptSrc + (pboxTmp - pbox); /* last point in band */
+
+ if (pptSrc->y == pbox->y1) {
+ while (pboxTmp != pboxBase) { /* for each box in band */
+ --pboxTmp;
+ --pptTmp;
+ lc0->extent = 0x80000000 | (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = (pptTmp->x + pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pptTmp->y + pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->copy = (pboxTmp->x2 - 1) | ((pboxTmp->y2 - 1) << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ } else {
+ while (pboxTmp != pboxBase) { /* for each box in band */
+ --pboxTmp;
+ --pptTmp;
+ lc0->extent = (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = pptTmp->x | (pptTmp->y << 11);
+ lc0->copy = pboxTmp->x1 | (pboxTmp->y1 << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ }
+ pboxBase = pboxNext;
+ }
+ } else {
+ while (nbox--) {
+ lc0->extent = (pboxTmp->x2 - pboxTmp->x1 - 1) |
+ ((pboxTmp->y2 - pboxTmp->y1 - 1) << 11);
+ lc0->src = pptTmp->x | (pptTmp->y << 11);
+ lc0->copy = pboxTmp->x1 | (pboxTmp->y1 << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ pboxTmp++;
+ pptTmp++;
+ }
+ }
+ }
+
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+}
+
+RegionPtr
+LeoCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height, int dstx, int dsty)
+{
+ if (pSrcDrawable->type != DRAWABLE_WINDOW)
+ return cfbCopyArea (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty);
+ return cfbBitBlt (pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty, (void (*)())LeoDoBitblt, 0);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_checks.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_checks.c
new file mode 100644
index 000000000..e0ad8abf0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_checks.c
@@ -0,0 +1,180 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - stipple/tile verification.
+ *
+ * Copyright (C) 1999 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_checks.c,v 1.1 2000/05/18 23:21:39 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+
+int
+LeoCheckTile (PixmapPtr pPixmap, LeoStipplePtr stipple, int ox, int oy)
+{
+ unsigned int *sbits;
+ unsigned int fg = 0, bg = 0;
+ int fgset = 0, bgset = 0;
+ unsigned int *tilebitsLine, *tilebits, tilebit;
+ unsigned int sbit, mask;
+ int nbwidth;
+ int h, w;
+ int x, y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 32 || (h & (h - 1)))
+ return FALSE;
+ w = pPixmap->drawable.width;
+ if (w > 32 || (w & (w - 1)))
+ return FALSE;
+ stipple->patalign = (oy << 16) | ox;
+ sbits = stipple->bits;
+ tilebitsLine = (unsigned int *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind / sizeof(unsigned int);
+
+ for (y = 0; y < h; y++) {
+ tilebits = tilebitsLine;
+ tilebitsLine += nbwidth;
+ sbit = 0;
+ mask = 1 << 31;
+ for (x = 0; x < w; x++) {
+ tilebit = *tilebits++;
+ if (fgset && tilebit == fg)
+ sbit |= mask;
+ else if (!bgset || tilebit != bg) {
+ if (!fgset) {
+ fgset = 1;
+ fg = tilebit;
+ sbit |= mask;
+ } else if (!bgset) {
+ bgset = 1;
+ bg = tilebit;
+ } else
+ return FALSE;
+ }
+ mask >>= 1;
+ }
+ for (s_x = w; s_x < 32; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ sbit = (sbit >> ox) | (sbit << (32 - ox));
+ for (s_y = y; s_y < 32; s_y += h)
+ sbits[(s_y + oy) & 31] = sbit;
+ }
+ stipple->fg = fg;
+ stipple->bg = bg;
+ return TRUE;
+}
+
+int
+LeoCheckStipple (PixmapPtr pPixmap, LeoStipplePtr stipple, int ox, int oy)
+{
+ unsigned int *sbits;
+ unsigned int *stippleBits;
+ unsigned int sbit, mask, nbwidth;
+ int h, w;
+ int y;
+ int s_y, s_x;
+
+ h = pPixmap->drawable.height;
+ if (h > 32 || (h & (h - 1)))
+ return FALSE;
+ w = pPixmap->drawable.width;
+ if (w > 32 || (w & (w - 1)))
+ return FALSE;
+ stipple->patalign = (oy << 16) | ox;
+ sbits = stipple->bits;
+ stippleBits = (unsigned int *) pPixmap->devPrivate.ptr;
+ nbwidth = pPixmap->devKind / sizeof(unsigned int);
+ mask = ~0 << (32 - w);
+ for (y = 0; y < h; y++) {
+ sbit = (*stippleBits) & mask;
+ stippleBits += nbwidth;
+ for (s_x = w; s_x < 32; s_x <<= 1)
+ sbit = sbit | (sbit >> s_x);
+ sbit = (sbit >> ox) | (sbit << (32 - ox));
+ for (s_y = y; s_y < 32; s_y += h)
+ sbits[(s_y + oy) & 31] = sbit;
+ }
+ return TRUE;
+}
+
+int
+LeoCheckFill (GCPtr pGC, DrawablePtr pDrawable)
+{
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+ LeoPtr pLeo = LeoGetScreenPrivate(pDrawable->pScreen);
+ LeoStipplePtr stipple;
+ unsigned int alu;
+ int xrot, yrot;
+
+ if (pGC->fillStyle == FillSolid) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return TRUE;
+ }
+ if (!(stipple = gcPriv->stipple)) {
+ if (!pLeo->tmpStipple) {
+ pLeo->tmpStipple = (LeoStipplePtr) xalloc (sizeof *pLeo->tmpStipple);
+ if (!pLeo->tmpStipple)
+ return FALSE;
+ }
+ stipple = pLeo->tmpStipple;
+ }
+ xrot = (pGC->patOrg.x + pDrawable->x) & 31;
+ yrot = (pGC->patOrg.y + pDrawable->y) & 31;
+ alu = pGC->alu;
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ if (!LeoCheckTile (pGC->tile.pixmap, stipple, xrot, yrot)) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ break;
+ case FillStippled:
+ alu |= 0x80;
+ case FillOpaqueStippled:
+ if (!LeoCheckStipple (pGC->stipple, stipple, xrot, yrot)) {
+ if (gcPriv->stipple) {
+ xfree (gcPriv->stipple);
+ gcPriv->stipple = 0;
+ }
+ return FALSE;
+ }
+ stipple->fg = pGC->fgPixel;
+ stipple->bg = pGC->bgPixel;
+ break;
+ }
+ stipple->alu = alu;
+ gcPriv->stipple = stipple;
+ if (stipple == pLeo->tmpStipple)
+ pLeo->tmpStipple = 0;
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_cursor.c
new file mode 100644
index 000000000..271a2228d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_cursor.c
@@ -0,0 +1,155 @@
+/*
+ * Hardware cursor support for Leo (ZX)
+ *
+ * Copyright 2000 by Jakub Jelinek <jakub@redhat.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 of Jakub
+ * Jelinek not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Jakub Jelinek makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL JAKUB JELINEK 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_cursor.c,v 1.1 2000/05/18 23:21:39 dawes Exp $ */
+
+#include "leo.h"
+
+static void LeoLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void LeoShowCursor(ScrnInfoPtr pScrn);
+static void LeoHideCursor(ScrnInfoPtr pScrn);
+static void LeoSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void LeoSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+
+static void
+LeoLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+ int i, j, x, y;
+ unsigned int *data = (unsigned int *)src, value;
+
+ pLeo->CursorData = src;
+ x = pLeo->CursorShiftX;
+ y = pLeo->CursorShiftY;
+ if (x >= 32 || y >= 32)
+ y = 32;
+ pLeo->dac->cur_type = 0;
+ for (j = 0; j < 2; j++) {
+ data += y;
+ for (i = y; i < 32; i++, data++) {
+ value = (*data >> 16) | (*data << 16);
+ value = ((value & 0xff00ff00) >> 8) |
+ ((value & 0x00ff00ff) << 8);
+ pLeo->dac->cur_data = value >> x;
+ }
+ for (i = 0; i < y; i++)
+ pLeo->dac->cur_data = 0;
+ }
+}
+
+static void
+LeoShowCursor(ScrnInfoPtr pScrn)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->dac->cur_misc |= 0x80;
+}
+
+static void
+LeoHideCursor(ScrnInfoPtr pScrn)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->dac->cur_misc &= ~0x80;
+ pLeo->CursorData = NULL;
+}
+
+static void
+LeoSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+ int CursorShiftX = 0, CursorShiftY = 0;
+
+ if (x < 0) {
+ CursorShiftX = -x;
+ x = 0;
+ if (CursorShiftX > 32)
+ CursorShiftX = 32;
+ }
+ if (y < 0) {
+ CursorShiftY = -y;
+ y = 0;
+ if (CursorShiftY > 32)
+ CursorShiftY = 32;
+ }
+ pLeo->dac->cur_misc &= ~0x80;
+ if ((CursorShiftX != pLeo->CursorShiftX ||
+ CursorShiftY != pLeo->CursorShiftY) &&
+ pLeo->CursorData != NULL) {
+ pLeo->CursorShiftX = CursorShiftX;
+ pLeo->CursorShiftY = CursorShiftY;
+ LeoLoadCursorImage(pScrn, pLeo->CursorData);
+ }
+
+ pLeo->dac->cur_cursxy = ((y & 0x7ff) << 11) | (x & 0x7ff);
+ pLeo->dac->cur_misc |= 0x30;
+ pLeo->dac->cur_misc |= 0x80;
+}
+
+static void
+LeoSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pLeo->dac->cur_type = 0x50;
+ pLeo->dac->cur_data = bg;
+ pLeo->dac->cur_data = fg;
+ pLeo->dac->cur_misc |= 0x03;
+}
+
+Bool
+LeoHWCursorInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ LeoPtr pLeo;
+ xf86CursorInfoPtr infoPtr;
+
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+ pLeo->CursorShiftX = 0;
+ pLeo->CursorShiftY = 0;
+ pLeo->CursorData = NULL;
+
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ pLeo->CursorInfoRec = infoPtr;
+ pLeo->dac = (LeoCursor *)((char *)pLeo->fb + LEO_LX0_CURSOR_VOFF);
+
+ infoPtr->MaxWidth = 32;
+ infoPtr->MaxHeight = 32;
+ infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
+ HARDWARE_CURSOR_BIT_ORDER_MSBFIRST |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED;
+
+ infoPtr->SetCursorColors = LeoSetCursorColors;
+ infoPtr->SetCursorPosition = LeoSetCursorPosition;
+ infoPtr->LoadCursorImage = LeoLoadCursorImage;
+ infoPtr->HideCursor = LeoHideCursor;
+ infoPtr->ShowCursor = LeoShowCursor;
+ infoPtr->UseHWCursor = NULL;
+
+ return xf86InitCursor(pScreen, infoPtr);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c
new file mode 100644
index 000000000..6ad57f3b2
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c
@@ -0,0 +1,690 @@
+/*
+ * Leo (ZX) framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_driver.c,v 1.2 2000/05/23 04:47:46 dawes Exp $ */
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#define PSZ 32
+#include "cfb.h"
+#undef PSZ
+#include "xf86cmap.h"
+#include "leo.h"
+
+static OptionInfoPtr LeoAvailableOptions(int chipid, int busid);
+static void LeoIdentify(int flags);
+static Bool LeoProbe(DriverPtr drv, int flags);
+static Bool LeoPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool LeoScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool LeoEnterVT(int scrnIndex, int flags);
+static void LeoLeaveVT(int scrnIndex, int flags);
+static Bool LeoCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool LeoSaveScreen(ScreenPtr pScreen, int mode);
+
+/* Required if the driver supports mode switching */
+static Bool LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void LeoAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void LeoFreeScreen(int scrnIndex, int flags);
+static int LeoValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void LeoSync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define LEO_NAME "SUNLEO"
+#define LEO_DRIVER_NAME "sunleo"
+#define LEO_MAJOR_VERSION 1
+#define LEO_MINOR_VERSION 0
+#define LEO_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNLEO = {
+ VERSION,
+ LEO_DRIVER_NAME,
+ LeoIdentify,
+ LeoProbe,
+ LeoAvailableOptions,
+ NULL,
+ 0
+};
+
+typedef enum {
+ OPTION_SW_CURSOR,
+ OPTION_HW_CURSOR,
+ OPTION_NOACCEL
+} LeoOpts;
+
+static OptionInfoRec LeoOptions[] = {
+ { OPTION_SW_CURSOR, "SWcursor", 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 }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(leoSetup);
+
+static XF86ModuleVersionInfo sunleoVersRec =
+{
+ "sunleo",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ LEO_MAJOR_VERSION, LEO_MINOR_VERSION, LEO_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData sunleoModuleData = { &sunleoVersRec, leoSetup, NULL };
+
+pointer
+leoSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNLEO, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+LeoGetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an LeoRec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(LeoRec), 1);
+ return TRUE;
+}
+
+static void
+LeoFreeRec(ScrnInfoPtr pScrn)
+{
+ LeoPtr pLeo;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+LeoAvailableOptions(int chipid, int busid)
+{
+ return LeoOptions;
+}
+
+/* Mandatory */
+static void
+LeoIdentify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for Leo (ZX)\n", LEO_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+LeoProbe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(LEO_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(LEO_NAME, SBUS_DEVICE_LEO,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = LEO_DRIVER_NAME;
+ pScrn->name = LEO_NAME;
+ pScrn->Probe = LeoProbe;
+ pScrn->PreInit = LeoPreInit;
+ pScrn->ScreenInit = LeoScreenInit;
+ pScrn->SwitchMode = LeoSwitchMode;
+ pScrn->AdjustFrame = LeoAdjustFrame;
+ pScrn->EnterVT = LeoEnterVT;
+ pScrn->LeaveVT = LeoLeaveVT;
+ pScrn->FreeScreen = LeoFreeScreen;
+ pScrn->ValidMode = LeoValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+LeoPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ LeoPtr pLeo;
+ sbusDevicePtr psdp;
+ MessageType from;
+ int i;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the LeoRec driverPrivate */
+ if (!LeoGetRec(pScrn)) {
+ return FALSE;
+ }
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* LEO is purely SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pLeo->psdp = psdp;
+ } else
+ return FALSE;
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support32bppFb)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 32:
+ /* OK */
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ /* Collect all of the relevant option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+ /* Process the options */
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, LeoOptions);
+
+ /*
+ * This must happen after pScrn->display has been set because
+ * xf86SetWeight references it.
+ */
+ if (pScrn->depth > 8) {
+ rgb weight = {10, 11, 11};
+ rgb mask = {0xff, 0xff00, 0xff0000};
+
+ if (!xf86SetWeight(pScrn, weight, mask)) {
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1)) {
+ return FALSE;
+ } else {
+ /* We don't currently support DirectColor */
+ if (pScrn->defaultVisual != TrueColor) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
+ " (%s) is not supported\n",
+ xf86GetVisualName(pScrn->defaultVisual));
+ return FALSE;
+ }
+ }
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* Set the bits per RGB for 8bpp mode */
+ from = X_DEFAULT;
+
+ /* determine whether we use hardware or software cursor */
+
+ pLeo->HWCursor = TRUE;
+ if (xf86GetOptValBool(LeoOptions, OPTION_HW_CURSOR, &pLeo->HWCursor))
+ from = X_CONFIG;
+ if (xf86ReturnOptValBool(LeoOptions, OPTION_SW_CURSOR, FALSE)) {
+ from = X_CONFIG;
+ pLeo->HWCursor = FALSE;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+ pLeo->HWCursor ? "HW" : "SW");
+
+ if (xf86ReturnOptValBool(LeoOptions, OPTION_NOACCEL, FALSE)) {
+ pLeo->NoAccel = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Acceleration disabled\n");
+ }
+
+ if (xf86LoadSubModule(pScrn, "cfb32") == NULL) {
+ LeoFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (pLeo->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) {
+ LeoFreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "Leo does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pLeo->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+LeoScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ LeoPtr pLeo;
+ int ret;
+ VisualPtr visual;
+ extern Bool LeoAccelInit(ScreenPtr pScreen, LeoPtr pLeo);
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ /* Map the Leo memory */
+ pLeo->fb =
+ xf86MapSbusMem (pLeo->psdp, LEO_FB0_VOFF, 0x803000);
+
+ if (! pLeo->fb)
+ return FALSE;
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ LeoSaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth, TrueColorMask, pScrn->rgbBits,
+ pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ ret = cfb32ScreenInit(pScreen, pLeo->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ 2048);
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ 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 (!LeoAccelInit(pScreen, pLeo))
+ return FALSE;
+
+ if (!pLeo->NoAccel)
+ xf86Msg(X_INFO, "%s: Using acceleration\n", pLeo->psdp->device);
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialize HW cursor layer.
+ Must follow software cursor initialization*/
+ if (pLeo->HWCursor) {
+ extern Bool LeoHWCursorInit(ScreenPtr pScreen);
+
+ if(!LeoHWCursorInit(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed\n");
+ return(FALSE);
+ }
+ xf86SbusHideOsHwCursor(pLeo->psdp);
+ }
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ pLeo->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = LeoCloseScreen;
+ pScreen->SaveScreen = LeoSaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ LeoSaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+LeoSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+LeoAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+extern void LeoVtChange (ScreenPtr pScreen, int enter);
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+LeoEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ LeoVtChange (pScrn->pScreen, TRUE);
+ if (pLeo->HWCursor)
+ xf86SbusHideOsHwCursor (pLeo->psdp);
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+LeoLeaveVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+
+ LeoVtChange (pScrn->pScreen, FALSE);
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+LeoCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ LeoPtr pLeo = GET_LEO_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ xf86UnmapSbusMem(pLeo->psdp, pLeo->fb, 0x803000);
+
+ pScreen->CloseScreen = pLeo->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+LeoFreeScreen(int scrnIndex, int flags)
+{
+ LeoFreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+LeoValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+LeoSaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+LeoSync(ScrnInfoPtr pScrn)
+{
+ return;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frect.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frect.c
new file mode 100644
index 000000000..4f1e854c8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frect.c
@@ -0,0 +1,233 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Rectangle filling.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frect.c,v 1.2 2000/05/23 04:47:47 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+#include "leo_regs.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+void
+LeoPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int n;
+ int xorg, yorg;
+
+ /* No garbage please. */
+ if(nrectFill <= 0)
+ return;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = pGC->fgPixel;
+
+ if (REGION_NUM_RECTS(prgnClip) == 1) {
+ int x1, y1, x2, y2;
+ int x, y, xx, yy;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ x = prect->x;
+ y = prect->y;
+ xx = x + prect->width;
+ yy = y + prect->height;
+ if (x < x1)
+ x = x1;
+ if (y < y1)
+ y = y1;
+ prect++;
+ if (xx > x2) xx = x2;
+ if (yy > y2) yy = y2;
+ if (x >= xx) continue;
+ if (y >= yy) continue;
+
+ lc0->extent = (xx - x - 1) | ((yy - y - 1) << 11);
+ lc0->fill = x | (y << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ } else {
+ int x1, y1, x2, y2, bx1, by1, bx2, by2;
+ int x, y, w, h;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ if ((bx1 = prect->x) < x1)
+ bx1 = x1;
+
+ if ((by1 = prect->y) < y1)
+ by1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+
+ prect++;
+
+ if (bx1 >= bx2 || by1 >= by2)
+ 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--) {
+ x = max(bx1, pbox->x1);
+ y = max(by1, pbox->y1);
+ w = min(bx2, pbox->x2) - x;
+ h = min(by2, pbox->y2) - y;
+ pbox++;
+
+ /* see if clipping left anything */
+ if (w > 0 && h > 0) {
+ lc0->extent = (w - 1) | ((h - 1) << 11);
+ lc0->fill = x | (y << 11);
+
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+ }
+ }
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
+
+void
+LeoPolyFillRect1Rect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ BoxPtr pextent;
+ int n;
+ int xorg, yorg;
+ int x1, y1, x2, y2;
+ int x, y, xx, yy;
+
+ /* No garbage please. */
+ if(nrectFill <= 0)
+ return;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = pGC->fgPixel;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ x = prect->x;
+ y = prect->y;
+ xx = x + prect->width;
+ yy = y + prect->height;
+ if (x < x1)
+ x = x1;
+ if (y < y1)
+ y = y1;
+ prect++;
+ if (xx > x2) xx = x2;
+ if (x >= xx) continue;
+ if (yy > y2) yy = y2;
+ if (y >= yy) continue;
+
+ lc0->extent = (xx - x - 1) | ((yy - y - 1) << 11);
+ lc0->fill = x | (y << 11);
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frectsp.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frectsp.c
new file mode 100644
index 000000000..8784acc10
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frectsp.c
@@ -0,0 +1,276 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Tiled/stippled rectangle filling.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_frectsp.c,v 1.2 2000/05/23 04:47:47 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+#include "leo_regs.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "cfbmskbits.h"
+
+void
+LeoPolyFillStippledRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ xRectangle *prect;
+ RegionPtr prgnClip;
+ register BoxPtr pbox;
+ BoxPtr pextent;
+ int n;
+ int xorg, yorg;
+ unsigned char *fb;
+ unsigned int *dst, *dline, *src, *srcstart, *srcend;
+
+ /* No garbage please. */
+ if(nrectFill <= 0)
+ return;
+
+ prgnClip = cfbGetCompositeClip(pGC);
+
+ prect = prectInit;
+ xorg = pDrawable->x;
+ yorg = pDrawable->y;
+ if (xorg || yorg) {
+ prect = prectInit;
+ n = nrectFill;
+ while(n--) {
+ prect->x += xorg;
+ prect->y += yorg;
+ prect++;
+ }
+ }
+
+ prect = prectInit;
+
+ if ((gcPriv->stipple->alu & 0xf) != GXcopy)
+ ld0->rop = leoRopTable[gcPriv->stipple->alu & 0xf];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = gcPriv->stipple->fg;
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ if (gcPriv->stipple->alu & 0x80) {
+ lc0->fontt = 1;
+ } else {
+ lc0->fontt = 0;
+ ld0->bg = gcPriv->stipple->bg;
+ }
+ fb = (unsigned char *)pLeo->fb;
+ srcstart = &gcPriv->stipple->bits[0];
+ srcend = &gcPriv->stipple->bits[32];
+
+ if (REGION_NUM_RECTS(prgnClip) == 1) {
+ int x1, y1, x2, y2;
+ int x, y, xx, yy, w, h;
+ int i, j, sw, sm, ew, em, s;
+
+ pextent = REGION_RECTS(prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ x = prect->x;
+ y = prect->y;
+ xx = x + prect->width;
+ yy = y + prect->height;
+ if (x < x1) x = x1;
+ if (y < y1) y = y1;
+ if (xx > x2) xx = x2;
+ if (yy > y2) yy = y2;
+ prect++;
+ if (x >= xx) continue;
+ if (y >= yy) continue;
+ prect++;
+ w = xx - x;
+ h = yy - y;
+ if (x & 31) {
+ sw = 32 - (x & 31);
+ sm = 0xffffffff >> (x & 31);
+ } else {
+ sw = 0;
+ sm = 0xffffffff;
+ }
+ dline = (unsigned int *)(fb + (y << 13) + ((x & ~31) << 2));
+ src = srcstart + (y & 31);
+ w -= sw;
+ if (w <= 0) {
+ if (w)
+ sm &= 0xffffffff << (32 - (w & 31));
+ lc0->fontmsk = sm;
+
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ *dline = s;
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ } else {
+ ew = w & 31;
+ em = 0xffffffff << (32 - ew);
+ w &= ~31;
+
+ if (!sw && !ew)
+ lc0->fontmsk = 0xffffffff;
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ dst = dline;
+ if (sw) {
+ lc0->fontmsk = sm;
+ *dst = s;
+ dst += 32;
+ lc0->fontmsk = 0xffffffff;
+ } else if (ew)
+ lc0->fontmsk = 0xffffffff;
+ for (j = 0; j < w; j += 32) {
+ *dst = s;
+ dst += 32;
+ }
+ if (ew) {
+ lc0->fontmsk = em;
+ *dst = s;
+ }
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ }
+ }
+ } else {
+ int x1, y1, x2, y2, bx1, by1, bx2, by2;
+ int x, y, w, h;
+ int i, j, sw, sm, ew, em, s;
+
+ pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
+ x1 = pextent->x1;
+ y1 = pextent->y1;
+ x2 = pextent->x2;
+ y2 = pextent->y2;
+ while (nrectFill--) {
+ if ((bx1 = prect->x) < x1)
+ bx1 = x1;
+
+ if ((by1 = prect->y) < y1)
+ by1 = y1;
+
+ bx2 = (int) prect->x + (int) prect->width;
+ if (bx2 > x2)
+ bx2 = x2;
+
+ by2 = (int) prect->y + (int) prect->height;
+ if (by2 > y2)
+ by2 = y2;
+
+ prect++;
+
+ if (bx1 >= bx2 || by1 >= by2)
+ 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--) {
+ x = max(bx1, pbox->x1);
+ y = max(by1, pbox->y1);
+ w = min(bx2, pbox->x2) - x;
+ h = min(by2, pbox->y2) - y;
+ pbox++;
+
+ /* see if clipping left anything */
+ if (w > 0 && h > 0) {
+ if (x & 31) {
+ sw = 32 - (x & 31);
+ sm = 0xffffffff >> (x & 31);
+ } else {
+ sw = 0;
+ sm = 0xffffffff;
+ }
+ dline = (unsigned int *)(fb + (y << 13) + ((x & ~31) << 2));
+ src = srcstart + (y & 31);
+ w -= sw;
+ if (w <= 0) {
+ w += 32;
+ if (w != 32)
+ sm &= 0xffffffff << (32 - (w & 31));
+ lc0->fontmsk = sm;
+
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ *dline = s;
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ } else {
+ ew = w & 31;
+ em = 0xffffffff << (32 - ew);
+ w &= ~31;
+
+ if (!sw && !ew)
+ lc0->fontmsk = 0xffffffff;
+
+ for (i = 0; i < h; i++) {
+ s = *src++;
+ dst = dline;
+ if (sw) {
+ lc0->fontmsk = sm;
+ *dst = s;
+ dst += 32;
+ lc0->fontmsk = 0xffffffff;
+ } else if (ew)
+ lc0->fontmsk = 0xffffffff;
+ for (j = 0; j < w; j += 32) {
+ *dst = s;
+ dst += 32;
+ }
+ if (ew) {
+ lc0->fontmsk = em;
+ *dst = s;
+ }
+ if (src == srcend)
+ src = srcstart;
+ dline += 2048;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspans.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspans.c
new file mode 100644
index 000000000..755870c1c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspans.c
@@ -0,0 +1,127 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Fill spans.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspans.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "mi.h"
+#include "mispans.h"
+
+void
+LeoFillSpansSolid (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ int numRects, *pwidthFree;
+ DDXPointPtr pptFree;
+ RegionPtr clip;
+ unsigned char *fb;
+ int fg;
+ int cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0;
+
+ clip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS(clip);
+
+ if (!numRects)
+ return;
+
+ if (numRects == 1) {
+ cx1 = clip->extents.x1;
+ cx2 = clip->extents.x2;
+ cy1 = clip->extents.y1;
+ cy2 = clip->extents.y2;
+ } else {
+ int nTmp = n * miFindMaxBand(clip);
+
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(clip,
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = fg = pGC->fgPixel;
+ fb = (unsigned char *)pLeo->fb;
+
+ while (n--) {
+ int x, y, w;
+ unsigned int *fbf;
+
+ w = *pwidth++;
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+
+ if (numRects == 1) {
+ if (y < cy1 || y >= cy2) continue;
+ if (x < cx1) {
+ w -= (cx1 - x);
+ if (w <= 0) continue;
+ x = cx1;
+ }
+ if (x + w > cx2) {
+ if (x >= cx2) continue;
+ w = cx2 - x;
+ }
+ }
+
+ if (w > 12) {
+ lc0->extent = w - 1;
+ lc0->fill = (y << 11) | x;
+ while (lc0->csr & LEO_CSR_BLT_BUSY);
+ } else {
+ fbf = (unsigned int *)(fb + (y << 13) + (x << 2));
+ while (w--)
+ *fbf++ = fg;
+ }
+ }
+
+ if (numRects != 1) {
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ }
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspanssp.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspanssp.c
new file mode 100644
index 000000000..92b46a1b7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspanssp.c
@@ -0,0 +1,166 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Fill tiled/stippled spans.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_fspanssp.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+#include "mi.h"
+#include "mispans.h"
+
+void
+LeoFillSpansStippled (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted)
+{
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ int numRects, *pwidthFree;
+ DDXPointPtr pptFree;
+ RegionPtr clip;
+ unsigned char *fb;
+ unsigned int *bits, msk;
+ int cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0;
+
+ clip = cfbGetCompositeClip(pGC);
+ numRects = REGION_NUM_RECTS(clip);
+
+ if (!numRects)
+ return;
+
+ if (numRects == 1) {
+ cx1 = clip->extents.x1;
+ cx2 = clip->extents.x2;
+ cy1 = clip->extents.y1;
+ cy2 = clip->extents.y2;
+ } else {
+ int nTmp = n * miFindMaxBand(clip);
+
+ pwidthFree = (int *)ALLOCATE_LOCAL(nTmp * sizeof(int));
+ pptFree = (DDXPointRec *)ALLOCATE_LOCAL(nTmp * sizeof(DDXPointRec));
+ if (!pptFree || !pwidthFree) {
+ if (pptFree) DEALLOCATE_LOCAL(pptFree);
+ if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree);
+ return;
+ }
+ n = miClipSpans(clip,
+ ppt, pwidth, n,
+ pptFree, pwidthFree, fSorted);
+ pwidth = pwidthFree;
+ ppt = pptFree;
+ }
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ ld0->fg = gcPriv->stipple->fg;
+ fb = (unsigned char *)pLeo->fb;
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ if (gcPriv->stipple->alu & 0x80) {
+ lc0->fontt = 1;
+ } else {
+ lc0->fontt = 0;
+ ld0->bg = gcPriv->stipple->bg;
+ }
+ lc0->fontmsk = 0xffffffff;
+ msk = 0xffffffff;
+ bits = &gcPriv->stipple->bits[0];
+ while (n--) {
+ int x, y, w;
+ unsigned int *dst, s, i, sw, sm;
+
+ w = *pwidth++;
+ x = ppt->x;
+ y = ppt->y;
+ ppt++;
+ if (numRects == 1) {
+ if (y < cy1 || y >= cy2) continue;
+ if (x < cx1) {
+ w -= (cx1 - x);
+ if (w <= 0) continue;
+ x = cx1;
+ }
+ if (x + w > cx2) {
+ if (x >= cx2) continue;
+ w = cx2 - x;
+ }
+ }
+ s = bits[y & 31];
+ dst = (unsigned int *)(fb + (y << 13) + ((x & ~31) << 2));
+ if (x & 31) {
+ sw = 32 - (x & 31);
+ sm = 0xffffffff >> (x & 31);
+ w -= sw;
+ if (w <= 0) {
+ if (w) sm &= 0xffffffff << (32 - (w & 31));
+ if (msk != sm) {
+ msk = sm;
+ lc0->fontmsk = sm;
+ }
+ *dst = s;
+ continue;
+ }
+ if (msk != sm) {
+ msk = sm;
+ lc0->fontmsk = sm;
+ }
+ *dst = s;
+ dst += 32;
+ } else {
+ sw = 0;
+ }
+ sw = w & 31;
+ w &= ~31;
+ if (w && msk != 0xffffffff) {
+ msk = 0xffffffff;
+ lc0->fontmsk = 0xffffffff;
+ for (i = 0; i < w; i += 32) {
+ *dst = s;
+ dst += 32;
+ }
+ }
+ if (sw) {
+ msk = 0xffffffff << (32 - sw);
+ lc0->fontmsk = msk;
+ *dst = s;
+ }
+ }
+
+ if (numRects != 1) {
+ DEALLOCATE_LOCAL(pptFree);
+ DEALLOCATE_LOCAL(pwidthFree);
+ }
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c
new file mode 100644
index 000000000..2a49d9121
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c
@@ -0,0 +1,590 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - GC implementation.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+#include "leo_regs.h"
+#include "leo_gc.h"
+
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "cfb.h"
+#include "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 "cfbmskbits.h"
+#include "cfb8bit.h"
+
+void LeoValidateGC(GCPtr, unsigned long, DrawablePtr);
+static void LeoDestroyGC(GCPtr);
+
+GCFuncs LeoGCFuncs = {
+ LeoValidateGC,
+ miChangeGC,
+ miCopyGC,
+ LeoDestroyGC,
+ miChangeClip,
+ miDestroyClip,
+ miCopyClip,
+};
+
+GCOps LeoTEOps1Rect = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ LeoCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+ cfb8LineSS1Rect,
+ cfb8SegmentSS1Rect,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ cfbFillPoly1RectCopy,
+ LeoPolyFillRect1Rect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ LeoTEGlyphBlt,
+ LeoPolyTEGlyphBlt,
+ mfbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps LeoNonTEOps1Rect = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ LeoCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+ cfb8LineSS1Rect,
+ cfb8SegmentSS1Rect,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ cfbFillPoly1RectCopy,
+ LeoPolyFillRect1Rect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ cfbImageGlyphBlt8,
+ LeoPolyGlyphBlt,
+ mfbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps LeoTEOps = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ LeoCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ miFillPolygon,
+ LeoPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ LeoTEGlyphBlt,
+ LeoPolyTEGlyphBlt,
+ mfbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps LeoNonTEOps = {
+ cfbSolidSpansCopy,
+ cfbSetSpans,
+ cfbPutImage,
+ LeoCopyArea,
+ cfbCopyPlane,
+ cfbPolyPoint,
+ cfbLineSS,
+ cfbSegmentSS,
+ miPolyRectangle,
+ cfbZeroPolyArcSS8Copy,
+ miFillPolygon,
+ LeoPolyFillRect,
+ cfbPolyFillArcSolidCopy,
+ miPolyText8,
+ miPolyText16,
+ miImageText8,
+ miImageText16,
+ cfbImageGlyphBlt8,
+ LeoPolyGlyphBlt,
+ mfbPushPixels
+#ifdef NEED_LINEHELPER
+ ,NULL
+#endif
+};
+
+GCOps *
+LeoMatchCommon (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))
+ if (devPriv->oneRect)
+ return &LeoTEOps1Rect;
+ else
+ return &LeoTEOps;
+ else
+ if (devPriv->oneRect)
+ return &LeoNonTEOps1Rect;
+ else
+ return &LeoNonTEOps;
+ }
+ return 0;
+}
+
+Bool
+LeoCreateGC(GCPtr pGC)
+{
+ LeoPrivGCPtr gcPriv;
+
+ if (pGC->depth == 1)
+ return mfbCreateGC (pGC);
+ if (!cfbCreateGC (pGC))
+ return FALSE;
+
+ pGC->ops = & LeoNonTEOps;
+ pGC->funcs = & LeoGCFuncs;
+ gcPriv = LeoGetGCPrivate (pGC);
+ gcPriv->type = DRAWABLE_WINDOW;
+ gcPriv->stipple = 0;
+ return TRUE;
+}
+
+static void
+LeoDestroyGC (GCPtr pGC)
+{
+ LeoPrivGCPtr gcPriv = LeoGetGCPrivate (pGC);
+
+ if (gcPriv->stipple)
+ xfree (gcPriv->stipple);
+ miDestroyGC (pGC);
+}
+
+void
+LeoValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
+{
+ int mask;
+ int index;
+ int new_rrop;
+ int new_line, new_text, new_fillspans, new_fillarea;
+ int new_rotate;
+ int xrot, yrot;
+ /* flags for changing the proc vector */
+ LeoPrivGCPtr gcPriv;
+ cfbPrivGCPtr devPriv;
+ int oneRect;
+
+ gcPriv = LeoGetGCPrivate (pGC);
+ if (pDrawable->type != DRAWABLE_WINDOW) {
+ if (gcPriv->type == DRAWABLE_WINDOW) {
+ extern GCOps cfbNonTEOps;
+
+ miDestroyGCOps (pGC->ops);
+ pGC->ops = &cfbNonTEOps;
+ changes = (1 << (GCLastBit+1)) - 1;
+ pGC->stateChanges = changes;
+ gcPriv->type = pDrawable->type;
+ }
+ cfbValidateGC (pGC, changes, pDrawable);
+ return;
+ }
+
+ if (gcPriv->type != DRAWABLE_WINDOW) {
+ changes = (1 << (GCLastBit+1)) - 1;
+ gcPriv->type = DRAWABLE_WINDOW;
+ }
+
+ new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
+ pGC->lastWinOrg.y != pDrawable->y;
+
+ 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);
+ oneRect = REGION_NUM_RECTS(cfbGetCompositeClip(pGC)) == 1;
+ if (oneRect != devPriv->oneRect)
+ new_line = TRUE;
+ devPriv->oneRect = oneRect;
+ }
+
+ mask = changes;
+ while (mask) {
+ index = lowbit (mask);
+ mask &= ~index;
+
+ /*
+ * this switch acculmulates a list of which procedures might have
+ * to change due to changes in the GC. in some cases (e.g.
+ * changing one 16 bit tile for another) we might not really need
+ * a change, but the code is being paranoid. this sort of batching
+ * wins if, for example, the alu and the font have been changed,
+ * or any other pair of items that both change the same thing.
+ */
+ 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:
+ if (pGC->stipple) {
+ int width = pGC->stipple->drawable.width;
+ PixmapPtr nstipple;
+
+ if ((width <= PGSZ) && !(width & (width - 1)) &&
+ (nstipple = cfbCopyPixmap(pGC->stipple))) {
+ cfbPadPixmap(nstipple);
+ (*pGC->pScreen->DestroyPixmap)(pGC->stipple);
+ pGC->stipple = nstipple;
+ }
+ }
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ break;
+
+ case GCTileStipXOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCTileStipYOrigin:
+ new_rotate = TRUE;
+ break;
+
+ case GCFont:
+ new_text = TRUE;
+ break;
+ case GCSubwindowMode:
+ break;
+ case GCGraphicsExposures:
+ break;
+ case GCClipXOrigin:
+ break;
+ case GCClipYOrigin:
+ break;
+ case GCClipMask:
+ break;
+ case GCDashOffset:
+ break;
+ case GCDashList:
+ break;
+ case GCArcMode:
+ break;
+ 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_rotate || new_fillspans) {
+ Bool new_pix = FALSE;
+
+ xrot = pGC->patOrg.x + pDrawable->x;
+ yrot = pGC->patOrg.y + pDrawable->y;
+
+ LeoCheckFill (pGC, pDrawable);
+
+ switch (pGC->fillStyle) {
+ case FillTiled:
+ if (!pGC->tileIsPixel) {
+ int width = pGC->tile.pixmap->drawable.width * PSZ;
+
+ if ((width <= 32) && !(width & (width - 1))) {
+ cfbCopyRotatePixmap(pGC->tile.pixmap,
+ &pGC->pRotatedPixmap,
+ xrot, yrot);
+ new_pix = TRUE;
+ }
+ }
+ break;
+ }
+
+ if (!new_pix && pGC->pRotatedPixmap) {
+ (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
+ pGC->pRotatedPixmap = (PixmapPtr) NULL;
+ }
+ }
+
+ if (new_rrop) {
+ int old_rrop;
+
+ if (gcPriv->stipple) {
+ if (pGC->fillStyle == FillStippled)
+ gcPriv->stipple->alu = pGC->alu | 0x80;
+ else
+ gcPriv->stipple->alu = pGC->alu;
+ if (pGC->fillStyle != FillTiled) {
+ gcPriv->stipple->fg = pGC->fgPixel;
+ gcPriv->stipple->bg = pGC->bgPixel;
+ }
+ }
+
+ 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 {
+ new_line = TRUE;
+ new_text = TRUE;
+ new_fillspans = TRUE;
+ new_fillarea = TRUE;
+ }
+ }
+
+ if (new_rrop || new_fillspans || new_text || new_fillarea || new_line) {
+ GCOps *newops;
+
+ if ((newops = LeoMatchCommon (pGC, devPriv)) != NULL) {
+ 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;
+ }
+ pGC->ops->CopyArea = LeoCopyArea;
+ }
+ }
+
+ /* deal with the changes we've collected */
+ if (new_line) {
+ pGC->ops->FillPolygon = miFillPolygon;
+ if (devPriv->oneRect && pGC->fillStyle == FillSolid) {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->FillPolygon = cfbFillPoly1RectCopy;
+ break;
+ default:
+ pGC->ops->FillPolygon = LeoFillPoly1RectGeneral;
+ break;
+ }
+ }
+ if (pGC->lineWidth == 0) {
+ if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)) {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy;
+ break;
+ default:
+ pGC->ops->PolyArc = LeoZeroPolyArcSS8General;
+ break;
+ }
+ } else
+ 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 (devPriv->oneRect &&
+ ((pDrawable->x >= pGC->pScreen->width - 32768) &&
+ (pDrawable->y >= pGC->pScreen->height - 32768))) {
+ pGC->ops->Polylines = cfb8LineSS1Rect;
+ pGC->ops->PolySegment = cfb8SegmentSS1Rect;
+ } else {
+ pGC->ops->Polylines = cfbLineSS;
+ pGC->ops->PolySegment = cfbSegmentSS;
+ }
+ } 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 {
+ if (pGC->fillStyle == FillSolid) {
+ if (TERMINALFONT (pGC->font))
+ pGC->ops->PolyGlyphBlt = LeoPolyTEGlyphBlt;
+ else
+ pGC->ops->PolyGlyphBlt = LeoPolyGlyphBlt;
+ } else
+ pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
+
+ /* special case ImageGlyphBlt for terminal emulator fonts */
+ if (TERMINALFONT (pGC->font))
+ pGC->ops->ImageGlyphBlt = LeoTEGlyphBlt;
+ else
+ pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
+ }
+ }
+
+ if (new_fillspans) {
+ switch (pGC->fillStyle) {
+ case FillSolid:
+ pGC->ops->FillSpans = LeoFillSpansSolid;
+ break;
+ case FillTiled:
+ if (pGC->pRotatedPixmap) {
+ if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
+ pGC->ops->FillSpans = cfbTile32FSCopy;
+ else
+ pGC->ops->FillSpans = LeoTile32FSGeneral;
+ } else
+ pGC->ops->FillSpans = cfbUnnaturalTileFS;
+ break;
+ case FillStippled:
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ case FillOpaqueStippled:
+ pGC->ops->FillSpans = cfbUnnaturalStippleFS;
+ break;
+ default:
+ FatalError("LeoValidateGC: illegal fillStyle\n");
+ }
+ if (gcPriv->stipple)
+ pGC->ops->FillSpans = LeoFillSpansStippled;
+ } /* end of new_fillspans */
+
+ if (new_fillarea) {
+ pGC->ops->PolyFillRect = miPolyFillRect;
+ if (pGC->fillStyle == FillSolid) {
+ if (devPriv->oneRect)
+ pGC->ops->PolyFillRect = LeoPolyFillRect1Rect;
+ else
+ pGC->ops->PolyFillRect = LeoPolyFillRect;
+ } else if (gcPriv->stipple)
+ pGC->ops->PolyFillRect = LeoPolyFillStippledRect;
+ else if (pGC->fillStyle == FillTiled)
+ pGC->ops->PolyFillRect = cfbPolyFillRect;
+ pGC->ops->PolyFillArc = miPolyFillArc;
+ if (pGC->fillStyle == FillSolid) {
+ switch (devPriv->rop) {
+ case GXcopy:
+ pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy;
+ break;
+ default:
+ pGC->ops->PolyFillArc = LeoPolyFillArcSolidGeneral;
+ break;
+ }
+ }
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.h b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.h
new file mode 100644
index 000000000..8b7d03235
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.h
@@ -0,0 +1,81 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Accel func declarations.
+ *
+ * Copyright (C) 1999 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_gc.h,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#ifndef LEOGC_H
+#define LEOGC_H
+
+extern RegionPtr LeoCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty);
+
+extern RegionPtr LeoCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable,
+ GCPtr pGC, int srcx, int srcy, int width, int height,
+ int dstx, int dsty, unsigned long bitPlane);
+
+extern void LeoFillBoxSolid (DrawablePtr pDrawable, int nBox,
+ BoxPtr pBox, unsigned long pixel);
+
+extern void LeoPolyFillRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+
+extern void LeoPolyFillRect1Rect(DrawablePtr pDrawable, register GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+
+extern void LeoPolyFillStippledRect(DrawablePtr pDrawable, GCPtr pGC,
+ int nrectFill, xRectangle *prectInit);
+
+extern void LeoFillSpansSolid (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted);
+
+extern void LeoFillSpansStippled (DrawablePtr pDrawable, GCPtr pGC,
+ int n, DDXPointPtr ppt,
+ int *pwidth, int fSorted);
+
+extern void LeoPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase);
+
+extern void LeoTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase);
+
+extern void LeoPolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase);
+
+extern void LeoFillPoly1RectGeneral(DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn);
+
+extern void LeoZeroPolyArcSS8General(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs);
+
+extern void LeoTile32FSGeneral(DrawablePtr pDrawable, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int fSorted);
+
+extern void LeoPolyFillArcSolidGeneral(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs);
+
+extern int LeoCheckFill (GCPtr pGC, DrawablePtr pDrawable);
+
+extern void LeoDoBitblt (DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst,
+ DDXPointPtr pptSrc, unsigned long planemask);
+
+#endif /* LEOGC_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_glyph.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_glyph.c
new file mode 100644
index 000000000..747865c85
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_glyph.c
@@ -0,0 +1,325 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Glyph rops.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_glyph.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+#include "fontstruct.h"
+#include "dixfontstr.h"
+
+#include "cfb.h"
+#include "mi.h"
+
+void
+LeoPolyGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ RegionPtr clip;
+ CharInfoPtr pci;
+ int w, h, x0, y0, i;
+ unsigned int *bits;
+ BoxRec box;
+ int curw = -1;
+ unsigned int *fbf;
+ unsigned char *fb;
+ int height, width;
+
+ clip = cfbGetCompositeClip(pGC);
+ /* compute an approximate (but covering) bounding box */
+ box.x1 = 0;
+ if (ppci[0]->metrics.leftSideBearing < 0)
+ box.x1 = ppci[0]->metrics.leftSideBearing;
+ h = nglyph - 1;
+ w = ppci[h]->metrics.rightSideBearing;
+ while (--h >= 0)
+ w += ppci[h]->metrics.characterWidth;
+ box.x2 = w;
+ box.y1 = -FONTMAXBOUNDS(pGC->font,ascent);
+ box.y2 = FONTMAXBOUNDS(pGC->font,descent);
+
+ box.x1 += pDrawable->x + x;
+ box.x2 += pDrawable->x + x;
+ box.y1 += pDrawable->y + y;
+ box.y2 += pDrawable->y + y;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &box)) {
+ case rgnPART:
+ if (REGION_NUM_RECTS(clip) == 1) {
+ ld0->vclipmin = (clip->extents.y1 << 16) | clip->extents.x1;
+ ld0->vclipmax = ((clip->extents.y2 - 1) << 16) | (clip->extents.x2 - 1);
+ break;
+ }
+ cfbPolyGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, pGlyphBase);
+ case rgnOUT:
+ return;
+ default:
+ clip = NULL;
+ break;
+ }
+
+ x += pDrawable->x;
+ y += pDrawable->y;
+
+ lc0->fontt = 1;
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ ld0->fg = pGC->fgPixel;
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ height = pLeo->height;
+ width = pLeo->width;
+
+ fb = (unsigned char *)pLeo->fb;
+
+ while (nglyph--) {
+ pci = *ppci++;
+
+ w = GLYPHWIDTHPIXELS (pci);
+ h = GLYPHHEIGHTPIXELS (pci);
+ if (!w || !h)
+ goto next_glyph;
+
+ x0 = x + pci->metrics.leftSideBearing;
+ y0 = y - pci->metrics.ascent;
+
+ /* We're off the screen to the left, making our way
+ * back onto the screen.
+ */
+ if((x0 >> 31) == -1)
+ goto next_glyph;
+
+ /* We walked off the screen (to the right or downwards)
+ * or we started there, we're never going to work our
+ * way back so stop now.
+ */
+ if(x0 >= width || y0 >= height)
+ break;
+
+ bits = (unsigned int *) pci->bits;
+
+ if (w != curw) {
+ curw = w;
+ if (w)
+ lc0->fontmsk = 0xffffffff << (32 - w);
+ else
+ lc0->fontmsk = 0;
+ }
+
+ fbf = (unsigned *)(fb + (y0 << 13) + (x0 << 2));
+ if (y0 + h <= height)
+ for (i = 0; i < h; i++) {
+ *fbf = *bits++;
+ fbf += 2048;
+ }
+ else
+ for (i = 0; i < h && y0 + i < height; i++) {
+ *fbf = *bits++;
+ fbf += 2048;
+ }
+ next_glyph:
+ x += pci->metrics.characterWidth;
+ }
+
+ lc0->addrspace = LEO_ADDRSPC_OBGR;
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ if (clip) {
+ ld0->vclipmin = 0;
+ ld0->vclipmax = pLeo->vclipmax;
+ }
+}
+
+void
+LeoTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pGC->pScreen);
+ LeoCommand0 *lc0 = pLeo->lc0;
+ LeoDraw *ld0 = pLeo->ld0;
+ RegionPtr clip;
+ int h, hTmp;
+ int widthGlyph, widthGlyphs;
+ BoxRec bbox;
+ FontPtr pfont = pGC->font;
+ int curw = -1;
+ unsigned int *fbf;
+ unsigned char *fb;
+ int height, width;
+
+ widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
+ h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ clip = cfbGetCompositeClip(pGC);
+ bbox.x1 = x + pDrawable->x;
+ bbox.x2 = bbox.x1 + (widthGlyph * nglyph);
+ bbox.y1 = y + pDrawable->y - FONTASCENT(pfont);
+ bbox.y2 = bbox.y1 + h;
+
+ /* If fully out of range, and we have no chance of getting back
+ * in range, no work to do.
+ */
+ y = y + pDrawable->y - FONTASCENT(pfont);
+ x += pDrawable->x;
+ height = pLeo->height;
+ width = pLeo->width;
+
+ if (x >= width)
+ return;
+
+ switch (RECT_IN_REGION(pGC->pScreen, clip, &bbox)) {
+ case rgnPART:
+ if (REGION_NUM_RECTS(clip) == 1) {
+ ld0->vclipmin = (clip->extents.y1 << 16) | clip->extents.x1;
+ ld0->vclipmax = ((clip->extents.y2 - 1) << 16) | (clip->extents.x2 - 1);
+ break;
+ }
+ x -= pDrawable->x;
+ y = y - pDrawable->y + FONTASCENT(pfont);
+ if (pGlyphBase)
+ cfbPolyGlyphBlt8 (pDrawable, pGC, x, y, nglyph, ppci, NULL);
+ else
+ miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pGlyphBase);
+ case rgnOUT:
+ return;
+ default:
+ clip = NULL;
+ break;
+ }
+
+ lc0->addrspace = LEO_ADDRSPC_FONT_OBGR;
+ ld0->fg = pGC->fgPixel;
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+
+ fb = (unsigned char *)pLeo->fb;
+
+ if(pGlyphBase)
+ lc0->fontt = 1;
+ else {
+ lc0->fontt = 0;
+ ld0->bg = pGC->bgPixel;
+ }
+
+#define LoopIt(count, w, loadup, fetch) \
+ if (w != curw) { \
+ curw = w; \
+ lc0->fontmsk = 0xffffffff << (32 - w); \
+ } \
+ while (nglyph >= count) { \
+ loadup \
+ nglyph -= count; \
+ fbf = (unsigned *)(fb + (y << 13) + (x << 2)); \
+ hTmp = h; \
+ if (y + h <= height) \
+ while (hTmp--) { \
+ *fbf = fetch; \
+ fbf += 2048; \
+ } \
+ else \
+ for (hTmp = 0; hTmp < h && y + hTmp < height; hTmp++) { \
+ *fbf = fetch; \
+ fbf += 2048; \
+ } \
+ x += w; \
+ if(x >= width) \
+ goto out; \
+ }
+
+ if (widthGlyph <= 8) {
+ widthGlyphs = widthGlyph << 2;
+ LoopIt(4, widthGlyphs,
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char2 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char3 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char4 = (unsigned int *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | ((*char3++ | (*char4++
+ >> widthGlyph))
+ >> widthGlyph))
+ >> widthGlyph)))
+ } else if (widthGlyph <= 10) {
+ widthGlyphs = (widthGlyph << 1) + widthGlyph;
+ LoopIt(3, widthGlyphs,
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char2 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char3 = (unsigned int *) (*ppci++)->bits;,
+ (*char1++ | ((*char2++ | (*char3++ >> widthGlyph)) >> widthGlyph)))
+ } else if (widthGlyph <= 16) {
+ widthGlyphs = widthGlyph << 1;
+ LoopIt(2, widthGlyphs,
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ unsigned int *char2 = (unsigned int *) (*ppci++)->bits;,
+ (*char1++ | (*char2++ >> widthGlyph)))
+ }
+ if(nglyph != 0) {
+ if (widthGlyph != curw) {
+ curw = widthGlyph;
+ lc0->fontmsk = 0xffffffff << (32 - widthGlyph);
+ }
+ while (nglyph--) {
+ unsigned int *char1 = (unsigned int *) (*ppci++)->bits;
+ fbf = (unsigned *)(fb + (y << 13) + (x << 2));
+ hTmp = h;
+ if (y + h <= height)
+ while (hTmp--) {
+ *fbf = *char1++;
+ fbf += 2048;
+ }
+ else
+ for (hTmp = 0; hTmp < h && y + hTmp < height; hTmp++) {
+ *fbf = *char1++;
+ fbf += 2048;
+ }
+ x += widthGlyph;
+ if (x >= width)
+ goto out;
+ }
+ }
+
+out: lc0->addrspace = LEO_ADDRSPC_OBGR;
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+ if (clip) {
+ ld0->vclipmin = 0;
+ ld0->vclipmax = pLeo->vclipmax;
+ }
+}
+
+void
+LeoPolyTEGlyphBlt (DrawablePtr pDrawable, GCPtr pGC, int x, int y,
+ unsigned int nglyph, CharInfoPtr *ppci, pointer pGlyphBase)
+{
+ LeoTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (char *) 1);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_regs.h
new file mode 100644
index 000000000..e00158726
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_regs.h
@@ -0,0 +1,198 @@
+/*
+ * Acceleration for the Leo(ZX) framebuffer - register layout.
+ *
+ * Copyright (C) 1999, 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_regs.h,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#ifndef LEOREGS_H
+#define LEOREGS_H
+
+/* rop register */
+#define LEO_ATTR_PICK_DISABLE 0x00000000
+#define LEO_ATTR_PICK_2D 0x80000000
+#define LEO_ATTR_PICK_3D 0xa0000000
+#define LEO_ATTR_PICK_2D_REND 0xc0000000
+#define LEO_ATTR_PICK_3D_REND 0xe0000000
+
+#define LEO_ATTR_DCE_DISABLE 0x00000000
+#define LEO_ATTR_DCE_ENABLE 0x10000000
+
+#define LEO_ATTR_APE_DISABLE 0x00000000
+#define LEO_ATTR_APE_ENABLE 0x08000000
+
+#define LEO_ATTR_COLOR_VAR 0x00000000
+#define LEO_ATTR_COLOR_CONST 0x04000000
+
+#define LEO_ATTR_AA_DISABLE 0x02000000
+#define LEO_ATTR_AA_ENABLE 0x01000000
+
+#define LEO_ATTR_ABE_BG 0x00000000 /* dst + alpha * (src - bg) */
+#define LEO_ATTR_ABE_FB 0x00800000 /* dst + alpha * (src - dst) */
+
+#define LEO_ATTR_ABE_DISABLE 0x00000000
+#define LEO_ATTR_ABE_ENABLE 0x00400000
+
+#define LEO_ATTR_BLTSRC_A 0x00000000
+#define LEO_ATTR_BLTSRC_B 0x00200000
+
+#define LEO_ROP_ZERO (0x0 << 18)
+#define LEO_ROP_NEW_AND_OLD (0x8 << 18)
+#define LEO_ROP_NEW_AND_NOLD (0x4 << 18)
+#define LEO_ROP_NEW (0xc << 18)
+#define LEO_ROP_NNEW_AND_OLD (0x2 << 18)
+#define LEO_ROP_OLD (0xa << 18)
+#define LEO_ROP_NEW_XOR_OLD (0x6 << 18)
+#define LEO_ROP_NEW_OR_OLD (0xe << 18)
+#define LEO_ROP_NNEW_AND_NOLD (0x1 << 18)
+#define LEO_ROP_NNEW_XOR_NOLD (0x9 << 18)
+#define LEO_ROP_NOLD (0x5 << 18)
+#define LEO_ROP_NEW_OR_NOLD (0xd << 18)
+#define LEO_ROP_NNEW (0x3 << 18)
+#define LEO_ROP_NNEW_OR_OLD (0xb << 18)
+#define LEO_ROP_NNEW_OR_NOLD (0x7 << 18)
+#define LEO_ROP_ONES (0xf << 18)
+
+#define LEO_ATTR_HSR_DISABLE 0x00000000
+#define LEO_ATTR_HSR_ENABLE 0x00020000
+
+#define LEO_ATTR_WRITEZ_DISABLE 0x00000000
+#define LEO_ATTR_WRITEZ_ENABLE 0x00010000
+
+#define LEO_ATTR_Z_VAR 0x00000000
+#define LEO_ATTR_Z_CONST 0x00008000
+
+#define LEO_ATTR_WCLIP_DISABLE 0x00000000
+#define LEO_ATTR_WCLIP_ENABLE 0x00004000
+
+#define LEO_ATTR_MONO 0x00000000
+#define LEO_ATTR_STEREO_LEFT 0x00001000
+#define LEO_ATTR_STEREO_RIGHT 0x00003000
+
+#define LEO_ATTR_WE_DISABLE 0x00000000
+#define LEO_ATTR_WE_ENABLE 0x00000800
+
+#define LEO_ATTR_FCE_DISABLE 0x00000000
+#define LEO_ATTR_FCE_ENABLE 0x00000400
+
+#define LEO_ATTR_RE_DISABLE 0x00000000
+#define LEO_ATTR_RE_ENABLE 0x00000200
+
+#define LEO_ATTR_GE_DISABLE 0x00000000
+#define LEO_ATTR_GE_ENABLE 0x00000100
+
+#define LEO_ATTR_BE_DISABLE 0x00000000
+#define LEO_ATTR_BE_ENABLE 0x00000080
+
+#define LEO_ATTR_RGBE_DISABLE 0x00000000
+#define LEO_ATTR_RGBE_ENABLE 0x00000380
+
+#define LEO_ATTR_OE_DISABLE 0x00000000
+#define LEO_ATTR_OE_ENABLE 0x00000040
+
+#define LEO_ATTR_ZE_DISABLE 0x00000000
+#define LEO_ATTR_ZE_ENABLE 0x00000020
+
+#define LEO_ATTR_FORCE_WID 0x00000010
+
+#define LEO_ATTR_FC_PLANE_MASK 0x0000000e
+
+#define LEO_ATTR_BUFFER_A 0x00000000
+#define LEO_ATTR_BUFFER_B 0x00000001
+
+/* csr */
+#define LEO_CSR_BLT_BUSY 0x20000000
+
+typedef struct LeoDraw {
+ unsigned char xxx0[0xe00];
+ volatile unsigned int csr;
+ volatile unsigned int wid;
+ volatile unsigned int wmask;
+ volatile unsigned int widclip;
+ volatile unsigned int vclipmin;
+ volatile unsigned int vclipmax;
+ volatile unsigned int pickmin; /* SS1 only */
+ volatile unsigned int pickmax; /* SS1 only */
+ volatile unsigned int fg;
+ volatile unsigned int bg;
+ volatile unsigned int src; /* Copy/Scroll (SS0 only) */
+ volatile unsigned int dst; /* Copy/Scroll/Fill (SS0 only) */
+ volatile unsigned int extent; /* Copy/Scroll/Fill size (SS0 only) */
+ unsigned int xxx1[3];
+ volatile unsigned int setsem; /* SS1 only */
+ volatile unsigned int clrsem; /* SS1 only */
+ volatile unsigned int clrpick; /* SS1 only */
+ volatile unsigned int clrdat; /* SS1 only */
+ volatile unsigned int alpha; /* SS1 only */
+ unsigned char xxx2[0x2c];
+ volatile unsigned int winbg;
+ volatile unsigned int planemask;
+ volatile unsigned int rop;
+ volatile unsigned int z;
+ volatile unsigned int dczf; /* SS1 only */
+ volatile unsigned int dczb; /* SS1 only */
+ volatile unsigned int dcs; /* SS1 only */
+ volatile unsigned int dczs; /* SS1 only */
+ volatile unsigned int pickfb; /* SS1 only */
+ volatile unsigned int pickbb; /* SS1 only */
+ volatile unsigned int dcfc; /* SS1 only */
+ volatile unsigned int forcecol; /* SS1 only */
+ volatile unsigned int door[8]; /* SS1 only */
+ volatile unsigned int pick[5]; /* SS1 only */
+} LeoDraw;
+
+#define LEO_ADDRSPC_OBGR 0x00
+#define LEO_ADDRSPC_Z 0x01
+#define LEO_ADDRSPC_W 0x02
+#define LEO_ADDRSPC_FONT_OBGR 0x04
+#define LEO_ADDRSPC_FONT_Z 0x05
+#define LEO_ADDRSPC_FONT_W 0x06
+#define LEO_ADDRSPC_O 0x08
+#define LEO_ADDRSPC_B 0x09
+#define LEO_ADDRSPC_G 0x0a
+#define LEO_ADDRSPC_R 0x0b
+
+typedef struct LeoCommand0 {
+ volatile unsigned int csr;
+ volatile unsigned int addrspace;
+ volatile unsigned int fontmsk;
+ volatile unsigned int fontt;
+ volatile unsigned int extent;
+ volatile unsigned int src;
+ unsigned int dst;
+ volatile unsigned int copy;
+ volatile unsigned int fill;
+} LeoCommand0;
+
+typedef struct LeoCross {
+ volatile unsigned int type;
+ volatile unsigned int csr;
+ volatile unsigned int value;
+} LeoCross;
+
+typedef struct LeoCursor {
+ unsigned char xxx0[16];
+ volatile unsigned int cur_type;
+ volatile unsigned int cur_misc;
+ volatile unsigned int cur_cursxy;
+ volatile unsigned int cur_data;
+} LeoCursor;
+
+#endif /* LEOREGS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_stubs.c b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_stubs.c
new file mode 100644
index 000000000..dca3516a5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_stubs.c
@@ -0,0 +1,104 @@
+/*
+ * Acceleration for the Leo (ZX) framebuffer - Unaccelerated stuff.
+ *
+ * Copyright (C) 1999 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.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/leo_stubs.c,v 1.1 2000/05/18 23:21:40 dawes Exp $ */
+
+#define PSZ 32
+
+#include "leo.h"
+
+#include "pixmapstr.h"
+#include "scrnintstr.h"
+
+#include "cfb.h"
+
+void
+LeoFillPoly1RectGeneral(DrawablePtr pDrawable, GCPtr pGC, int shape,
+ int mode, int count, DDXPointPtr ptsIn)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoDraw *ld0 = pLeo->ld0;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ cfbFillPoly1RectCopy(pDrawable, pGC, shape, mode, count, ptsIn);
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
+
+void
+LeoZeroPolyArcSS8General(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoDraw *ld0 = pLeo->ld0;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ cfbZeroPolyArcSS8Copy(pDrawable, pGC, narcs, parcs);
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
+
+void
+LeoTile32FSGeneral(DrawablePtr pDrawable, GCPtr pGC, int nInit,
+ DDXPointPtr pptInit, int *pwidthInit, int fSorted)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoDraw *ld0 = pLeo->ld0;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ cfbTile32FSCopy(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
+
+void
+LeoPolyFillArcSolidGeneral(DrawablePtr pDrawable, GCPtr pGC,
+ int narcs, xArc *parcs)
+{
+ LeoPtr pLeo = LeoGetScreenPrivate (pDrawable->pScreen);
+ LeoDraw *ld0 = pLeo->ld0;
+
+ if (pGC->alu != GXcopy)
+ ld0->rop = leoRopTable[pGC->alu];
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = pGC->planemask;
+ cfbPolyFillArcSolidCopy(pDrawable, pGC, narcs, parcs);
+ if (pGC->alu != GXcopy)
+ ld0->rop = LEO_ATTR_RGBE_ENABLE|LEO_ROP_NEW;
+ if (pGC->planemask != 0xffffff)
+ ld0->planemask = 0xffffff;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp
new file mode 100644
index 000000000..78aba7702
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunleo/sunleo.cpp,v 1.3 2000/06/14 02:13:14 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNLEO __drivermansuffix__ "Version 4.0.1" "XFree86"
+.SH NAME
+sunleo \- Leo video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsunleo\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B leo
+is an XFree86 driver for Sun Leo (ZX) video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B leo
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suntcx/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/Imakefile
new file mode 100644
index 000000000..78a184cbf
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/Imakefile
@@ -0,0 +1,38 @@
+XCOMM
+XCOMM This is an Imakefile for the tcx driver.
+XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/Imakefile,v 1.1 2000/06/30 17:15:16 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = tcx_driver.c tcx_cursor.c
+OBJS = tcx_driver.o tcx_cursor.o
+
+#if defined(XF86DriverSDK)
+INCLUDES = -I. -I../../include
+#else
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+ -I$(SERVERSRC)/Xext -I$(SERVERSRC)/cfb \
+ -I$(XF86SRC)/ramdac \
+ -I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(EXTINCSRC)
+#endif
+
+#if MakeHasPosixVariableSubstitutions
+SubdirLibraryRule($(OBJS))
+#endif
+
+ModuleObjectRule()
+
+ObjectModuleTarget(suntcx,$(OBJS))
+
+InstallObjectModule(suntcx,$(MODULEDIR),drivers)
+
+#if !defined(XF86DriverSDK)
+CppManTarget(suntcx,)
+InstallModuleManPage(suntcx)
+#endif
+
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp
new file mode 100644
index 000000000..392c74ba8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp
@@ -0,0 +1,30 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/suntcx.cpp,v 1.1 2000/06/30 17:15:16 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH SUNTCX __drivermansuffix__ "Version 4.0" "XFree86"
+.SH NAME
+suntcx \- TCX video driver
+.SH SYNOPSIS
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qsuntcx\*q"
+\ \ ...
+.B EndSection
+.fi
+.SH DESCRIPTION
+.B suntcx
+is an XFree86 driver for Sun TCX video cards.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+The
+.B suntcx
+driver supports...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details. This section only covers configuration details specific to this
+driver.
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
+.SH AUTHORS
+Authors include: Jakub Jelinek <jakub@redhat.com>
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx.h b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx.h
new file mode 100644
index 000000000..da02617a4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx.h
@@ -0,0 +1,69 @@
+/*
+ * TCX framebuffer - defines.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx.h,v 1.1 2000/06/30 17:15:16 dawes Exp $ */
+
+#ifndef TCX_H
+#define TCX_H
+
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86RamDac.h"
+#include "Xmd.h"
+#include "gcstruct.h"
+#include "xf86sbusBus.h"
+#include "tcx_regs.h"
+
+/* Various offsets in virtual (ie. mmap()) spaces Linux and Solaris support. */
+#define TCX_RAM8_VOFF 0x00000000
+#define TCX_RAM24_VOFF 0x01000000
+#define TCX_CPLANE_VOFF 0x28000000
+#define TCX_TEC_VOFF 0x70000000
+#define TCX_BTREGS_VOFF 0x70002000
+#define TCX_THC_VOFF 0x70004000
+#define TCX_DHC_VOFF 0x70008000
+#define TCX_ALT_VOFF 0x7000a000
+#define TCX_SYNC_VOFF 0x7000e000
+
+typedef struct {
+ unsigned char *fb;
+ int width;
+ int height;
+ unsigned int *cplane;
+ TcxThcPtr thc;
+ sbusDevicePtr psdp;
+ CloseScreenProcPtr CloseScreen;
+ Bool HWCursor;
+ xf86CursorInfoPtr CursorInfoRec;
+ unsigned int CursorXY;
+ int CursorBg, CursorFg;
+ Bool CursorEnabled;
+ unsigned char CursorShiftX, CursorShiftY;
+ unsigned char *CursorData;
+} TcxRec, *TcxPtr;
+
+#define TCX_CPLANE_MODE 0x03000000
+
+#define GET_TCX_FROM_SCRN(p) ((TcxPtr)((p)->driverPrivate))
+
+#endif /* TCX_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_cursor.c b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_cursor.c
new file mode 100644
index 000000000..61ec1d6e6
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_cursor.c
@@ -0,0 +1,156 @@
+/*
+ * Hardware cursor support for TCX
+ *
+ * Copyright 2000 by Jakub Jelinek <jakub@redhat.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 of Jakub
+ * Jelinek not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior
+ * permission. Jakub Jelinek makes no representations about the
+ * suitability of this software for any purpose. It is provided "as
+ * is" without express or implied warranty.
+ *
+ * JAKUB JELINEK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL JAKUB JELINEK 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_cursor.c,v 1.1 2000/06/30 17:15:16 dawes Exp $ */
+
+#include "tcx.h"
+
+static void TCXLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src);
+static void TCXShowCursor(ScrnInfoPtr pScrn);
+static void TCXHideCursor(ScrnInfoPtr pScrn);
+static void TCXSetCursorPosition(ScrnInfoPtr pScrn, int x, int y);
+static void TCXSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg);
+
+static void
+TCXLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+{
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+ int i, x, y;
+ unsigned int *data = (unsigned int *)src;
+
+ pTcx->CursorData = src;
+ x = pTcx->CursorShiftX;
+ y = pTcx->CursorShiftY;
+ if (x >= 32 || y >= 32)
+ y = 32;
+ data += y;
+ for (i = 0; i < 32 - y; i++)
+ pTcx->thc->thc_cursmask[i] = *data++ << x;
+ for (; i < 32; i++)
+ pTcx->thc->thc_cursmask[i] = 0;
+ data += y;
+ for (i = 0; i < 32 - y; i++)
+ pTcx->thc->thc_cursbits[i] = *data++ << x;
+ for (; i < 32; i++)
+ pTcx->thc->thc_cursbits[i] = 0;
+}
+
+static void
+TCXShowCursor(ScrnInfoPtr pScrn)
+{
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ pTcx->thc->thc_cursxy = pTcx->CursorXY;
+ pTcx->CursorEnabled = TRUE;
+}
+
+static void
+TCXHideCursor(ScrnInfoPtr pScrn)
+{
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ pTcx->thc->thc_cursxy = ((65536 - 32) << 16) | (65536 - 32);
+ pTcx->CursorEnabled = FALSE;
+}
+
+static void
+TCXSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+{
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+ int CursorShiftX = 0, CursorShiftY = 0;
+
+ if (x < 0) {
+ CursorShiftX = -x;
+ x = 0;
+ if (CursorShiftX > 32)
+ CursorShiftX = 32;
+ }
+ if (y < 0) {
+ CursorShiftY = -y;
+ y = 0;
+ if (CursorShiftY > 32)
+ CursorShiftY = 32;
+ }
+ if ((CursorShiftX != pTcx->CursorShiftX ||
+ CursorShiftY != pTcx->CursorShiftY) &&
+ pTcx->CursorData != NULL) {
+ pTcx->CursorShiftX = CursorShiftX;
+ pTcx->CursorShiftY = CursorShiftY;
+ TCXLoadCursorImage(pScrn, pTcx->CursorData);
+ }
+
+ pTcx->CursorXY = ((x & 0xffff) << 16) | (y & 0xffff);
+ if (pTcx->CursorEnabled)
+ pTcx->thc->thc_cursxy = pTcx->CursorXY;
+}
+
+static void
+TCXSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+{
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ if (bg != pTcx->CursorBg || fg != pTcx->CursorFg) {
+ xf86SbusSetOsHwCursorCmap(pTcx->psdp, bg, fg);
+ pTcx->CursorBg = bg;
+ pTcx->CursorFg = fg;
+ }
+}
+
+Bool
+TCXHWCursorInit(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ TcxPtr pTcx;
+ xf86CursorInfoPtr infoPtr;
+
+ pTcx = GET_TCX_FROM_SCRN(pScrn);
+ pTcx->CursorXY = 0;
+ pTcx->CursorBg = pTcx->CursorFg = 0;
+ pTcx->CursorEnabled = FALSE;
+ pTcx->CursorShiftX = 0;
+ pTcx->CursorShiftY = 0;
+ pTcx->CursorData = NULL;
+
+ infoPtr = xf86CreateCursorInfoRec();
+ if(!infoPtr) return FALSE;
+
+ pTcx->CursorInfoRec = infoPtr;
+
+ infoPtr->MaxWidth = 32;
+ infoPtr->MaxHeight = 32;
+ infoPtr->Flags = HARDWARE_CURSOR_AND_SOURCE_WITH_MASK |
+ HARDWARE_CURSOR_SWAP_SOURCE_AND_MASK |
+ HARDWARE_CURSOR_SOURCE_MASK_NOT_INTERLEAVED |
+ HARDWARE_CURSOR_TRUECOLOR_AT_8BPP;
+
+ infoPtr->SetCursorColors = TCXSetCursorColors;
+ infoPtr->SetCursorPosition = TCXSetCursorPosition;
+ infoPtr->LoadCursorImage = TCXLoadCursorImage;
+ infoPtr->HideCursor = TCXHideCursor;
+ infoPtr->ShowCursor = TCXShowCursor;
+ infoPtr->UseHWCursor = NULL;
+
+ return xf86InitCursor(pScreen, infoPtr);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c
new file mode 100644
index 000000000..8741adec5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c
@@ -0,0 +1,769 @@
+/*
+ * TCX framebuffer driver.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_driver.c,v 1.1 2000/06/30 17:15:16 dawes Exp $ */
+
+#define PSZ 8
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+#include "mibstore.h"
+#include "micmap.h"
+
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "xf86cmap.h"
+#include "tcx.h"
+
+static OptionInfoPtr TCXAvailableOptions(int chipid, int busid);
+static void TCXIdentify(int flags);
+static Bool TCXProbe(DriverPtr drv, int flags);
+static Bool TCXPreInit(ScrnInfoPtr pScrn, int flags);
+static Bool TCXScreenInit(int Index, ScreenPtr pScreen, int argc,
+ char **argv);
+static Bool TCXEnterVT(int scrnIndex, int flags);
+static void TCXLeaveVT(int scrnIndex, int flags);
+static Bool TCXCloseScreen(int scrnIndex, ScreenPtr pScreen);
+static Bool TCXSaveScreen(ScreenPtr pScreen, int mode);
+static void TCXInitCplane24(ScrnInfoPtr pScrn);
+
+/* Required if the driver supports mode switching */
+static Bool TCXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
+/* Required if the driver supports moving the viewport */
+static void TCXAdjustFrame(int scrnIndex, int x, int y, int flags);
+
+/* Optional functions */
+static void TCXFreeScreen(int scrnIndex, int flags);
+static int TCXValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose,
+ int flags);
+
+void TCXSync(ScrnInfoPtr pScrn);
+
+#define VERSION 4000
+#define TCX_NAME "SUNTCX"
+#define TCX_DRIVER_NAME "suntcx"
+#define TCX_MAJOR_VERSION 1
+#define TCX_MINOR_VERSION 0
+#define TCX_PATCHLEVEL 0
+
+/*
+ * This contains the functions needed by the server after loading the driver
+ * module. It must be supplied, and gets passed back by the SetupProc
+ * function in the dynamic case. In the static case, a reference to this
+ * is compiled in, and this requires that the name of this DriverRec be
+ * an upper-case version of the driver name.
+ */
+
+DriverRec SUNTCX = {
+ VERSION,
+ TCX_DRIVER_NAME,
+ TCXIdentify,
+ TCXProbe,
+ TCXAvailableOptions,
+ NULL,
+ 0
+};
+
+typedef enum {
+ OPTION_SW_CURSOR,
+ OPTION_HW_CURSOR
+} TCXOpts;
+
+static OptionInfoRec TCXOptions[] = {
+ { OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_HW_CURSOR, "HWcursor", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE }
+};
+
+#ifdef XFree86LOADER
+
+static MODULESETUPPROTO(tcxSetup);
+
+static XF86ModuleVersionInfo suntcxVersRec =
+{
+ "suntcx",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ TCX_MAJOR_VERSION, TCX_MINOR_VERSION, TCX_PATCHLEVEL,
+ ABI_CLASS_VIDEODRV,
+ ABI_VIDEODRV_VERSION,
+ MOD_CLASS_VIDEODRV,
+ {0,0,0,0}
+};
+
+XF86ModuleData suntcxModuleData = { &suntcxVersRec, tcxSetup, NULL };
+
+pointer
+tcxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ static Bool setupDone = FALSE;
+
+ if (!setupDone) {
+ setupDone = TRUE;
+ xf86AddDriver(&SUNTCX, module, 0);
+
+ /*
+ * Modules that this driver always requires can be loaded here
+ * by calling LoadSubModule().
+ */
+
+ /*
+ * The return value must be non-NULL on success even though there
+ * is no TearDownProc.
+ */
+ return (pointer)TRUE;
+ } else {
+ if (errmaj) *errmaj = LDR_ONCEONLY;
+ return NULL;
+ }
+}
+
+#endif /* XFree86LOADER */
+
+static Bool
+TCXGetRec(ScrnInfoPtr pScrn)
+{
+ /*
+ * Allocate an TcxRec, and hook it into pScrn->driverPrivate.
+ * pScrn->driverPrivate is initialised to NULL, so we can check if
+ * the allocation has already been done.
+ */
+ if (pScrn->driverPrivate != NULL)
+ return TRUE;
+
+ pScrn->driverPrivate = xnfcalloc(sizeof(TcxRec), 1);
+ return TRUE;
+}
+
+static void
+TCXFreeRec(ScrnInfoPtr pScrn)
+{
+ TcxPtr pTcx;
+
+ if (pScrn->driverPrivate == NULL)
+ return;
+
+ pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ xfree(pScrn->driverPrivate);
+ pScrn->driverPrivate = NULL;
+
+ return;
+}
+
+static
+OptionInfoPtr
+TCXAvailableOptions(int chipid, int busid)
+{
+ return TCXOptions;
+}
+
+/* Mandatory */
+static void
+TCXIdentify(int flags)
+{
+ xf86Msg(X_INFO, "%s: driver for TCX\n", TCX_NAME);
+}
+
+
+/* Mandatory */
+static Bool
+TCXProbe(DriverPtr drv, int flags)
+{
+ int i;
+ GDevPtr *devSections = NULL;
+ int *usedChips;
+ int numDevSections;
+ int numUsed;
+ Bool foundScreen = FALSE;
+ EntityInfoPtr pEnt;
+
+ /*
+ * The aim here is to find all cards that this driver can handle,
+ * and for the ones not already claimed by another driver, claim the
+ * slot, and allocate a ScrnInfoRec.
+ *
+ * This should be a minimal probe, and it should under no circumstances
+ * change the state of the hardware. Because a device is found, don't
+ * assume that it will be used. Don't do any initialisations other than
+ * the required ScrnInfoRec initialisations. Don't allocate any new
+ * data structures.
+ */
+
+ /*
+ * Next we check, if there has been a chipset override in the config file.
+ * For this we must find out if there is an active device section which
+ * is relevant, i.e., which has no driver specified or has THIS driver
+ * specified.
+ */
+
+ if ((numDevSections = xf86MatchDevice(TCX_DRIVER_NAME,
+ &devSections)) <= 0) {
+ /*
+ * There's no matching device section in the config file, so quit
+ * now.
+ */
+ return FALSE;
+ }
+
+ /*
+ * We need to probe the hardware first. We then need to see how this
+ * fits in with what is given in the config file, and allow the config
+ * file info to override any contradictions.
+ */
+
+ numUsed = xf86MatchSbusInstances(TCX_NAME, SBUS_DEVICE_TCX,
+ devSections, numDevSections,
+ drv, &usedChips);
+
+ if (devSections)
+ xfree(devSections);
+ devSections = NULL;
+ if (numUsed <= 0)
+ return FALSE;
+
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ pEnt = xf86GetEntityInfo(usedChips[i]);
+
+ /*
+ * Check that nothing else has claimed the slots.
+ */
+ if(pEnt->active) {
+ ScrnInfoPtr pScrn;
+
+ /* Allocate a ScrnInfoRec and claim the slot */
+ pScrn = xf86AllocateScreen(drv, 0);
+
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = TCX_DRIVER_NAME;
+ pScrn->name = TCX_NAME;
+ pScrn->Probe = TCXProbe;
+ pScrn->PreInit = TCXPreInit;
+ pScrn->ScreenInit = TCXScreenInit;
+ pScrn->SwitchMode = TCXSwitchMode;
+ pScrn->AdjustFrame = TCXAdjustFrame;
+ pScrn->EnterVT = TCXEnterVT;
+ pScrn->LeaveVT = TCXLeaveVT;
+ pScrn->FreeScreen = TCXFreeScreen;
+ pScrn->ValidMode = TCXValidMode;
+ xf86AddEntityToScreen(pScrn, pEnt->index);
+ foundScreen = TRUE;
+ }
+ xfree(pEnt);
+ }
+ return foundScreen;
+}
+
+/* Mandatory */
+static Bool
+TCXPreInit(ScrnInfoPtr pScrn, int flags)
+{
+ TcxPtr pTcx;
+ sbusDevicePtr psdp = NULL;
+ MessageType from;
+ int i;
+ int hwCursor, lowDepth;
+
+ if (flags & PROBE_DETECT) return FALSE;
+
+ /*
+ * Note: This function is only called once at server startup, and
+ * not at the start of each server generation. This means that
+ * only things that are persistent across server generations can
+ * be initialised here. xf86Screens[] is (pScrn is a pointer to one
+ * of these). Privates allocated using xf86AllocateScrnInfoPrivateIndex()
+ * are too, and should be used for data that must persist across
+ * server generations.
+ *
+ * Per-generation data should be allocated with
+ * AllocateScreenPrivateIndex() from the ScreenInit() function.
+ */
+
+ /* Allocate the TcxRec driverPrivate */
+ if (!TCXGetRec(pScrn)) {
+ return FALSE;
+ }
+ pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ /* Set pScrn->monitor */
+ pScrn->monitor = pScrn->confScreen->monitor;
+
+ /* This driver doesn't expect more than one entity per screen */
+ if (pScrn->numEntities > 1)
+ return FALSE;
+ /* This is the general case */
+ for (i = 0; i < pScrn->numEntities; i++) {
+ EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[i]);
+
+ /* TCX is purely AFX, but we handle it like SBUS */
+ if (pEnt->location.type == BUS_SBUS) {
+ psdp = xf86GetSbusInfoForEntity(pEnt->index);
+ pTcx->psdp = psdp;
+ } else
+ return FALSE;
+ }
+ if (psdp == NULL)
+ return FALSE;
+
+ /**********************
+ check card capabilities
+ **********************/
+ hwCursor = 0;
+ lowDepth = 1;
+ if (sparcPromInit() >= 0) {
+ hwCursor = sparcPromGetBool(&psdp->node, "hw-cursor");
+ lowDepth = sparcPromGetBool(&psdp->node, "tcx-8-bit");
+ sparcPromClose();
+ }
+
+ /*********************
+ deal with depth
+ *********************/
+
+ if (!xf86SetDepthBpp(pScrn, 0, 0, 0,
+ lowDepth ? NoDepth24Support : Support32bppFb)) {
+ return FALSE;
+ } else {
+ /* Check that the returned depth is one we support */
+ switch (pScrn->depth) {
+ case 8:
+ /* OK */
+ break;
+ case 32:
+ /* unless lowDepth OK */
+ if (lowDepth) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (32) not supported by hardware\n");
+ return FALSE;
+ }
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Given depth (%d) is not supported by this driver\n",
+ pScrn->depth);
+ return FALSE;
+ }
+ }
+
+ /* Collect all of the relevant option flags (fill in pScrn->options) */
+ xf86CollectOptions(pScrn, NULL);
+ /* Process the options */
+ xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, TCXOptions);
+
+ /*
+ * This must happen after pScrn->display has been set because
+ * xf86SetWeight references it.
+ */
+ if (pScrn->depth > 8) {
+ rgb weight = {10, 11, 11};
+ rgb mask = {0xff, 0xff00, 0xff0000};
+
+ if (!xf86SetWeight(pScrn, weight, mask)) {
+ return FALSE;
+ }
+ }
+
+ if (!xf86SetDefaultVisual(pScrn, -1))
+ return FALSE;
+ else if (pScrn->depth > 8) {
+ /* We don't currently support DirectColor */
+ if (pScrn->defaultVisual != TrueColor) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Given default visual"
+ " (%s) is not supported\n",
+ xf86GetVisualName(pScrn->defaultVisual));
+ return FALSE;
+ }
+ }
+
+ /*
+ * The new cmap code requires this to be initialised.
+ */
+
+ {
+ Gamma zeros = {0.0, 0.0, 0.0};
+
+ if (!xf86SetGamma(pScrn, zeros)) {
+ return FALSE;
+ }
+ }
+
+ /* determine whether we use hardware or software cursor */
+
+ from = X_PROBED;
+ pTcx->HWCursor = FALSE;
+ if (hwCursor) {
+ from = X_DEFAULT;
+ pTcx->HWCursor = TRUE;
+ if (xf86GetOptValBool(TCXOptions, OPTION_HW_CURSOR, &pTcx->HWCursor))
+ from = X_CONFIG;
+ if (xf86ReturnOptValBool(TCXOptions, OPTION_SW_CURSOR, FALSE)) {
+ from = X_CONFIG;
+ pTcx->HWCursor = FALSE;
+ }
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, from, "Using %s cursor\n",
+ pTcx->HWCursor ? "HW" : "SW");
+
+ if (xf86LoadSubModule(pScrn, pScrn->depth > 8 ? "cfb32" : "cfb") ==
+ NULL) {
+ TCXFreeRec(pScrn);
+ return FALSE;
+ }
+
+ if (pTcx->HWCursor && xf86LoadSubModule(pScrn, "ramdac") == NULL) {
+ TCXFreeRec(pScrn);
+ return FALSE;
+ }
+
+ /*********************
+ set up clock and mode stuff
+ *********************/
+
+ pScrn->progClock = TRUE;
+
+ if(pScrn->display->virtualX || pScrn->display->virtualY) {
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+ "TCX does not support a virtual desktop\n");
+ pScrn->display->virtualX = 0;
+ pScrn->display->virtualY = 0;
+ }
+
+ xf86SbusUseBuiltinMode(pScrn, pTcx->psdp);
+ pScrn->currentMode = pScrn->modes;
+ pScrn->displayWidth = pScrn->virtualX;
+
+ /* Set display resolution */
+ xf86SetDpi(pScrn, 0, 0);
+
+ return TRUE;
+}
+
+/* Mandatory */
+
+/* This gets called at the start of each server generation */
+
+static Bool
+TCXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
+{
+ ScrnInfoPtr pScrn;
+ TcxPtr pTcx;
+ VisualPtr visual;
+ int ret;
+
+ /*
+ * First get the ScrnInfoRec
+ */
+ pScrn = xf86Screens[pScreen->myNum];
+
+ pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ /* Map the TCX memory */
+ if (pScrn->depth == 8)
+ pTcx->fb =
+ xf86MapSbusMem (pTcx->psdp, TCX_RAM8_VOFF,
+ (pTcx->psdp->width * pTcx->psdp->height));
+ else {
+ pTcx->fb =
+ xf86MapSbusMem (pTcx->psdp, TCX_RAM24_VOFF,
+ (pTcx->psdp->width * pTcx->psdp->height * 4));
+ pTcx->cplane =
+ xf86MapSbusMem (pTcx->psdp, TCX_CPLANE_VOFF,
+ (pTcx->psdp->width * pTcx->psdp->height * 4));
+ if (! pTcx->cplane)
+ return FALSE;
+ }
+ if (pTcx->HWCursor == TRUE) {
+ pTcx->thc = xf86MapSbusMem (pTcx->psdp, TCX_THC_VOFF, 8192);
+ if (! pTcx->thc)
+ return FALSE;
+ }
+
+ if (! pTcx->fb)
+ return FALSE;
+
+ /* Darken the screen for aesthetic reasons and set the viewport */
+ TCXSaveScreen(pScreen, SCREEN_SAVER_ON);
+
+ /*
+ * The next step is to setup the screen's visuals, and initialise the
+ * framebuffer code. In cases where the framebuffer's default
+ * choices for things like visual layouts and bits per RGB are OK,
+ * this may be as simple as calling the framebuffer's ScreenInit()
+ * function. If not, the visuals will need to be setup before calling
+ * a fb ScreenInit() function and fixed up after.
+ */
+
+ /*
+ * Reset visual list.
+ */
+ miClearVisualTypes();
+
+ if (pScrn->depth == 8)
+ /* Set the bits per RGB for 8bpp mode */
+ pScrn->rgbBits = 8;
+
+ /* Setup the visuals we support. */
+
+ if (!miSetVisualTypes(pScrn->depth,
+ pScrn->depth != 8 ? TrueColorMask :
+ miGetDefaultVisualMask(pScrn->depth),
+ pScrn->rgbBits, pScrn->defaultVisual))
+ return FALSE;
+
+ /*
+ * Call the framebuffer layer's ScreenInit function, and fill in other
+ * pScreen fields.
+ */
+
+ if (pScrn->depth == 8)
+ ret = cfbScreenInit(pScreen, pTcx->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX);
+ else {
+ TCXInitCplane24(pScrn);
+ ret = cfb32ScreenInit(pScreen, pTcx->fb, pScrn->virtualX,
+ pScrn->virtualY, pScrn->xDpi, pScrn->yDpi,
+ pScrn->virtualX);
+ }
+
+ if (!ret)
+ return FALSE;
+
+ miInitializeBackingStore(pScreen);
+ xf86SetBackingStore(pScreen);
+ xf86SetSilkenMouse(pScreen);
+
+ xf86SetBlackWhitePixels(pScreen);
+
+ if (pScrn->bitsPerPixel > 8) {
+ /* Fixup RGB ordering */
+ visual = pScreen->visuals + pScreen->numVisuals;
+ while (--visual >= pScreen->visuals) {
+ 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;
+ }
+ }
+ }
+
+ /* Initialise cursor functions */
+ miDCInitialize (pScreen, xf86GetPointerScreenFuncs());
+
+ /* Initialize HW cursor layer.
+ Must follow software cursor initialization*/
+ if (pTcx->HWCursor) {
+ extern Bool TCXHWCursorInit(ScreenPtr pScreen);
+
+ if(!TCXHWCursorInit(pScreen)) {
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+ "Hardware cursor initialization failed\n");
+ return(FALSE);
+ }
+ xf86SbusHideOsHwCursor(pTcx->psdp);
+ }
+
+ /* Initialise default colourmap */
+ if (!miCreateDefColormap(pScreen))
+ return FALSE;
+
+ if(pScrn->depth == 8 && !xf86SbusHandleColormaps(pScreen, pTcx->psdp))
+ return FALSE;
+
+ pTcx->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = TCXCloseScreen;
+ pScreen->SaveScreen = TCXSaveScreen;
+
+ /* Report any unused options (only for the first generation) */
+ if (serverGeneration == 1) {
+ xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options);
+ }
+
+ /* unblank the screen */
+ TCXSaveScreen(pScreen, SCREEN_SAVER_OFF);
+
+ /* Done */
+ return TRUE;
+}
+
+
+/* Usually mandatory */
+static Bool
+TCXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
+{
+ return TRUE;
+}
+
+
+/*
+ * This function is used to initialize the Start Address - the first
+ * displayed location in the video memory.
+ */
+/* Usually mandatory */
+static void
+TCXAdjustFrame(int scrnIndex, int x, int y, int flags)
+{
+ /* we don't support virtual desktops */
+ return;
+}
+
+/*
+ * This is called when VT switching back to the X server. Its job is
+ * to reinitialise the video mode.
+ */
+
+/* Mandatory */
+static Bool
+TCXEnterVT(int scrnIndex, int flags)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ if (pTcx->HWCursor) {
+ xf86SbusHideOsHwCursor (pTcx->psdp);
+ pTcx->CursorFg = 0;
+ pTcx->CursorBg = 0;
+ }
+ if (pTcx->cplane) {
+ TCXInitCplane24 (pScrn);
+ }
+ return TRUE;
+}
+
+
+/*
+ * This is called when VT switching away from the X server.
+ */
+
+/* Mandatory */
+static void
+TCXLeaveVT(int scrnIndex, int flags)
+{
+ return;
+}
+
+
+/*
+ * This is called at the end of each server generation. It restores the
+ * original (text) mode. It should really also unmap the video memory too.
+ */
+
+/* Mandatory */
+static Bool
+TCXCloseScreen(int scrnIndex, ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+
+ pScrn->vtSema = FALSE;
+ if (pScrn->depth == 8)
+ xf86UnmapSbusMem(pTcx->psdp, pTcx->fb,
+ (pTcx->psdp->width * pTcx->psdp->height));
+ else {
+ xf86UnmapSbusMem(pTcx->psdp, pTcx->fb,
+ (pTcx->psdp->width * pTcx->psdp->height * 4));
+ xf86UnmapSbusMem(pTcx->psdp, pTcx->cplane,
+ (pTcx->psdp->width * pTcx->psdp->height * 4));
+ }
+ if (pTcx->thc)
+ xf86UnmapSbusMem(pTcx->psdp, pTcx->fb, 8192);
+
+ pScreen->CloseScreen = pTcx->CloseScreen;
+ return (*pScreen->CloseScreen)(scrnIndex, pScreen);
+ return FALSE;
+}
+
+
+/* Free up any per-generation data structures */
+
+/* Optional */
+static void
+TCXFreeScreen(int scrnIndex, int flags)
+{
+ TCXFreeRec(xf86Screens[scrnIndex]);
+}
+
+
+/* Checks if a mode is suitable for the selected chipset. */
+
+/* Optional */
+static int
+TCXValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
+{
+ if (mode->Flags & V_INTERLACE)
+ return(MODE_BAD);
+
+ return(MODE_OK);
+}
+
+/* Do screen blanking */
+
+/* Mandatory */
+static Bool
+TCXSaveScreen(ScreenPtr pScreen, int mode)
+ /* this function should blank the screen when unblank is FALSE and
+ unblank it when unblank is TRUE -- it doesn't actually seem to be
+ used for much though */
+{
+ return TRUE;
+}
+
+/*
+ * This is the implementation of the Sync() function.
+ */
+void
+TCXSync(ScrnInfoPtr pScrn)
+{
+ return;
+}
+
+/*
+ * This initializes CPLANE for 24 bit mode.
+ */
+static void
+TCXInitCplane24(ScrnInfoPtr pScrn)
+{
+ TcxPtr pTcx = GET_TCX_FROM_SCRN(pScrn);
+ int size;
+ unsigned int *p, *q;
+
+ if (!pTcx->cplane)
+ return;
+
+ size = pScrn->virtualX * pScrn->virtualY;
+ memset (pTcx->fb, 0, size * 4);
+ p = pTcx->cplane;
+ for (q = pTcx->cplane + size; p != q; p++)
+ *p = (*p & 0xffffff) | TCX_CPLANE_MODE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_regs.h
new file mode 100644
index 000000000..61e4b0aad
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_regs.h
@@ -0,0 +1,56 @@
+/*
+ * TCX framebuffer - hardware registers.
+ *
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/suntcx/tcx_regs.h,v 1.1 2000/06/30 17:15:17 dawes Exp $ */
+
+#ifndef TCX_REGS_H
+#define TCX_REGS_H
+
+/* THC definitions */
+#define TCX_THC_MISC_REV_SHIFT 16
+#define TCX_THC_MISC_REV_MASK 15
+#define TCX_THC_MISC_RESET (1 << 12)
+#define TCX_THC_MISC_VIDEO (1 << 10)
+#define TCX_THC_MISC_SYNC (1 << 9)
+#define TCX_THC_MISC_VSYNC (1 << 8)
+#define TCX_THC_MISC_SYNC_ENAB (1 << 7)
+#define TCX_THC_MISC_CURS_RES (1 << 6)
+#define TCX_THC_MISC_INT_ENAB (1 << 5)
+#define TCX_THC_MISC_INT (1 << 4)
+#define TCX_THC_MISC_INIT 0x9f
+
+typedef struct tcx_thc {
+ unsigned int thc_pad0[512];
+ volatile unsigned int thc_hs; /* hsync timing */
+ volatile unsigned int thc_hsdvs;
+ volatile unsigned int thc_hd;
+ volatile unsigned int thc_vs; /* vsync timing */
+ volatile unsigned int thc_vd;
+ volatile unsigned int thc_refresh;
+ volatile unsigned int thc_misc;
+ unsigned int thc_pad1[56];
+ volatile unsigned int thc_cursxy; /* cursor x,y position (16 bits each) */
+ volatile unsigned int thc_cursmask[32];/* cursor mask bits */
+ volatile unsigned int thc_cursbits[32];/* what to show where mask enabled */
+} TcxThc, *TcxThcPtr;
+
+#endif /* TCX_REGS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile
index 4fe4392cb..29db072d0 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile,v 1.12 2000/03/03 01:05:43 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/Imakefile,v 1.16 2000/06/30 17:15:17 dawes Exp $
XCOMM
XCOMM This is the Imakefile for the TDFX driver.
XCOMM
@@ -12,22 +12,16 @@ XCOMM
#if BuildXF86DRI
DRISRCS = tdfx_dri.c
DRIOBJS = tdfx_dri.o
-DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri
+DRIINCLUDES = -I$(SERVERSRC)/GL/dri -I$(LIBSRC)/GL/dri -I$(TOP)/include
+
DRIDEFINES = $(GLX_DEFINES)
#endif
-#
-# Uncomment these only if you have the proprietary sources
-#
-PRIVSRCS = tdfx_priv.c
-PRIVOBJS = tdfx_priv.o
-PRIVDEFINES = -DPROP_3DFX
-
SRCS = tdfx_driver.c tdfx_io.c tdfx_hwcurs.c tdfx_accel.c \
- tdfx_dga.c $(DRISRCS) $(PRIVSRCS)
+ tdfx_dga.c tdfx_priv.c tdfx_sli.c $(DRISRCS)
OBJS = tdfx_driver.o tdfx_io.o tdfx_hwcurs.o tdfx_accel.o \
- tdfx_dga.o $(DRIOBJS) $(PRIVOBJS)
+ tdfx_dga.o tdfx_priv.o tdfx_sli.o $(DRIOBJS)
#if defined(XF86DriverSDK)
INCLUDES = -I. -I../../include
@@ -35,7 +29,7 @@ INCLUDES = -I. -I../../include
INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
-I$(XF86SRC)/xaa -I$(XF86SRC)/rac -I$(XF86SRC)/int10 \
- -I$(SERVERSRC)/cfb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \
+ -I$(SERVERSRC)/fb -I$(XF86SRC)/xaa -I$(XF86SRC)/ramdac \
-I$(XF86SRC)/vgahw -I$(XF86SRC)/ddc -I$(XF86SRC)/i2c \
-I$(XF86SRC)/ddc -I$(XF86OSSRC)/vbe -I$(SERVERSRC)/Xext \
-I$(FONTINCSRC) -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
@@ -43,7 +37,7 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
$(DRIINCLUDES)
#endif
-DEFINES = $(DRIDEFINES) $(PRIVDEFINES)
+DEFINES = -DPROP_3DFX $(DRIDEFINES)
#if MakeHasPosixVariableSubstitutions
SubdirLibraryRule($(OBJS))
@@ -74,5 +68,8 @@ InstallDriverSDKNonExecFile(tdfx_dripriv.h,$(DRIVERSDKDIR)/drivers/tdfx)
InstallDriverSDKNonExecFile(tdfx_driver.c,$(DRIVERSDKDIR)/drivers/tdfx)
InstallDriverSDKNonExecFile(tdfx_hwcurs.c,$(DRIVERSDKDIR)/drivers/tdfx)
InstallDriverSDKNonExecFile(tdfx_io.c,$(DRIVERSDKDIR)/drivers/tdfx)
+InstallDriverSDKNonExecFile(tdfx_priv.c,$(DRIVERSDKDIR)/drivers/tdfx)
+InstallDriverSDKNonExecFile(tdfx_priv.h,$(DRIVERSDKDIR)/drivers/tdfx)
+InstallDriverSDKNonExecFile(tdfx_sli.c,$(DRIVERSDKDIR)/drivers/tdfx)
InstallDriverSDKObjectModule(tdfx,$(DRIVERSDKMODULEDIR),drivers)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp
index 1a7c2dad2..a92c55a65 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp,v 1.1 2000/03/03 01:05:43 dawes Exp $
-.TH TDFX __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.cpp,v 1.4 2000/06/14 02:13:15 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH TDFX __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
tdfx \- 3Dfx video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""tdfx"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qtdfx\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B tdfx
is an XFree86 driver for 3Dfx video cards.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h
index f64489092..74eab72e8 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h
@@ -5,7 +5,7 @@
Copyright: 1998,1999
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h,v 1.9 2000/02/18 12:20:02 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx.h,v 1.10 2000/06/17 00:03:24 martin Exp $ */
#ifndef _TDFX_H_
#define _TDFX_H_
@@ -25,9 +25,22 @@
#include "tdfx_dripriv.h"
#endif
+#define TDFX_VERSION 4000
+#define TDFX_NAME "TDFX"
+#define TDFX_DRIVER_NAME "tdfx"
+#define TDFX_MAJOR_VERSION 1
+#define TDFX_MINOR_VERSION 0
+#define TDFX_PATCHLEVEL 0
+
struct _TDFXRec;
typedef struct _TDFXRec *TDFXPtr;
+#ifdef XF86DRI
+#define PIXMAP_CACHE_LINES 128
+#else
+#define PIXMAP_CACHE_LINES 512
+#endif
+
#ifdef PROP_3DFX
#include "tdfx_priv.h"
#else
@@ -37,6 +50,7 @@ typedef struct _TDFXRec *TDFXPtr;
extern Bool TDFXInitPrivate(ScreenPtr pScreen);
extern void TDFXShutdownPrivate(ScreenPtr pScreen);
extern void TDFXSwapContextPrivate(ScreenPtr pScreen);
+extern void TDFXLostContext(ScreenPtr pScreen);
#ifdef XF86DRI
extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI);
@@ -49,6 +63,7 @@ extern void FillPrivateDRI(TDFXPtr pTDFX, TDFXDRIPtr pTDFXDRI);
#define TDFX_DEBUG_CMDS
#define TRACECURS 1
#define REGDEBUG 1
+#define TRACEREG
#endif
#ifdef TRACE
@@ -84,6 +99,14 @@ typedef char (*TDFXReadIndexedByteFunc)(TDFXPtr pTDFX, int addr,
char index);
typedef void (*TDFXWriteWordFunc)(TDFXPtr pTDFX, int addr, int value);
typedef int (*TDFXReadWordFunc)(TDFXPtr pTDFX, int addr);
+typedef void (*TDFXWriteChipIndexedByteFunc)(TDFXPtr pTDFX, int chip,
+ int addr, char index, char value);
+typedef char (*TDFXReadChipIndexedByteFunc)(TDFXPtr pTDFX, int chip,
+ int addr, char index);
+typedef void (*TDFXWriteChipWordFunc)(TDFXPtr pTDFX, int chip,
+ int addr, int value);
+typedef int (*TDFXReadChipWordFunc)(TDFXPtr pTDFX, int chip,
+ int addr);
typedef void (*TDFXSyncFunc)(ScrnInfoPtr pScrn);
typedef void (*TDFXBufferFunc)(TDFXPtr pTDFX, int which);
@@ -111,21 +134,26 @@ typedef struct TextureData_t {
struct TextureData_t *next;
} TextureData;
+#define MAXCHIPS 4
+
typedef struct _TDFXRec {
- unsigned char *MMIOBase;
+ unsigned char *MMIOBase[MAXCHIPS];
unsigned char *FbBase;
- unsigned int PIOBase;
+ unsigned char *myFbBase;
+ unsigned int PIOBase[MAXCHIPS];
long FbMapSize;
+ int pixelFormat;
int stride;
int cpp;
int maxClip;
int MaxClock;
- int Chipset;
- int LinearAddr;
- int MMIOAddr;
- EntityInfoPtr pEnt;
+ int ChipType;
pciVideoPtr PciInfo;
- PCITAG PciTag;
+ int LinearAddr[MAXCHIPS];
+ int MMIOAddr[MAXCHIPS];
+ EntityInfoPtr pEnt;
+ int numChips;
+ PCITAG PciTag[MAXCHIPS];
int HasSGRAM;
int PciCnt;
int PrevDrawState;
@@ -142,6 +170,7 @@ typedef struct _TDFXRec {
Bool NoAccel;
DGAModePtr DGAModes;
Bool DGAactive;
+ Bool initDone;
int DGAViewportStatus;
int cursorOffset;
int fbOffset;
@@ -153,6 +182,8 @@ typedef struct _TDFXRec {
TDFXReadIndexedByteFunc readControl;
TDFXWriteWordFunc writeLong;
TDFXReadWordFunc readLong;
+ TDFXWriteChipWordFunc writeChipLong;
+ TDFXReadChipWordFunc readChipLong;
TDFXSyncFunc sync;
int syncDone;
int scanlineWidth;
@@ -188,6 +219,10 @@ typedef struct {
#define TDFX2XCUTOFF 135000
+#ifndef PCI_CHIP_VOODOO5
+#define PCI_CHIP_VOODOO5 9
+#endif
+
extern Bool TDFXAccelInit(ScreenPtr pScreen);
extern Bool TDFXCursorInit(ScreenPtr pScreen);
extern void TDFXSync(ScrnInfoPtr pScrn);
@@ -197,6 +232,7 @@ extern Bool TDFXDRIFinishScreenInit(ScreenPtr pScreen);
extern Bool TDFXDGAInit(ScreenPtr pScreen);
extern void TDFXCursorGrabMemory(ScreenPtr pScreen);
extern void TDFXSetLFBConfig(TDFXPtr pTDFX);
+extern void TDFXSendNOPPrivate(ScrnInfoPtr pScrn);
extern Bool TDFXSwitchMode(int scrnIndex, DisplayModePtr mode, int flags);
extern void TDFXAdjustFrame(int scrnIndex, int x, int y, int flags);
@@ -221,6 +257,9 @@ extern void TDFXSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
extern void TDFXSubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y,
int w, int h);
+extern void TDFXSelectBuffer(TDFXPtr pTDFX, int which);
+
+
#ifndef PROP_3DFX
#define DECLARE(a)
#define DECLARE_LAUNCH(size, x)
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
index 14365b441..450d07294 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c,v 1.9 2000/03/02 16:07:52 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_accel.c,v 1.12 2000/06/17 17:44:25 dawes Exp $ */
/* All drivers should typically include these */
#include "xf86.h"
@@ -79,15 +79,22 @@ void
TDFXNeedSync(ScrnInfoPtr pScrn) {
TDFXPtr pTDFX = TDFXPTR(pScrn);
pTDFX->syncDone=FALSE;
+ pTDFX->AccelInfoRec->NeedToSync = TRUE;
}
-static void
+void
TDFXFirstSync(ScrnInfoPtr pScrn) {
TDFXPtr pTDFX = TDFXPTR(pScrn);
if (!pTDFX->syncDone) {
- pTDFX->sync(pScrn);
+#ifdef XF86DRI
+ if (pTDFX->directRenderingEnabled) {
+ DRILock(screenInfo.screens[pScrn->scrnIndex], 0);
+ TDFXSwapContextPrivate(screenInfo.screens[pScrn->scrnIndex]);
+ }
+#endif
pTDFX->syncDone=TRUE;
+ pTDFX->sync(pScrn);
}
}
@@ -98,12 +105,17 @@ TDFXCheckSync(ScrnInfoPtr pScrn) {
if (pTDFX->syncDone) {
pTDFX->sync(pScrn);
pTDFX->syncDone=FALSE;
+#ifdef XF86DRI
+ if (pTDFX->directRenderingEnabled) {
+ TDFXLostContext(screenInfo.screens[pScrn->scrnIndex]);
+ DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
+ }
+#endif
}
}
void
TDFXSelectBuffer(TDFXPtr pTDFX, int which) {
-#ifdef XF86DRI
int fmt;
TDFXMakeRoom(pTDFX, 4);
@@ -118,29 +130,49 @@ TDFXSelectBuffer(TDFXPtr pTDFX, int which) {
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt);
break;
case TDFX_BACK:
- fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ if (pTDFX->cpp==2)
+ fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ else
+ fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */
TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->backOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt);
TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->backOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt);
break;
case TDFX_DEPTH:
- fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ if (pTDFX->cpp==2)
+ fmt=((pTDFX->stride+127)/128)|(3<<16); /* Tiled 16bpp */
+ else
+ fmt=((pTDFX->stride+127)/128)|(5<<16); /* Tiled 32bpp */
TDFXWriteLong(pTDFX, SST_2D_DSTBASEADDR, pTDFX->depthOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_DSTFORMAT, fmt);
TDFXWriteLong(pTDFX, SST_2D_SRCBASEADDR, pTDFX->depthOffset|BIT(31));
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, fmt);
break;
default:
+ ;
}
-#endif
}
void
TDFXSetLFBConfig(TDFXPtr pTDFX) {
- TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) |
- SST_RAW_LFB_ADDR_STRIDE_4K |
- ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
+ if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) {
+ TDFXWriteLongMMIO(pTDFX, LFBMEMORYCONFIG, (pTDFX->backOffset>>12) |
+ SST_RAW_LFB_ADDR_STRIDE_4K |
+ ((pTDFX->stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
+ } else {
+ int chip;
+ int stride, bits;
+ if (pTDFX->cpp==2) stride=pTDFX->stride;
+ else stride=4*pTDFX->stride/pTDFX->cpp;
+ bits=pTDFX->backOffset>>12;
+ for (chip=0; chip<pTDFX->numChips; chip++) {
+ TDFXWriteChipLongMMIO(pTDFX, chip, LFBMEMORYCONFIG, (bits&0x1FFF) |
+ SST_RAW_LFB_ADDR_STRIDE_4K |
+ ((bits&0x6000)<<10) |
+ ((stride+127)/128)<<SST_RAW_LFB_TILE_STRIDE_SHIFT);
+ }
+ }
}
Bool
@@ -265,8 +297,11 @@ static void TDFXMakeRoomNoProp(TDFXPtr pTDFX, int size) {
}
}
-static void TDFXSendNOPNoProp(TDFXPtr pTDFX)
+static void TDFXSendNOPNoProp(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
TDFXMakeRoomNoProp(pTDFX, 1);
TDFXWriteLongMMIO(pTDFX, SST_2D_COMMAND, SST_2D_NOP);
}
@@ -280,7 +315,7 @@ void TDFXSync(ScrnInfoPtr pScrn)
TDFXTRACEACCEL("TDFXSync\n");
pTDFX=TDFXPTR(pScrn);
- TDFXSendNOPNoProp(pTDFX);
+ TDFXSendNOPNoProp(pScrn);
i=0;
do {
stat=TDFXReadLongMMIO(pTDFX, 0);
@@ -322,10 +357,15 @@ TDFXMatchState(TDFXPtr pTDFX)
}
static void
-TDFXClearState(TDFXPtr pTDFX)
+TDFXClearState(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
pTDFX->Cmd=0;
pTDFX->DrawState&=~DRAW_STATE_TRANSPARENT;
+ /* Make sure we've done a sync */
+ TDFXFirstSync(pScrn);
}
static void
@@ -366,8 +406,7 @@ TDFXSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop,
"rop=%d planemask=%d trans_color=%d\n",
xdir, ydir, rop, planemask, trans_color);
pTDFX=TDFXPTR(pScrn);
- TDFXFirstSync(pScrn);
- TDFXClearState(pTDFX);
+ TDFXClearState(pScrn);
if (trans_color!=-1) {
TDFXMakeRoom(pTDFX, 3);
@@ -410,7 +449,7 @@ TDFXSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int srcX, int srcY,
}
if ((srcY>=dstY-32 && srcY<=dstY)||
(srcY>=pTDFX->prevBlitDest.y1-32 && srcY<=pTDFX->prevBlitDest.y1)) {
- TDFXSendNOP(pTDFX);
+ TDFXSendNOP(pScrn);
}
pTDFX->sync(pScrn);
@@ -434,8 +473,7 @@ TDFXSetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop,
TDFXTRACEACCEL("TDFXSetupForSolidFill color=%d rop=%d planemask=%d\n",
color, rop, planemask);
pTDFX=TDFXPTR(pScrn);
- TDFXClearState(pTDFX);
- TDFXFirstSync(pScrn);
+ TDFXClearState(pScrn);
pTDFX->Cmd=TDFXROPCvt[rop]<<24;
if (pTDFX->cpp==1) fmt=(1<<16)|pTDFX->stride;
@@ -479,8 +517,7 @@ TDFXSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patx, int paty,
" bg=%d rop=%d planemask=%d\n", patx, paty, fg, bg, rop,
planemask);
pTDFX=TDFXPTR(pScrn);
- TDFXClearState(pTDFX);
- TDFXFirstSync(pScrn);
+ TDFXClearState(pScrn);
pTDFX->Cmd = (TDFXROPCvt[rop+ROP_PATTERN_OFFSET]<<24) |
SST_2D_MONOCHROME_PATTERN;
@@ -525,8 +562,7 @@ TDFXSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop,
TDFXTRACEACCEL("TDFXSetupForSolidLine\n");
pTDFX=TDFXPTR(pScrn);
- TDFXClearState(pTDFX);
- TDFXFirstSync(pScrn);
+ TDFXClearState(pScrn);
pTDFX->Cmd = (TDFXROPCvt[rop]<<24);
@@ -591,8 +627,7 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n,
TDFXTRACEACCEL("TDFXNonTEGlyphRenderer\n");
pTDFX=TDFXPTR(pScrn);
- TDFXFirstSync(pScrn);
- TDFXClearState(pTDFX);
+ TDFXClearState(pScrn);
/* Don't bother fixing clip1, we're going to change it anyway */
pTDFX->DrawState&=~DRAW_STATE_CLIP1CHANGED;
TDFXMatchState(pTDFX);
@@ -608,8 +643,8 @@ TDFXNonTEGlyphRenderer(ScrnInfoPtr pScrn, int x, int y, int n,
SSTCP_SRCXY|SSTCP_COLORFORE|SSTCP_COMMAND);
TDFXWriteLong(pTDFX, SST_2D_CLIP1MIN, ((pbox->y1&0x1FFF)<<16) |
(pbox->x1&0x1FFF));
- TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, (((pbox->y2+1)&0x1FFF)<<16) |
- ((pbox->x2+1)&0x1FFF));
+ TDFXWriteLong(pTDFX, SST_2D_CLIP1MAX, ((pbox->y2&0x1FFF)<<16) |
+ (pbox->x2&0x1FFF));
TDFXWriteLong(pTDFX, SST_2D_SRCFORMAT, SST_2D_PIXFMT_1BPP |
SST_2D_SOURCE_PACKING_DWORD);
TDFXWriteLong(pTDFX, SST_2D_SRCXY, 0);
@@ -657,8 +692,7 @@ TDFXSetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop,
TDFXTRACEACCEL("TDFXSetupForDashedLine\n");
pTDFX=TDFXPTR(pScrn);
- TDFXClearState(pTDFX);
- TDFXFirstSync(pScrn);
+ TDFXClearState(pScrn);
pTDFX->Cmd = (TDFXROPCvt[rop]<<24) | SST_2D_STIPPLE_LINE;
if(bg == -1) {
@@ -701,8 +735,7 @@ TDFXSetupForScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg,
TDFXTRACEACCEL("TDFXSetupForScreenToScreenColorExpandFill\n");
pTDFX=TDFXPTR(pScrn);
- TDFXClearState(pTDFX);
- TDFXFirstSync(pScrn);
+ TDFXClearState(pScrn);
TDFXMatchState(pTDFX);
pTDFX->Cmd|=SST_2D_SCRNTOSCRNBLIT|(TDFXROPCvt[rop]<<24);
@@ -736,7 +769,7 @@ TDFXSubsequentScreenToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y,
pTDFX->DrawState|=DRAW_STATE_CLIP1CHANGED;
if (srcy>=pTDFX->prevBlitDest.y1-8 && srcy<=pTDFX->prevBlitDest.y1) {
- TDFXSendNOP(pTDFX);
+ TDFXSendNOP(pScrn);
}
if (pTDFX->cpp==1) fmt=(1<<16)|pTDFX->stride;
@@ -767,8 +800,7 @@ TDFXSetupForCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg,
TDFXTRACEACCEL("SetupForCPUToScreenColorExpandFill bg=%x fg=%x rop=%d\n",
bg, fg, rop);
pTDFX=TDFXPTR(pScrn);
- TDFXClearState(pTDFX);
- TDFXFirstSync(pScrn);
+ TDFXClearState(pScrn);
pTDFX->Cmd|=SST_2D_HOSTTOSCRNBLIT|(TDFXROPCvt[rop]<<24);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c
index 1976e9a7c..896add046 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c,v 1.2 2000/02/08 17:19:17 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dga.c,v 1.3 2000/06/17 00:03:25 martin Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -31,6 +31,13 @@ DGAFunctionRec TDFX_DGAFuncs = {
TDFX_BlitTransRect
};
+/*
+We should allow you to change the depth, but the accel driver isn't
+ready to handle that yet. Also, we are currently taking the default
+visual and using it for the visual reported by DGA. It would be
+relatively easy to at least give DirectColor and TrueColor visuals
+instead of just the default
+*/
Bool
TDFXDGAInit(ScreenPtr pScreen)
{
@@ -71,12 +78,13 @@ SECOND_PASS:
currentMode->red_mask = pScrn->mask.red;
currentMode->green_mask = pScrn->mask.green;
currentMode->blue_mask = pScrn->mask.blue;
+ currentMode->visualClass = pScrn->defaultVisual;
currentMode->viewportWidth = pMode->HDisplay;
currentMode->viewportHeight = pMode->VDisplay;
currentMode->xViewportStep = (3 - pTDFX->cpp);
currentMode->yViewportStep = 1;
currentMode->viewportFlags = DGA_FLIP_RETRACE;
- currentMode->offset = 0;
+ currentMode->offset = pTDFX->fbOffset;
currentMode->address = pTDFX->FbBase;
if (oneMore) { /* first one is narrow width */
@@ -214,7 +222,7 @@ TDFX_OpenFramebuffer(
TDFXPtr pTDFX = TDFXPTR(pScrn);
*name = NULL; /* no special device */
- *mem = (unsigned char*)pTDFX->LinearAddr;
+ *mem = (unsigned char*)pTDFX->LinearAddr[0];
*size = pTDFX->FbMapSize;
*offset = 0;
*flags = DGA_NEED_ROOT;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c
index 510cfd097..d41141490 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c
@@ -1,22 +1,14 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c,v 1.6 2000/02/15 07:13:42 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_dri.c,v 1.10 2000/06/23 23:43:45 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
#include "xf86_ansic.h"
#include "xf86Priv.h"
-
#include "xf86PciInfo.h"
#include "xf86Pci.h"
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-#include "cfb16.h"
-#include "cfb32.h"
-
+#include "fb.h"
#include "miline.h"
-
#include "GL/glxtokens.h"
-
#include "tdfx.h"
#include "tdfx_dri.h"
#include "tdfx_dripriv.h"
@@ -24,7 +16,6 @@
static char TDFXKernelDriverName[] = "tdfx";
static char TDFXClientDriverName[] = "tdfx";
-static Bool TDFXInitVisualConfigs(ScreenPtr pScreen);
static Bool TDFXCreateContext(ScreenPtr pScreen, VisualPtr visual,
drmContext hwContext, void *pVisualConfigPriv,
DRIContextType contextStore);
@@ -48,15 +39,12 @@ TDFXInitVisualConfigs(ScreenPtr pScreen)
__GLXvisualConfig *pConfigs = 0;
TDFXConfigPrivPtr pTDFXConfigs = 0;
TDFXConfigPrivPtr *pTDFXConfigPtrs = 0;
- int i;
+ int i, db, stencil, accum, depth;
switch (pScrn->bitsPerPixel) {
case 8:
- case 24:
- case 32:
- break;
case 16:
- numConfigs = 2;
+ numConfigs = 16;
if (!(pConfigs = (__GLXvisualConfig*)xnfcalloc(sizeof(__GLXvisualConfig),
numConfigs))) {
@@ -76,64 +64,167 @@ TDFXInitVisualConfigs(ScreenPtr pScreen)
for (i=0; i<numConfigs; i++)
pTDFXConfigPtrs[i] = &pTDFXConfigs[i];
- pConfigs[0].vid = -1;
- pConfigs[0].class = -1;
- pConfigs[0].rgba = TRUE;
- pConfigs[0].redSize = 5;
- pConfigs[0].greenSize = 6;
- pConfigs[0].blueSize = 5;
- pConfigs[0].redMask = 0x0000F800;
- pConfigs[0].greenMask = 0x000007E0;
- pConfigs[0].blueMask = 0x0000001F;
- pConfigs[0].alphaMask = 0;
- pConfigs[0].accumRedSize = 0;
- pConfigs[0].accumGreenSize = 0;
- pConfigs[0].accumBlueSize = 0;
- pConfigs[0].accumAlphaSize = 0;
- pConfigs[0].doubleBuffer = TRUE;
- pConfigs[0].stereo = FALSE;
- pConfigs[0].bufferSize = 16;
- pConfigs[0].depthSize = 16;
- pConfigs[0].stencilSize = 0;
- pConfigs[0].auxBuffers = 0;
- pConfigs[0].level = 0;
- pConfigs[0].visualRating = 0;
- pConfigs[0].transparentPixel = 0;
- pConfigs[0].transparentRed = 0;
- pConfigs[0].transparentGreen = 0;
- pConfigs[0].transparentBlue = 0;
- pConfigs[0].transparentAlpha = 0;
- pConfigs[0].transparentIndex = 0;
-
- pConfigs[1].vid = -1;
- pConfigs[1].class = -1;
- pConfigs[1].rgba = TRUE;
- pConfigs[1].redSize = 5;
- pConfigs[1].greenSize = 6;
- pConfigs[1].blueSize = 5;
- pConfigs[1].redMask = 0x0000F800;
- pConfigs[1].greenMask = 0x000007E0;
- pConfigs[1].blueMask = 0x0000001F;
- pConfigs[1].alphaMask = 0;
- pConfigs[1].accumRedSize = 0;
- pConfigs[1].accumGreenSize = 0;
- pConfigs[1].accumBlueSize = 0;
- pConfigs[1].accumAlphaSize = 0;
- pConfigs[1].doubleBuffer = FALSE;
- pConfigs[1].stereo = FALSE;
- pConfigs[1].bufferSize = 16;
- pConfigs[1].depthSize = 16;
- pConfigs[1].stencilSize = 0;
- pConfigs[1].auxBuffers = 0;
- pConfigs[1].level = 0;
- pConfigs[1].visualRating = 0;
- pConfigs[1].transparentPixel = 0;
- pConfigs[1].transparentRed = 0;
- pConfigs[1].transparentGreen = 0;
- pConfigs[1].transparentBlue = 0;
- pConfigs[1].transparentAlpha = 0;
- pConfigs[1].transparentIndex = 0;
+ i=0;
+ depth=1;
+ for (db = 0; db <=1; db++) {
+ for (depth = 0; depth<=1; depth++) {
+ for (accum = 0; accum <= 1; accum++) {
+ for (stencil = 0; stencil <= 1; stencil++) {
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 5;
+ pConfigs[i].greenSize = 6;
+ pConfigs[i].blueSize = 5;
+ pConfigs[i].redMask = 0x0000F800;
+ pConfigs[i].greenMask = 0x000007E0;
+ pConfigs[i].blueMask = 0x0000001F;
+ pConfigs[i].alphaMask = 0;
+ if (accum) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ if (db)
+ pConfigs[i].doubleBuffer = TRUE;
+ else
+ pConfigs[i].doubleBuffer = FALSE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if (depth) {
+ if (pTDFX->cpp>2)
+ pConfigs[i].depthSize = 24;
+ else
+ pConfigs[i].depthSize = 16;
+ } else {
+ pConfigs[i].depthSize = 0;
+ }
+ if (stencil)
+ pConfigs[i].stencilSize = 8;
+ else
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (stencil || accum)
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ else
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ }
+ }
+ }
+ }
+ if (i!=numConfigs) {
+ ErrorF("Incorrect initialization of visuals\n");
+ return FALSE;
+ } else ErrorF("Created %d visuals\n", numConfigs);
+ break; /* 16bpp */
+ case 24:
+ case 32:
+ numConfigs = 8;
+
+ pConfigs = (__GLXvisualConfig*) xnfcalloc(sizeof(__GLXvisualConfig), numConfigs);
+ if (!pConfigs)
+ return FALSE;
+
+ pTDFXConfigs = (TDFXConfigPrivPtr) xnfcalloc(sizeof(TDFXConfigPrivRec), numConfigs);
+ if (!pTDFXConfigs) {
+ xfree(pConfigs);
+ return FALSE;
+ }
+
+ pTDFXConfigPtrs = (TDFXConfigPrivPtr *) xnfcalloc(sizeof(TDFXConfigPrivPtr), numConfigs);
+ if (!pTDFXConfigPtrs) {
+ xfree(pConfigs);
+ xfree(pTDFXConfigs);
+ return FALSE;
+ }
+
+ for (i = 0; i < numConfigs; i++)
+ pTDFXConfigPtrs[i] = &pTDFXConfigs[i];
+
+ i=0;
+ for (db = 0; db <=1; db++) {
+ for (depth = 0; depth<=1; depth++) {
+ /*stencil = depth;*/ /* Z and stencil share the same memory */
+ for (accum = 0; accum <= 1; accum++) {
+ /*for (stencil = 0; stencil <=1; stencil++) {*/
+ stencil = depth;
+ pConfigs[i].vid = -1;
+ pConfigs[i].class = -1;
+ pConfigs[i].rgba = TRUE;
+ pConfigs[i].redSize = 8;
+ pConfigs[i].greenSize = 8;
+ pConfigs[i].blueSize = 8;
+ pConfigs[i].alphaSize = (pScrn->bitsPerPixel==32) ? 8 : 0;
+ pConfigs[i].redMask = 0x00ff0000;
+ pConfigs[i].greenMask = 0x0000ff00;
+ pConfigs[i].blueMask = 0x000000ff;
+ pConfigs[i].alphaMask = (pScrn->bitsPerPixel==32) ? 0xff000000 : 0;
+ if (accum) {
+ pConfigs[i].accumRedSize = 16;
+ pConfigs[i].accumGreenSize = 16;
+ pConfigs[i].accumBlueSize = 16;
+ pConfigs[i].accumAlphaSize = (pScrn->bitsPerPixel==32) ? 16 : 0;
+ } else {
+ pConfigs[i].accumRedSize = 0;
+ pConfigs[i].accumGreenSize = 0;
+ pConfigs[i].accumBlueSize = 0;
+ pConfigs[i].accumAlphaSize = 0;
+ }
+ if (db)
+ pConfigs[i].doubleBuffer = TRUE;
+ else
+ pConfigs[i].doubleBuffer = FALSE;
+ pConfigs[i].stereo = FALSE;
+ pConfigs[i].bufferSize = 16;
+ if (depth) {
+ if (pTDFX->cpp > 2)
+ pConfigs[i].depthSize = 24;
+ else
+ pConfigs[i].depthSize = 16;
+ } else {
+ pConfigs[i].depthSize = 0;
+ }
+ if (stencil)
+ pConfigs[i].stencilSize = 8;
+ else
+ pConfigs[i].stencilSize = 0;
+ pConfigs[i].auxBuffers = 0;
+ pConfigs[i].level = 0;
+ if (accum)
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ else
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ pConfigs[i].transparentPixel = 0;
+ pConfigs[i].transparentRed = 0;
+ pConfigs[i].transparentGreen = 0;
+ pConfigs[i].transparentBlue = 0;
+ pConfigs[i].transparentAlpha = 0;
+ pConfigs[i].transparentIndex = 0;
+ i++;
+ /*}*/
+ }
+ }
+ }
+ if (i!=numConfigs) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "Incorrect initialization of visuals\n");
+ return FALSE;
+ } else ErrorF("Created %d visuals\n", numConfigs);
break;
}
pTDFX->numVisualConfigs = numConfigs;
@@ -143,6 +234,26 @@ TDFXInitVisualConfigs(ScreenPtr pScreen)
return TRUE;
}
+static void
+TDFXDoWakeupHandler(int screenNum, pointer wakeupData, unsigned long result,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ TDFXNeedSync(pScrn);
+}
+
+static void
+TDFXDoBlockHandler(int screenNum, pointer blockData, pointer pTimeout,
+ pointer pReadmask)
+{
+ ScreenPtr pScreen = screenInfo.screens[screenNum];
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+
+ TDFXCheckSync(pScrn);
+}
+
Bool TDFXDRIScreenInit(ScreenPtr pScreen)
{
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
@@ -150,16 +261,42 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
DRIInfoPtr pDRIInfo;
TDFXDRIPtr pTDFXDRI;
-#if XFree86LOADER
+ switch (pScrn->bitsPerPixel) {
+ case 8:
+ return FALSE;
+ case 16:
+ break;
+ case 24:
+ case 32:
+ if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) return FALSE;
+ }
+
/* Check that the GLX, DRI, and DRM modules have been loaded by testing
for canonical symbols in each module. */
- if (!LoaderSymbol("GlxSetVisualConfigs")) return FALSE;
- if (!LoaderSymbol("DRIScreenInit")) return FALSE;
- if (!LoaderSymbol("drmAvailable")) return FALSE;
-#endif
+ if (!xf86LoaderCheckSymbol("GlxSetVisualConfigs")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIScreenInit")) return FALSE;
+ if (!xf86LoaderCheckSymbol("drmAvailable")) return FALSE;
+ if (!xf86LoaderCheckSymbol("DRIQueryVersion")) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "TDFXDRIScreenInit failed (libdri.a too old)\n");
+ return FALSE;
+ }
+
+ /* Check the DRI version */
+ {
+ int major, minor, patch;
+ DRIQueryVersion(&major, &minor, &patch);
+ if (major != 3 || minor != 0 || patch < 0) {
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "TDFXDRIScreenInit failed (DRI version = %d.%d.%d, expected 3.0.x). Disabling DRI.\n",
+ major, minor, patch);
+ return FALSE;
+ }
+ }
pDRIInfo = DRICreateInfoRec();
- if (!pDRIInfo) return FALSE;
+ if (!pDRIInfo)
+ return FALSE;
pTDFX->pDRIInfo = pDRIInfo;
pDRIInfo->drmDriverName = TDFXKernelDriverName;
@@ -169,14 +306,19 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
((pciConfigPtr)pTDFX->PciInfo->thisCard)->busnum,
((pciConfigPtr)pTDFX->PciInfo->thisCard)->devnum,
((pciConfigPtr)pTDFX->PciInfo->thisCard)->funcnum);
- pDRIInfo->ddxDriverMajorVersion = 0;
- pDRIInfo->ddxDriverMinorVersion = 1;
- pDRIInfo->ddxDriverPatchVersion = 0;
- pDRIInfo->frameBufferPhysicalAddress = pTDFX->LinearAddr;
+ pDRIInfo->ddxDriverMajorVersion = TDFX_MAJOR_VERSION;
+ pDRIInfo->ddxDriverMinorVersion = TDFX_MINOR_VERSION;
+ pDRIInfo->ddxDriverPatchVersion = TDFX_PATCHLEVEL;
+ pDRIInfo->frameBufferPhysicalAddress = pTDFX->LinearAddr[0];
pDRIInfo->frameBufferSize = pTDFX->FbMapSize;
pDRIInfo->frameBufferStride = pTDFX->stride;
pDRIInfo->ddxDrawableTableEntry = TDFX_MAX_DRAWABLES;
+ pDRIInfo->wrap.ValidateTree = 0;
+ pDRIInfo->wrap.PostValidateTree = 0;
+ pDRIInfo->wrap.BlockHandler = TDFXDoBlockHandler;
+ pDRIInfo->wrap.WakeupHandler = TDFXDoWakeupHandler;
+
if (SAREA_MAX_DRAWABLES < TDFX_MAX_DRAWABLES)
pDRIInfo->maxDrawableTableEntry = SAREA_MAX_DRAWABLES;
else
@@ -194,7 +336,7 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
* in the SAREA header
*/
if (sizeof(XF86DRISAREARec)+sizeof(TDFXSAREAPriv)>SAREA_MAX) {
- ErrorF("Data does not fit in SAREA\n");
+ xf86DrvMsg(pScreen->myNum, X_ERROR, "Data does not fit in SAREA\n");
return FALSE;
}
pDRIInfo->SAREASize = SAREA_MAX;
@@ -224,8 +366,29 @@ Bool TDFXDRIScreenInit(ScreenPtr pScreen)
return FALSE;
}
+ /* Check the TDFX DRM version */
+ {
+ drmVersionPtr version = drmGetVersion(pTDFX->drmSubFD);
+ if (version) {
+ if (version->version_major != 1 ||
+ version->version_minor != 0 ||
+ version->version_patchlevel < 0) {
+ /* incompatible drm version */
+ xf86DrvMsg(pScreen->myNum, X_ERROR,
+ "TDFXDRIScreenInit failed (DRM version = %d.%d.%d, expected 1.0.x). Disabling DRI.\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel);
+ TDFXDRICloseScreen(pScreen);
+ drmFreeVersion(version);
+ return FALSE;
+ }
+ drmFreeVersion(version);
+ }
+ }
+
pTDFXDRI->regsSize=TDFXIOMAPSIZE;
- if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr,
+ if (drmAddMap(pTDFX->drmSubFD, (drmHandle)pTDFX->MMIOAddr[0],
pTDFXDRI->regsSize, DRM_REGISTERS, 0, &pTDFXDRI->regs)<0) {
TDFXDRICloseScreen(pScreen);
return FALSE;
@@ -267,8 +430,6 @@ TDFXCreateContext(ScreenPtr pScreen, VisualPtr visual,
drmContext hwContext, void *pVisualConfigPriv,
DRIContextType contextStore)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- TDFXPtr pTDFX = TDFXPTR(pScrn);
TDFXConfigPrivPtr pTDFXConfig = (TDFXConfigPrivPtr)pVisualConfigPriv;
TDFXDRIContextPtr ctx;
@@ -315,14 +476,21 @@ TDFXDRISwapContext(ScreenPtr pScreen, DRISyncType syncType,
DRIContextType oldContextType, void *oldContext,
DRIContextType newContextType, void *newContext)
{
- if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
- (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
- TDFXSwapContextPrivate(pScreen);
- }
+#if 0
+ ScrnInfoPtr pScrn;
+
+ pScrn = xf86Screens[pScreen->myNum];
if ((syncType==DRI_2D_SYNC) && (oldContextType==DRI_NO_CONTEXT) &&
(newContextType==DRI_2D_CONTEXT)) { /* Exiting from Block Handler */
+ TDFXCheckSync(pScrn);
TDFXLostContext(pScreen);
}
+ if ((syncType==DRI_3D_SYNC) && (oldContextType==DRI_2D_CONTEXT) &&
+ (newContextType==DRI_2D_CONTEXT)) { /* Entering from Wakeup */
+ TDFXSwapContextPrivate(pScreen);
+ TDFXNeedSync(pScrn);
+ }
+#endif
}
static void
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
index ec2729055..55de9b066 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c
@@ -25,7 +25,7 @@ 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/drivers/tdfx/tdfx_driver.c,v 1.30 2000/03/06 23:54:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_driver.c,v 1.39 2000/06/23 23:43:45 alanh Exp $ */
/*
* Authors:
@@ -35,10 +35,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/*
* This server does not support these XFree 4.0 features yet
- * DDC1 & DDC2 (requires I2C)
+ * DDC2 (requires I2C)
* shadowFb (if requested or acceleration is off)
* Overlay planes
- * DGA
*/
/*
@@ -75,17 +74,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Required for line biases */
#include "miline.h"
-/* Drivers using cfb need: */
-
-#define PSZ 8
-#include "cfb.h"
-#undef PSZ
-
-/* Drivers supporting bpp 16, 24 or 32 with cfb need one or more of: */
-
-#include "cfb16.h"
-#include "cfb24.h"
-#include "cfb32.h"
+#include "fb.h"
/* !!! These need to be checked !!! */
#if 0
@@ -110,6 +99,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
/* Required Functions: */
+static OptionInfoPtr TDFXAvailableOptions(int chipid, int busid);
/* Print a driver identifying message. */
static void TDFXIdentify(int flags);
@@ -147,23 +137,18 @@ static void TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn,
int PowerManagermentMode, int flags);
#endif
-#define VERSION 4000
-#define TDFX_NAME "TDFX"
-#define TDFX_DRIVER_NAME "tdfx"
-#define TDFX_MAJOR_VERSION 1
-#define TDFX_MINOR_VERSION 0
-#define TDFX_PATCHLEVEL 0
#define PCI_SUBDEVICE_ID_VOODOO3_2000 0x0036
#define PCI_SUBDEVICE_ID_VOODOO3_3000 0x003a
DriverRec TDFX = {
- VERSION,
+ TDFX_VERSION,
TDFX_DRIVER_NAME,
#if 0
- "Accelerated driver for 3dfx Voodoo Banshee and Voodoo3 cards",
+ "Accelerated driver for 3dfx cards",
#endif
TDFXIdentify,
TDFXProbe,
+ TDFXAvailableOptions,
NULL,
0
};
@@ -172,12 +157,14 @@ DriverRec TDFX = {
static SymTabRec TDFXChipsets[] = {
{ PCI_CHIP_BANSHEE, "3dfx Banshee"},
{ PCI_CHIP_VOODOO3, "3dfx Voodoo3"},
+ { PCI_CHIP_VOODOO5, "3dfx Voodoo5"},
{ -1, NULL }
};
static PciChipsets TDFXPciChipsets[] = {
{ PCI_CHIP_BANSHEE, PCI_CHIP_BANSHEE, RES_SHARED_VGA },
{ PCI_CHIP_VOODOO3, PCI_CHIP_VOODOO3, RES_SHARED_VGA },
+ { PCI_CHIP_VOODOO5, PCI_CHIP_VOODOO5, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED }
};
@@ -187,13 +174,15 @@ static PciChipsets TDFXPciChipsets[] = {
typedef enum {
OPTION_NOACCEL,
OPTION_SW_CURSOR,
- OPTION_USE_PIO
+ OPTION_USE_PIO,
+ OPTION_NO_SLI
} TDFXOpts;
static OptionInfoRec TDFXOptions[] = {
{ OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE },
{ OPTION_USE_PIO, "UsePIO", OPTV_BOOLEAN, {0}, FALSE},
+ { OPTION_NO_SLI, "NoSLI", OPTV_BOOLEAN, {0}, FALSE},
{ -1, NULL, OPTV_NONE, {0}, FALSE}
};
@@ -214,13 +203,8 @@ static const char *vgahwSymbols[] = {
0
};
-static const char *cfbSymbols[] = {
- "cfbScreenInit",
- "cfb16ScreenInit",
- "cfb24ScreenInit",
- "cfb32ScreenInit",
- "cfb8_32ScreenInit",
- "cfb24_32ScreenInit",
+static const char *fbSymbols[] = {
+ "fbScreenInit",
NULL
};
@@ -271,6 +255,8 @@ static const char *drmSymbols[] = {
"drmMapBufs",
"drmMarkBufs",
"drmUnmapBufs",
+ "drmFreeVersion",
+ "drmGetVersion",
NULL
};
@@ -287,6 +273,7 @@ static const char *driSymbols[] = {
"DRIUnlock",
"DRIGetSAREAPrivate",
"DRIGetContext",
+ "DRIQueryVersion",
"GlxSetVisualConfigs",
NULL
};
@@ -333,7 +320,7 @@ tdfxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
* Tell the loader about symbols from other modules that this module
* might refer to.
*/
- LoaderRefSymLists(vgahwSymbols, cfbSymbols, xaaSymbols,
+ LoaderRefSymLists(vgahwSymbols, fbSymbols, xaaSymbols,
xf8_32bppSymbols, ramdacSymbols, vbeSymbols,
#ifdef XF86DRI
drmSymbols, driSymbols,
@@ -388,6 +375,26 @@ TDFXIdentify(int flags) {
xf86PrintChipsets(TDFX_NAME, "Driver for 3dfx Banshee/Voodoo3 chipsets", TDFXChipsets);
}
+static
+OptionInfoPtr
+TDFXAvailableOptions(int chipid, int busid)
+{
+ return TDFXOptions;
+}
+
+void
+TDFXProbeDDC(ScrnInfoPtr pScrn, int index)
+{
+ vbeInfoPtr pVbe;
+#ifdef XFree86LOADER
+ if (xf86LoadSubModule(pScrn, "vbe"))
+#endif
+ {
+ pVbe = VBEInit(NULL,index);
+ vbeDoEDID(pVbe, NULL);
+ }
+}
+
/*
* TDFXProbe --
*
@@ -420,9 +427,9 @@ TDFXProbe(DriverPtr drv, int flags) {
TDFXChipsets, TDFXPciChipsets,
devSections, numDevSections,
drv, &usedChips);
+
if (devSections)
xfree(devSections);
- devSections=NULL;
if (numUsed<=0) return FALSE;
if (flags & PROBE_DETECT)
@@ -431,23 +438,24 @@ TDFXProbe(DriverPtr drv, int flags) {
ScrnInfoPtr pScrn;
/* Allocate new ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = TDFX_DRIVER_NAME;
- pScrn->name = TDFX_NAME;
- pScrn->Probe = TDFXProbe;
- pScrn->PreInit = TDFXPreInit;
- pScrn->ScreenInit = TDFXScreenInit;
- pScrn->SwitchMode = TDFXSwitchMode;
- pScrn->AdjustFrame = TDFXAdjustFrame;
- pScrn->EnterVT = TDFXEnterVT;
- pScrn->LeaveVT = TDFXLeaveVT;
- pScrn->FreeScreen = TDFXFreeScreen;
- pScrn->ValidMode = TDFXValidMode;
- foundScreen = TRUE;
-
- xf86ConfigActivePciEntity(pScrn, usedChips[i], TDFXPciChipsets, 0, 0, 0, 0, 0);
+ pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, usedChips[i],
+ TDFXPciChipsets, 0, 0, 0, 0, 0))) {
+
+ pScrn->driverVersion = TDFX_VERSION;
+ pScrn->driverName = TDFX_DRIVER_NAME;
+ pScrn->name = TDFX_NAME;
+ pScrn->Probe = TDFXProbe;
+ pScrn->PreInit = TDFXPreInit;
+ pScrn->ScreenInit = TDFXScreenInit;
+ pScrn->SwitchMode = TDFXSwitchMode;
+ pScrn->AdjustFrame = TDFXAdjustFrame;
+ pScrn->EnterVT = TDFXEnterVT;
+ pScrn->LeaveVT = TDFXLeaveVT;
+ pScrn->FreeScreen = TDFXFreeScreen;
+ pScrn->ValidMode = TDFXValidMode;
+ foundScreen = TRUE;
+ }
}
xfree(usedChips);
@@ -463,10 +471,11 @@ TDFXCountRam(ScrnInfoPtr pScrn) {
pTDFX = TDFXPTR(pScrn);
TDFXTRACE("TDFXCountRam start\n");
memSize=0;
- if (pTDFX->PIOBase) {
+ if (pTDFX->PIOBase[0]) {
CARD32
partSize, /* size of SGRAM chips in Mbits */
nChips, /* # chips of SDRAM/SGRAM */
+ banks, /* Number of banks of chips */
dramInit0_strap,
dramInit1_strap,
dramInit1,
@@ -492,23 +501,28 @@ TDFXCountRam(ScrnInfoPtr pScrn) {
/* determine memory size from strapping pins (dramInit0 and dramInit1) */
dramInit0_strap = pTDFX->readLong(pTDFX, DRAMINIT0);
- dramInit0_strap &= SST_SGRAM_TYPE | SST_SGRAM_NUM_CHIPSETS;
-
- if ( memType == MEM_TYPE_SDRAM ) {
- memSize = 16;
- } else {
- nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS) == 0) ? 4 : 8;
-
- if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_8MBIT ) {
- partSize = 8;
- } else if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_16MBIT) {
- partSize = 16;
+ if (pTDFX->ChipType<=PCI_CHIP_VOODOO3) { /* Banshee/V3 */
+ if (memType == MEM_TYPE_SDRAM) {
+ memSize = 16;
} else {
- ErrorF("Invalid sgram type = 0x%x",
- (dramInit0_strap & SST_SGRAM_TYPE) << SST_SGRAM_TYPE_SHIFT );
- return 0;
+ nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS) == 0) ? 4 : 8;
+
+ if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_8MBIT ) {
+ partSize = 8;
+ } else if ( (dramInit0_strap & SST_SGRAM_TYPE) == SST_SGRAM_TYPE_16MBIT) {
+ partSize = 16;
+ } else {
+ ErrorF("Invalid sgram type = 0x%x",
+ (dramInit0_strap & SST_SGRAM_TYPE) << SST_SGRAM_TYPE_SHIFT );
+ return 0;
+ }
+ memSize = (nChips * partSize) / 8; /* in MBytes */
}
- memSize = (nChips * partSize) / 8; /* in MBytes */
+ } else { /* V4, V5 */
+ nChips = ((dramInit0_strap & SST_SGRAM_NUM_CHIPSETS)==0) ? 4 : 8;
+ partSize=1<<((dramInit0_strap&0x38000000)>>28);
+ banks=((dramInit0_strap&BIT(30))==0) ? 2 : 4;
+ memSize=nChips*partSize*banks;
}
TDFXTRACEREG("dramInit0 = %x dramInit1 = %x\n", dramInit0_strap, dramInit1_strap);
TDFXTRACEREG("MemConfig %d chips %d size %d total\n", nChips, partSize, memSize);
@@ -528,18 +542,85 @@ TDFXCountRam(ScrnInfoPtr pScrn) {
return memSize*1024;
}
-extern xf86MonPtr ConfiguredMonitor;
+static int TDFXCfgToSize(int cfg)
+{
+ if (cfg<4) return 0x8000000<<cfg;
+ return 0x4000000>>(cfg-4);
+}
-void
-TDFXProbeDDC(ScrnInfoPtr pScrn, int index)
+static int TDFXSizeToCfg(int size)
{
- vbeInfoPtr pVbe;
- if (xf86LoadSubModule(pScrn, "vbe")) {
- pVbe = VBEInit(NULL,index);
- ConfiguredMonitor = vbeDoEDID(pVbe);
+ switch (size) {
+ case 0x40000000: return 3;
+ case 0x20000000: return 2;
+ case 0x10000000: return 1;
+ case 0x08000000: return 0;
+ case 0x04000000: return 4;
+ case 0x02000000: return 5;
+ case 0x01000000: return 6;
+ case 0x00800000: return 7;
+ case 0x00400000: return 8;
+ default:
+ return -1;
+ }
+}
+
+static void
+TDFXFindChips(ScrnInfoPtr pScrn, pciVideoPtr match)
+{
+ TDFXPtr pTDFX;
+ pciVideoPtr *ppPci;
+
+ pTDFX=TDFXPTR(pScrn);
+ pTDFX->numChips=0;
+ pTDFX->ChipType=match->chipType;
+ for (ppPci = xf86GetPciVideoInfo(); *ppPci != NULL; ppPci++) {
+ if ((*ppPci)->bus == match->bus &&
+ (*ppPci)->device == match->device) {
+ pTDFX->PciTag[pTDFX->numChips] = pciTag((*ppPci)->bus,
+ (*ppPci)->device,
+ (*ppPci)->func);
+ pTDFX->PIOBase[pTDFX->numChips] = (*ppPci)->ioBase[2]&0xFFFFFFFC;
+ pTDFX->numChips++;
}
+ }
+ /* Disable the secondary chips for now */
+ pTDFX->numChips=1;
}
+static void
+TDFXInitChips(ScrnInfoPtr pScrn)
+{
+ TDFXPtr pTDFX;
+ int i, cfgbits, initbits;
+ int mem0base, mem1base, mem0size, mem0bits, mem1size, mem1bits;
+
+ pTDFX=TDFXPTR(pScrn);
+ cfgbits=pciReadLong(pTDFX->PciTag[0], CFG_PCI_DECODE);
+ mem0base=pciReadLong(pTDFX->PciTag[0], CFG_MEM0BASE);
+ mem1base=pciReadLong(pTDFX->PciTag[0], CFG_MEM1BASE);
+ mem0size=32*1024*1024; /* Registers are always 32MB */
+ mem1size=pScrn->videoRam*1024*2; /* Linear mapping is 2x memory */
+ mem0bits=TDFXSizeToCfg(mem0size);
+ mem1bits=TDFXSizeToCfg(mem1size)<<4;
+ cfgbits=(cfgbits&~(0xFF))|mem0bits|mem1bits;
+ for (i=0; i<pTDFX->numChips; i++) {
+ initbits=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ initbits|=BIT(10);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits);
+ pTDFX->MMIOAddr[i]=mem0base+i*mem0size;
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, 0xFFFFFFFF);
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM0BASE, pTDFX->MMIOAddr[i]);
+ pTDFX->MMIOAddr[i]&=0xFFFFFF00;
+ pTDFX->LinearAddr[i]=mem1base+i*mem1size;
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, 0xFFFFFFFF);
+ pciWriteLong(pTDFX->PciTag[i], CFG_MEM1BASE, pTDFX->LinearAddr[i]);
+ pTDFX->LinearAddr[i]&=0xFFFFFF00;
+ pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, cfgbits);
+ initbits&=~BIT(10);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, initbits);
+ }
+}
/*
* TDFXPreInit --
@@ -549,8 +630,8 @@ TDFXProbeDDC(ScrnInfoPtr pScrn, int index)
*
*/
static Bool
-TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
- vgaHWPtr hwp;
+TDFXPreInit(ScrnInfoPtr pScrn, int flags)
+{
TDFXPtr pTDFX;
ClockRangePtr clockRanges;
int i;
@@ -558,6 +639,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
char *mod=0, *reqSym=0;
int flags24;
rgb defaultWeight = {0, 0, 0};
+ pciVideoPtr match;
TDFXTRACE("TDFXPreInit start\n");
if (pScrn->numEntities != 1) return FALSE;
@@ -569,10 +651,29 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
pTDFX = TDFXPTR(pScrn);
+ pTDFX->initDone=FALSE;
pTDFX->pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
+ if (flags & PROBE_DETECT) {
+ TDFXProbeDDC(pScrn, pTDFX->pEnt->index);
+ return TRUE;
+ }
+
if (pTDFX->pEnt->location.type != BUS_PCI) return FALSE;
+ if (flags & PROBE_DETECT) {
+ TDFXProbeDDC(pScrn, pTDFX->pEnt->index);
+ return FALSE;
+ }
+
+ /* The vgahw module should be loaded here when needed */
+ if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE;
+
+ xf86LoaderReqSymLists(vgahwSymbols, NULL);
+
+ /* Allocate a vgaHWRec */
+ if (!vgaHWGetHWRec(pScrn)) return FALSE;
+
if (xf86LoadSubModule(pScrn, "int10")) {
xf86Int10InfoPtr pInt;
xf86DrvMsg(pScrn->scrnIndex, X_INFO,
@@ -591,9 +692,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
}
}
- pTDFX->PciInfo = xf86GetPciInfoForEntity(pTDFX->pEnt->index);
- pTDFX->PciTag = pciTag(pTDFX->PciInfo->bus, pTDFX->PciInfo->device,
- pTDFX->PciInfo->func);
+ match=pTDFX->PciInfo=xf86GetPciInfoForEntity(pTDFX->pEnt->index);
+ TDFXFindChips(pScrn, match);
if (xf86RegisterResources(pTDFX->pEnt->index, 0, ResNone))
return FALSE;
@@ -602,11 +702,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
else
pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
- if (flags & PROBE_DETECT) {
- TDFXProbeDDC(pScrn, pTDFX->pEnt->index);
- return FALSE;
- }
-
/* Set pScrn->monitor */
pScrn->monitor = pScrn->confScreen->monitor;
@@ -634,7 +729,6 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
return FALSE;
}
- pScrn->rgbBits=8;
if (!xf86SetDefaultVisual(pScrn, -1)) {
return FALSE;
} else {
@@ -647,18 +741,9 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
}
}
- /* The vgahw module should be loaded here when needed */
- if (!xf86LoadSubModule(pScrn, "vgahw")) return FALSE;
-
- xf86LoaderReqSymLists(vgahwSymbols, NULL);
-
- /* Allocate a vgaHWRec */
- if (!vgaHWGetHWRec(pScrn)) return FALSE;
-
/* We use a programamble clock */
pScrn->progClock = TRUE;
- hwp = VGAHWPTR(pScrn);
pTDFX->cpp = pScrn->bitsPerPixel/8;
/* Process the options */
@@ -679,7 +764,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
pTDFX->pEnt->device->chipID);
} else {
from = X_PROBED;
- pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, pTDFX->PciInfo->chipType);
+ pScrn->chipset = (char *)xf86TokenToString(TDFXChipsets, match->chipType);
}
if (pTDFX->pEnt->device->chipRev >= 0) {
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "ChipRev override: %d\n",
@@ -689,11 +774,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
xf86DrvMsg(pScrn->scrnIndex, from, "Chipset: \"%s\"\n", pScrn->chipset);
if (pTDFX->pEnt->device->MemBase != 0) {
- pTDFX->LinearAddr = pTDFX->pEnt->device->MemBase;
+ pTDFX->LinearAddr[0] = pTDFX->pEnt->device->MemBase;
from = X_CONFIG;
} else {
- if (pTDFX->PciInfo->memBase[1] != 0) {
- pTDFX->LinearAddr = pTDFX->PciInfo->memBase[1];
+ if (match->memBase[1] != 0) {
+ pTDFX->LinearAddr[0] = match->memBase[1];
from = X_PROBED;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -703,14 +788,14 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
}
}
xf86DrvMsg(pScrn->scrnIndex, from, "Linear framebuffer at 0x%lX\n",
- (unsigned long)pTDFX->LinearAddr);
+ (unsigned long)pTDFX->LinearAddr[0]);
if (pTDFX->pEnt->device->IOBase != 0) {
- pTDFX->MMIOAddr = pTDFX->pEnt->device->IOBase;
+ pTDFX->MMIOAddr[0] = pTDFX->pEnt->device->IOBase;
from = X_CONFIG;
} else {
- if (pTDFX->PciInfo->memBase[0]) {
- pTDFX->MMIOAddr = pTDFX->PciInfo->memBase[0];
+ if (match->memBase[0]) {
+ pTDFX->MMIOAddr[0] = match->memBase[0];
from = X_PROBED;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -722,8 +807,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
xf86DrvMsg(pScrn->scrnIndex, from, "MMIO registers at addr 0x%lX\n",
(unsigned long)pTDFX->MMIOAddr);
- if (pTDFX->PciInfo->ioBase[2]) {
- pTDFX->PIOBase = pTDFX->PciInfo->ioBase[2]&0xFFFFFFFC;
+ if (match->ioBase[2]) {
+ pTDFX->PIOBase[0] = match->ioBase[2]&0xFFFFFFFC;
} else {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"No valid PIO address in PCI config space\n");
@@ -731,7 +816,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
return FALSE;
}
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "PIO registers at addr 0x%lX\n",
- (unsigned long)pTDFX->PIOBase);
+ (unsigned long)pTDFX->PIOBase[0]);
/* We have to use PIO to probe, because we haven't mappend yet */
TDFXSetPIOAccess(pTDFX);
@@ -744,6 +829,8 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
from = X_CONFIG;
}
+ TDFXInitChips(pScrn);
+
/* Multiple by two because tiled access requires more address space */
pTDFX->FbMapSize = pScrn->videoRam*1024*2;
xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte Mapping %d kByte\n",
@@ -778,12 +865,12 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
pTDFX->MaxClock = pTDFX->pEnt->device->dacSpeeds[0];
from = X_CONFIG;
} else {
- switch (pTDFX->PciInfo->chipType) {
+ switch (pTDFX->ChipType) {
case PCI_CHIP_BANSHEE:
pTDFX->MaxClock = 270000;
break;
case PCI_CHIP_VOODOO3:
- switch(pTDFX->PciInfo->subsysCard) {
+ switch(match->subsysCard) {
case PCI_SUBDEVICE_ID_VOODOO3_2000:
pTDFX->MaxClock = 300000;
break;
@@ -795,14 +882,17 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
break;
}
break;
+ case PCI_CHIP_VOODOO5:
+ pTDFX->MaxClock = 350000;
+ break;
}
}
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next=NULL;
clockRanges->minClock= 12000; /* !!! What's the min clock? !!! */
clockRanges->maxClock=pTDFX->MaxClock;
clockRanges->clockIndex = -1;
- clockRanges->interlaceAllowed = TRUE;
+ clockRanges->interlaceAllowed = FALSE;
clockRanges->doubleScanAllowed = TRUE;
i = xf86ValidateModes(pScrn, pScrn->monitor->Modes,
@@ -833,29 +923,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
xf86SetDpi(pScrn, 0, 0);
- switch (pScrn->bitsPerPixel) {
- case 8:
- mod = "cfb";
- reqSym = "cfbScreenInit";
- break;
- case 16:
- mod = "cfb16";
- reqSym = "cfb16ScreenInit";
- break;
- case 24:
- mod = "cfb24";
- reqSym = "cfb24ScreenInit";
- break;
- case 32:
- mod = "cfb32";
- reqSym = "cfb32ScreenInit";
- break;
- }
- if (mod && !xf86LoadSubModule(pScrn, mod)) {
+ if (!xf86LoadSubModule(pScrn, "fb")) {
TDFXFreeRec(pScrn);
return FALSE;
}
- xf86LoaderReqSymbols(reqSym, NULL);
+ xf86LoaderReqSymbols("fbScreenInit", NULL);
if (!xf86ReturnOptValBool(TDFXOptions, OPTION_NOACCEL, FALSE)) {
if (!xf86LoadSubModule(pScrn, "xaa")) {
@@ -883,25 +955,11 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
/* Initialize DDC1 if possible */
if (xf86LoadSubModule(pScrn, "vbe")) {
xf86MonPtr pMon;
- pMon = vbeDoEDID(VBEInit(NULL,pTDFX->pEnt->index));
+ pMon = vbeDoEDID(VBEInit(NULL,pTDFX->pEnt->index), NULL);
xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon));
}
-
- /* We wont be using the VGA access after the probe */
- if (!xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) {
- resRange vgaio[] = { {ResShrIoBlock,0x3B0,0x3BB},
- {ResShrIoBlock,0x3C0,0x3DF},
- _END };
- resRange vgamem[] = {{ResShrMemBlock,0xA0000,0xAFFFF},
- {ResShrMemBlock,0xB8000,0xBFFFF},
- {ResShrMemBlock,0xB0000,0xB7FFF},
- _END };
-
- pTDFX->usePIO=FALSE;
- xf86SetOperatingState(vgaio, pTDFX->pEnt->index, ResUnusedOpr);
- xf86SetOperatingState(vgamem, pTDFX->pEnt->index, ResDisableOpr);
- } else {
+ if (xf86ReturnOptValBool(TDFXOptions, OPTION_USE_PIO, FALSE)) {
pTDFX->usePIO=TRUE;
}
@@ -911,7 +969,7 @@ TDFXPreInit(ScrnInfoPtr pScrn, int flags) {
static Bool
TDFXMapMem(ScrnInfoPtr pScrn)
{
- int mmioFlags;
+ int mmioFlags, i;
TDFXPtr pTDFX;
TDFXTRACE("TDFXMapMem start\n");
@@ -919,15 +977,18 @@ TDFXMapMem(ScrnInfoPtr pScrn)
mmioFlags = VIDMEM_MMIO | VIDMEM_READSIDEEFFECT;
- pTDFX->MMIOBase = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,
- pTDFX->PciTag,
- pTDFX->MMIOAddr,
- TDFXIOMAPSIZE);
- if (!pTDFX->MMIOBase) return FALSE;
+ for (i=0; i<pTDFX->numChips; i++) {
+ pTDFX->MMIOBase[i] = xf86MapPciMem(pScrn->scrnIndex, mmioFlags,
+ pTDFX->PciTag[i],
+ pTDFX->MMIOAddr[i],
+ TDFXIOMAPSIZE);
+
+ if (!pTDFX->MMIOBase[i]) return FALSE;
+ }
pTDFX->FbBase = xf86MapPciMem(pScrn->scrnIndex, VIDMEM_FRAMEBUFFER,
- pTDFX->PciTag,
- pTDFX->LinearAddr,
+ pTDFX->PciTag[0],
+ pTDFX->LinearAddr[0],
pTDFX->FbMapSize);
if (!pTDFX->FbBase) return FALSE;
@@ -938,12 +999,16 @@ static Bool
TDFXUnmapMem(ScrnInfoPtr pScrn)
{
TDFXPtr pTDFX;
+ int i;
TDFXTRACE("TDFXUnmapMem start\n");
pTDFX = TDFXPTR(pScrn);
- xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase, TDFXIOMAPSIZE);
- pTDFX->MMIOBase=0;
+ for (i=0; i<pTDFX->numChips; i++) {
+ xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->MMIOBase[i],
+ TDFXIOMAPSIZE);
+ pTDFX->MMIOBase[i]=0;
+ }
xf86UnMapVidMem(pScrn->scrnIndex, (pointer)pTDFX->FbBase, pTDFX->FbMapSize);
pTDFX->FbBase = 0;
@@ -1118,12 +1183,20 @@ TDFXRestore(ScrnInfoPtr pScrn) {
#define REFFREQ 14318.18
static int
-CalcPLL(int freq, int *f_out) {
+CalcPLL(int freq, int *f_out, int isBanshee) {
int m, n, k, best_m, best_n, best_k, f_cur, best_error;
+ int minm, maxm;
TDFXTRACE("CalcPLL start\n");
best_error=freq;
best_n=best_m=best_k=0;
+ if (isBanshee) {
+ minm=24;
+ maxm=24;
+ } else {
+ minm=1;
+ maxm=64;
+ }
for (n=1; n<256; n++) {
f_cur=REFFREQ*(n+2);
if (f_cur<freq) {
@@ -1136,7 +1209,7 @@ CalcPLL(int freq, int *f_out) {
continue;
}
}
- for (m=1; m<64; m++) {
+ for (m=minm; m<maxm; m++) {
for (k=0; k<4; k++) {
f_cur=REFFREQ*(n+2)/(m+2)/(1<<k);
if (abs(f_cur-freq)<best_error) {
@@ -1175,7 +1248,7 @@ SetupVidPLL(ScrnInfoPtr pScrn, DisplayModePtr mode) {
tdfxReg->dacmode|=SST_DAC_MODE_2X;
tdfxReg->vidcfg|=SST_VIDEO_2X_MODE_EN;
}
- tdfxReg->vidpll=CalcPLL(freq, &f_out);
+ tdfxReg->vidpll=CalcPLL(freq, &f_out, 0);
TDFXTRACEREG("Vid PLL freq=%d f_out=%d reg=%x\n", freq, f_out,
tdfxReg->vidpll);
return TRUE;
@@ -1207,7 +1280,10 @@ SetupGfxPLL(int freq) {
TDFXTRACE("SetupGfxPLL start\n");
pTDFX=TDFXPTR();
tdfxReg=(vgaTDFXPtr)vgaNewVideoState;
- tdfxReg->gfxpll=CalcPLL(freq, &f_out);
+ if (pTDFX->chipType==PCI_CHIP_BANSHEE)
+ tdfxReg->gfxpll=CalcPLL(freq, &f_out, 1);
+ else
+ tdfxReg->gfxpll=CalcPLL(freq, &f_out, 0);
pTDFX->writeLong(pTDFX, PLLCTRL2, tdfxReg->gfxpll);
TDFXTRACEREG("Gfx PLL freq=%d f_out=%d reg=%x\n", freq, f_out,
tdfxReg->gfxpll);
@@ -1218,14 +1294,13 @@ SetupGfxPLL(int freq) {
static Bool
TDFXInitVGA(ScrnInfoPtr pScrn)
{
- static Bool initDone=FALSE;
TDFXPtr pTDFX;
TDFXRegPtr tdfxReg;
TDFXTRACE("TDFXInitVGA start\n");
- if (initDone) return TRUE;
- initDone=TRUE;
pTDFX=TDFXPTR(pScrn);
+ if (pTDFX->initDone) return TRUE;
+ pTDFX->initDone=TRUE;
tdfxReg = &pTDFX->ModeReg;
tdfxReg->vgainit0 = 0;
tdfxReg->vgainit0 |= SST_VGA0_EXTENSIONS;
@@ -1240,8 +1315,9 @@ TDFXInitVGA(ScrnInfoPtr pScrn)
tdfxReg->vidcfg = SST_VIDEO_PROCESSOR_EN | SST_CURSOR_X11 | SST_DESKTOP_EN |
(pTDFX->cpp-1)<<SST_DESKTOP_PIXEL_FORMAT_SHIFT;
- if (pTDFX->cpp!=1) tdfxReg->vidcfg |= SST_DESKTOP_CLUT_BYPASS;
+ /* tdfxReg->vidcfg |= SST_DESKTOP_CLUT_BYPASS; */
+
tdfxReg->stride = pTDFX->stride;
tdfxReg->clip0min = tdfxReg->clip1min = 0;
@@ -1377,8 +1453,9 @@ TDFXModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
#endif
DoRestore(pScrn, &hwp->ModeReg, &pTDFX->ModeReg, FALSE);
#ifdef XF86DRI
- if (pTDFX->directRenderingEnabled)
+ if (pTDFX->directRenderingEnabled) {
DRIUnlock(screenInfo.screens[pScrn->scrnIndex]);
+ }
#endif
return TRUE;
@@ -1388,30 +1465,37 @@ static void
TDFXLoadPalette16(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
short visualClass) {
TDFXPtr pTDFX;
- vgaHWPtr hwp;
- int i, index;
- unsigned char r, g, b;
+ int i, j, index, v, repeat, max;
TDFXTRACE("TDFXLoadPalette16 start\n");
pTDFX = TDFXPTR(pScrn);
- hwp = VGAHWPTR(pScrn);
for (i=0; i<numColors; i++) {
- index=indices[i/2];
- r=colors[index].red;
- b=colors[index].blue;
index=indices[i];
- g=colors[index].green;
- hwp->writeDacWriteAddr(hwp, index<<2);
- hwp->writeDacData(hwp, r);
- hwp->writeDacData(hwp, g);
- hwp->writeDacData(hwp, b);
- i++;
- index=indices[i];
- g=colors[index].green;
- hwp->writeDacWriteAddr(hwp, index<<2);
- hwp->writeDacData(hwp, r);
- hwp->writeDacData(hwp, g);
- hwp->writeDacData(hwp, b);
+ v=(colors[index/2].red<<16)|(colors[index].green<<8)|colors[index/2].blue;
+ if (i<numColors-1) max=indices[i+1]<<2;
+ else max=256;
+ for (j=index<<2; j<max; j++) {
+ repeat=100;
+ do {
+ pTDFX->writeLong(pTDFX, DACADDR, j);
+ } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=j);
+ if (!repeat) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, "
+ "bypassing CLUT\n");
+ pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS;
+ return;
+ }
+ repeat=100;
+ do {
+ pTDFX->writeLong(pTDFX, DACDATA, v);
+ } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v);
+ if (!repeat) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, "
+ "bypassing CLUT\n");
+ pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS;
+ return;
+ }
+ }
}
}
@@ -1419,23 +1503,33 @@ static void
TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
short visualClass) {
TDFXPtr pTDFX;
- vgaHWPtr hwp;
- int i, index;
- unsigned char r, g, b;
+ int i, index, v, repeat;
TDFXTRACE("TDFXLoadPalette24 start\n");
pTDFX = TDFXPTR(pScrn);
- hwp = VGAHWPTR(pScrn);
for (i=0; i<numColors; i++) {
index=indices[i];
- r=colors[index].red;
- b=colors[index].blue;
- index=indices[i];
- g=colors[index].green;
- hwp->writeDacWriteAddr(hwp, index);
- hwp->writeDacData(hwp, r);
- hwp->writeDacData(hwp, g);
- hwp->writeDacData(hwp, b);
+ v=(colors[index].red<<16)|(colors[index].green<<8)|colors[index].blue;
+ repeat=100;
+ do {
+ pTDFX->writeLong(pTDFX, DACADDR, index);
+ } while (--repeat && pTDFX->readLong(pTDFX, DACADDR)!=index);
+ if (!repeat) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac index, "
+ "bypassing CLUT\n");
+ pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS;
+ return;
+ }
+ repeat=100;
+ do {
+ pTDFX->writeLong(pTDFX, DACDATA, v);
+ } while (--repeat && pTDFX->readLong(pTDFX, DACDATA)!=v);
+ if (!repeat) {
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Failed to set dac value, "
+ "bypassing CLUT\n");
+ pTDFX->ModeReg.vidcfg |= SST_DESKTOP_CLUT_BYPASS;
+ return;
+ }
}
}
@@ -1443,20 +1537,17 @@ TDFXLoadPalette24(ScrnInfoPtr pScrn, int numColors, int *indices, LOCO *colors,
#define TILE_HEIGHT 32
static int
-calcBufferStride(int xres, Bool tiled)
+calcBufferStride(int xres, Bool tiled, int cpp)
{
int strideInTiles;
if (tiled == TRUE) {
/* Calculate tile width stuff */
- strideInTiles = (xres << 1) >> 7;
- if ((xres << 1) & (TILE_WIDTH - 1))
- strideInTiles++;
+ strideInTiles = (xres+TILE_WIDTH-1)/TILE_WIDTH;
- return (strideInTiles * TILE_WIDTH);
-
+ return strideInTiles*cpp*TILE_WIDTH;
} else {
- return (xres << 1);
+ return xres*cpp;
}
} /* calcBufferStride */
@@ -1477,26 +1568,26 @@ calcBufferHeightInTiles(int yres)
} /* calcBufferHeightInTiles */
static int
-calcBufferSizeInTiles(int xres, int yres) {
+calcBufferSizeInTiles(int xres, int yres, int cpp) {
int bufSizeInTiles; /* Size of buffer in tiles */
bufSizeInTiles =
- calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE) >> 7);
+ calcBufferHeightInTiles(yres) * (calcBufferStride(xres, TRUE, cpp) >> 7);
return bufSizeInTiles;
} /* calcBufferSizeInTiles */
static int
-calcBufferSize(int xres, int yres, Bool tiled)
+calcBufferSize(int xres, int yres, Bool tiled, int cpp)
{
int stride, height, bufSize;
if (tiled) {
- stride = calcBufferStride(xres, tiled);
+ stride = calcBufferStride(xres, tiled, cpp);
height = TILE_HEIGHT * calcBufferHeightInTiles(yres);
} else {
- stride = xres << 1;
+ stride = xres*cpp;
height = yres;
}
@@ -1522,7 +1613,15 @@ static void allocateMemory(ScrnInfoPtr pScrn) {
/* Remove one scanline for page alignment */
memRemaining-=4095;
/* Remove the back and Z buffers */
- screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY, TRUE);
+ if (pTDFX->cpp!=3) {
+ screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY,
+ TRUE, pTDFX->cpp);
+ }
+ else {
+ /* cpp==3 needs to bump up to 4 */
+ screenSizeInTiles=calcBufferSize(pScrn->virtualX, pScrn->virtualY,
+ TRUE, 4);
+ }
memRemaining-=screenSizeInTiles*2;
/* Give all the rest to textures, rounded down to a page */
@@ -1578,20 +1677,26 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
hwp = VGAHWPTR(pScrn);
if (!TDFXMapMem(pScrn)) return FALSE;
- pScrn->memPhysBase = (int)pTDFX->LinearAddr;
+ pScrn->memPhysBase = (int)pTDFX->LinearAddr[0];
- if (!pTDFX->usePIO) {
- TDFXSetMMIOAccess(pTDFX);
- hwp->IOBase = ((hwp->readMiscOut(hwp) & 0x01) ?
- VGA_IOBASE_COLOR : VGA_IOBASE_MONO) + (unsigned long)pTDFX->MMIOBase -
- 0x300;
- } else {
- vgaHWGetIOBase(hwp);
- }
+ if (!pTDFX->usePIO) TDFXSetMMIOAccess(pTDFX);
+ vgaHWGetIOBase(hwp);
if (!vgaHWMapMem(pScrn)) return FALSE;
allocateMemory(pScrn);
+ if (pTDFX->numChips>1) {
+ if (xf86ReturnOptValBool(TDFXOptions, OPTION_NO_SLI, FALSE)) {
+ TDFXSetupSLI(pScrn, FALSE, 0);
+ } else {
+ TDFXSetupSLI(pScrn, TRUE, 0);
+ }
+ }
+
+ TDFXSetLFBConfig(pTDFX);
+
+ /* We initialize in the state that our FIFO is up to date */
+ pTDFX->syncDone=TRUE;
#ifdef PROP_3DFX
if (!TDFXInitPrivate(pScreen)) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Failed to initialize private\n");
@@ -1620,42 +1725,25 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
#ifdef XF86DRI
/*
- * Setup DRI after visuals have been established, but before cfbScreenInit
- * is called. cfbScreenInit will eventually call into the drivers
+ * Setup DRI after visuals have been established, but before fbScreenInit
+ * is called. fbScreenInit will eventually call into the drivers
* InitGLXVisuals call back.
*/
pTDFX->directRenderingEnabled = TDFXDRIScreenInit(pScreen);
/* Force the initialization of the context */
- TDFXLostContext(pScreen);
+ if (pTDFX->directRenderingEnabled)
+ TDFXLostContext(pScreen);
#endif
switch (pScrn->bitsPerPixel) {
case 8:
- if (!cfbScreenInit(pScreen, pTDFX->FbBase+pTDFX->fbOffset,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth))
- return FALSE;
- break;
case 16:
- if (!cfb16ScreenInit(pScreen, pTDFX->FbBase+pTDFX->fbOffset,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth))
- return FALSE;
- break;
case 24:
- if (!cfb24ScreenInit(pScreen, pTDFX->FbBase+pTDFX->fbOffset,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth))
- return FALSE;
- break;
case 32:
- if (!cfb32ScreenInit(pScreen, pTDFX->FbBase+pTDFX->fbOffset,
- pScrn->virtualX, pScrn->virtualY,
- pScrn->xDpi, pScrn->yDpi,
- pScrn->displayWidth))
+ if (!fbScreenInit(pScreen, pTDFX->FbBase+pTDFX->fbOffset,
+ pScrn->virtualX, pScrn->virtualY,
+ pScrn->xDpi, pScrn->yDpi,
+ pScrn->displayWidth, pScrn->bitsPerPixel))
return FALSE;
break;
default:
@@ -1732,14 +1820,13 @@ TDFXScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) {
#ifdef XF86DRI
if (pTDFX->directRenderingEnabled) {
- /* Now that mi, cfb, drm and others have done their thing,
+ /* Now that mi, fb, drm and others have done their thing,
* complete the DRI setup.
*/
pTDFX->directRenderingEnabled = TDFXDRIFinishScreenInit(pScreen);
}
if (pTDFX->directRenderingEnabled) {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering enabled\n");
- TDFXSetLFBConfig(pTDFX);
} else {
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "direct rendering disabled\n");
}
@@ -1806,6 +1893,7 @@ TDFXEnterVT(int scrnIndex, int flags) {
if (pTDFX->directRenderingEnabled) {
pScreen = screenInfo.screens[scrnIndex];
DRIUnlock(pScreen);
+ TDFXLostContext(pScreen);
}
#endif
if (!TDFXModeInit(pScrn, pScrn->currentMode)) return FALSE;
@@ -1832,6 +1920,7 @@ TDFXLeaveVT(int scrnIndex, int flags) {
pTDFX = TDFXPTR(pScrn);
if (pTDFX->directRenderingEnabled) {
DRILock(pScreen, 0);
+ TDFXSwapContextPrivate(pScreen);
}
#endif
}
@@ -1978,3 +2067,4 @@ TDFXDisplayPowerManagementSet(ScrnInfoPtr pScrn, int PowerManagementMode,
pTDFX->writeLong(pTDFX, DACMODE, dacmode);
}
#endif
+
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c
index 62b883a16..f15f321bf 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c
@@ -24,7 +24,7 @@ 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/drivers/tdfx/tdfx_io.c,v 1.4 2000/02/23 04:47:21 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_io.c,v 1.5 2000/06/17 00:03:25 martin Exp $ */
/*
* Authors:
@@ -39,27 +39,35 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "tdfx.h"
-#define minb(p) MMIO_IN8(pTDFX->MMIOBase, (p))
-#define moutb(p,v) MMIO_OUT8(pTDFX->MMIOBase, (p),(v))
-#define minl(p) MMIO_IN32(pTDFX->MMIOBase, (p))
-#define moutl(p,v) MMIO_OUT32(pTDFX->MMIOBase, (p),(v))
+#define minb(b, p) MMIO_IN8((b), (p))
+#define moutb(b, p,v) MMIO_OUT8((b), (p),(v))
+#define minl(b, p) MMIO_IN32((b), (p))
+#define moutl(b, p,v) MMIO_OUT32((b), (p),(v))
static void TDFXWriteControlPIO(TDFXPtr pTDFX, int addr, char index, char val) {
- outb(pTDFX->PIOBase+addr, index);
- outb(pTDFX->PIOBase+addr+1, val);
+ outb(pTDFX->PIOBase[0]+addr, index);
+ outb(pTDFX->PIOBase[0]+addr+1, val);
}
static char TDFXReadControlPIO(TDFXPtr pTDFX, int addr, char index) {
- outb(pTDFX->PIOBase+addr, index);
- return inb(pTDFX->PIOBase+addr+1);
+ outb(pTDFX->PIOBase[0]+addr, index);
+ return inb(pTDFX->PIOBase[0]+addr+1);
+}
+
+void TDFXWriteChipLongPIO(TDFXPtr pTDFX, int chip, int addr, int val) {
+ outl(pTDFX->PIOBase[chip]+addr, val);
+}
+
+int TDFXReadChipLongPIO(TDFXPtr pTDFX, int chip, int addr) {
+ return inl(pTDFX->PIOBase[chip]+addr);
}
static void TDFXWriteLongPIO(TDFXPtr pTDFX, int addr, int val) {
- outl(pTDFX->PIOBase+addr, val);
+ TDFXWriteChipLongPIO(pTDFX, 0, addr, val);
}
static int TDFXReadLongPIO(TDFXPtr pTDFX, int addr) {
- return inl(pTDFX->PIOBase+addr);
+ return TDFXReadChipLongPIO(pTDFX, 0, addr);
}
void TDFXSetPIOAccess(TDFXPtr pTDFX) {
@@ -69,24 +77,34 @@ void TDFXSetPIOAccess(TDFXPtr pTDFX) {
pTDFX->readControl=TDFXReadControlPIO;
pTDFX->writeLong=TDFXWriteLongPIO;
pTDFX->readLong=TDFXReadLongPIO;
+ pTDFX->readChipLong=TDFXReadChipLongPIO;
+ pTDFX->writeChipLong=TDFXWriteChipLongPIO;
}
static void TDFXWriteControlMMIO(TDFXPtr pTDFX, int addr, char index, char val) {
- moutb(addr, index);
- moutb(addr+1, val);
+ moutb(pTDFX->MMIOBase[0], addr, index);
+ moutb(pTDFX->MMIOBase[0], addr+1, val);
}
static char TDFXReadControlMMIO(TDFXPtr pTDFX, int addr, char index) {
- moutb(addr, index);
- return minb(addr+1);
+ moutb(pTDFX->MMIOBase[0], addr, index);
+ return minb(pTDFX->MMIOBase[0], addr+1);
+}
+
+void TDFXWriteChipLongMMIO(TDFXPtr pTDFX, int chip, int addr, int val) {
+ moutl(pTDFX->MMIOBase[chip], addr, val);
+}
+
+static int TDFXReadChipLongMMIO(TDFXPtr pTDFX, int chip, int addr) {
+ return minl(pTDFX->MMIOBase[chip], addr);
}
void TDFXWriteLongMMIO(TDFXPtr pTDFX, int addr, int val) {
- moutl(addr, val);
+ TDFXWriteChipLongMMIO(pTDFX, 0, addr, val);
}
int TDFXReadLongMMIO(TDFXPtr pTDFX, int addr) {
- return minl(addr);
+ return TDFXReadChipLongMMIO(pTDFX, 0, addr);
}
void TDFXSetMMIOAccess(TDFXPtr pTDFX) {
@@ -96,5 +114,7 @@ void TDFXSetMMIOAccess(TDFXPtr pTDFX) {
pTDFX->readControl=TDFXReadControlMMIO;
pTDFX->writeLong=TDFXWriteLongMMIO;
pTDFX->readLong=TDFXReadLongMMIO;
+ pTDFX->writeChipLong=TDFXWriteChipLongMMIO;
+ pTDFX->readChipLong=TDFXReadChipLongMMIO;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c
index e8a75056f..41d9d2270 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c,v 1.7 2000/02/18 12:20:05 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_priv.c,v 1.10 2000/06/21 21:40:04 tsi Exp $ */
#if 0
@@ -23,28 +23,41 @@
C - D-1 : Z buffer
*/
-void TDFXSendNOPPrivate2D(TDFXPtr pTDFX)
+void TDFXSendNOPPrivate3D(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
TDFXAllocateSlots(pTDFX, 2);
- SET_3DPK4_HEADER(1, 0x48);
+ SET_3DPK4_HEADER(1, 0x48<<3);
WRITE_FIFO(pTDFX, 0, 0);
}
-void TDFXSendNOPPrivate3D(TDFXPtr pTDFX)
+void TDFXSendNOPPrivate2D(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
+ if (!pTDFX->syncDone) {
+ TDFXFirstSync(pScrn);
+ return;
+ }
TDFXAllocateSlots(pTDFX, 2);
SET_PKT2_HEADER(SSTCP_COMMAND);
WRITE_FIFO(pTDFX, SST_2D_COMMAND, SST_2D_NOP|SST_2D_GO);
}
-void TDFXSendNOPPrivate(TDFXPtr pTDFX)
+void TDFXSendNOPPrivate(ScrnInfoPtr pScrn)
{
- TDFXSendNOPPrivate2D(pTDFX);
- TDFXSendNOPPrivate3D(pTDFX);
+ TDFXSendNOPPrivate2D(pScrn);
+ TDFXSendNOPPrivate3D(pScrn);
}
-void InstallFifo(TDFXPtr pTDFX)
+void InstallFifo(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
+
+ pTDFX=TDFXPTR(pScrn);
/* Install the fifo */
TDFXWriteLongMMIO(pTDFX, SST_FIFO_BASEADDR0, pTDFX->fifoOffset>>12);
TDFXWriteLongMMIO(pTDFX, SST_FIFO_BUMP0, 0);
@@ -54,7 +67,7 @@ void InstallFifo(TDFXPtr pTDFX)
TDFXWriteLongMMIO(pTDFX, SST_FIFO_AMAX0, pTDFX->fifoOffset-4);
TDFXWriteLongMMIO(pTDFX, SST_FIFO_DEPTH0, 0);
TDFXWriteLongMMIO(pTDFX, SST_FIFO_HOLECNT0, 0);
- if (pTDFX->PciInfo->chipType == PCI_CHIP_BANSHEE)
+ if (pTDFX->ChipType == PCI_CHIP_BANSHEE)
TDFXWriteLongMMIO(pTDFX, SST_FIFO_FIFOTHRESH, (0x9<<5) | 0x2);
else
TDFXWriteLongMMIO(pTDFX, SST_FIFO_FIFOTHRESH, (0xf<<5) | 0x8);
@@ -65,33 +78,35 @@ void InstallFifo(TDFXPtr pTDFX)
pTDFX->fifoPtr = pTDFX->fifoBase;
pTDFX->fifoSlots = (pTDFX->fifoSize>>2) - 1;
pTDFX->fifoEnd = pTDFX->fifoBase+pTDFX->fifoSlots;
- TDFXSendNOPPrivate(pTDFX);
+ TDFXSendNOPPrivate(pScrn);
}
-void TDFXResetFifo(TDFXPtr pTDFX)
+void TDFXResetFifo(ScrnInfoPtr pScrn)
{
+ TDFXPtr pTDFX;
int oldValue;
- CARD32 start_sec, end_sec, dummy;
+ long start_sec, end_sec, dummy;
+ pTDFX=TDFXPTR(pScrn);
ErrorF("Resetting FIFO\n");
/* Shut down the fifo */
TDFXWriteLongMMIO(pTDFX, SST_FIFO_BASESIZE0, 0);
/* Toggle the reset bits */
oldValue=TDFXReadLongMMIO(pTDFX, MISCINIT0);
TDFXWriteLongMMIO(pTDFX, MISCINIT0, oldValue|0x23);
- xf86getsecs(&start_sec, &dummy);
+ getsecs(&start_sec, &dummy);
do {
- xf86getsecs(&end_sec, &dummy);
+ getsecs(&end_sec, &dummy);
} while (end_sec-start_sec<2);
TDFXWriteLongMMIO(pTDFX, MISCINIT0, oldValue);
oldValue=TDFXReadLongMMIO(pTDFX, MISCINIT1);
TDFXWriteLongMMIO(pTDFX, MISCINIT1, oldValue|BIT(19));
- xf86getsecs(&start_sec, &dummy);
+ getsecs(&start_sec, &dummy);
do {
- xf86getsecs(&end_sec, &dummy);
+ getsecs(&end_sec, &dummy);
} while (end_sec-start_sec<2);
TDFXWriteLongMMIO(pTDFX, MISCINIT1, oldValue);
- InstallFifo(pTDFX);
+ InstallFifo(pScrn);
}
/*
@@ -102,16 +117,16 @@ void TDFXResetFifo(TDFXPtr pTDFX)
!!! We should use expedential backoff in our reads !!!
*/
-void TDFXSyncFifo(ScrnInfoPtr pScrn)
+static void TDFXSyncFifo(ScrnInfoPtr pScrn)
{
TDFXPtr pTDFX;
int i, cnt;
int stat;
- CARD32 start_sec, end_sec, dummy;
+ long start_sec, end_sec, dummy;
TDFXTRACEACCEL("TDFXSyncFifo start\n");
pTDFX=TDFXPTR(pScrn);
- TDFXSendNOPPrivate(pTDFX);
+ TDFXSendNOPPrivate(pScrn);
i=0;
cnt=0;
start_sec=0;
@@ -121,11 +136,11 @@ void TDFXSyncFifo(ScrnInfoPtr pScrn)
cnt++;
if (cnt==1000) {
if (!start_sec) {
- xf86getsecs(&start_sec, &dummy);
+ getsecs(&start_sec, &dummy);
} else {
- xf86getsecs(&end_sec, &dummy);
+ getsecs(&end_sec, &dummy);
if (end_sec-start_sec>3) {
- TDFXResetFifo(pTDFX);
+ TDFXResetFifo(pScrn);
start_sec=0;
}
}
@@ -153,7 +168,7 @@ Bool TDFXInitPrivate(ScreenPtr pScreen)
pTDFX->fifoMirrorPtr = pTDFX->fifoMirrorBase;
#endif
pTDFX->sync=TDFXSyncFifo;
- InstallFifo(pTDFX);
+ InstallFifo(pScrn);
return TRUE;
}
@@ -190,7 +205,6 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen)
ScrnInfoPtr pScrn;
TDFXPtr pTDFX;
int dummy, readPos;
- int offset;
TDFXSAREAPriv *sPriv;
pScrn = xf86Screens[pScreen->myNum];
@@ -214,7 +228,7 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen)
(sPriv->fifoRead<pTDFX->fifoOffset) ||
(sPriv->fifoRead>(int)pTDFX->fifoOffset+pTDFX->fifoSize)) {
ErrorF("Invalid offsets passed between client and X server\n");
- ResetFifo(pTDFX);
+ ResetFifo(pScrn);
} else {
pTDFX->fifoPtr = (unsigned int *)(pTDFX->FbBase+sPriv->fifoPtr);
pTDFX->fifoRead = (unsigned int *)(pTDFX->FbBase+sPriv->fifoRead);
@@ -226,7 +240,8 @@ void TDFXSwapContextPrivate(ScreenPtr pScreen)
pTDFX->fifoSlots = pTDFX->fifoEnd-pTDFX->fifoPtr-8;
}
-void TDFXLostContext(ScreenPtr pScreen) {
+void TDFXLostContext(ScreenPtr pScreen)
+{
ScrnInfoPtr pScrn;
TDFXPtr pTDFX;
TDFXSAREAPriv *sPriv;
@@ -312,10 +327,14 @@ TDFXMakeSpace(TDFXPtr pTDFX, uint32 slots)
}
void
-TDFXAllocateSlots(TDFXPtr pTDFX, int slots) {
+TDFXAllocateSlots(TDFXPtr pTDFX, int slots)
+{
#ifdef TDFX_DEBUG_FIFO
if (pTDFX->fifoEnd-pTDFX->fifoPtr<pTDFX->fifoSlots)
ErrorF("FIFO overrun\n");
+ if (!pTDFX->syncDone) {
+ ErrorF("Writing to FIFO without sync\n");
+ }
#endif
pTDFX->fifoSlots-=slots;
if (pTDFX->fifoSlots<0) TDFXMakeSpace(pTDFX, slots);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c
new file mode 100644
index 000000000..dbe60a608
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c
@@ -0,0 +1,769 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfx_sli.c,v 1.2 2000/06/17 18:23:23 dawes Exp $ */
+
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+#include "xf86Pci.h"
+#include "tdfx.h"
+
+#define AACLKOUTDEL 0x2
+#define CFGSWAPALGORITHM 0x1
+
+/* #define RD_ABORT_ERROR */
+#define H3VDD
+
+static Bool TDFXDisableSLI(TDFXPtr pTDFX)
+{
+ int i;
+ int v;
+
+ for (i=0; i<pTDFX->numChips; i++) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE,
+ v&~(CFG_SNOOP_MEMBASE0 | CFG_SNOOP_EN | CFG_SNOOP_MEMBASE0_EN |
+ CFG_SNOOP_MEMBASE1_EN | CFG_SNOOP_SLAVE |
+ CFG_SNOOP_FBIINIT_WR_EN | CFG_SWAP_ALGORITHM |
+ CFG_SWAP_QUICK));
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL,
+ v&~(CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN |
+ CFG_SLI_RD_EN));
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL, 0);
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_AACTRL, 0);
+#endif
+ v=pciReadLong(pTDFX->PciTag[i], CFG_AA_LFB_CTRL);
+ pciWriteLong(pTDFX->PciTag[i], CFG_AA_LFB_CTRL,
+ v&~(CFG_AA_LFB_CPU_WR_EN | CFG_AA_LFB_DPTCH_WR_EN |
+ CFG_AA_LFB_RD_EN));
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC,
+ (v&~CFG_VGA_VSYNC_OFFSET) |
+ (0 << CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT) |
+ (0 << CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT) |
+ (0 << CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0, 0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1, 0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2, 0);
+
+ if (pTDFX->numChips>1) {
+ v=pTDFX->readChipLong(pTDFX, i, PCIINIT0);
+ pTDFX->writeChipLong(pTDFX, i, PCIINIT0,
+ (v&~(SST_PCI_DISABLE_IO|SST_PCI_DISABLE_MEM|
+ SST_PCI_RETRY_INTERVAL)) |
+ (0<<SST_PCI_RETRY_INTERVAL_SHIFT) |
+ SST_PCI_FORCE_FB_HIGH);
+ } else {
+ v=pTDFX->readChipLong(pTDFX, i, PCIINIT0);
+ pTDFX->writeChipLong(pTDFX, i, PCIINIT0,
+ (v&~(SST_PCI_DISABLE_IO|SST_PCI_DISABLE_MEM|
+ SST_PCI_RETRY_INTERVAL)) |
+ (0<<SST_PCI_RETRY_INTERVAL_SHIFT));
+ }
+
+#if 0
+ if (i>0) {
+ pTDFX->writeChipLong(pTDFX, i, DACMODE,
+ SST_DAC_DPMS_ON_VSYNC | SST_DAC_DPMS_ON_HSYNC);
+ v=pTDFX->readChipLong(pTDFX, i, VIDPROCCFG);
+ pTDFX->writeChipLong(pTDFX, i, VIDPROCCFG, v&~SST_VIDEO_PROCESSOR_EN);
+ }
+#endif
+ }
+ return TRUE;
+}
+
+Bool TDFXSetupSLI(ScrnInfoPtr pScrn, Bool sliEnable, int aaSamples)
+{
+ TDFXPtr pTDFX;
+ int i, sliLines, sliLinesLog2, nChipsLog2, v;
+ int sli_renderMask, sli_compareMask, sli_scanMask;
+ int sliAnalog, dwFormat;
+
+ pTDFX=TDFXPTR(pScrn);
+ if (pScrn->depth == 24 || pScrn->depth==32) {
+ if ((aaSamples == 4) && (pTDFX->numChips>1)) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_4_ARGB_8888;
+ } else if (aaSamples >= 2) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_2_ARGB_8888;
+ } else {
+ pTDFX->pixelFormat=GR_PIXFMT_ARGB_8888;
+ }
+ } else if (pScrn->depth == 16) {
+ if ((aaSamples == 4) && (pTDFX->numChips>1)) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_4_RGB_565;
+ } else if (aaSamples >= 2) {
+ pTDFX->pixelFormat=GR_PIXFMT_AA_2_RGB_565;
+ } else {
+ pTDFX->pixelFormat=GR_PIXFMT_RGB_565;
+ }
+ } else if (pScrn->depth == 8) {
+ pTDFX->pixelFormat=GR_PIXFMT_I_8;
+ }
+ if (!sliEnable && !aaSamples) { /* Turn off */
+ return TDFXDisableSLI(pTDFX);
+ }
+
+ if (pScrn->virtualY>768) sliLinesLog2=5;
+ else sliLinesLog2=4;
+ sliLines=1<<sliLinesLog2;
+ if (pScrn->virtualY*pScrn->virtualX>1600*1024) sliAnalog=1;
+ else sliAnalog=0;
+ /* XXX We need to avoid SLI in double scan modes somehow */
+
+ switch (pTDFX->numChips) {
+ case 1:
+ nChipsLog2=0;
+ break;
+ case 2:
+ nChipsLog2=1;
+ break;
+ case 4:
+ nChipsLog2=2;
+ break;
+ default:
+ return FALSE;
+ /* XXX Huh? Unsupported configuration */
+ }
+
+ for (i=0; i<pTDFX->numChips; i++) {
+ /* Do we want to set these differently for a VIA board? */
+ v=pTDFX->readChipLong(pTDFX, i, PCIINIT0);
+ v=(v&~(SST_PCI_RETRY_INTERVAL|SST_PCI_FORCE_FB_HIGH)) |
+ SST_PCI_READ_WS | SST_PCI_WRITE_WS |
+ SST_PCI_DISABLE_IO | SST_PCI_DISABLE_MEM |
+ (5<<SST_PCI_RETRY_INTERVAL_SHIFT);
+ pTDFX->writeChipLong(pTDFX, i, PCIINIT0,
+ (v&~(SST_PCI_RETRY_INTERVAL|SST_PCI_FORCE_FB_HIGH)) |
+ SST_PCI_READ_WS | SST_PCI_WRITE_WS |
+ SST_PCI_DISABLE_IO | SST_PCI_DISABLE_MEM |
+ (5<<SST_PCI_RETRY_INTERVAL_SHIFT));
+ v=pTDFX->readChipLong(pTDFX, i, TMUGBEINIT);
+ pTDFX->writeChipLong(pTDFX, i, TMUGBEINIT,
+ (v&~(SST_AA_CLK_DELAY | SST_AA_CLK_INVERT)) |
+ (AACLKOUTDEL<<SST_AA_CLK_DELAY_SHIFT) |
+ SST_AA_CLK_INVERT);
+
+ if (pTDFX->numChips>1) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, v |
+ (CFGSWAPALGORITHM << CFG_SWAPBUFFER_ALGORITHM_SHIFT) |
+ CFG_SWAP_ALGORITHM | ((!i)? CFG_SWAP_MASTER : 0));
+ if (!i) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE,
+ v | CFG_SNOOP_EN);
+ v=pciReadLong(pTDFX->PciTag[i], CFG_PCI_DECODE);
+ } else {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_INIT_ENABLE);
+ v=(v & ~CFG_SNOOP_MEMBASE0) | CFG_SNOOP_EN |
+ CFG_SNOOP_MEMBASE0_EN | CFG_SNOOP_MEMBASE1_EN |
+ CFG_SNOOP_SLAVE | CFG_SNOOP_FBIINIT_WR_EN |
+ (((pTDFX->MMIOAddr[0]>>22)&0x3ff)<<CFG_SNOOP_MEMBASE0_SHIFT) |
+ ((pTDFX->numChips>2)? CFG_SWAP_QUICK : 0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_INIT_ENABLE, v);
+ v=pciReadLong(pTDFX->PciTag[i], CFG_PCI_DECODE);
+ v=(v & ~CFG_SNOOP_MEMBASE1) |
+ ((pTDFX->LinearAddr[0]>>22)&0x3ff)<<CFG_SNOOP_MEMBASE1_SHIFT;
+ pciWriteLong(pTDFX->PciTag[i], CFG_PCI_DECODE, v);
+ }
+ }
+
+ if (sliEnable && aaSamples<4) {
+ /* SLI is on and we're using less than 4 AA samples */
+ sli_renderMask = (pTDFX->numChips-1) << sliLinesLog2;
+ sli_compareMask = i << sliLinesLog2;
+ sli_scanMask = sliLines - 1;
+ v = (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) |
+ (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) |
+ (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) |
+ (nChipsLog2 << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) |
+ CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN;
+#ifndef RD_ABORT_ERROR
+ v|=CFG_SLI_RD_EN;
+#endif
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, v);
+
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL,
+ (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) |
+ (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) |
+ (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) |
+ (nChipsLog2 << SLICTL_3D_NUMCHIPS_LOG2_SHIFT) |
+ SLICTL_3D_EN);
+#endif
+ } else if (!sliEnable && aaSamples) {
+ /* SLI is off and AA is on */
+ sli_renderMask = 0;
+ sli_compareMask = 0;
+ sli_scanMask = 0;
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL,
+ (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) |
+ (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) |
+ (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) |
+ (0x0 << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT));
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL,
+ (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) |
+ (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) |
+ (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) |
+ (0 << SLICTL_3D_NUMCHIPS_LOG2_SHIFT));
+#endif
+ } else {
+ /* SLI is on && aaSamples=4 */
+ sli_renderMask = ((pTDFX->numChips>>1)-1) << sliLinesLog2;
+ sli_compareMask = (i>>1) << sliLinesLog2;
+ sli_scanMask = sliLines - 1;
+ v = (sli_renderMask << CFG_SLI_LFB_RENDERMASK_SHIFT) |
+ (sli_compareMask << CFG_SLI_LFB_COMPAREMASK_SHIFT) |
+ (sli_scanMask << CFG_SLI_LFB_SCANMASK_SHIFT) |
+ ((nChipsLog2-1) << CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT) |
+ CFG_SLI_LFB_CPU_WR_EN | CFG_SLI_LFB_DPTCH_WR_EN;
+#ifndef RD_ABORT_ERROR
+ v|=CFG_SLI_RD_EN;
+#endif
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_LFB_CTRL, v);
+#ifdef H3VDD
+ pTDFX->writeChipLong(pTDFX, i, SST_3D_SLICTRL,
+ (sli_renderMask << SLICTL_3D_RENDERMASK_SHIFT) |
+ (sli_compareMask << SLICTL_3D_COMPAREMASK_SHIFT) |
+ (sli_scanMask << SLICTL_3D_SCANMASK_SHIFT) |
+ ((nChipsLog2-1) << SLICTL_3D_NUMCHIPS_LOG2_SHIFT) |
+ SLICTL_3D_EN);
+#endif
+ }
+
+ TDFXSetLFBConfig(pTDFX);
+ if (pTDFX->cpp==2) dwFormat = CFG_AA_LFB_RD_FORMAT_16BPP;
+ else dwFormat = CFG_AA_LFB_RD_FORMAT_32BPP;
+ if (pTDFX->numChips==2 && !sliEnable && aaSamples==2)
+ dwFormat|=CFG_AA_LFB_RD_DIVIDE_BY_4;
+ /* Thess are wrong, because we don't know where the secondary buffers
+ are located */
+ pTDFX->writeChipLong(pTDFX, i, CFG_AA_LFB_CTRL,
+ (pScrn->videoRam<<10 /* 2nd buf */ << CFG_AA_BASEADDR_SHIFT) |
+ CFG_AA_LFB_CPU_WR_EN | CFG_AA_LFB_DPTCH_WR_EN |
+ CFG_AA_LFB_RD_EN | dwFormat |
+ ((aaSamples==4)?CFG_AA_LFB_RD_DIVIDE_BY_4:0));
+ pTDFX->writeChipLong(pTDFX, i, CFG_AA_ZBUFF_APERTURE,
+ ((pTDFX->depthOffset>>12)<<CFG_AA_DEPTH_BUFFER_BEG_SHIFT) |
+ ((pScrn->videoRam>>2)<<CFG_AA_DEPTH_BUFFER_END_SHIFT));
+
+ if (pTDFX->numChips>1 && i && (aaSamples || sliEnable)) {
+ int vsyncOffsetPixels, vsyncOffsetChars, vsyncOffsetHXtra;
+
+ if (aaSamples || (pTDFX->numChips==4 && sliEnable && aaSamples==4 &&
+ sliAnalog && i==3)) {
+ vsyncOffsetPixels=7;
+ vsyncOffsetChars=4;
+ vsyncOffsetHXtra=0;
+ } else {
+ vsyncOffsetPixels=7;
+ vsyncOffsetChars=5;
+ vsyncOffsetHXtra=0;
+ }
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC,
+ (v&~CFG_VGA_VSYNC_OFFSET) |
+ (vsyncOffsetPixels << CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT) |
+ (vsyncOffsetChars << CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT) |
+ (vsyncOffsetHXtra <<
+ CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT));
+ }
+ if (pTDFX->numChips==1 && aaSamples) {
+ /* 1 chip 2 AA */
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ CFG_VIDEO_OTHERMUX_SEL_PIPE<<CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ 0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT |
+ 0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT |
+ 0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT |
+ 0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ 0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT |
+ 0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT);
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==4 &&
+ !sliAnalog) {
+ /* 2 chips 4 digital AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ (CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==4 && sliAnalog) {
+ /* 2 chips 4 analog AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ (CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && sliEnable && !aaSamples && !sliAnalog) {
+ /* 2 chips 2 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ (CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ ((0x0<<sliLinesLog2) << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips>=2 && sliEnable && !aaSamples && sliAnalog) {
+ /* 2 or 4 chips 2/4 analog SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((i<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && sliEnable && aaSamples==2 && !sliAnalog) {
+ /* 2 chips 2 AA 2 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x1<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==2 && !sliAnalog) {
+ /* 2 chips 2 digital AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==2 && !sliEnable && aaSamples==2 && sliAnalog) {
+ /* 2 chips 2 analog AA */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ }
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (0x0 << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else if (pTDFX->numChips>=2 && sliEnable && aaSamples==2 && sliAnalog) {
+ /* 2 or 4 chips 2 AA 2 or 4 analog SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && !aaSamples && !sliAnalog) {
+ /* 4 chips 4 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_SLI_AAFIFO_COMPARE_INV |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x0<<sliLinesLog2) <<
+ CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && aaSamples==2 && !sliAnalog) {
+ /* 4 chips 2 AA 4 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_SLI_AAFIFO_COMPARE_INV |
+ CFG_DIVIDE_VIDEO_BY_2);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ (0x0 << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (((pTDFX->numChips-1)<<sliLinesLog2) <<
+ CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ ((i<<sliLinesLog2) << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && !sliAnalog) {
+ /* 4 chips 4 AA 2 digital SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else if (i==1 || i==3) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_1);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0xff<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO <<
+ CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0xff << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ } else if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && sliAnalog) {
+ /* 4 chips 4 AA 2 analog SLI */
+ if (!i) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x0<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else if (i==1 || i==3) {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_DAC_HSYNC_TRISTATE |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((((i+1)>>2)<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ } else {
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ CFG_ENHANCED_VIDEO_EN |
+ CFG_ENHANCED_VIDEO_SLV |
+ CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY |
+ (CFG_VIDEO_OTHERMUX_SEL_PIPE <<
+ CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT) |
+ CFG_DIVIDE_VIDEO_BY_4);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL1,
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_FETCH_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_RENDERMASK_CRT_SHIFT) |
+ ((0x1<<sliLinesLog2) << CFG_SLI_COMPAREMASK_CRT_SHIFT));
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL2,
+ (0x0 << CFG_SLI_RENDERMASK_AAFIFO_SHIFT) |
+ (0x0 << CFG_SLI_COMPAREMASK_AAFIFO_SHIFT));
+ }
+ }
+ if (pTDFX->numChips==4 && sliEnable && aaSamples==4 && i==3) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC);
+ pciWriteLong(pTDFX->PciTag[i], CFG_SLI_AA_MISC,
+ v | CFG_AA_LFB_RD_SLV_WAIT);
+ }
+ if (i) {
+ v=pciReadLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0);
+ pciWriteLong(pTDFX->PciTag[i], CFG_VIDEO_CTRL0,
+ v|CFG_VIDPLL_SEL);
+ v=pTDFX->readChipLong(pTDFX, i, MISCINIT1);
+ pTDFX->writeChipLong(pTDFX, i, MISCINIT1, v|SST_POWERDOWN_DAC);
+ }
+ }
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h
index bb82da4cd..ed177cb5a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h,v 1.5 2000/02/15 07:13:44 martin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tdfx/tdfxdefs.h,v 1.6 2000/06/17 00:03:25 martin Exp $ */
/*
Voodoo Banshee driver version 1.0.1
@@ -176,7 +176,184 @@
#define SST_3D_NOP 0
/* 3D Registers */
-#define SST_3D_OFFSET 0x200000
-#define SST_3D_COMMAND SST_3D_OFFSET+0x120
+#define SST_3D_OFFSET 0x200000
+#define SST_3D_COMMAND SST_3D_OFFSET+0x120
+#define SST_3D_SLICTRL SST_3D_OFFSET+0x20C
+#define SST_3D_AACTRL SST_3D_OFFSET+0x210
+#define SST_3D_CHIPMASK SST_3D_OFFSET+0x214
+
+/* NAPALM REGISTERS */
+#define CFG_MEM0BASE 16
+#define CFG_MEM1BASE 20
+#define CFG_INIT_ENABLE 64
+#define CFG_PCI_DECODE 72
+#define CFG_VIDEO_CTRL0 128
+#define CFG_VIDEO_CTRL1 132
+#define CFG_VIDEO_CTRL2 136
+#define CFG_SLI_LFB_CTRL 140
+#define CFG_AA_ZBUFF_APERTURE 144
+#define CFG_AA_LFB_CTRL 148
+#define CFG_SLI_AA_MISC 172
+
+/* Pixel Formats */
+#define GR_PIXFMT_I_8 0x0001
+#define GR_PIXFMT_AI_88 0x0002
+#define GR_PIXFMT_RGB_565 0x0003
+#define GR_PIXFMT_ARGB_1555 0x0004
+#define GR_PIXFMT_ARGB_8888 0x0005
+#define GR_PIXFMT_AA_2_RGB_565 0x0006
+#define GR_PIXFMT_AA_2_ARGB_1555 0x0007
+#define GR_PIXFMT_AA_2_ARGB_8888 0x0008
+#define GR_PIXFMT_AA_4_RGB_565 0x0009
+#define GR_PIXFMT_AA_4_ARGB_1555 0x000a
+#define GR_PIXFMT_AA_4_ARGB_8888 0x000b
+
+/* pciInit0 */
+#define SST_PCI_STALL_ENABLE BIT(0)
+#define SST_PCI_LOWTHRESH_SHIFT 2
+#define SST_PCI_LOWTHRESH (0xF << SST_PCI_LOWTHRESH_SHIFT)
+#define SST_PCI_HARDCODE_BASE BIT(7)
+#define SST_PCI_READ_WS BIT(8)
+#define SST_PCI_WRITE_WS BIT(9)
+#define SST_PCI_DISABLE_IO BIT(11)
+#define SST_PCI_DISABLE_MEM BIT(12)
+#define SST_PCI_RETRY_INTERVAL_SHIFT 13
+#define SST_PCI_RETRY_INTERVAL (0x1F << SST_PCI_RETRY_INTERVAL_SHIFT)
+#define SST_PCI_INTERRUPT_ENABLE BIT(18)
+#define SST_PCI_TIMEOUT_ENABLE BIT(19)
+#define SST_PCI_FORCE_FB_HIGH BIT(26)
+
+#define SST_AA_CLK_INVERT BIT(20)
+#define SST_AA_CLK_DELAY_SHIFT 21
+#define SST_AA_CLK_DELAY (0xF<<SST_AA_CLK_DELAY_SHIFT)
+
+#define CFG_SWAP_ALGORITHM_VSYNC (0x00)
+#define CFG_SWAP_ALGORITHM_SYNCIN (0x01)
+#define CFG_SWAPBUFFER_ALGORITHM_SHIFT (25)
+
+/* CFG_INIT_ENABLE */
+#define CFG_UPDATE_MEMBASE_LSBS BIT(10)
+#define CFG_SNOOP_EN BIT(11)
+#define CFG_SNOOP_MEMBASE0_EN BIT(12)
+#define CFG_SNOOP_MEMBASE1_EN BIT(13)
+#define CFG_SNOOP_SLAVE BIT(14)
+#define CFG_SNOOP_MEMBASE0_SHIFT 15
+#define CFG_SNOOP_MEMBASE0 (0x3FF<<CFG_SNOOP_MEMBASE0_SHIFT)
+#define CFG_SWAP_ALGORITHM BIT(25)
+#define CFG_SWAP_MASTER BIT(26)
+#define CFG_SWAP_QUICK BIT(27)
+#define CFG_MULTI_FUNCTION_DEV BIT(28)
+#define CFG_LFB_RD_CACHE_DISABLE BIT(29)
+#define CFG_SNOOP_FBIINIT_WR_EN BIT(30)
+#define CFG_SNOOP_MEMBASE0_DECODE_SHIFT 10
+#define CFG_SNOOP_MEMBASE0_DECODE (0xF<<CFG_SNOOP_MEMBASE0_DECODE_SHIFT)
+#define CFG_SNOOP_MEMBASE1_DECODE_SHIFT 14
+#define CFG_SNOOP_MEMBASE1_DECODE (0xF<<CFG_SNOOP_MEMBASE1_DECODE_SHIFT)
+#define CFG_SNOOP_MEMBASE1_SHIFT 18
+#define CFG_SNOOP_MEMBASE1 (0x3FF<<CFG_SNOOP_MEMBASE1_SHIFT)
+
+/* CFG_VIDEO_CTRL0 */
+#define CFG_ENHANCED_VIDEO_EN BIT(0)
+#define CFG_ENHANCED_VIDEO_SLV BIT(1)
+#define CFG_VIDEO_TV_OUTPUT_EN BIT(2)
+#define CFG_VIDEO_LOCALMUX_SEL BIT(3)
+#define CFG_VIDEO_LOCALMUX_DESKTOP_PLUS_OVERLAY BIT(3)
+#define CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT 4
+#define CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT 6
+#define CFG_VIDEO_OTHERMUX_SEL_TRUE (0x3<<CFG_VIDEO_OTHERMUX_SEL_TRUE_SHIFT)
+#define CFG_VIDEO_OTHERMUX_SEL_FALSE (0x3<<CFG_VIDEO_OTHERMUX_SEL_FALSE_SHIFT)
+#define CFG_VIDEO_OTHERMUX_SEL_PIPE 0
+#define CFG_VIDEO_OTHERMUX_SEL_PIPE_PLUS_AAFIFO 1
+#define CFG_VIDEO_OTHERMUX_SEL_AAFIFO 2
+#define CFG_SLI_FETCH_COMPARE_INV BIT(8)
+#define CFG_SLI_CRT_COMPARE_INV BIT(9)
+#define CFG_SLI_AAFIFO_COMPARE_INV BIT(10)
+#define CFG_VIDPLL_SEL BIT(11)
+#define CFG_DIVIDE_VIDEO_SHIFT 12
+#define CFG_DIVIDE_VIDEO (0x7<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_1 (0x0<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_2 (0x1<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_4 (0x2<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_8 (0x3<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_16 (0x4<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_DIVIDE_VIDEO_BY_32 (0x5<<CFG_DIVIDE_VIDEO_SHIFT)
+#define CFG_ALWAYS_DRIVE_AA_BUS BIT(15)
+#define CFG_VSYNC_IN_DEL_SHIFT 16
+#define CFG_VSYNC_IN_DEL (0xF<<CFG_VSYNC_IN_DEL_SHIFT)
+#define CFG_DAC_VSYNC_TRISTATE BIT(24)
+#define CFG_DAC_HSYNC_TRISTATE BIT(25)
+
+/* CFG_VIDEO_CTRL1 */
+#define CFG_SLI_RENDERMASK_FETCH_SHIFT 0
+#define CFG_SLI_RENDERMASK_FETCH (0xFF<<CFG_SLI_RENDERMASK_FETCH_SHIFT)
+#define CFG_SLI_COMPAREMASK_FETCH_SHIFT 8
+#define CFG_SLI_COMPAREMASK_FETCH (0xFF<<CFG_SLI_COMPAREMASK_FETCH_SHIFT)
+#define CFG_SLI_RENDERMASK_CRT_SHIFT 16
+#define CFG_SLI_RENDERMASK_CRT (0xFF<<CFG_SLI_RENDERMASK_CRT_SHIFT)
+#define CFG_SLI_COMPAREMASK_CRT_SHIFT 24
+#define CFG_SLI_COMPAREMASK_CRT (0xFF<<CFG_SLI_COMPAREMASK_CRT_SHIFT)
+
+/* CFG_VIDEO_CTRL2 */
+#define CFG_SLI_RENDERMASK_AAFIFO_SHIFT 0
+#define CFG_SLI_RENDERMASK_AAFIFO (0xFF<<CFG_SLI_RENDERMASK_AAFIFO_SHIFT)
+#define CFG_SLI_COMPAREMASK_AAFIFO_SHIFT 8
+#define CFG_SLI_COMPAREMASK_AAFIFO (0xFF<<CFG_SLI_COMPAREMASK_AAFIFO_SHIFT)
+
+/* CFG_SLI_LFB_CTRL */
+#define CFG_SLI_LFB_RENDERMASK_SHIFT 0
+#define CFG_SLI_LFB_RENDERMASK (0xFF<<CFG_SLI_LFB_RENDERMASK_SHIFT)
+#define CFG_SLI_LFB_COMPAREMASK_SHIFT 8
+#define CFG_SLI_LFB_COMPAREMASK (0xFF<<CFG_SLI_LFB_COMPAREMASK_SHIFT)
+#define CFG_SLI_LFB_SCANMASK_SHIFT 16
+#define CFG_SLI_LFB_SCANMASK (0xFF<<CFG_SLI_LFB_SCANMASK_SHIFT)
+#define CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT 24
+#define CFG_SLI_LFB_NUMCHIPS_LOG2 (0x3<<CFG_SLI_LFB_NUMCHIPS_LOG2_SHIFT)
+#define CFG_SLI_LFB_CPU_WR_EN BIT(26)
+#define CFG_SLI_LFB_DPTCH_WR_EN BIT(27)
+#define CFG_SLI_RD_EN BIT(28)
+
+/* CFG_AA_ZBUFF_APERTURE */
+#define CFG_AA_DEPTH_BUFFER_BEG_SHIFT 0
+#define CFG_AA_DEPTH_BUFFER_BEG (0x7FFF<<CFG_AA_DEPTH_BUFFER_BEG_SHIFT)
+#define CFG_AA_DEPTH_BUFFER_END_SHIFT 16
+#define CFG_AA_DEPTH_BUFFER_END (0xFFFF<<CFG_AA_DEPTH_BUFFER_END_SHIFT)
+
+/* CFG_AA_LFB_CTRL */
+#define CFG_AA_BASEADDR_SHIFT 0
+#define CFG_AA_BASEADDR (0x3FFFFFF<<CFG_AA_BASEADDR_SHIFT)
+#define CFG_AA_LFB_CPU_WR_EN BIT(26)
+#define CFG_AA_LFB_DPTCH_WR_EN BIT(27)
+#define CFG_AA_LFB_RD_EN BIT(28)
+#define CFG_AA_LFB_RD_FORMAT_SHIFT 29
+#define CFG_AA_LFB_RD_FORMAT (0x3<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_FORMAT_16BPP (0x0<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_FORMAT_15BPP (0x1<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_FORMAT_32BPP (0x2<<CFG_AA_LFB_RD_FORMAT_SHIFT)
+#define CFG_AA_LFB_RD_DIVIDE_BY_4 BIT(31)
+
+/* CFG_SLI_AA_MISC */
+#define CFG_VGA_VSYNC_OFFSET_SHIFT 0
+#define CFG_VGA_VSYNC_OFFSET (0x1ff<<CFG_VGA_VSYNC_OFFSET_SHIFT)
+#define CFG_VGA_VSYNC_OFFSET_PIXELS_SHIFT 0
+#define CFG_VGA_VSYNC_OFFSET_CHARS_SHIFT 3
+#define CFG_VGA_VSYNC_OFFSET_HXTRA_SHIFT 6
+#define CFG_HOTPLUG_SHIFT 9
+#define CFG_HOTPLUG_TRISTATE (0x0<<CFG_HOTPLUG_SHIFT)
+#define CFG_HOTPLUG_DRIVE0 (0x2<<CFG_HOTPLUG_SHIFT)
+#define CFG_HOTPLUG_DRIVE1 (0x3<<CFG_HOTPLUG_SHIFT)
+#define CFG_AA_LFB_RD_SLV_WAIT BIT(12)
+
+/* SLICTL_3D_CTRL */
+#define SLICTL_3D_RENDERMASK_SHIFT 0
+#define SLICTL_3D_RENDERMASK (0xFF<<SLICTL_3D_RENDERMASK_SHIFT)
+#define SLICTL_3D_COMPAREMASK_SHIFT 8
+#define SLICTL_3D_COMPAREMASK (0xFF<<SLICTL_3D_COMPAREMASK_SHIFT)
+#define SLICTL_3D_SCANMASK_SHIFT 16
+#define SLICTL_3D_SCANMASK (0xFF<<SLICTL_3D_SCANMASK_SHIFT)
+#define SLICTL_3D_NUMCHIPS_LOG2_SHIFT 24
+#define SLICTL_3D_NUMCHIPS_LOG2 (0x3<<SLICTL_3D_NUMCHIPS_LOG2_SHIFT)
+#define SLICTL_3D_EN BIT(26)
+
+#define SST_POWERDOWN_DAC BIT(8)
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c
index 9afad6faf..10acfa712 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c
@@ -22,9 +22,8 @@
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
* Matthew Grossman, <mattg@oz.net> - acceleration and misc fixes
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c,v 1.42 2000/03/06 22:59:32 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tga/tga_driver.c,v 1.45 2000/06/21 17:28:15 dawes Exp $ */
-/* #include "compiler.h" */
/* everybody includes these */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -375,19 +374,15 @@ TGAProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
- pEnt = xf86GetEntityInfo(usedChips[i]);
-
/*
* Check that nothing else has claimed the slots.
*/
- if(pEnt->active) {
- ScrnInfoPtr pScrn;
-
- /* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- pPci = xf86GetPciInfoForEntity(pEnt->index);
+ ScrnInfoPtr pScrn = NULL;
+ /* Allocate a ScrnInfoRec and claim the slot */
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0, pEnt->index,
+ TGAPciChipsets, NULL, NULL,
+ NULL, NULL, NULL))) {
/* Fill in what we can of the ScrnInfoRec */
pScrn->driverVersion = VERSION;
pScrn->driverName = TGA_DRIVER_NAME;
@@ -401,15 +396,9 @@ TGAProbe(DriverPtr drv, int flags)
pScrn->LeaveVT = TGALeaveVT;
pScrn->FreeScreen = TGAFreeScreen;
pScrn->ValidMode = TGAValidMode;
-/* pScrn->device = usedDevs[i]; */
- xf86ConfigActivePciEntity(pScrn, pEnt->index, TGAPciChipsets, NULL,
- NULL, NULL, NULL, NULL);
foundScreen = TRUE;
}
- xfree(pEnt);
}
-/* xfree(usedDevs); */
-/* xfree(usedPci); */
return foundScreen;
}
@@ -872,7 +861,7 @@ TGAPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
clockRanges->minClock = pTga->MinClock;
clockRanges->maxClock = pTga->MaxClock;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp
index 0db87b93a..ad4f3567d 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp,v 1.1 2000/03/03 01:05:44 dawes Exp $
-.TH TRIDENT __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.cpp,v 1.4 2000/06/14 02:13:15 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH TRIDENT __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
trident \- Trident video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""trident"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qtrident\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B trident
is an XFree86 driver for Trident video chips.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h
index 6942c40fb..6d9b3dc33 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h
@@ -21,7 +21,7 @@
*
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h,v 1.20 2000/02/06 20:04:46 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident.h,v 1.24 2000/06/13 02:28:34 dawes Exp $ */
#ifndef _TRIDENT_H_
#define _TRIDENT_H_
@@ -39,7 +39,7 @@ typedef struct {
unsigned char tridentRegs3CE[0x100];
unsigned char tridentRegs3C4[0x100];
unsigned char tridentRegsDAC[0x01];
- unsigned char tridentRegsClock[0x03];
+ unsigned char tridentRegsClock[0x03];
unsigned char DacRegs[0x300];
} TRIDENTRegRec, *TRIDENTRegPtr;
@@ -67,6 +67,7 @@ typedef struct {
Bool NoAccel;
Bool HWCursor;
Bool UsePCIRetry;
+ Bool UsePCIBurst;
Bool UseGERetry;
Bool NewClockCode;
Bool Clipping;
@@ -75,8 +76,13 @@ typedef struct {
Bool HasSGRAM;
Bool MUX;
Bool IsCyber;
+#if 0
+ /* obsolete */
+ Bool CyberShadowSet;
+#endif
Bool CyberShadow;
Bool NoMMIO;
+ Bool MMIOonly;
Bool ShadowFB;
Bool Linear;
DGAModePtr DGAModes;
@@ -97,6 +103,7 @@ typedef struct {
int MCLK;
int dwords;
int height;
+ int lcdMode;
TRIDENTRegRec SavedReg;
TRIDENTRegRec ModeReg;
I2CBusPtr DDC;
@@ -110,11 +117,34 @@ typedef struct {
xf86Int10InfoPtr Int10;
XAAInfoRecPtr AccelInfoRec;
CloseScreenProcPtr CloseScreen;
+ int panelWidth;
+ int panelHeight;
unsigned int (*ddc1Read)(ScrnInfoPtr);
CARD8* XAAScanlineColorExpandBuffers[2];
CARD8* XAAImageScanlineBuffer[1];
} TRIDENTRec, *TRIDENTPtr;
+typedef struct {
+ CARD8 mode;
+ char* display;
+ int clock;
+ int shadow_0;
+ int shadow_3;
+ int shadow_4;
+ int shadow_5;
+ int shadow_6;
+ int shadow_7;
+ int shadow_10;
+ int shadow_11;
+ int shadow_16;
+} tridentLCD;
+
+typedef struct {
+ int x_res;
+ int y_res;
+ int mode;
+} biosMode;
+
/* Prototypes */
Bool TRIDENTClockSelect(ScrnInfoPtr pScrn, int no);
@@ -192,7 +222,8 @@ typedef enum {
BLADE3D,
CYBERBLADEI7,
CYBERBLADEI7D,
- CYBERBLADEI1
+ CYBERBLADEI1,
+ CYBERBLADEI1D
} TRIDENTType;
#define UseMMIO (pTrident->NoMMIO == FALSE)
@@ -215,6 +246,7 @@ typedef enum {
(pTrident->Chipset == CYBERBLADEI7) || \
(pTrident->Chipset == CYBERBLADEI7D) || \
(pTrident->Chipset == CYBERBLADEI1) || \
+ (pTrident->Chipset == CYBERBLADEI1D) || \
(pTrident->Chipset == BLADE3D))
/*
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c
index 892b3737f..251574a01 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c
@@ -21,7 +21,7 @@
*
* Author: Alan Hourihane, alanh@fairlite.demon.co.uk
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c,v 1.18 2000/02/17 21:36:23 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_dac.c,v 1.23 2000/06/23 18:25:58 eich Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -35,6 +35,109 @@
#include "trident.h"
#include "trident_regs.h"
+extern tridentLCD LCD[];
+
+biosMode bios1[] = {
+ { 640, 480, 0x11 }
+};
+
+biosMode bios4[] = {
+ { 320, 200, 0xd },
+ { 640, 200, 0xe },
+ { 640, 350, 0x11 },
+ { 640, 480, 0x12 },
+ { 800, 600, 0x5b },
+ { 1024, 768 , 0x5f },
+ { 1280, 1024, 0x63 },
+ { 1600, 1200, 0x65 }
+};
+
+biosMode bios8[] = {
+ { 320, 200, 0x13 },
+ { 640, 400, 0x52 },
+ { 640, 480, 0x5d },
+ { 720, 480, 0x60 },
+ { 1024, 768, 0x62 },
+ { 1280, 1024, 0x64 },
+ { 1600, 1200, 0x66 }
+};
+
+biosMode bios15[] = {
+ { 640, 400, 0x72 },
+ { 640, 480, 0x74 },
+ { 720, 480, 0x70 },
+ { 800, 600, 0x76 },
+ { 1024, 768, 0x78 }
+};
+
+biosMode bios16[] = {
+ { 640, 400, 0x73 },
+ { 640, 480, 0x75 },
+ { 720, 480, 0x71 },
+ { 800, 600, 0x77 },
+ { 1024, 768, 0x79 }
+};
+
+biosMode bios24[] = {
+ { 640, 400, 0x6b },
+ { 640, 480, 0x6c },
+ { 720, 480, 0x61 },
+ { 800, 600, 0x6d },
+ { 1024, 768, 0x6e }
+};
+
+
+static int
+findMode(int xres, int yres, int depth)
+{
+ int xres_s;
+ int i, size;
+ biosMode *mode;
+
+ switch (depth) {
+ case 1:
+ size = sizeof(bios1) / sizeof(biosMode);
+ mode = bios1;
+ break;
+ case 4:
+ size = sizeof(bios4) / sizeof(biosMode);
+ mode = bios4;
+ break;
+ case 8:
+ size = sizeof(bios8) / sizeof(biosMode);
+ mode = bios8;
+ break;
+ case 15:
+ size = sizeof(bios15) / sizeof(biosMode);
+ mode = bios15;
+ break;
+ case 16:
+ size = sizeof(bios16) / sizeof(biosMode);
+ mode = bios16;
+ break;
+ case 24:
+ size = sizeof(bios24) / sizeof(biosMode);
+ mode = bios24;
+ break;
+ default:
+ return 0;
+ }
+
+ for (i = 0; i < size; i++) {
+ if (xres <= mode[i].x_res) {
+ xres_s = mode[i].x_res;
+ for (; i < size; i++) {
+ if (mode[i].x_res != xres_s)
+ return mode[i-1].mode;
+ if (yres <= mode[i].y_res)
+ return mode[i].mode;
+ }
+ }
+ }
+ return mode[size - 1].mode;
+
+}
+
Bool
TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
{
@@ -43,8 +146,18 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
int vgaIOBase;
int offset = 0;
int clock = mode->Clock;
+ CARD8 protect;
+
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ vgaRegPtr vgaReg = &hwp->ModeReg;
vgaHWGetIOBase(VGAHWPTR(pScrn));
vgaIOBase = VGAHWPTR(pScrn)->IOBase;
+
+
+ /* Unprotect */
+ OUTB(0x3C4, 0x11);
+ protect = INB(0x3C4);
+ OUTB(0x3C5, 0x92);
OUTB(0x3C4, 0x0B); INB(0x3C5); /* Ensure we are in New Mode */
@@ -60,6 +173,7 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
case CYBERBLADEI7:
case CYBERBLADEI7D:
case CYBERBLADEI1:
+ case CYBERBLADEI1D:
case BLADE3D:
OUTB(vgaIOBase + 4, RAMDACTiming);
pReg->tridentRegs3x4[RAMDACTiming] |= 0x0F;
@@ -101,6 +215,15 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
if (pTrident->IsCyber) {
+ Bool LCDActive;
+ Bool ShadowModeActive;
+ int i;
+
+ OUTB(0x3CE, CyberControl);
+ ShadowModeActive = ((INB(0x3CF) & 0x81) == 0x81);
+ OUTB(0x3CE, FPConfig);
+ LCDActive = (INB(0x3CF) & 0x10);
+
OUTB(0x3CE, CyberEnhance);
pReg->tridentRegs3CE[CyberEnhance] = INB(0x3CF) & 0x8F;
if (mode->CrtcVDisplay > 768)
@@ -111,9 +234,111 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
else
if (mode->CrtcVDisplay > 480)
pReg->tridentRegs3CE[CyberEnhance] |= 0x10;
+
OUTB(0x3CE, CyberControl);
- if (!pTrident->CyberShadow)
- pReg->tridentRegs3CE[CyberControl] = INB(0x3CF) & 0x7E;
+ pReg->tridentRegs3CE[CyberControl] = INB(0x3CF);
+
+ OUTB(0x3CE,HorStretch);
+ pReg->tridentRegs3CE[HorStretch] = INB(0x3CF);
+ OUTB(0x3CE,VertStretch);
+ pReg->tridentRegs3CE[VertStretch] = INB(0x3CF);
+
+ if ((!((pReg->tridentRegs3CE[VertStretch] & 1) ||
+ (pReg->tridentRegs3CE[HorStretch] & 1)))
+ && (!LCDActive || ShadowModeActive)) {
+ unsigned char tmp;
+
+ SHADOW_ENABLE(tmp);
+ OUTB(vgaIOBase + 4,0);
+ pReg->tridentRegs3x4[0x0] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,3);
+ pReg->tridentRegs3x4[0x3] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,4);
+ pReg->tridentRegs3x4[0x4] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,5);
+ pReg->tridentRegs3x4[0x5] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,0x6);
+ pReg->tridentRegs3x4[0x6] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,0x7);
+ pReg->tridentRegs3x4[0x7] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,0x10);
+ pReg->tridentRegs3x4[0x10] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,0x11);
+ pReg->tridentRegs3x4[0x11] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,0x16);
+ pReg->tridentRegs3x4[0x16] = INB(vgaIOBase + 5);
+ SHADOW_RESTORE(tmp);
+ xf86DrvMsgVerb(pScrn->scrnIndex,X_INFO,1,"Timing shadow registers:"
+ "0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x 0x%2.2x "
+ "0x%2.2x 0x%2.2x 0x%2.2x\n",pReg->tridentRegs3x4[0],
+ pReg->tridentRegs3x4[3], pReg->tridentRegs3x4[4],
+ pReg->tridentRegs3x4[5], pReg->tridentRegs3x4[6],
+ pReg->tridentRegs3x4[7], pReg->tridentRegs3x4[0x10],
+ pReg->tridentRegs3x4[0x11],
+ pReg->tridentRegs3x4[0x16]);
+ } else {
+ if ((i = pTrident->lcdMode)) {
+ pReg->tridentRegs3x4[0x0] = LCD[i].shadow_0;
+ pReg->tridentRegs3x4[0x3] = LCD[i].shadow_3;
+ pReg->tridentRegs3x4[0x4] = LCD[i].shadow_4;
+ pReg->tridentRegs3x4[0x5] = LCD[i].shadow_5;
+ pReg->tridentRegs3x4[0x6] = LCD[i].shadow_6;
+ pReg->tridentRegs3x4[0x7] = LCD[i].shadow_7;
+ pReg->tridentRegs3x4[0x10] = LCD[i].shadow_10;
+ pReg->tridentRegs3x4[0x11] = LCD[i].shadow_11;
+ pReg->tridentRegs3x4[0x16] = LCD[i].shadow_16;
+ /* Not yet implemented */
+ clock = LCD[i].clock;
+ }
+ }
+ /* copy over common bits from normal VGA */
+
+ pReg->tridentRegs3x4[0x7] &= ~0x52;
+ pReg->tridentRegs3x4[0x7] |= (vgaReg->CRTC[0x7] & 0x52);
+
+ /* disable stretching, enable centering */
+ pReg->tridentRegs3CE[VertStretch] &= 0xFE;
+ pReg->tridentRegs3CE[VertStretch] |= 0x80;
+ pReg->tridentRegs3CE[HorStretch] &= 0xFE;
+ pReg->tridentRegs3CE[HorStretch] |= 0x80;
+
+ {
+ int mul = pScrn->bitsPerPixel >> 3;
+ int val;
+
+ if (!mul) mul = 1;
+
+ /* this is what my BIOS does */
+ val = (pScrn->currentMode->HDisplay * mul / 8) + 16;
+
+ pReg->tridentRegs3x4[PreEndControl] = 2 | ((val >> 8) & 1);
+ pReg->tridentRegs3x4[PreEndFetch] = val & 0xff;
+ }
+#if 0
+ OUTB(vgaIOBase + 4,PreEndControl);
+ pReg->tridentRegs3x4[PreEndControl] = INB(vgaIOBase + 5);
+ OUTB(vgaIOBase + 4,PreEndFetch);
+ pReg->tridentRegs3x4[PreEndFetch] = INB(vgaIOBase + 5);
+#endif
+ /* set mode */
+ pReg->tridentRegs3CE[BiosMode] = findMode(pScrn->currentMode->HDisplay,
+ pScrn->currentMode->VDisplay,
+ pScrn->depth);
+ xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 1, "Setting BIOS Mode: %x\n",
+ pReg->tridentRegs3CE[BiosMode]);
+
+ /* no stretch */
+ pReg->tridentRegs3CE[BiosReg] = 0;
+
+#if 0
+ /* obsolete */
+ if (pTrident->CyberShadowSet) {
+ if (pTrident->CyberShadow) {
+ pReg->tridentRegs3CE[CyberControl] |= 0x81;
+ } else
+ pReg->tridentRegs3CE[CyberControl] &= 0x7E;
+ }
+#endif
}
/* Defaults for all trident chipsets follows */
@@ -174,6 +399,7 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
pReg->tridentRegs3C4[NewMode1] = 0xC0;
+ pReg->tridentRegs3C4[Protection] = 0x92;
if (pTrident->Linear)
pReg->tridentRegs3x4[LinearAddReg] = ((pTrident->FbAddress >> 24) << 6)|
@@ -198,6 +424,8 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
pReg->tridentRegs3x4[Performance] = INB(vgaIOBase + 5) | 0x10;
OUTB(vgaIOBase+ 4, DRAMControl);
pReg->tridentRegs3x4[DRAMControl] = INB(vgaIOBase + 5) | 0x10;
+ if (pTrident->IsCyber && !pTrident->MMIOonly)
+ pReg->tridentRegs3x4[DRAMControl] |= 0x20;
OUTB(vgaIOBase+ 4, AddColReg);
pReg->tridentRegs3x4[AddColReg] = INB(vgaIOBase + 5) & 0xEF;
pReg->tridentRegs3x4[AddColReg] |= (offset & 0x100) >> 4;
@@ -224,8 +452,17 @@ TridentInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
else
pReg->tridentRegs3x4[PCIReg] = INB(vgaIOBase + 5) & 0xF8;
/* Enable PCI Bursting on capable chips */
- if (pTrident->Chipset >= TGUI9660) pReg->tridentRegs3x4[PCIReg] |= 0x06;
-
+ if (pTrident->Chipset >= TGUI9660) {
+ if(pTrident->UsePCIBurst) {
+ pReg->tridentRegs3x4[PCIReg] |= 0x06;
+ } else {
+ pReg->tridentRegs3x4[PCIReg] &= 0xF9;
+ }
+ }
+ /* restore */
+ OUTB(0x3C4, 0x11);
+ OUTB(0x3C5, protect);
+
return(TRUE);
}
@@ -238,13 +475,15 @@ TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg)
vgaHWGetIOBase(VGAHWPTR(pScrn));
vgaIOBase = VGAHWPTR(pScrn)->IOBase;
+ OUTB(0x3C4, Protection);
+ OUTB(0x3C5, 0x92);
/* Goto New Mode */
OUTB(0x3C4, 0x0B);
temp = INB(0x3C5);
/* Unprotect registers */
OUTW(0x3C4, ((0xC0 ^ 0x02) << 8) | NewMode1);
-
+
temp = INB(0x3C8);
temp = INB(0x3C6);
temp = INB(0x3C6);
@@ -272,8 +511,27 @@ TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg)
if (pTrident->Chipset >= PROVIDIA9685) OUTW_3x4(Enhancement0);
if (pTrident->Chipset >= BLADE3D) OUTW_3x4(RAMDACTiming);
if (pTrident->IsCyber) {
+ CARD8 tmp;
+
+ OUTW_3CE(VertStretch);
+ OUTW_3CE(HorStretch);
+ OUTW_3CE(BiosMode);
+ OUTW_3CE(BiosReg);
OUTW_3CE(CyberControl);
OUTW_3CE(CyberEnhance);
+ SHADOW_ENABLE(tmp);
+ OUTW_3x4(0x0);
+ OUTW_3x4(0x3);
+ OUTW_3x4(0x4);
+ OUTW_3x4(0x5);
+ OUTW_3x4(0x6);
+ OUTW_3x4(0x7);
+ OUTW_3x4(0x10);
+ OUTW_3x4(0x11);
+ OUTW_3x4(0x96);
+ SHADOW_RESTORE(tmp);
+ OUTW_3x4(PreEndControl);
+ OUTW_3x4(PreEndFetch);
}
if (Is3Dchip) {
@@ -293,6 +551,8 @@ TridentRestore(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg)
}
OUTB(0x3C2, tridentReg->tridentRegsClock[0x00]);
+ OUTB(0x3C4, Protection);
+ OUTB(0x3C5, tridentReg->tridentRegs3C4[Protection]);
OUTW(0x3C4, ((tridentReg->tridentRegs3C4[NewMode1] ^ 0x02) << 8)| NewMode1);
}
@@ -310,7 +570,8 @@ TridentSave(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg)
temp = INB(0x3C5);
INB_3C4(NewMode1);
-
+ INB_3C4(Protection);
+
/* Unprotect registers */
OUTW(0x3C4, ((0xC0 ^ 0x02) << 8) | NewMode1);
OUTW(vgaIOBase + 4, (0x92 << 8) | NewMode1);
@@ -330,8 +591,26 @@ TridentSave(ScrnInfoPtr pScrn, TRIDENTRegPtr tridentReg)
if (pTrident->Chipset >= PROVIDIA9685) INB_3x4(Enhancement0);
if (pTrident->Chipset >= BLADE3D) INB_3x4(RAMDACTiming);
if (pTrident->IsCyber) {
+ CARD8 tmp;
+ INB_3CE(VertStretch);
+ INB_3CE(HorStretch);
+ INB_3CE(BiosMode);
+ INB_3CE(BiosReg);
INB_3CE(CyberControl);
INB_3CE(CyberEnhance);
+ SHADOW_ENABLE(tmp);
+ INB_3x4(0x0);
+ INB_3x4(0x3);
+ INB_3x4(0x4);
+ INB_3x4(0x5);
+ INB_3x4(0x6);
+ INB_3x4(0x7);
+ INB_3x4(0x10);
+ INB_3x4(0x11);
+ INB_3x4(0x16);
+ SHADOW_RESTORE(tmp);
+ INB_3x4(PreEndControl);
+ INB_3x4(PreEndFetch);
}
/* save cursor registers */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c
index 877b0b4d1..4c1c23537 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c
@@ -28,7 +28,7 @@
* Massimiliano Ghilardi, max@Linuz.sns.it, some fixes to the
* clockchip programming code.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c,v 1.90 2000/03/06 23:54:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_driver.c,v 1.100 2000/06/21 17:28:16 dawes Exp $ */
#include "cfb24_32.h"
@@ -48,6 +48,8 @@
#include "xf86RAC.h"
#include "vbe.h"
+#include "compiler.h"
+
#include "mipointer.h"
#include "mibstore.h"
@@ -95,6 +97,9 @@ static Bool TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
static void TRIDENTEnableMMIO(ScrnInfoPtr pScrn);
static void TRIDENTDisableMMIO(ScrnInfoPtr pScrn);
+static void PC98TRIDENTInit(ScrnInfoPtr pScrn);
+static void PC98TRIDENTEnable(ScrnInfoPtr pScrn);
+static void PC98TRIDENTDisable(ScrnInfoPtr pScrn);
/*
* This is intentionally screen-independent. It indicates the binding
* choice made in the first PreInit.
@@ -152,6 +157,7 @@ static SymTabRec TRIDENTChipsets[] = {
{ CYBERBLADEI7, "cyberbladei7" },
{ CYBERBLADEI7D, "cyberbladei7d" },
{ CYBERBLADEI1, "cyberbladei1" },
+ { CYBERBLADEI1D, "cyberbladei1d" },
{ -1, NULL }
};
@@ -182,6 +188,7 @@ static PciChipsets TRIDENTPciChipsets[] = {
{ CYBERBLADEI7, PCI_CHIP_8400, RES_SHARED_VGA },
{ CYBERBLADEI7D, PCI_CHIP_8420, RES_SHARED_VGA },
{ CYBERBLADEI1, PCI_CHIP_8500, RES_SHARED_VGA },
+ { CYBERBLADEI1D, PCI_CHIP_8520, RES_SHARED_VGA },
{ -1, -1, RES_UNDEFINED }
};
@@ -194,8 +201,13 @@ typedef enum {
OPTION_SETMCLK,
OPTION_MUX_THRESHOLD,
OPTION_SHADOW_FB,
+ OPTION_MMIO_ONLY,
+#if 0
+ /* obsolete */
OPTION_CYBER_SHADOW,
- OPTION_NOMMIO
+#endif
+ OPTION_NOMMIO,
+ OPTION_NOPCIBURST
} TRIDENTOpts;
static OptionInfoRec TRIDENTOptions[] = {
@@ -206,8 +218,13 @@ static OptionInfoRec TRIDENTOptions[] = {
{ OPTION_SETMCLK, "SetMClk", OPTV_FREQ, {0}, FALSE },
{ OPTION_MUX_THRESHOLD, "MUXThreshold", OPTV_INTEGER, {0}, FALSE },
{ OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
+#if 0
+ /* obsolete */
{ OPTION_CYBER_SHADOW, "CyberShadow", OPTV_BOOLEAN, {0}, FALSE },
+#endif
{ OPTION_NOMMIO, "NoMMIO", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_NOPCIBURST, "NoPciBurst", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_MMIO_ONLY, "MMIOonly", OPTV_BOOLEAN, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -276,6 +293,7 @@ static int ClockLimit[] = {
230000,
230000,
230000,
+ 230000,
};
static int ClockLimit16bpp[] = {
@@ -310,6 +328,7 @@ static int ClockLimit16bpp[] = {
230000,
230000,
230000,
+ 230000,
};
static int ClockLimit24bpp[] = {
@@ -344,6 +363,7 @@ static int ClockLimit24bpp[] = {
115000,
115000,
115000,
+ 115000,
};
static int ClockLimit32bpp[] = {
@@ -378,9 +398,24 @@ static int ClockLimit32bpp[] = {
115000,
115000,
115000,
+ 115000,
+};
+
+/*
+ * These are fixed modelines for all physical display dimensions the
+ * chipsets supports on FPs. Most of them are not tested yet.
+ */
+tridentLCD LCD[] = {
+ { 0,"640x480",25200,0x5f,0x82,0x54,0x80,0xb,0x3e,0xea,0x8c,0xb},
+ { 1,"800x600",40000,0x7f,0x82,0x6b,0x1b,0x72,0xf8,0x58,0x8c,0x72},
+ { 2,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96},
+ { 3,"1024x768",65000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96},
+ { 4,"1280x1024",108000,0xa3,0x6,0x8f,0xa0,0x24,0xf5,0x0f,0x25,0x96},
+ { 5,"1024x600",50500 ,0xa3,0x6,0x8f,0xa0,0xb,0x3e,0xea,0x8c,0xb},
+ { 0xff,"", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};
-static const char *xaaSymbols[] = {
+ static const char *xaaSymbols[] = {
"XAADestroyInfoRec",
"XAACreateInfoRec",
"XAAHelpPatternROP",
@@ -805,33 +840,31 @@ TRIDENTProbe(DriverPtr drv, int flags)
numDevSections, drv, &usedChips);
if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn;
-
- /* Allocate a ScrnInfoRec and claim the slot */
- pScrn = xf86AllocateScreen(drv, 0);
-
- /* Fill in what we can of the ScrnInfoRec */
- pScrn->driverVersion = VERSION;
- pScrn->driverName = TRIDENT_DRIVER_NAME;
- pScrn->name = TRIDENT_NAME;
- pScrn->Probe = TRIDENTProbe;
- pScrn->PreInit = TRIDENTPreInit;
- pScrn->ScreenInit = TRIDENTScreenInit;
- pScrn->SwitchMode = TRIDENTSwitchMode;
- pScrn->AdjustFrame = TRIDENTAdjustFrame;
- pScrn->EnterVT = TRIDENTEnterVT;
- pScrn->LeaveVT = TRIDENTLeaveVT;
- pScrn->FreeScreen = TRIDENTFreeScreen;
- pScrn->ValidMode = TRIDENTValidMode;
- foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn, usedChips[i], TRIDENTPciChipsets,
- NULL, NULL, NULL, NULL, NULL);
- }
- xfree(usedChips);
- }
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+
+ if ((pScrn = xf86ConfigPciEntity(pScrn, 0,usedChips[i],
+ TRIDENTPciChipsets, NULL,
+ NULL, NULL, NULL, NULL))) {
+ /* Fill in what we can of the ScrnInfoRec */
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = TRIDENT_DRIVER_NAME;
+ pScrn->name = TRIDENT_NAME;
+ pScrn->Probe = TRIDENTProbe;
+ pScrn->PreInit = TRIDENTPreInit;
+ pScrn->ScreenInit = TRIDENTScreenInit;
+ pScrn->SwitchMode = TRIDENTSwitchMode;
+ pScrn->AdjustFrame = TRIDENTAdjustFrame;
+ pScrn->EnterVT = TRIDENTEnterVT;
+ pScrn->LeaveVT = TRIDENTLeaveVT;
+ pScrn->FreeScreen = TRIDENTFreeScreen;
+ pScrn->ValidMode = TRIDENTValidMode;
+ foundScreen = TRUE;
+ }
+ }
+ }
}
/* Isa Bus */
@@ -842,27 +875,29 @@ TRIDENTProbe(DriverPtr drv, int flags)
if (numUsed > 0) {
if (flags & PROBE_DETECT)
foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
-
- pScrn->driverVersion = VERSION;
- pScrn->driverName = TRIDENT_DRIVER_NAME;
- pScrn->name = TRIDENT_NAME;
- pScrn->Probe = TRIDENTProbe;
- pScrn->PreInit = TRIDENTPreInit;
- pScrn->ScreenInit = TRIDENTScreenInit;
- pScrn->SwitchMode = TRIDENTSwitchMode;
- pScrn->AdjustFrame = TRIDENTAdjustFrame;
- pScrn->EnterVT = TRIDENTEnterVT;
- pScrn->LeaveVT = TRIDENTLeaveVT;
- pScrn->FreeScreen = TRIDENTFreeScreen;
- pScrn->ValidMode = TRIDENTValidMode;
- foundScreen = TRUE;
- xf86ConfigActiveIsaEntity(pScrn,usedChips[i],TRIDENTISAchipsets,
- NULL,NULL,NULL,NULL,NULL);
+ else for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn,0,usedChips[i],
+ TRIDENTISAchipsets,NULL,
+ NULL,NULL,NULL,NULL))) {
+ pScrn->driverVersion = VERSION;
+ pScrn->driverName = TRIDENT_DRIVER_NAME;
+ pScrn->name = TRIDENT_NAME;
+ pScrn->Probe = TRIDENTProbe;
+ pScrn->PreInit = TRIDENTPreInit;
+ pScrn->ScreenInit = TRIDENTScreenInit;
+ pScrn->SwitchMode = TRIDENTSwitchMode;
+ pScrn->AdjustFrame = TRIDENTAdjustFrame;
+ pScrn->EnterVT = TRIDENTEnterVT;
+ pScrn->LeaveVT = TRIDENTLeaveVT;
+ pScrn->FreeScreen = TRIDENTFreeScreen;
+ pScrn->ValidMode = TRIDENTValidMode;
+ foundScreen = TRUE;
+ }
}
xfree(usedChips);
}
+
if (devSections)
xfree(devSections);
return foundScreen;
@@ -929,15 +964,13 @@ TRIDENTRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
}
}
-extern xf86MonPtr ConfiguredMonitor;
-
void
TRIDENTProbeDDC(ScrnInfoPtr pScrn, int index)
{
vbeInfoPtr pVbe;
if (xf86LoadSubModule(pScrn, "vbe")) {
pVbe = VBEInit(NULL,index);
- ConfiguredMonitor = vbeDoEDID(pVbe);
+ ConfiguredMonitor = vbeDoEDID(pVbe, NULL);
}
}
@@ -958,7 +991,8 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
ClockRangePtr clockRanges;
char *mod = NULL;
const char *Sym = "";
-
+ Bool ddcLoaded = FALSE;
+
/* Allocate the TRIDENTRec driverPrivate */
if (!TRIDENTGetRec(pScrn)) {
return FALSE;
@@ -986,7 +1020,7 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
pTrident->Linear = FALSE;
}
}
-
+
if (flags & PROBE_DETECT) {
TRIDENTProbeDDC(pScrn, pTrident->pEnt->index);
return TRUE;
@@ -1050,9 +1084,6 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
xf86SetOperatingState(RES_SHARED_VGA, pTrident->pEnt->index, ResUnusedOpr);
- pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
- pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
-
/* The ramdac module should be loaded here when needed */
if (!xf86LoadSubModule(pScrn, "ramdac"))
return FALSE;
@@ -1134,14 +1165,33 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
pTrident->UsePCIRetry = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI retry enabled\n");
}
- if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_CYBER_SHADOW, FALSE)) {
- pTrident->CyberShadow = TRUE;
- xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Cyber Shadow Registers enabled\n");
+ pTrident->UsePCIBurst = TRUE;
+ if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_NOPCIBURST, FALSE)) {
+ pTrident->UsePCIBurst = FALSE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "PCI Burst disbled\n");
}
+#if 0
+ /* obsolete */
+ if ((pTrident->CyberShadowSet = xf86GetOptValBool(TRIDENTOptions,
+ OPTION_CYBER_SHADOW,
+ &pTrident->CyberShadow)))
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Cyber Shadow Registers %s\n",
+ pTrident->CyberShadow?"enabled":"disabled");
+#endif
if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_NOMMIO, FALSE)) {
pTrident->NoMMIO = TRUE;
xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MMIO Disabled\n");
}
+ if (xf86ReturnOptValBool(TRIDENTOptions, OPTION_MMIO_ONLY, FALSE)) {
+ if (pTrident->NoMMIO)
+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "MMIO only cannot be set"
+ " with NoMMIO\n");
+ else {
+ pTrident->MMIOonly = TRUE;
+ xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "MMIO Disabled\n");
+ }
+ }
+
pTrident->MUXThreshold = 80000; /* 100MHz */
if (xf86GetOptValInteger(TRIDENTOptions, OPTION_MUX_THRESHOLD,
&pTrident->MUXThreshold)) {
@@ -1221,11 +1271,39 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
return FALSE;
}
+ /* Initialize VBE if possible
+ * Don't move this past MMIO enable!!
+ * PIO access will be blocked
+ * when MMIO is turned on!
+ */
+ if (xf86LoadSubModule(pScrn, "vbe")) {
+ xf86MonPtr pMon;
+ pMon = vbeDoEDID(VBEInit(pTrident->Int10,
+ pTrident->pEnt->index), NULL);
+ if (pMon) {
+ if (!xf86LoadSubModule(pScrn, "ddc")) {
+ TRIDENTFreeRec(pScrn);
+ return FALSE;
+ } else {
+ xf86LoaderReqSymLists(ddcSymbols, NULL);
+ xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon));
+ ddcLoaded = TRUE;
+ }
+ }
+
+ }
+
if (IsPciCard && UseMMIO) {
if (!TRIDENTMapMem(pScrn))
return FALSE;
TRIDENTEnableMMIO(pScrn);
+ /*
+ * PC-9821 PCI Trident Card Magic Setup!!
+ */
+ if (IsPciCard && xf86IsPc98()) {
+ PC98TRIDENTInit(pScrn);
+ }
}
OUTB(0x3C4, RevisionID); revision = INB(0x3C5);
@@ -1557,6 +1635,20 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
pTrident->NewClockCode = TRUE;
pTrident->frequency = NTSC;
break;
+ case CYBERBLADEI1D:
+ pTrident->ddc1Read = Tridentddc1Read;
+ if ((INB(vgaIOBase + 5) & 0x0C) == 0x08)
+ ramtype = "SDRAM";
+ if ((INB(vgaIOBase + 5) & 0x0C) == 0x0C) {
+ pTrident->HasSGRAM = TRUE;
+ ramtype = "SGRAM";
+ }
+ pTrident->IsCyber = TRUE;
+ Support24bpp = TRUE;
+ chipset = "CyberBlade/DSTN/i1";
+ pTrident->NewClockCode = TRUE;
+ pTrident->frequency = NTSC;
+ break;
}
if (!pScrn->progClock) {
@@ -1617,6 +1709,8 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
break;
case 0x07:
pScrn->videoRam = 2048;
+ if (pTrident->Chipset == CYBER9525DVD)
+ pScrn->videoRam = 2560;
break;
case 0x0F:
pScrn->videoRam = 4096;
@@ -1630,10 +1724,24 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
}
}
-
xf86DrvMsg(pScrn->scrnIndex, from, "VideoRAM: %d kByte\n",
pScrn->videoRam);
+ if (pTrident->IsCyber) {
+ unsigned char tmp;
+
+ pTrident->lcdMode = 0xff;
+ OUTB(0x3CE,0x41);
+ tmp = INB(0x3CF);
+ for (i = 0; LCD[i].mode != 0xff; i++) {
+ if (LCD[i].mode == (tmp & 0x7)) {
+ pTrident->lcdMode = i;
+ xf86DrvMsg(pScrn->scrnIndex, X_PROBED,"%s Panel %s found\n",
+ (tmp & 0x8) ? "DSTN" : "TFT", LCD[i].display);
+ }
+ }
+ }
+
pTrident->MCLK = 0;
mclk = CalculateMCLK(pScrn);
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Memory Clock is %3.2f MHz\n", mclk);
@@ -1698,7 +1806,7 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
* Setup the ClockRanges, which describe what clock ranges are available,
* and what sort of modes they can be used for.
*/
- clockRanges = xnfalloc(sizeof(ClockRange));
+ clockRanges = xnfcalloc(sizeof(ClockRange), 1);
clockRanges->next = NULL;
if (!pScrn->progClock) {
if (pScrn->bitsPerPixel == 16)
@@ -1878,33 +1986,32 @@ TRIDENTPreInit(ScrnInfoPtr pScrn, int flags)
/* Load DDC if needed */
/* This gives us DDC1 - we should be able to get DDC2B using i2c */
- if (!xf86LoadSubModule(pScrn, "ddc")) {
- if (IsPciCard && UseMMIO) {
- TRIDENTDisableMMIO(pScrn);
- TRIDENTUnmapMem(pScrn);
+
+ if (! ddcLoaded)
+ if (!xf86LoadSubModule(pScrn, "ddc")) {
+ if (IsPciCard && UseMMIO) {
+ TRIDENTDisableMMIO(pScrn);
+ TRIDENTUnmapMem(pScrn);
+ }
+ TRIDENTFreeRec(pScrn);
+ return FALSE;
}
- TRIDENTFreeRec(pScrn);
- return FALSE;
- }
+
xf86LoaderReqSymLists(ddcSymbols, NULL);
- /* Initialize DDC1 if possible */
- if (IsPrimaryCard) {
- if (pTrident->ddc1Read) {
- if (xf86LoadSubModule(pScrn, "vbe")) {
- xf86MonPtr pMon;
- pMon = vbeDoEDID(VBEInit(NULL,pTrident->pEnt->index));
- xf86SetDDCproperties(pScrn,xf86PrintEDID(pMon));
- }
- }
- }
-
if (IsPciCard && UseMMIO) {
TRIDENTDisableMMIO(pScrn);
TRIDENTUnmapMem(pScrn);
}
pTrident->FbMapSize = pScrn->videoRam * 1024;
+
+ pScrn->racMemFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
+
+ if (pTrident->IsCyber && pTrident->MMIOonly)
+ pScrn->racIoFlags = 0;
+ else
+ pScrn->racIoFlags = RAC_FB | RAC_COLORMAP | RAC_CURSOR | RAC_VIEWPORT;
return TRUE;
}
@@ -2031,6 +2138,7 @@ TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
case CYBERBLADEI7:
case CYBERBLADEI7D:
case CYBERBLADEI1:
+ case CYBERBLADEI1D:
case CYBER9520:
case CYBER9525DVD:
case CYBER9540:
@@ -2058,6 +2166,19 @@ TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
return FALSE;
pScrn->vtSema = TRUE;
+ /* Program the registers */
+ vgaHWProtect(pScrn, TRUE);
+ vgaReg = &hwp->ModeReg;
+ tridentReg = &pTrident->ModeReg;
+
+ vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
+
+ /*
+ * TridentInit() has to modified registers
+ * that have already been set by vgaHWRestore().
+ * So we call it _after_ vgaHWRestore() has
+ * programmed these registers.
+ */
if (pScrn->progClock) {
if (!TridentInit(pScrn, mode))
return FALSE;
@@ -2066,13 +2187,6 @@ TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
return FALSE;
}
- /* Program the registers */
- vgaHWProtect(pScrn, TRUE);
- vgaReg = &hwp->ModeReg;
- tridentReg = &pTrident->ModeReg;
-
- vgaHWRestore(pScrn, vgaReg, VGA_SR_MODE);
-
if (pScrn->progClock)
TridentRestore(pScrn, tridentReg);
else
@@ -2080,6 +2194,9 @@ TRIDENTModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
vgaHWProtect(pScrn, FALSE);
+ if (xf86IsPc98())
+ PC98TRIDENTEnable(pScrn);
+
return TRUE;
}
@@ -2304,6 +2421,7 @@ TRIDENTScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
if ((pTrident->Chipset == CYBERBLADEI7) ||
(pTrident->Chipset == CYBERBLADEI7D) ||
(pTrident->Chipset == CYBERBLADEI1) ||
+ (pTrident->Chipset == CYBERBLADEI1D) ||
(pTrident->Chipset == BLADE3D))
BladeAccelInit(pScreen);
else
@@ -2475,6 +2593,10 @@ TRIDENTLeaveVT(int scrnIndex, int flags)
TRIDENTRestore(pScrn);
vgaHWLock(hwp);
+
+ if (xf86IsPc98())
+ PC98TRIDENTDisable(pScrn);
+
if (IsPciCard && UseMMIO) TRIDENTDisableMMIO(pScrn);
}
@@ -2492,6 +2614,9 @@ TRIDENTCloseScreen(int scrnIndex, ScreenPtr pScreen)
vgaHWPtr hwp = VGAHWPTR(pScrn);
TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ if (xf86IsPc98())
+ PC98TRIDENTDisable(pScrn);
+
if (pScrn->vtSema) {
TRIDENTRestore(pScrn);
vgaHWLock(hwp);
@@ -2550,6 +2675,13 @@ TRIDENTEnableMMIO(ScrnInfoPtr pScrn)
CARD8 temp = 0;
TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ /*
+ * Skip MMIO Enable in PC-9821 PCI Trident Card!!
+ * Because of lack of non PCI VGA port
+ */
+ if (IsPciCard && xf86IsPc98())
+ return;
+
/* Goto New Mode */
outb(0x3C4, 0x0B); inb(0x3C5);
@@ -2573,6 +2705,13 @@ TRIDENTDisableMMIO(ScrnInfoPtr pScrn)
CARD8 temp = 0;
TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ /*
+ * Skip MMIO Disable in PC-9821 PCI Trident Card!!
+ * Because of lack of non PCI VGA port
+ */
+ if (IsPciCard && xf86IsPc98())
+ return;
+
/* Goto New Mode */
OUTB(0x3C4, 0x0B); temp = INB(0x3C5);
@@ -2589,3 +2728,164 @@ TRIDENTDisableMMIO(ScrnInfoPtr pScrn)
outb(0x3C4, NewMode1);
outb(0x3C5, temp);
}
+/* Initialize VGA Block on Trident(PC-98x1 Only) */
+static void
+PC98TRIDENTInit(ScrnInfoPtr pScrn)
+{
+ TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ vgaHWPtr hwp = VGAHWPTR(pScrn);
+ CARD8 temp = 0;
+
+ vgaHWProtect(pScrn, TRUE);
+
+ /* Video SusSystem Enable */
+ temp = INB(0x3CC);
+ OUTB(0x3C2, temp | 0xC3);
+ /* Switch Old */
+ OUTB(0x3C4, 0x0B); temp = INB(0x3C5);
+ OUTW(0x3C4, 0x0B | (temp << 8));
+ /* Select Configuration Port 1 */
+ OUTB(0x3C4, 0x0E); temp = INB(0x3C5);
+ OUTW(0x3C4, 0x0E | ((temp | 0x20) << 8));
+
+ OUTB(0x3C4, 0x0c);
+ if((INB(0x3C5) & 0x10) == 0x10)
+ {
+ OUTB(0x3C4, 0x0E | (temp << 8));
+ OUTB(0x94, 0x00);
+ OUTB(0x102, 0x01);
+ OUTB(0x94, 0x20);
+ temp = INB(0x3C3);
+ OUTB(0x3C3, temp | 0x01);
+ } else {
+ OUTB(0x3C4, 0x0E | (temp << 8));
+ OUTB(0x46E8, 0x10);
+ OUTB(0x102, 0x01);
+ OUTB(0x46E8, 0x08);
+ }
+
+ INB(0x3DA);
+ OUTB(0x3C0,0x10);
+ OUTB(0x3C0,0x41);
+
+ /* Register Unlock */
+ vgaHWUnlock(hwp);
+ OUTB(0x3C4, 0x0B); temp = INB(0x3C5); /* Switch New */
+ OUTB(0x3C4, 0x0E); temp = INB(0x3C5);
+ OUTW(0x3C4, 0x0E | ((temp | 0x80) << 8));
+
+ /* For Speed Up [Facoor 2 at Xengine] */
+ OUTW(0x3D4, 0x3820); /* Command FIFO Register */
+ OUTW(0x3D4, 0x2020); /* Command FIFO Register */
+ /* Latency Control Registers 0x30 - 0x32 */
+ /* Parameter Range 0x00 - 0x0F */
+ /* Tune these parameter to avoid GE Timeout */
+ OUTW(0x3D4, 0x0E30); /* Display Queue Latency Control */
+ /* 8bpp GE No Timeout Parameter 0x0D - 0x0F for PC-9821Xa7 TGUi9680 */
+ OUTW(0x3D4, 0x0031); /* Frame Buffer Latency Control */
+ OUTW(0x3D4, 0x0032); /* Display & Frame Buffer Latency Control */
+ OUTW(0x3D4, 0x213B); /* Clock and Tuning */
+
+ /* MCLK Init */
+ OUTB(0x43C6, 0xAF); OUTB(0x43C7, 0x00); /* 80.0MHz */
+#if 0
+ /* Sample MCLKs */
+ OUTB(0x43C6, 0xAF); OUTB(0x43C7, 0x00); /* 80.0MHz */
+ OUTB(0x43C6, 0xA7); OUTB(0x43C7, 0x00); /* 77.0MHz */
+ OUTB(0x43C6, 0x8E); OUTB(0x43C7, 0x00); /* 75.0MHz */
+ OUTB(0x43C6, 0x86); OUTB(0x43C7, 0x00); /* 72.0MHz */
+ OUTB(0x43C6, 0x8F); OUTB(0x43C7, 0x00); /* 67.2MHz */
+ OUTB(0x43C6, 0xD5); OUTB(0x43C7, 0x02); /* 61.6MHz */
+#endif
+
+ /* Register Lock */
+ OUTB(0x3C4, 0x0B); temp = INB(0x3C5); /* Switch New */
+ OUTB(0x3C4, 0x0E); temp = INB(0x3C5);
+ OUTW(0x3C4, 0x0E | ((temp & 0x7F) << 8));
+ vgaHWLock(hwp);
+
+ vgaHWProtect(pScrn, FALSE);
+}
+
+static void
+PC98TRIDENTEnable(ScrnInfoPtr pScrn)
+{
+ TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ CARD8 temp = 0;
+
+ outb(0x68, 0x0E);
+ outb(0x6A, 0x07);
+ outb(0x6A, 0x8F);
+ outb(0x6A, 0x06);
+
+ vgaHWProtect(pScrn, TRUE);
+
+ OUTB(0x3D4, 0x23); temp = INB(0x3D5);
+ OUTW(0x3D4, 0x23 | ((temp & 0xDF) << 8));
+
+ OUTB(0x3D4, 0x29); temp = INB(0x3D5);
+ OUTW(0x3D4, 0x29 | ((temp | 0x04) << 8));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp | 0x06));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp | 0x08));
+
+ OUTB(0x3CE, 0x23); temp = INB(0x3CF);
+ OUTW(0x3CE, 0x23 | ((temp & 0xFC) << 8));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp | 0x01));
+
+ OUTB(0x3C4, 0x01); temp = INB(0x3C5);
+ OUTW(0x3C4, 0x01 | ((temp & 0xEF) << 8));
+
+ vgaHWProtect(pScrn, FALSE);
+
+ outb(0xFAC, 0x02);
+}
+
+static void
+PC98TRIDENTDisable(ScrnInfoPtr pScrn){
+ TRIDENTPtr pTrident = TRIDENTPTR(pScrn);
+ CARD8 temp = 0;
+
+ outb(0xFAC, 0x00);
+
+ vgaHWProtect(pScrn, TRUE);
+
+ OUTB(0x3C4, 0x01); temp = INB(0x3C5);
+ OUTW(0x3C4, 0x01 | ((temp | 0x10) << 8));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp & 0xFE));
+
+ OUTB(0x3CE, 0x23); temp = INB(0x3CF);
+ OUTW(0x3CE, 0x23 | (((temp & 0xFC) | 0x01) << 8));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp & 0xFD));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp & 0xCF));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp & 0xF7));
+
+ OUTB(0x83C8, 0x04); temp = INB(0x83c6);
+ OUTB(0x83C8, 0x04); OUTB(0x83c6, (temp & 0xFB));
+
+ OUTB(0x3D4, 0x29); temp = INB(0x3D5);
+ OUTW(0x3D4, 0x29 | ((temp & 0xFB) << 8));
+
+ OUTB(0x3D4, 0x23); temp = INB(0x3D5);
+ OUTW(0x3D4, 0x23 | ((temp | 0x20) << 8));
+
+ vgaHWProtect(pScrn, FALSE);
+
+ outb(0x6A, 0x07);
+ outb(0x6A, 0x8E);
+ outb(0x6A, 0x06);
+ outb(0x68, 0x0F);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h
index fec032227..e0d5bb863 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h
@@ -21,7 +21,7 @@
*
* Author: Alan Hourihane, alanh@fairlite.demon.co.uk
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h,v 1.11 1999/10/24 18:01:47 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/trident/trident_regs.h,v 1.12 2000/06/06 18:07:37 eich Exp $ */
#define DEBUG 1
@@ -89,12 +89,20 @@
#define TVinterface 0xC0
#define TVMode 0xC1
#define ClockControl 0xCF
+#define PreEndControl 0x56
+#define PreEndFetch 0x57
+
/* 3CE */
#define MiscExtFunc 0x0F
#define MiscIntContReg 0x2F
#define CyberControl 0x30
#define CyberEnhance 0x31
+#define FPConfig 0x34
+#define VertStretch 0x52
+#define HorStretch 0x53
+#define BiosMode 0x5c
+#define BiosReg 0x5d
/* Graphics Engine for 9420/9430 */
@@ -209,15 +217,15 @@
((((CARD32)(y)&0xFFFF) << 16) | ((CARD32)(x) & 0xffff))
#define TRIDENT_WRITE_REG(v,r) \
- (*(volatile CARD32 *)((char*)pTrident->IOBase+(r)) = (v))
+ MMIO_OUT32(pTrident->IOBase,(r),(v))
#define TRIDENT_READ_REG(r) \
- *(volatile CARD32 *)((char*)pTrident->IOBase+(r))
+ MMIO_IN32(pTrident->IOBase,(r))
#define OUTB(addr, data) \
{ \
if (IsPciCard && UseMMIO) { \
- (*(volatile CARD8 *)(pTrident->IOBase + (addr)) = (data)); \
+ MMIO_OUT8(pTrident->IOBase, addr, data); \
} else { \
outb(addr, data); \
} \
@@ -225,12 +233,12 @@
#define OUTW(addr, data) \
{ \
if (IsPciCard && UseMMIO) { \
- (*(volatile CARD16 *)(pTrident->IOBase + (addr)) = (data)); \
+ MMIO_OUT16(pTrident->IOBase, addr, data); \
} else { \
outw(addr, data); \
} \
}
-#define INB(addr) ((IsPciCard && UseMMIO) ? *(volatile CARD8 *)(pTrident->IOBase + addr) : inb(addr))
+#define INB(addr) ((IsPciCard && UseMMIO) ? MMIO_IN8(pTrident->IOBase, addr) : inb(addr))
#define OUTW_3C4(reg) \
OUTW(0x3C4, (tridentReg->tridentRegs3C4[reg])<<8 | (reg))
@@ -249,85 +257,98 @@
tridentReg->tridentRegs3CE[reg] = INB(0x3CF);
#define BLTBUSY(b) \
- (b = (*(volatile CARD8 *)(pTrident->IOBase+GER_STATUS)) & GE_BUSY)
+ (b = MMIO_IN8(pTrident->IOBase,GER_STATUS) & GE_BUSY)
#define OLDBLTBUSY(b) \
- (b = (*(volatile CARD8 *)(pTrident->IOBase+OLDGER_STATUS))&GE_BUSY)
+ (b = MMIO_IN8(pTrident->IOBase,OLDGER_STATUS) & GE_BUSY)
#define IMAGE_STATUS(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + IMAGE_GE_STATUS) = (c))
+ MMIO_OUT32(pTrident->IOBase, IMAGE_GE_STATUS, (c))
#define TGUI_STATUS(c) \
- (*(volatile CARD8 *)(pTrident->IOBase + GER_STATUS) = (c))
+ MMIO_OUT8(pTrident->IOBase, GER_STATUS, (c))
#define OLDTGUI_STATUS(c) \
- (*(volatile CARD8 *)(pTrident->IOBase + OLDGER_STATUS) = (c))
+ MMIO_OUT8(pTrident->IOBase, OLDGER_STATUS, (c))
#define TGUI_OPERMODE(c) \
- (*(volatile CARD16 *)(pTrident->IOBase + GER_OPERMODE) = (c))
+ MMIO_OUT16(pTrident->IOBase, GER_OPERMODE, (c))
/* XXX */
#define OLDTGUI_OPERMODE(c) \
{ \
- *(CARD16 *)(pTrident->IOBase + OLDGER_MWIDTH) = \
- vga256InfoRec.displayWidth - 1; \
- *(CARD8 *)(pTrident->IOBase + OLDGER_MFORMAT) = c; \
+ MMIO_OUT16(pTrident->IOBase, OLDGER_MWIDTH, \
+ vga256InfoRec.displayWidth - 1); \
+ MMIO_OUT8(pTrident->IOBase, OLDGER_MFORMAT, (c)); \
}
#define TGUI_FCOLOUR(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_FCOLOUR) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_FCOLOUR, (c))
#define TGUI_FPATCOL(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_FPATCOL) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_FPATCOL, (c))
#define OLDTGUI_FCOLOUR(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + OLDGER_FCOLOUR) = (c))
+ MMIO_OUT32(pTrident->IOBase, OLDGER_FCOLOUR, (c))
#define TGUI_BCOLOUR(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_BCOLOUR) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_BCOLOUR, (c))
#define TGUI_BPATCOL(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_BPATCOL) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_BPATCOL, (c))
#define OLDTGUI_BCOLOUR(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + OLDGER_BCOLOUR) = (c))
+ MMIO_OUT32(pTrident->IOBase, OLDGER_BCOLOUR, (c))
#define IMAGE_DRAWENV(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + IMAGE_GE_DRAWENV) = (c))
+ MMIO_OUT32(pTrident->IOBase, IMAGE_GE_DRAWENV, (c))
#define TGUI_DRAWFLAG(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_DRAWFLAG) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_DRAWFLAG, (c))
#define OLDTGUI_STYLE(c) \
- (*(volatile CARD16 *)(pTrident->IOBase + OLDGER_STYLE) = (c))
+ MMIO_OUT16(pTrident->IOBase, OLDGER_STYLE, (c))
#define TGUI_FMIX(c) \
- (*(volatile CARD8 *)(pTrident->IOBase + GER_FMIX) = (c))
+ MMIO_OUT8(pTrident->IOBase, GER_FMIX, (c))
#define OLDTGUI_FMIX(c) \
- (*(volatile CARD8 *)(pTrident->IOBase + OLDGER_FMIX) = (c))
+ MMIO_OUT8(pTrident->IOBase, OLDGER_FMIX, (c))
#define OLDTGUI_BMIX(c) \
- (*(volatile CARD8 *)(pTrident->IOBase + OLDGER_BMIX) = (c))
+ MMIO_OUT8(pTrident->IOBase, OLDGER_BMIX, (c))
#define TGUI_DIM_XY(w,h) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_DIM_XY) = XY_MERGE((w)-1,(h)-1))
+ MMIO_OUT32(pTrident->IOBase, GER_DIM_XY, XY_MERGE((w)-1,(h)-1))
#define TGUI_STYLE(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_STYLE) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_STYLE, (c))
#define OLDTGUI_DIMXY(w,h) \
- (*(volatile CARD32 *)(pTrident->IOBase + OLDGER_DIMXY) = XY_MERGE((w)-1,(h)-1))
+ MMIO_OUT32(pTrident->IOBase, OLDGER_DIMXY, XY_MERGE((w)-1,(h)-1))
#define TGUI_SRC_XY(x,y) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_SRC_XY) = XY_MERGE(x,y))
+ MMIO_OUT32(pTrident->IOBase, GER_SRC_XY, XY_MERGE(x,y))
#define TGUI_DEST_XY(x,y) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_DEST_XY) = XY_MERGE(x,y))
+ MMIO_OUT32(pTrident->IOBase, GER_DEST_XY, XY_MERGE(x,y))
#define OLDTGUI_DESTXY(x,y) \
- (*(volatile CARD32 *)(pTrident->IOBase + OLDGER_DESTXY) = XY_MERGE(x,y))
+ MMIO_OUT32(pTrident->IOBase, OLDGER_DESTXY, XY_MERGE(x,y))
#define OLDTGUI_DESTLINEAR(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + OLDGER_DESTLINEAR) = (c))
+ MMIO_OUT32(pTrident->IOBase, OLDGER_DESTLINEAR, (c))
#define TGUI_SRCCLIP_XY(x,y) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_SRCCLIP_XY) = XY_MERGE(x,y))
+ MMIO_OUT32(pTrident->IOBase, GER_SRCCLIP_XY, XY_MERGE(x,y))
#define TGUI_DSTCLIP_XY(x,y) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_DSTCLIP_XY) = XY_MERGE(x,y))
+ MMIO_OUT32(pTrident->IOBase, GER_DSTCLIP_XY, XY_MERGE(x,y))
#define TGUI_PATLOC(addr) \
- (*(volatile CARD16 *)(pTrident->IOBase + GER_PATLOC) = (addr))
+ MMIO_OUT16(pTrident->IOBase, GER_PATLOC, (addr))
#define TGUI_CKEY(c) \
- (*(volatile CARD32 *)(pTrident->IOBase + GER_CKEY) = (c))
+ MMIO_OUT32(pTrident->IOBase, GER_CKEY, (c))
#define IMAGEBUSY(b) \
- (b = (*(volatile CARD32 *)(pTrident->IOBase+IMAGE_GE_STATUS)) & 0xF0000000)
+ (b = MMIO_IN32(pTrident->IOBase,IMAGE_GE_STATUS) & 0xF0000000)
#define BLADEBUSY(b) \
- (b = (*(volatile CARD32 *)(pTrident->IOBase+BLADE_GE_STATUS)) & 0xFE800000)
+ (b = MMIO_IN32(pTrident->IOBase,BLADE_GE_STATUS) & 0xFE800000)
#define IMAGE_OUT(addr, c) \
- (*(volatile CARD32 *)(pTrident->IOBase + addr) = (c))
+ MMIO_OUT32(pTrident->IOBase, addr, (c))
#define BLADE_OUT(addr, c) \
- (*(volatile CARD32 *)(pTrident->IOBase + addr) = (c))
+ MMIO_OUT32(pTrident->IOBase, addr, (c))
#define TGUI_OUTL(addr, c) \
- (*(volatile CARD32 *)(pTrident->IOBase + addr) = (c))
+ MMIO_OUT32(pTrident->IOBase, addr, (c))
#define TGUI_COMMAND(c) \
- (*(volatile CARD8 *)(pTrident->IOBase + GER_COMMAND) = (c))
+ MMIO_OUT8(pTrident->IOBase, GER_COMMAND, (c))
#define OLDTGUI_COMMAND(c) \
do { \
OLDTGUI_OPERMODE(GE_OP); \
OLDTGUISync(); \
- *(volatile CARD32 *)(pTrident->IOBase + OLDGER_COMMAND) = (c); \
+ MMIO_OUT32(pTrident->IOBase, OLDGER_COMMAND, (c)); \
} while (0)
+
+/* Cyber FP support */
+#define SHADOW_ENABLE(oldval) \
+ do {\
+ OUTB(0x3CE, CyberControl); \
+ oldval = INB(0x3CF);\
+ OUTB(0x3CF,oldval | (1 << 6));\
+ } while (0)
+#define SHADOW_RESTORE(val) \
+ do {\
+ OUTB(0x3CE, CyberControl); \
+ OUTB(0x3CF,tmp); \
+ } while (0);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp
index 7ed52b27f..5d0cbfe5b 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp,v 1.1 2000/03/03 01:05:44 dawes Exp $
-.TH TSENG __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng.cpp,v 1.4 2000/06/14 02:13:15 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH TSENG __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
tseng \- Tseng Labs video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""tseng"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qtseng\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B tseng
is an XFree86 driver for Tseng Labs video cards.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c
index 5363a44ef..012e35ab7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c
@@ -1,5 +1,5 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c,v 1.14 1999/06/12 07:18:58 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_clock.c,v 1.15 2000/06/21 17:28:16 dawes Exp $ */
@@ -175,7 +175,7 @@ void tseng_clock_setup(ScrnInfoPtr pScrn)
*
* First, we set up the default case, and modify it later if needed.
*/
- pTseng->clockRange[0] = xnfalloc(sizeof(ClockRange));
+ pTseng->clockRange[0] = xnfcalloc(sizeof(ClockRange), 1);
pTseng->clockRange[0]->next = NULL;
pTseng->clockRange[0]->minClock = pTseng->MinClock;
pTseng->clockRange[0]->maxClock = dacspeed;
@@ -199,7 +199,7 @@ void tseng_clock_setup(ScrnInfoPtr pScrn)
(!(DAC_is_GenDAC && pTseng->NoClockchip)) ) {
pTseng->clockRange[0]->maxClock = MAX_TSENG_CLOCK;
/* set up 2nd clock range for PIXMUX modes */
- pTseng->clockRange[1] = xnfalloc(sizeof(ClockRange));
+ pTseng->clockRange[1] = xnfcalloc(sizeof(ClockRange), 1);
pTseng->clockRange[0]->next = pTseng->clockRange[1];
pTseng->clockRange[1]->next = NULL;
pTseng->clockRange[1]->minClock = 75000;
@@ -225,7 +225,7 @@ void tseng_clock_setup(ScrnInfoPtr pScrn)
pTseng->clockRange[0]->ClockDivFactor = 1;
/* in addition, 16-bit DACs can also transport 2 bytes per clock */
if (pTseng->DacInfo.DacPort16) {
- pTseng->clockRange[1] = xnfalloc(sizeof(ClockRange));
+ pTseng->clockRange[1] = xnfcalloc(sizeof(ClockRange), 1);
pTseng->clockRange[0]->next = pTseng->clockRange[1];
pTseng->clockRange[1]->next = NULL;
pTseng->clockRange[1]->minClock = pTseng->MinClock;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c
index d16ce7819..c839cde9a 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c
@@ -1,5 +1,5 @@
/*
- * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c,v 1.68 2000/03/06 23:54:15 dawes Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/drivers/tseng/tseng_driver.c,v 1.69 2000/04/17 16:30:09 eich Exp $
*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
*
@@ -96,7 +96,7 @@ static ModeStatus TsengValidMode(int scrnIndex, DisplayModePtr mode,
static Bool TsengMapMem(ScrnInfoPtr pScrn);
static Bool TsengUnmapMem(ScrnInfoPtr pScrn);
static void TsengSave(ScrnInfoPtr pScrn);
-static void TsengRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TsengRegPtr tsengReg);
+static void TsengRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TsengRegPtr tsengReg, int flags);
static Bool TsengModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode);
static void TsengUnlock(void);
static void TsengLock(void);
@@ -516,13 +516,15 @@ TsengProbe(DriverPtr drv, int flags)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
/* Allocate a ScrnInfoRec */
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
- TsengAssignFPtr(pScrn);
- xf86ConfigActivePciEntity(pScrn,usedChips[i],TsengPciChipsets,
- NULL,NULL,NULL,NULL,NULL);
- foundScreen = TRUE;
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
+ TsengPciChipsets,NULL,
+ NULL,NULL,NULL,NULL))) {
+ TsengAssignFPtr(pScrn);
+ foundScreen = TRUE;
+ }
+ xfree(usedChips);
}
- xfree(usedChips);
}
}
@@ -534,11 +536,13 @@ TsengProbe(DriverPtr drv, int flags)
if (flags & PROBE_DETECT)
foundScreen = TRUE;
else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
- TsengAssignFPtr(pScrn);
- foundScreen = TRUE;
- xf86ConfigActiveIsaEntity(pScrn,usedChips[i],TsengIsaChipsets,
- NULL,NULL,NULL,NULL,NULL);
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn,0,usedChips[i],
+ TsengIsaChipsets,NULL,
+ NULL,NULL,NULL,NULL))) {
+ TsengAssignFPtr(pScrn);
+ foundScreen = TRUE;
+ }
}
xfree(usedChips);
}
@@ -1458,6 +1462,7 @@ TsengPreInit(ScrnInfoPtr pScrn, int flags)
if (flags & PROBE_DETECT) return FALSE;
PDEBUG(" TsengPreInit\n");
+
/*
* Note: This function is only called once at server startup, and
* not at the start of each server generation. This means that
@@ -2193,7 +2198,8 @@ TsengLeaveVT(int scrnIndex, int flags)
#endif
PDEBUG(" TsengLeaveVT\n");
- TsengRestore(pScrn, &(VGAHWPTR(pScrn)->SavedReg), &pTseng->SavedReg);
+ TsengRestore(pScrn, &(VGAHWPTR(pScrn)->SavedReg),
+ &pTseng->SavedReg,VGA_SR_ALL);
TsengLock();
vgaHWLock(VGAHWPTR(pScrn));
@@ -2208,7 +2214,8 @@ TsengCloseScreen(int scrnIndex, ScreenPtr pScreen)
PDEBUG(" TsengCloseScreen\n");
if (pScrn->vtSema) {
- TsengRestore(pScrn, &(VGAHWPTR(pScrn)->SavedReg), &(pTseng->SavedReg));
+ TsengRestore(pScrn, &(VGAHWPTR(pScrn)->SavedReg),
+ &(pTseng->SavedReg),VGA_SR_ALL);
TsengUnmapMem(pScrn);
}
if (pTseng->AccelInfoRec)
@@ -2656,7 +2663,7 @@ TsengModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode)
}
vgaHWUnlock(hwp); /* TODO: is this needed (tsengEnterVT does this) */
/* Program the registers */
- TsengRestore(pScrn, &hwp->ModeReg, new);
+ TsengRestore(pScrn, &hwp->ModeReg, new, VGA_SR_MODE);
return TRUE;
}
@@ -2916,7 +2923,8 @@ TsengSave(ScrnInfoPtr pScrn)
*/
static void
-TsengRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TsengRegPtr tsengReg)
+TsengRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TsengRegPtr tsengReg,
+ int flags)
{
vgaHWPtr hwp;
TsengPtr pTseng;
@@ -3053,7 +3061,7 @@ TsengRestore(ScrnInfoPtr pScrn, vgaRegPtr vgaReg, TsengRegPtr tsengReg)
outw(iobase + 4, (tsengReg->ExtCRTC[0x3F] << 8) | 0x3F);
outw(iobase + 4, (tsengReg->ExtCRTC[0x30] << 8) | 0x30);
outw(iobase + 4, (tsengReg->ExtCRTC[0x31] << 8) | 0x31);
- vgaHWRestore(pScrn, vgaReg, VGA_SR_ALL); /* TODO: does this belong HERE, in the middle? */
+ vgaHWRestore(pScrn, vgaReg, flags); /* TODO: does this belong HERE, in the middle? */
outw(0x3C4, (tsengReg->ExtTS[6] << 8) | 0x06);
outw(0x3C4, (tsengReg->ExtTS[7] << 8) | 0x07);
tmp = inb(iobase + 0x0A); /* reset flip-flop */
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c b/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c
index 6ef875e7f..065df36c3 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c
@@ -2,7 +2,7 @@
* video4linux Xv Driver
* based on Michael Schimek's permedia 2 driver.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c,v 1.16 2000/02/22 02:00:54 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.c,v 1.19 2000/06/13 02:28:34 dawes Exp $ */
#include "videodev.h"
#include "xf86.h"
@@ -25,7 +25,11 @@ typedef unsigned long ulong;
/* XXX Lots of xalloc() calls don't check for failure. */
-#define DEBUG(x) (x)
+#if 0
+# define DEBUG(x) (x)
+#else
+# define DEBUG(x)
+#endif
static void V4LIdentify(int flags);
static Bool V4LProbe(DriverPtr drv, int flags);
@@ -100,20 +104,27 @@ v4lSetup(pointer module, pointer opts, int *errmaj, int *errmin)
#endif
+#define VIDEO_OFF 0 /* really off */
+#define VIDEO_RGB 1 /* rgb overlay (directly to fb) */
+#define VIDEO_YUV 2 /* yuv overlay (to offscreen memory + hw scaling) */
+#define VIDEO_RECLIP 3 /* temporarly off, window clipping changes */
+
typedef struct _PortPrivRec {
ScrnInfoPtr pScrn;
FBAreaPtr pFBArea[2];
- int VideoOn; /* yes/no */
+ int VideoOn;
Bool StreamOn;
/* file handle */
int fd;
char devname[16];
int useCount;
+ struct video_capability cap;
- /* overlay */
- struct video_buffer ov_fbuf;
- struct video_window ov_win;
+ /* RGB overlay */
+ struct video_buffer rgb_fbuf;
+ struct video_window rgb_win;
+ int rgbpalette;
/* attributes */
struct video_picture pict;
@@ -121,6 +132,17 @@ typedef struct _PortPrivRec {
XF86VideoEncodingPtr enc;
int nenc,cenc;
+
+ /* yuv to offscreen */
+ XF86OffscreenImagePtr format; /* list */
+ int nformat; /* # if list entries */
+ XF86OffscreenImagePtr myfmt; /* which one is YUY2 (packed) */
+ int have_yuv;
+
+ int yuv_width,yuv_height;
+ XF86SurfacePtr surface;
+ struct video_buffer yuv_fbuf;
+ struct video_window yuv_win;
} PortPrivRec, *PortPrivPtr;
#define XV_ENCODING "XV_ENCODING"
@@ -143,8 +165,24 @@ InputVideoFormats[] = {
{ 15, TrueColor },
{ 16, TrueColor },
{ 24, TrueColor },
+ { 32, TrueColor },
};
+#define V4L_ATTR (sizeof(Attributes) / sizeof(XF86AttributeRec))
+
+static XF86AttributeRec Attributes[] = {
+ {XvSettable | XvGettable, -1000, 1000, XV_ENCODING},
+ {XvSettable | XvGettable, -1000, 1000, XV_BRIGHTNESS},
+ {XvSettable | XvGettable, -1000, 1000, XV_CONTRAST},
+ {XvSettable | XvGettable, -1000, 1000, XV_SATURATION},
+ {XvSettable | XvGettable, -1000, 1000, XV_HUE},
+ {XvSettable | XvGettable, 0, 1, XV_MUTE},
+ {XvSettable | XvGettable, 0, 16*1000, XV_FREQ},
+};
+static XF86AttributeRec VolumeAttr =
+ {XvSettable | XvGettable, -1000, 1000, XV_VOLUME};
+
+
/* ---------------------------------------------------------------------- */
/* forward decl */
@@ -172,14 +210,26 @@ static int V4lOpenDevice(PortPrivPtr pPPriv, ScrnInfoPtr pScrn)
if (pPPriv->fd == -1) {
pPPriv->fd = open(pPPriv->devname, O_RDWR, 0);
- pPPriv->ov_fbuf.width = pScrn->virtualX;
- pPPriv->ov_fbuf.height = pScrn->virtualY;
- pPPriv->ov_fbuf.depth = pScrn->bitsPerPixel;
- pPPriv->ov_fbuf.bytesperline = pScrn->displayWidth * ((pScrn->bitsPerPixel + 7)/8);
- pPPriv->ov_fbuf.base = (pointer)(pScrn->memPhysBase + pScrn->fbOffset);
+ pPPriv->rgb_fbuf.width = pScrn->virtualX;
+ pPPriv->rgb_fbuf.height = pScrn->virtualY;
+ pPPriv->rgb_fbuf.depth = pScrn->bitsPerPixel;
+ pPPriv->rgb_fbuf.bytesperline = pScrn->displayWidth * ((pScrn->bitsPerPixel + 7)/8);
+ pPPriv->rgb_fbuf.base = (pointer)(pScrn->memPhysBase + pScrn->fbOffset);
- if (-1 == ioctl(pPPriv->fd,VIDIOCSFBUF,&(pPPriv->ov_fbuf)))
- perror("ioctl VIDIOCSFBUF");
+ switch (pScrn->bitsPerPixel) {
+ case 16:
+ if (pScrn->weight.green == 5)
+ pPPriv->rgbpalette = VIDEO_PALETTE_RGB555;
+ else
+ pPPriv->rgbpalette = VIDEO_PALETTE_RGB565;
+ break;
+ case 24:
+ pPPriv->rgbpalette = VIDEO_PALETTE_RGB24;
+ break;
+ case 32:
+ pPPriv->rgbpalette = VIDEO_PALETTE_RGB32;
+ break;
+ }
}
if (pPPriv->fd == -1)
@@ -200,7 +250,6 @@ static void V4lCloseDevice(PortPrivPtr pPPriv)
}
}
-
static int
V4lPutVideo(ScrnInfoPtr pScrn,
short vid_x, short vid_y, short drw_x, short drw_y,
@@ -210,13 +259,133 @@ V4lPutVideo(ScrnInfoPtr pScrn,
PortPrivPtr pPPriv = (PortPrivPtr) data;
struct video_clip *clip;
BoxPtr pBox;
+ RegionRec newReg;
+ BoxRec newBox;
unsigned int i,dx,dy,dw,dh;
+ int width,height;
int one=1;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV\n"));
+ /* Open a file handle to the device */
+ if (VIDEO_OFF == pPPriv->VideoOn) {
+ if (V4lOpenDevice(pPPriv, pScrn))
+ return BadAccess;
+ }
+
+ if (pPPriv->have_yuv) {
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV yuv\n"));
+ width = pPPriv->enc[pPPriv->cenc].width;
+ height = pPPriv->enc[pPPriv->cenc].height/2; /* no interlace */
+ if (drw_w < width)
+ width = drw_w;
+ if (drw_h < height)
+ height = drw_h;
+ if ((height != pPPriv->yuv_height) || (width != pPPriv->yuv_width)) {
+ /* new size -- free old surface */
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface resize\n"));
+ if (pPPriv->surface) {
+ pPPriv->VideoOn = VIDEO_OFF;
+ pPPriv->myfmt->stop(pPPriv->surface);
+ pPPriv->myfmt->free_surface(pPPriv->surface);
+ xfree(pPPriv->surface);
+ pPPriv->surface = NULL;
+ }
+ pPPriv->yuv_width = width;
+ pPPriv->yuv_height = height;
+ }
+ if (!pPPriv->surface) {
+ /* allocate + setup offscreen surface */
+ if (NULL == (pPPriv->surface = xalloc(sizeof(XF86SurfaceRec))))
+ return FALSE;
+ if (Success != pPPriv->myfmt->alloc_surface
+ (pScrn,pPPriv->myfmt->image->id,
+ pPPriv->yuv_width,pPPriv->yuv_height,pPPriv->surface)) {
+ xfree(pPPriv->surface);
+ pPPriv->surface = NULL;
+ goto fallback_to_rgb;
+ }
+ pPPriv->yuv_fbuf.width = pPPriv->surface->width;
+ pPPriv->yuv_fbuf.height = pPPriv->surface->height;
+ pPPriv->yuv_fbuf.depth = 16;
+ pPPriv->yuv_fbuf.bytesperline = pPPriv->surface->pitches[0];
+ pPPriv->yuv_fbuf.base =
+ (pointer)(pScrn->memPhysBase + pPPriv->surface->offsets[0]);
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " surface: %p+%d = %p, %dx%d, pitch %d\n",
+ pScrn->memPhysBase,pPPriv->surface->offsets[0],
+ pScrn->memPhysBase+pPPriv->surface->offsets[0],
+ pPPriv->surface->width,pPPriv->surface->height,
+ pPPriv->surface->pitches[0]));
+ pPPriv->yuv_win.width = pPPriv->surface->width;
+ pPPriv->yuv_win.height = pPPriv->surface->height;
+ }
+
+ /* program driver */
+ if (VIDEO_YUV != pPPriv->VideoOn) {
+ if (-1 == ioctl(pPPriv->fd,VIDIOCSFBUF,&(pPPriv->yuv_fbuf)))
+ perror("ioctl VIDIOCSFBUF");
+ if (-1 == ioctl(pPPriv->fd,VIDIOCGPICT,&pPPriv->pict))
+ perror("ioctl VIDIOCGPICT");
+ pPPriv->pict.palette = VIDEO_PALETTE_YUV422;
+ if (-1 == ioctl(pPPriv->fd,VIDIOCSPICT,&pPPriv->pict))
+ perror("ioctl VIDIOCSPICT");
+ if (-1 == ioctl(pPPriv->fd,VIDIOCSWIN,&(pPPriv->yuv_win)))
+ perror("ioctl VIDIOCSWIN");
+ if (-1 == ioctl(pPPriv->fd, VIDIOCCAPTURE, &one))
+ perror("ioctl VIDIOCCAPTURE(1)");
+ }
+
+ if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
+ /* invert cliplist */
+ newBox.x1 = drw_x;
+ newBox.y1 = drw_y;
+ newBox.x2 = drw_x + drw_w;
+ newBox.y2 = drw_y + drw_h;
+
+ if (pPPriv->myfmt->flags & VIDEO_CLIP_TO_VIEWPORT) {
+ /* trim to the viewport */
+ if(newBox.x1 < pScrn->frameX0)
+ newBox.x1 = pScrn->frameX0;
+ if(newBox.x2 > pScrn->frameX1)
+ newBox.x2 = pScrn->frameX1;
+
+ if(newBox.y1 < pScrn->frameY0)
+ newBox.y1 = pScrn->frameY0;
+ if(newBox.y2 > pScrn->frameY1)
+ newBox.y2 = pScrn->frameY1;
+ }
+
+ REGION_INIT(pScrn->pScreen, &newReg, &newBox, 1);
+ REGION_SUBTRACT(pScrn->pScreen, &newReg, &newReg, clipBoxes);
+ clipBoxes = &newReg;
+ }
+
+ /* start overlay */
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
+ "over: - %d,%d -> %d,%d (%dx%d) (yuv=%dx%d)\n",
+ drw_x, drw_y,
+ drw_x+drw_w, drw_y+drw_h,
+ drw_w, drw_h,
+ pPPriv->surface->width,pPPriv->surface->height));
+ pPPriv->myfmt->display(pPPriv->surface,
+ 0, 0, drw_x, drw_y,
+ pPPriv->surface->width,
+ pPPriv->surface->height,
+ drw_w, drw_h,
+ clipBoxes);
+ if (0 == (pPPriv->myfmt->flags & VIDEO_INVERT_CLIPLIST)) {
+ REGION_UNINIT(pScrn->pScreen, &newReg);
+ }
+ pPPriv->VideoOn = VIDEO_YUV;
+ return Success;
+ }
+
+ fallback_to_rgb:
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/PV rgb\n"));
/* FIXME: vid-* is ignored for now, not supported by v4l */
- V4lQueryBestSize(pScrn, 0, vid_w, vid_h, drw_w, drw_h, &dw, &dh, data);
+ dw = (drw_w < pPPriv->enc[pPPriv->cenc].width) ?
+ drw_w : pPPriv->enc[pPPriv->cenc].width;
+ dh = (drw_h < pPPriv->enc[pPPriv->cenc].height) ?
+ drw_h : pPPriv->enc[pPPriv->cenc].height;
/* if the window is too big, center the video */
dx = drw_x + (drw_w - dw)/2;
dy = drw_y + (drw_h - dh)/2;
@@ -230,25 +399,25 @@ V4lPutVideo(ScrnInfoPtr pScrn,
drw_w,drw_h,drw_x,drw_y));
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, " use: %dx%d+%d+%d\n",
dw,dh,dx,dy));
- pPPriv->ov_win.x = dx;
- pPPriv->ov_win.y = dy;
- pPPriv->ov_win.width = dw;
- pPPriv->ov_win.height = dh;
- pPPriv->ov_win.flags = 0;
+ pPPriv->rgb_win.x = dx;
+ pPPriv->rgb_win.y = dy;
+ pPPriv->rgb_win.width = dw;
+ pPPriv->rgb_win.height = dh;
+ pPPriv->rgb_win.flags = 0;
/* clipping */
- if (pPPriv->ov_win.clips) {
- xfree(pPPriv->ov_win.clips);
- pPPriv->ov_win.clips = NULL;
+ if (pPPriv->rgb_win.clips) {
+ xfree(pPPriv->rgb_win.clips);
+ pPPriv->rgb_win.clips = NULL;
}
- pPPriv->ov_win.clipcount = REGION_NUM_RECTS(clipBoxes);
+ pPPriv->rgb_win.clipcount = REGION_NUM_RECTS(clipBoxes);
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2," clip: have #%d\n",
- pPPriv->ov_win.clipcount));
- if (0 != pPPriv->ov_win.clipcount) {
- pPPriv->ov_win.clips = xalloc(pPPriv->ov_win.clipcount*sizeof(struct video_clip));
- memset(pPPriv->ov_win.clips,0,pPPriv->ov_win.clipcount*sizeof(struct video_clip));
+ pPPriv->rgb_win.clipcount));
+ if (0 != pPPriv->rgb_win.clipcount) {
+ pPPriv->rgb_win.clips = xalloc(pPPriv->rgb_win.clipcount*sizeof(struct video_clip));
+ memset(pPPriv->rgb_win.clips,0,pPPriv->rgb_win.clipcount*sizeof(struct video_clip));
pBox = REGION_RECTS(clipBoxes);
- clip = pPPriv->ov_win.clips;
+ clip = pPPriv->rgb_win.clips;
for (i = 0; i < REGION_NUM_RECTS(clipBoxes); i++, pBox++, clip++) {
clip->x = pBox->x1 - dx;
clip->y = pBox->y1 - dy;
@@ -257,20 +426,21 @@ V4lPutVideo(ScrnInfoPtr pScrn,
}
}
- /* Open a file handle to the device */
-
- if (!pPPriv->VideoOn) {
- if (V4lOpenDevice(pPPriv, pScrn))
- return BadAccess;
- pPPriv->VideoOn = 1;
- }
-
/* start */
-
- if (-1 == ioctl(pPPriv->fd,VIDIOCSWIN,&(pPPriv->ov_win)))
+ if (VIDEO_RGB != pPPriv->VideoOn) {
+ if (-1 == ioctl(pPPriv->fd,VIDIOCSFBUF,&(pPPriv->rgb_fbuf)))
+ perror("ioctl VIDIOCSFBUF");
+ if (-1 == ioctl(pPPriv->fd,VIDIOCGPICT,&pPPriv->pict))
+ perror("ioctl VIDIOCGPICT");
+ pPPriv->pict.palette = pPPriv->rgbpalette;
+ if (-1 == ioctl(pPPriv->fd,VIDIOCSPICT,&pPPriv->pict))
+ perror("ioctl VIDIOCSPICT");
+ }
+ if (-1 == ioctl(pPPriv->fd,VIDIOCSWIN,&(pPPriv->rgb_win)))
perror("ioctl VIDIOCSWIN");
if (-1 == ioctl(pPPriv->fd, VIDIOCCAPTURE, &one))
perror("ioctl VIDIOCCAPTURE(1)");
+ pPPriv->VideoOn = VIDEO_RGB;
return Success;
}
@@ -295,18 +465,34 @@ V4lStopVideo(ScrnInfoPtr pScrn, pointer data, Bool exit)
PortPrivPtr pPPriv = (PortPrivPtr) data;
int zero=0;
- if (!pPPriv->VideoOn) {
+ if (VIDEO_OFF == pPPriv->VideoOn) {
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2,
"Xv/StopVideo called with video already off\n"));
return;
}
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/StopVideo\n"));
-
- if (-1 == ioctl(pPPriv->fd, VIDIOCCAPTURE, &zero))
- perror("ioctl VIDIOCCAPTURE(0)");
-
- V4lCloseDevice(pPPriv);
- pPPriv->VideoOn = 0;
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/StopVideo exit=%d\n",exit));
+
+ if (!exit) {
+ /* just reclipping, we have to stop DMA transfers to the visible screen */
+ if (VIDEO_RGB == pPPriv->VideoOn) {
+ if (-1 == ioctl(pPPriv->fd, VIDIOCCAPTURE, &zero))
+ perror("ioctl VIDIOCCAPTURE(0)");
+ pPPriv->VideoOn = VIDEO_RECLIP;
+ }
+ } else {
+ /* video stop - turn off and free everything */
+ if (VIDEO_YUV == pPPriv->VideoOn) {
+ pPPriv->myfmt->stop(pPPriv->surface);
+ pPPriv->myfmt->free_surface(pPPriv->surface);
+ xfree(pPPriv->surface);
+ pPPriv->surface = NULL;
+ }
+ if (-1 == ioctl(pPPriv->fd, VIDIOCCAPTURE, &zero))
+ perror("ioctl VIDIOCCAPTURE(0)");
+
+ V4lCloseDevice(pPPriv);
+ pPPriv->VideoOn = VIDEO_OFF;
+ }
}
/* v4l uses range 0 - 65535; Xv uses -1000 - 1000 */
@@ -333,12 +519,12 @@ V4lSetPortAttribute(ScrnInfoPtr pScrn,
struct video_channel chan;
int ret = Success;
- DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/SPA %d, %d\n",
- attribute, value));
-
if (V4lOpenDevice(pPPriv, pScrn))
return BadAccess;
+ DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/SPA %d, %d\n",
+ attribute, value));
+
if (-1 == pPPriv->fd) {
ret = Success /* FIXME: EBUSY/ENODEV ?? */;
} else if (attribute == xvEncoding) {
@@ -370,8 +556,9 @@ V4lSetPortAttribute(ScrnInfoPtr pScrn,
pPPriv->audio.flags |= VIDEO_AUDIO_MUTE;
else
pPPriv->audio.flags &= ~VIDEO_AUDIO_MUTE;
- } else if (attribute == xvVolume && (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)) {
- pPPriv->audio.volume = xv_to_v4l(value);
+ } else if (attribute == xvVolume) {
+ if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
+ pPPriv->audio.volume = xv_to_v4l(value);
} else {
ret = BadValue;
}
@@ -381,6 +568,10 @@ V4lSetPortAttribute(ScrnInfoPtr pScrn,
} else if (attribute == xvFreq) {
if (-1 == ioctl(pPPriv->fd,VIDIOCSFREQ,&value))
perror("ioctl VIDIOCSFREQ");
+ } else if (pPPriv->have_yuv &&
+ pPPriv->myfmt->setAttribute) {
+ /* not mine -> pass to yuv scaler driver */
+ ret = pPPriv->myfmt->setAttribute(pScrn, attribute, value);
} else {
ret = BadValue;
}
@@ -417,13 +608,18 @@ V4lGetPortAttribute(ScrnInfoPtr pScrn,
ioctl(pPPriv->fd,VIDIOCGAUDIO,&pPPriv->audio);
if (attribute == xvMute) {
*value = (pPPriv->audio.flags & VIDEO_AUDIO_MUTE) ? 1 : 0;
- } else if (attribute == xvVolume && (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)) {
- *value = v4l_to_xv(pPPriv->audio.volume);
+ } else if (attribute == xvVolume) {
+ if (pPPriv->audio.flags & VIDEO_AUDIO_VOLUME)
+ *value = v4l_to_xv(pPPriv->audio.volume);
} else {
ret = BadValue;
}
} else if (attribute == xvFreq) {
ioctl(pPPriv->fd,VIDIOCGFREQ,value);
+ } else if (pPPriv->have_yuv &&
+ pPPriv->myfmt->getAttribute) {
+ /* not mine -> pass to yuv scaler driver */
+ ret = pPPriv->myfmt->getAttribute(pScrn, attribute, value);
} else {
ret = BadValue;
}
@@ -444,8 +640,13 @@ V4lQueryBestSize(ScrnInfoPtr pScrn, Bool motion,
int maxx = pPPriv->enc[pPPriv->cenc].width;
int maxy = pPPriv->enc[pPPriv->cenc].height;
- *p_w = (drw_w < maxx) ? drw_w : maxx;
- *p_h = (drw_h < maxy) ? drw_h : maxy;
+ if (pPPriv->have_yuv) {
+ *p_w = pPPriv->myfmt->max_width;
+ *p_h = pPPriv->myfmt->max_height;
+ } else {
+ *p_w = (drw_w < maxx) ? drw_w : maxx;
+ *p_h = (drw_h < maxy) ? drw_h : maxy;
+ }
DEBUG(xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 2, "Xv/BS %d %dx%d %dx%d\n",
pPPriv->cenc,drw_w,drw_h,*p_w,*p_h));
@@ -467,32 +668,28 @@ V4LIdentify(int flags)
static char*
fixname(char *str)
{
- int s,d;
- for (s=0, d=0;; s++) {
- if (str[s] == '-')
- continue;
- str[d++] = tolower(str[s]);
- if (0 == str[s])
- break;
- }
- return str;
+ int s,d;
+ for (s=0, d=0;; s++) {
+ if (str[s] == '-')
+ continue;
+ str[d++] = tolower(str[s]);
+ if (0 == str[s])
+ break;
+ }
+ return str;
}
static XF86VideoEncodingPtr
-V4LBuildEncodings(int fd, int *count)
+V4LBuildEncodings(int fd, int *count, int channels)
{
- static struct video_capability cap;
static struct video_channel channel;
XF86VideoEncodingPtr enc;
int i;
- if (-1 == ioctl(fd,VIDIOCGCAP,&cap))
- return NULL;
-
- enc = xalloc(sizeof(XF86VideoEncodingRec)*3*cap.channels);
- memset(enc,0,sizeof(XF86VideoEncodingRec)*3*cap.channels);
+ enc = xalloc(sizeof(XF86VideoEncodingRec)*3*channels);
+ memset(enc,0,sizeof(XF86VideoEncodingRec)*3*channels);
- for (i = 0; i < 3*cap.channels; ) {
+ for (i = 0; i < 3*channels; ) {
channel.channel = i/3;
if (-1 == ioctl(fd,VIDIOCGCHAN,&channel)) {
perror("ioctl VIDIOCGCHAN");
@@ -533,38 +730,28 @@ V4LBuildEncodings(int fd, int *count)
return enc;
}
-
-static XF86AttributeRec Attributes[8] = {
- {XvSettable | XvGettable, -1000, 1000, XV_ENCODING},
- {XvSettable | XvGettable, -1000, 1000, XV_BRIGHTNESS},
- {XvSettable | XvGettable, -1000, 1000, XV_CONTRAST},
- {XvSettable | XvGettable, -1000, 1000, XV_SATURATION},
- {XvSettable | XvGettable, -1000, 1000, XV_HUE},
- {XvSettable | XvGettable, -1000, 1000, XV_VOLUME},
- {XvSettable | XvGettable, 0, 1, XV_MUTE},
- {XvSettable | XvGettable, 0, 16*1000, XV_FREQ},
-};
-
-
static int
V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
{
+ ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
PortPrivPtr pPPriv;
DevUnion *Private;
XF86VideoAdaptorPtr *VAR = NULL;
XF86VideoEncodingPtr enc;
- char dev[16];
- int fd,i,nenc;
+ char dev[18];
+ int fd,i,j,nenc;
DEBUG(xf86Msg(X_INFO, "v4l: init start\n"));
for (i = 0; i < 4; i++) {
- sprintf(dev,"/dev/video%d",i);
+ sprintf(dev, "/dev/video%d", i);
fd = open(dev, O_RDWR, 0);
- if (fd == -1)
- break;
- if (NULL == (enc = V4LBuildEncodings(fd,&nenc)))
- break;
+ if (fd == -1) {
+ sprintf(dev, "/dev/v4l/video%d", i);
+ fd = open(dev, O_RDWR, 0);
+ if (fd == -1)
+ break;
+ }
DEBUG(xf86Msg(X_INFO, "v4l: %s ok\n",dev));
@@ -576,9 +763,44 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
pPPriv->fd = -1;
strncpy(pPPriv->devname, dev, 16);
pPPriv->useCount=0;
+
+ /* check device */
+ if (-1 == ioctl(fd,VIDIOCGCAP,&pPPriv->cap) ||
+ NULL == (enc = V4LBuildEncodings
+ (fd,&nenc,pPPriv->cap.channels))) {
+ xfree(pPPriv);
+ break;
+ }
pPPriv->enc = enc;
pPPriv->nenc = nenc;
+#if 1
+ /* check for yuv (see if the driver accepts VIDEO_PALETTE_YUV422) */
+ ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
+ pPPriv->pict.palette = VIDEO_PALETTE_YUV422;
+ if (0 == ioctl(fd,VIDIOCSPICT,&pPPriv->pict)) {
+ ioctl(fd,VIDIOCGPICT,&pPPriv->pict);
+ if (VIDEO_PALETTE_YUV422 == pPPriv->pict.palette) {
+ /* works, check screen capabilities */
+ DEBUG(xf86Msg(X_INFO, "v4l: kernel driver supports yuv422.\n"));
+ pPPriv->format = xf86XVQueryOffscreenImages
+ (pScreen,&pPPriv->nformat);
+ DEBUG(xf86Msg(X_INFO, "v4l: screen driver supports %d yuv formats (%p)\n",
+ pPPriv->nformat,pPPriv->format));
+ for (j = 0; j < pPPriv->nformat; j++) {
+ DEBUG(xf86Msg(X_INFO, "v4l: yuv format: %4.4s\n",
+ (char*)&(pPPriv->format[j].image->id)));
+ if (pPPriv->format[j].image->id == 0x32595559 &&
+ pPPriv->format[j].image->format == XvPacked) {
+ pPPriv->have_yuv = 1;
+ pPPriv->myfmt = pPPriv->format+j;
+ DEBUG(xf86Msg(X_INFO, "v4l: matching format found, offscreen yuv enabled.\n"));
+ }
+ }
+ }
+ }
+#endif
+
/* alloc VideoAdaptorRec */
VAR = xrealloc(VAR,sizeof(XF86VideoAdaptorPtr)*(i+1));
VAR[i] = xalloc(sizeof(XF86VideoAdaptorRec));
@@ -587,8 +809,18 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
memset(VAR[i],0,sizeof(XF86VideoAdaptorRec));
/* add attribute lists */
- VAR[i]->nAttributes = 8;
- VAR[i]->pAttributes = Attributes;
+ if (pPPriv->have_yuv) {
+ VAR[i]->nAttributes = V4L_ATTR + pPPriv->myfmt->num_attributes;
+ VAR[i]->pAttributes = xalloc(VAR[i]->nAttributes *
+ sizeof(XF86AttributeRec));
+ memcpy(VAR[i]->pAttributes, Attributes,
+ sizeof(XF86AttributeRec) * V4L_ATTR);
+ memcpy(VAR[i]->pAttributes+V4L_ATTR, pPPriv->myfmt->attributes,
+ sizeof(XF86AttributeRec) * pPPriv->myfmt->num_attributes);
+ } else {
+ VAR[i]->nAttributes = V4L_ATTR;
+ VAR[i]->pAttributes = Attributes;
+ }
/* hook in private data */
Private = xalloc(sizeof(DevUnion));
@@ -616,6 +848,27 @@ V4LInit(ScrnInfoPtr pScrn, XF86VideoAdaptorPtr **adaptors)
VAR[i]->nFormats =
sizeof(InputVideoFormats) / sizeof(InputVideoFormats[0]);
VAR[i]->pFormats = InputVideoFormats;
+
+ /* Check whether we have VIDEO_AUDIO_VOLUME */
+ if (!ioctl(pPPriv->fd,VIDIOCGAUDIO,&pPPriv->audio) &&
+ pPPriv->audio.flags & VIDEO_AUDIO_VOLUME) {
+ XF86AttributeRec *oldattrs = VAR[i]->pAttributes;
+ int nattrs = VAR[i]->nAttributes;
+
+ DEBUG(xf86Msg(X_INFO, "v4l: Volume supported, adding XV_VOLUME to attribute list\n"));
+
+ VAR[i]->pAttributes = xalloc((nattrs + 1) *
+ sizeof(XF86AttributeRec));
+ memcpy(VAR[i]->pAttributes, oldattrs,
+ sizeof(XF86AttributeRec) * nattrs);
+ memcpy(VAR[i]->pAttributes+nattrs, &VolumeAttr,
+ sizeof(XF86AttributeRec));
+ VAR[i]->nAttributes++;
+ } else {
+ DEBUG(xf86Msg(X_INFO, "v4l: Volume not supported\n"));
+ }
+
+
if (fd != -1)
close(fd);
}
@@ -640,8 +893,9 @@ static Bool
V4LProbe(DriverPtr drv, int flags)
{
if (flags & PROBE_DETECT)
- return FALSE;
+ return TRUE;
xf86XVRegisterGenericAdaptorDriver(V4LInit);
+ drv->refCount++;
return TRUE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp b/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp
index a2bf9f4b3..fb06a6567 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp,v 1.1 2000/03/03 01:05:45 dawes Exp $
-.TH V4L __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/v4l/v4l.cpp,v 1.4 2000/06/14 02:13:16 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH V4L __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
v4l \- Video 4 Linux driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""v4l"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qv4l\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B v4l
is an XFree86 driver for Video 4 Linux.
@@ -25,6 +25,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details. This section only covers configuration details specific to this
driver.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: ...
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c b/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c
index 45e0a9c45..987543bf1 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c,v 1.42 2000/03/06 23:54:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/generic.c,v 1.44 2000/04/27 16:26:49 eich Exp $ */
/*
* Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
*
@@ -104,11 +104,13 @@ DriverRec VGA =
};
typedef enum {
- OPTION_SHADOW_FB
+ OPTION_SHADOW_FB,
+ OPTION_VGA_CLOCKS
} GenericOpts;
static OptionInfoRec GenericOptions[] = {
{ OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE },
+ { OPTION_VGA_CLOCKS, "VGAClocks", OPTV_BOOLEAN, {0}, FALSE },
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
@@ -232,7 +234,6 @@ static Bool
GenericProbe(DriverPtr drv, int flags)
{
Bool foundScreen = FALSE;
- pciVideoPtr pPci;
int numDevSections, numUsed;
GDevPtr *devSections = NULL;
int *usedChips;
@@ -254,12 +255,49 @@ GenericProbe(DriverPtr drv, int flags)
devSections,numDevSections,
drv, &usedChips);
if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else {
- for (i = 0; i < numUsed; i++) {
- /* Allocate a ScrnInfoRec */
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
+ if (flags & PROBE_DETECT)
+ foundScreen = TRUE;
+ else {
+ for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ /* Allocate a ScrnInfoRec */
+ if ((pScrn = xf86ConfigPciEntity(pScrn,0,usedChips[i],
+ GenericPCIchipsets,NULL,
+ NULL,NULL,NULL,NULL))){
+ pScrn->driverVersion = VGA_VERSION_CURRENT;
+ pScrn->driverName = VGA_DRIVER_NAME;
+ pScrn->name = VGA_NAME;
+ pScrn->Probe = GenericProbe;
+ pScrn->PreInit = GenericPreInit;
+ pScrn->ScreenInit = GenericScreenInit;
+ pScrn->SwitchMode = GenericSwitchMode;
+ pScrn->AdjustFrame = GenericAdjustFrame;
+ pScrn->EnterVT = GenericEnterVT;
+ pScrn->LeaveVT = GenericLeaveVT;
+ pScrn->FreeScreen = GenericFreeScreen;
+ pScrn->ValidMode = GenericValidMode;
+ foundScreen = TRUE;
+ }
+ xfree(usedChips);
+ }
+ }
+ }
+ }
+
+ /* Isa Bus */
+ numUsed = xf86MatchIsaInstances(VGA_NAME,GenericChipsets,
+ GenericISAchipsets,drv,
+ VGAFindIsaDevice,devSections,
+ numDevSections,&usedChips);
+ if(numUsed > 0) {
+ if (flags & PROBE_DETECT)
+ return TRUE;
+ for (i = 0; i < numUsed; i++) {
+ ScrnInfoPtr pScrn = NULL;
+ if ((pScrn = xf86ConfigIsaEntity(pScrn,0,usedChips[i],
+ GenericISAchipsets,NULL,
+ NULL,NULL,NULL,NULL))) {
+
pScrn->driverVersion = VGA_VERSION_CURRENT;
pScrn->driverName = VGA_DRIVER_NAME;
pScrn->name = VGA_NAME;
@@ -273,43 +311,11 @@ GenericProbe(DriverPtr drv, int flags)
pScrn->FreeScreen = GenericFreeScreen;
pScrn->ValidMode = GenericValidMode;
foundScreen = TRUE;
- xf86ConfigActivePciEntity(pScrn,usedChips[i],GenericPCIchipsets,
- NULL,NULL,NULL,NULL,NULL);
}
- }
- xfree(usedChips);
+ xfree(usedChips);
}
}
- /* Isa Bus */
- numUsed = xf86MatchIsaInstances(VGA_NAME,GenericChipsets,
- GenericISAchipsets,drv,
- VGAFindIsaDevice,devSections,
- numDevSections,&usedChips);
- if (numUsed > 0) {
- if (flags & PROBE_DETECT)
- foundScreen = TRUE;
- else for (i = 0; i < numUsed; i++) {
- ScrnInfoPtr pScrn = xf86AllocateScreen(drv,0);
-
- pScrn->driverVersion = VGA_VERSION_CURRENT;
- pScrn->driverName = VGA_DRIVER_NAME;
- pScrn->name = VGA_NAME;
- pScrn->Probe = GenericProbe;
- pScrn->PreInit = GenericPreInit;
- pScrn->ScreenInit = GenericScreenInit;
- pScrn->SwitchMode = GenericSwitchMode;
- pScrn->AdjustFrame = GenericAdjustFrame;
- pScrn->EnterVT = GenericEnterVT;
- pScrn->LeaveVT = GenericLeaveVT;
- pScrn->FreeScreen = GenericFreeScreen;
- pScrn->ValidMode = GenericValidMode;
- foundScreen = TRUE;
- xf86ConfigActiveIsaEntity(pScrn,usedChips[i],GenericISAchipsets,
- NULL,NULL,NULL,NULL,NULL);
- }
- xfree(usedChips);
- }
if (devSections)
xfree(devSections);
return foundScreen;
@@ -594,8 +600,11 @@ GenericPreInit(ScrnInfoPtr pScreenInfo, int flags)
for (i = 0; i < pScreenInfo->numClocks; i++)
pScreenInfo->clock[i] = pEnt->device->clock[i];
From = X_CONFIG;
- }
- else
+ } else if (xf86ReturnOptValBool(GenericOptions,OPTION_VGA_CLOCKS,FALSE)) {
+ pScreenInfo->numClocks = 2;
+ pScreenInfo->clock[0] = 25175;
+ pScreenInfo->clock[1] = 28322;
+ } else
{
xf86GetClocks(pScreenInfo, 4, GenericClockSelect, GenericProtect,
GenericBlankScreen, VGAHW_GET_IOBASE() + 0x0A, 0x08, 1, 28322);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp b/xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp
index 35456d07d..b837d4320 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp
+++ b/xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp,v 1.3 2000/03/03 01:05:47 dawes Exp $
-.TH VGA __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/drivers/vga/vga.cpp,v 1.6 2000/06/14 02:13:16 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH VGA __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
vga \- Generic VGA video driver
.SH SYNOPSIS
-.B "Section ""Device"""
-.br
-.BI " Identifier """ devname """"
-.br
-.B " Driver ""vga"""
-.br
+.nf
+.B "Section \*qDevice\*q"
+.BI " Identifier \*q" devname \*q
+.B " Driver \*qvga\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B vga
is an XFree86 driver for generic VGA video cards. It can drive most
@@ -35,7 +35,7 @@ driver.
The driver auto-detects the presence of VGA-compatible hardware. The
.B ChipSet
name may optionally be specified in the config file
-.B """Device"""
+.B \*qDevice\*q
section, and will override the auto-detection:
.PP
.RS 4
@@ -52,7 +52,7 @@ The following driver
.B Options
are supported:
.TP
-.BI "Option ""ShadowFB"" """ boolean """
+.BI "Option \*qShadowFB\*q \*q" boolean \*q
Enable or disable use of the shadow framebuffer layer. See
shadowfb(__drivermansuffix__) for further information. Default: off.
@@ -61,6 +61,6 @@ This option is recommended for performance reasons when running at depths
when using those depths in a multi-head configuration where one or more
of the other screens is operating at a different depth.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1)
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__)
.SH AUTHORS
Authors include: Marc La France, David Dawes, and Dirk Hohndel.
diff --git a/xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c b/xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c
index 8d9acf5d9..072f639ca 100644
--- a/xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c
+++ b/xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c,v 1.1 2000/02/13 03:06:40 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/dummylib/xf86errorf.c,v 1.2 2000/05/31 07:15:05 eich Exp $ */
#include "X.h"
#include "os.h"
@@ -20,3 +20,12 @@ xf86ErrorF(const char *format, ...)
va_end(ap);
}
+void
+ErrorF(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+ VErrorFVerb(1, format, ap);
+ va_end(ap);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh b/xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh
index ed1455f63..b2dd8279c 100644
--- a/xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh
+++ b/xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh
@@ -1,12 +1,13 @@
#!/bin/sh
#
-# $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.7 2000/02/29 18:01:20 dawes Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/Xinstall.sh,v 1.13 2000/06/30 21:44:37 dawes Exp $
#
# Copyright © 2000 by Precision Insight, Inc.
+# Copyright © 2000 by VA Linux Systems, Inc.
# Portions Copyright © 1996-2000 by The XFree86 Project, Inc.
#
-# This script should be used to install XFree86 4.0.
+# This script should be used to install XFree86 4.0.1.
#
# Parts of this script are based on the old preinst.sh and postinst.sh
# scripts.
@@ -16,7 +17,7 @@
# Authors: David Dawes <dawes@xfree86.org>
#
-VERSION=4.0
+VERSION=4.0.1
RUNDIR=/usr/X11R6
ETCDIR=/etc/X11
@@ -39,6 +40,12 @@ OLDDIRS=" \
$RUNDIR/lib/X11/xkb/compiled \
"
+OLDMODULES=" \
+ xie.so \
+ pex5.so \
+ glx.so \
+ "
+
BASEDIST=" \
Xbin.tgz \
Xlib.tgz \
@@ -50,7 +57,7 @@ BASEDIST=" \
ETCDIST="Xetc.tgz"
-VARDIST="Xvar.tgz"
+VARDIST=""
SERVDIST=" \
Xxserv.tgz \
@@ -85,6 +92,8 @@ ETCLINKS=" \
xserver \
"
+XKBDIR="/etc/X11/xkb"
+
FONTDIRS=" \
local \
misc
@@ -235,8 +244,12 @@ GetOsInfo()
;;
*)
L="-L"
+ ;;
esac
;;
+ SunOS)
+ L="-h" # /bin/sh built-in doesn't do -L
+ ;;
OS-with-no-symlinks) # Need to set this correctly
L="-b"
NoSymlinks=YES
@@ -417,6 +430,16 @@ FindDistName()
;;
esac
;;
+ mips)
+ case "$OsLibcMajor.$OsLibcMinor" in
+ 6.0)
+ DistName="Linux-mips-glibc20"
+ ;;
+ *)
+ Message="No Linux/Mips binaries for this libc version"
+ ;;
+ esac
+ ;;
*)
Message="No Linux binaries available for this architecture"
;;
@@ -557,16 +580,20 @@ fi
GetOsInfo
-# Make OS-specific adjustments to the distribution file lists
+# Make OS-specific adjustments
case "$OsName" in
+FreeBSD|NetBSD|OpenBSD)
+ VARDIST="Xvar.tgz"
+ XKBDIR="/var/db/xkb"
+ ;;
Interactive) # Need the correct name for this
- VARDIST=""
EXTRADIST="Xbin1.tgz"
EXTRAOPTDIST="Xxdm.tgz"
;;
-LynxOS)
- VARDIST=""
+Linux)
+ VARDIST="Xvar.tgz"
+ XKBDIR="/var/state/xkb"
;;
esac
@@ -677,6 +704,8 @@ if [ X"$NEEDSOMETHING" != X ]; then
exit 1
fi
+echo ""
+
# Link extract to gnu-tar so it can also be used as a regular tar
rm -f gnu-tar
ln extract gnu-tar
@@ -737,6 +766,10 @@ if [ X"$OLDDIRS" != X ]; then
echo ""
fi
+if [ ! -d $RUNDIR/lib/X11/xkb ]; then
+ echo "Creating $RUNDIR/lib/X11/xkb"
+ mkdir $RUNDIR/lib/X11/xkb
+fi
# Check for config file directories that may need to be moved.
EtcToMove=
@@ -768,7 +801,7 @@ if [ X"$EtcToMove" != X ]; then
;;
esac
echo ""
- if [ X"NoSymlinks" != XYES ]; then
+ if [ X"$NoSymLinks" != XYES ]; then
for i in $EtcToMove; do
echo "Moving $RUNDIR/lib/X11/$i to $ETCDIR/$i ..."
if [ ! -d $ETCDIR/$i ]; then
@@ -823,8 +856,20 @@ for i in $ETCLINKS; do
$TAR -C $RUNDIR/lib/X11/$i -v -x -p -U -f -
fi
done
+if [ X"$XKBDIR" != X ]; then
+ rm -fr $RUNDIR/lib/X11/xkb/compiled
+ if [ X"$NoSymLinks" = XYES ]; then
+ XKBDIR=$RUNDIR/lib/X11/xkb/compiled
+ fi
+ if [ -d .etctmp/xkb ]; then
+ mkdir $XKBDIR
+ $TAR -C .etctmp/xkb -c -f - . | \
+ $TAR -C $XKBDIR -v -x -p -U -f -
+ fi
+fi
rm -fr .etctmp
+echo ""
echo "Installing the mandatory parts of the binary distribution"
echo ""
for i in $BASEDIST $SERVDIST; do
@@ -834,6 +879,11 @@ if [ X"$VARDIST" != X ]; then
(cd $VARDIR; $EXTRACT $WDIR/$VARDIST)
fi
+if [ X"$XKBDIR" != X -a X"$XKBDIR" != X"$RUNDIR/lib/X11/xkb/compiled" ]; then
+ rm -fr $RUNDIR/lib/X11/xkb/compiled
+ ln -s $XKBDIR $RUNDIR/lib/X11/xkb/compiled
+fi
+
echo "Checking for optional components to install ..."
for i in $OPTDIST $EXTRAOPTDIST; do
if [ -f $i ]; then
@@ -969,6 +1019,67 @@ if [ -d $TINFODIR ]; then
esac
fi
+if [ -f $RUNDIR/lib/libGL.so ]; then
+ existing=""
+ if [ -f /usr/lib/libGL.so ]; then
+ existing="$existing /usr/lib/libGL.so"
+ fi
+ if [ -f /usr/lib/libGL.so.1 ]; then
+ existing="$existing /usr/lib/libGL.so.1"
+ fi
+ if [ -d /usr/include/GL ]; then
+ existing="$existing /usr/include/GL"
+ fi
+ echo ""
+ echo "On some platforms (e.g., Linux), the OpenGL standard requires"
+ echo "that the GL shared library and header files be visible from the"
+ echo "standard system lib and include directories (/usr/lib and"
+ echo "/usr/include). This can be done by installing links in those"
+ echo "directories to the files that have been installed under $RUNDIR."
+ echo ""
+ echo "NOTE: installing these links will overwrite existing files or"
+ echo "links."
+ if [ X"$existing" != X ]; then
+ echo ""
+ echo "The follwing links/files/directories already exist:"
+ echo ""
+ ls -ld $existing
+ fi
+ echo ""
+ Echo "Do you wish to have the (new) links installed (y/n)? [n] "
+ read response
+ case "$response" in
+ [yY]*)
+ rm -f /usr/lib/libGL.so
+ if [ ! -f /usr/lib/libGL.so ]; then
+ echo "Creating link from $RUNDIR/lib/libGL.so to /usr/lib/libGL.so"
+ ln -s $RUNDIR/lib/libGL.so /usr/lib/libGL.so
+ else
+ echo "Could not remove existing /usr/lib/libGL.so, so the new"
+ echo "link has not been created."
+ fi
+ rm -f /usr/lib/libGL.so.1
+ if [ ! -f /usr/lib/libGL.so.1 ]; then
+ echo "Creating link from $RUNDIR/lib/libGL.so.1 to /usr/lib/libGL.so.1"
+ ln -s $RUNDIR/lib/libGL.so.1 /usr/lib/libGL.so.1
+ else
+ echo "Could not remove existing /usr/lib/libGL.so.1, so the new"
+ echo "link has not been created."
+ fi
+ if [ -d $RUNDIR/include/GL ]; then
+ rm -f /usr/include/GL
+ if [ ! -d /usr/include/GL ]; then
+ echo "Creating link from $RUNDIR/include/GL to /usr/include/GL"
+ ln -s $RUNDIR/include/GL /usr/include/GL
+ else
+ echo "Could not remove existing /usr/include/GL, so the new"
+ echo "link has not been created."
+ fi
+ fi
+ ;;
+ esac
+fi
+
if [ -f $RUNDIR/bin/rstartd ]; then
echo ""
echo "If you are going to use rstart and $RUNDIR/bin isn't in the"
@@ -986,6 +1097,60 @@ if [ -f $RUNDIR/bin/rstartd ]; then
esac
fi
+# Finally, check for old 3.3.x modules that will conflict with 4.x
+if [ -d $RUNDIR/lib/modules ]; then
+ for i in $OLDMODULES; do
+ if [ -f $RUNDIR/lib/modules/$i ]; then
+ ModList="$ModList $i"
+ fi
+ done
+ if [ X"$ModList" != X ]; then
+ echo ""
+ echo "The following 3.3.x X server modules were found in"
+ echo "$RUNDIR/lib/modules, and they may cause problems when running"
+ echo "$VERSION:"
+ echo ""
+ echo " $ModList"
+ echo ""
+ echo "Do you want them moved to $RUNDIR/lib/modules/old?"
+ echo "Note: that if you want to use them with 3.3.x again, you'll"
+ Echo "need to move them back manually. (y/n) [n] "
+ read response
+ case "$response" in
+ [yY]*)
+ if [ ! -d $RUNDIR/lib/modules/old ]; then
+ echo ""
+ echo "Creating $RUNDIR/lib/modules/old"
+ mkdir $RUNDIR/lib/modules/old
+ else
+ echo ""
+ fi
+ if [ -d $RUNDIR/lib/modules/old ]; then
+ for i in $ModList; do
+ echo "Moving $i to $RUNDIR/lib/modules/old"
+ mv $RUNDIR/lib/modules/$i $RUNDIR/lib/modules/old/$i
+ done
+ else
+ echo "Failed to create directory $RUNDIR/lib/modules/old"
+ fi
+ ;;
+ *)
+ echo ""
+ echo "Make sure that you rename, move or delete the old modules"
+ echo "before running $VERSION."
+ esac
+ fi
+ # Some distributions have old codeconv modules
+ if [ -d $RUNDIR/lib/modules/codeconv ]; then
+ if [ -f $RUNDIR/lib/modules/codeconv/ISO8859_1.so ]; then
+ echo ""
+ echo "Warning: it looks like there are some old *.so modules"
+ echo "in $RUNDIR/lib/modules/codeconv. You may need to rename,"
+ echo "move or delete them if you use the xtt font module."
+ fi
+ fi
+fi
+
echo ""
echo "Installation complete."
diff --git a/xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar b/xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar
index 73923458e..b88a8d590 100644
--- a/xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar
+++ b/xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar
@@ -1,6 +1,6 @@
# 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
+# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
@@ -28,7 +28,7 @@
# xf86test/Makefile
# xf86test/xf86test.c
#
-# $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.11 1999/12/14 02:40:14 robin Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.12 2000/05/11 18:14:36 tsi Exp $
#
echo x - COPYRIGHT
sed 's/^X//' >COPYRIGHT << 'END-of-COPYRIGHT'
@@ -125,7 +125,7 @@ XVersion 2.0
X-----------
X
XThis module was originally written to help work around the security
-Xfeature of NetBSD that prevents read/write access to /dev/mem. It also
+Xfeature of NetBSD that prevents read/write access to /dev/mem. It also
Xprovide Pentium II and AMD K6 MTRR control in order to control
Xwrite-combining to the framebuffer memory.
X
@@ -133,24 +133,24 @@ XXFree86 can take advantage of having direct access to video
Xmemory (especially with VLB and PCI cards) and even requires it for
Xthe most recent PCI or AGP video boards.
X
-XThis driver works like the standard /dev/mem driver. It just allows
+XThis driver works like the standard /dev/mem driver. It just allows
Xmapping of the VGA framebuffer and BIOS even if kernel security level
Xis > 0. The driver only implements the open(), close(), ioctl() and
-Xmmap() calls. In order not to defeat kernel security, only one open()
-Xat a time is allowed and only a process with effective user id of 0 can
-Xperform it. So while you're running XFree86, no other process will be
+Xmmap() calls. In order not to defeat kernel security, only one open()
+Xat a time is allowed and only a process with effective user id of 0 can
+Xperform it. So while you're running XFree86, no other process will be
Xallowed to open /dev/xf86.
X
XThis work is originally heavily inspired from the Solaris x86 aperture
Xdriver by Doug Anson (danson@lgc.com) and David Holland
-X(davidh@use.com). MTRR support is derived from FreeBSD.
+X(davidh@use.com). MTRR support is derived from FreeBSD.
X
X
XInstallation:
X-------------
X
Xo Optionnally, edit Makefile.inc to set the APDIR variable to the
-X directory where you want to install the aperture driver. If you change
+X directory where you want to install the aperture driver. If you change
X this, and want to rebuild XFree86 from source, also define
X NetBSDApertureDir in xc/config/cf/host.def before rebuilding it.
X
@@ -170,7 +170,7 @@ X in /etc/rc.conf
X
Xo Reboot your system.
X
-Xo Test the module by running 'aptest' as root. The outpout will look like:
+Xo Test the module by running 'aptest' as root. The output will look like:
X
X # ./aptest
X NOTICE: VGA mapped [0xa0000 ,size=4096) to addr=0x10073000...
@@ -179,7 +179,7 @@ X DONE displaying memory contents (80 bytes)
X UNMAPPING [0xa0000 ,size=4096) to addr=0x10073000... and closing...DONE.
X Exiting successful...
X
-Xo Start the XFree86 server. All XFree86 versions post 3.9.16d have support
+Xo Start the XFree86 server. All XFree86 versions post 3.9.16d have support
X for the aperture driver enabled.
X
XBug reports, comments, suggestions can be sent to <herrb@XFree86.Org>
@@ -775,7 +775,6 @@ X#endif
X#include "xf86_reg.h"
X#include "memrange.h"
X
-X#define ISA_START 0xA0000
X#define ISA_END 0xFFFFF
X#ifdef PC98
X#define HOLE16M_START 0xF00000
@@ -842,7 +841,7 @@ X#ifdef XF86_DEBUG
X printf("xf86mmap: addr 0x%x\n", offset);
X#endif
X if ((minor(dev) == 0)
-X && ((offset >= ISA_START && offset <= ISA_END )
+X && ((offset <= ISA_END )
X || (unsigned)offset > (unsigned)ctob(physmem)
X#ifdef PC98
X || ((unsigned)offset >=HOLE16M_START
@@ -1971,8 +1970,8 @@ X seltrue, xf86mmap, 0};
X
XMOD_DEV("xf86", LM_DT_CHAR, -1, &newdev)
X
-Xchar *xf86_major_version = "1";
-Xchar *xf86_minor_version = "99b";
+Xchar *xf86_major_version = "2";
+Xchar *xf86_minor_version = "0";
X
Xstatic int xf86action __P((struct lkm_table *lktmp, int cmd));
X
@@ -2041,7 +2040,7 @@ sed 's/^X//' >module/xf86_mod.h << 'END-of-module/xf86_mod.h'
X/*
X * Copyright (C) 1999, The XFree86 Project Inc.
X *
-X * $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.11 1999/12/14 02:40:14 robin Exp $
+X * $XFree86: xc/programs/Xserver/hw/xfree86/etc/apNetBSD.shar,v 3.12 2000/05/11 18:14:36 tsi Exp $
X */
X#ifndef _XF86_MOD_H
X#define _XF86_MOD_H
@@ -2104,6 +2103,7 @@ X#define MTRR_N64K 8 /* numbers of fixed-size entries */
X#define MTRR_N16K 16
X#define MTRR_N4K 64
X
+X#if defined(__NetBSD__) && (__NetBSD_Version__ < 10424000)
X/*
X * XXX - These belong to cpufunc.h
X */
@@ -2127,6 +2127,7 @@ Xwrmsr(u_int msr, u_int64_t newval)
X{
X __asm __volatile(".byte 0x0f, 0x30" : : "A" (newval), "c" (msr));
X}
+X#endif /* __NetBSD_Version__ */
X
X#ifndef M_MEMDESC
X#define M_MEMDESC M_TEMP /* XXX */
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def
index 2b7697375..4059b1755 100644
--- a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def
@@ -1,14 +1,18 @@
/*
* Host.def for building Linux/ix86 bindists
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def,v 1.5 2000/03/07 14:47:33 dawes Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-ix86/host.def,v 1.6 2000/03/17 15:59:46 dawes Exp $
*/
#define InstallEmptyHostDef
-/* Need to have glide 2 and glide 3 installed */
+/* Need to have glide 2 and glide 3 installed, where available */
#define HasGlide2 YES
+#if LinuxCLibMajorVersion > 5
#define HasGlide3 YES
+#endif
+
+#define BuildXF86DRI YES
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-excl b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-excl
new file mode 100644
index 000000000..c7f43558f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-excl
@@ -0,0 +1,10 @@
+bin/XF86_*
+bin/XF98_*
+bin/XF86Setup
+bin/Xnest
+bin/Xprt
+bin/Xvfb
+bin/X
+bin/xfs
+bin/xmseconfig
+bin/XFree86
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list
new file mode 100644
index 000000000..071c399e9
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/bin-list
@@ -0,0 +1,60 @@
+bin
+lib/libGL.so.1.2
+lib/libGL.so.1
+lib/libGL.so
+lib/libICE.so.6.3
+lib/libICE.so.6
+lib/libICE.so
+lib/libPEX5.so.6.0
+lib/libPEX5.so.6
+lib/libPEX5.so
+lib/libSM.so.6.0
+lib/libSM.so.6
+lib/libSM.so
+lib/libX11.so.6.1
+lib/libX11.so.6
+lib/libX11.so
+lib/libXIE.so.6.0
+lib/libXIE.so.6
+lib/libXIE.so
+lib/libXaw.so.6.1
+lib/libXaw.so.6
+lib/libXaw.so.7.0
+lib/libXaw.so.7
+lib/libXaw.so
+lib/libXext.so.6.4
+lib/libXext.so.6
+lib/libXext.so
+lib/libXfont.so.1.3
+lib/libXfont.so.1
+lib/libXfont.so
+lib/libXi.so.6.0
+lib/libXi.so.6
+lib/libXi.so
+lib/libXmu.so.6.1
+lib/libXmu.so.6
+lib/libXmu.so
+lib/libXp.so.6.2
+lib/libXp.so.6
+lib/libXp.so
+lib/libXpm.so.4.11
+lib/libXpm.so.4
+lib/libXpm.so
+lib/libXt.so.6.0
+lib/libXt.so.6
+lib/libXt.so
+lib/libXtst.so.6.1
+lib/libXtst.so.6
+lib/libXtst.so
+lib/libdps.so.1.0
+lib/libdps.so.1
+lib/libdps.so
+lib/libdpstk.so.1.0
+lib/libdpstk.so.1
+lib/libdpstk.so
+lib/libpsres.so.1.0
+lib/libpsres.so.1
+lib/libpsres.so
+lib/libxrx.so.6.3
+lib/libxrx.so.6
+lib/libxrx.so
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/dir b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/dir
new file mode 100644
index 000000000..11c5b9da7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/dir
@@ -0,0 +1 @@
+usr/X11R6
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-dir b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-dir
new file mode 100644
index 000000000..412cec0c3
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-dir
@@ -0,0 +1 @@
+etc/X11
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-list
new file mode 100644
index 000000000..9c558e357
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/etc-list
@@ -0,0 +1 @@
+.
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/fsrv-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/fsrv-list
new file mode 100644
index 000000000..e18f38dd8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/fsrv-list
@@ -0,0 +1,2 @@
+bin/xfs
+man/man1/xfs.1x
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-excl b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-excl
new file mode 100644
index 000000000..d7fb5cb03
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-excl
@@ -0,0 +1,14 @@
+lib/X11/XF86Setup
+lib/X11/app-defaults
+lib/X11/config
+lib/X11/doc
+lib/X11/fonts
+lib/X11/fs
+lib/X11/lbxproxy
+lib/X11/proxymngr
+lib/X11/rstart
+lib/X11/twm
+lib/X11/xdm
+lib/X11/xinit
+lib/X11/xsm
+lib/X11/xserver
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-list
new file mode 100644
index 000000000..9673fea05
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/lib-list
@@ -0,0 +1,2 @@
+lib/X11
+include/X11/bitmaps
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-excl b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-excl
new file mode 100644
index 000000000..81792cce1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-excl
@@ -0,0 +1,3 @@
+man/man1/XF86Setup.1x
+man/man1/xfs.1x
+man/man1/xmseconfig.1x
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-list
new file mode 100644
index 000000000..2a3700c15
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/man-list
@@ -0,0 +1 @@
+man
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/mod-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/mod-list
new file mode 100644
index 000000000..7054fc153
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/mod-list
@@ -0,0 +1 @@
+lib/modules
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/nest-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/nest-list
new file mode 100644
index 000000000..eff754d76
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/nest-list
@@ -0,0 +1 @@
+bin/Xnest
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-excl b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-excl
new file mode 100644
index 000000000..113d220ef
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-excl
@@ -0,0 +1,5 @@
+lib/Server
+lib/X11
+lib/lib*.so*
+lib/modules
+include/X11/bitmaps
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-list
new file mode 100644
index 000000000..059b71061
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prog-list
@@ -0,0 +1,3 @@
+lib
+include
+lib/X11/config
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prt-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prt-list
new file mode 100644
index 000000000..0646e7927
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/prt-list
@@ -0,0 +1 @@
+bin/Xprt
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list
new file mode 100644
index 000000000..83d032807
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/set-list
@@ -0,0 +1,5 @@
+bin/XF86Setup
+bin/xmseconfig
+lib/X11/XF86Setup
+man/man1/XF86Setup.1x
+man/man1/xmseconfig.1x
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-dir b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-dir
new file mode 100644
index 000000000..186857b9e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-dir
@@ -0,0 +1 @@
+var
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list
new file mode 100644
index 000000000..ff72b5c73
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/var-list
@@ -0,0 +1 @@
+state
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/vfb-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/vfb-list
new file mode 100644
index 000000000..e2d161bbc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/vfb-list
@@ -0,0 +1 @@
+bin/Xvfb
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/xserv-list b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/xserv-list
new file mode 100644
index 000000000..334bbd1e4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/Linux-mips/xserv-list
@@ -0,0 +1,2 @@
+bin/XFree86
+bin/X
diff --git a/xc/programs/Xserver/hw/xfree86/etc/bindist/os2/host.def b/xc/programs/Xserver/hw/xfree86/etc/bindist/os2/host.def
new file mode 100644
index 000000000..1997259df
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/etc/bindist/os2/host.def
@@ -0,0 +1,7 @@
+#define NormalLibFont YES
+#define SharedLibFont NO
+#define BuildDPSLibrary YES
+#define XprtServer NO
+#define XnestServer NO
+#define XVirtualFramebufferServer NO
+
diff --git a/xc/programs/Xserver/hw/xfree86/etc/scanpci.c b/xc/programs/Xserver/hw/xfree86/etc/scanpci.c
index 161f589a4..b7a57bee9 100644
--- a/xc/programs/Xserver/hw/xfree86/etc/scanpci.c
+++ b/xc/programs/Xserver/hw/xfree86/etc/scanpci.c
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.76 2000/02/13 07:39:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/etc/scanpci.c,v 3.80 2000/06/20 19:38:04 eich Exp $ */
#include "X.h"
#include "os.h"
@@ -116,10 +116,11 @@ pciVendorDevFuncInfo vendorDeviceFuncInfo[] = {
void
usage(void)
{
- printf("Usage: scanpci [-v12fV]\n");
+ printf("Usage: scanpci [-v12OfV]\n");
printf(" -v print config space\n");
printf(" -1 config type 1\n");
printf(" -2 config type 2\n");
+ printf(" -O use OS config support\n");
printf(" -f force config type\n");
printf(" -V set message verbosity level\n");
}
@@ -135,7 +136,7 @@ main(int argc, char *argv[])
xf86Info.pciFlags = PCIProbe1;
- while ((c = getopt(argc, argv, "?v12fV:")) != -1)
+ while ((c = getopt(argc, argv, "?v12OfV:")) != -1)
switch(c) {
case 'v':
Verbose = 1;
@@ -146,6 +147,9 @@ main(int argc, char *argv[])
case '2':
xf86Info.pciFlags = PCIProbe2;
break;
+ case 'O':
+ xf86Info.pciFlags = PCIOsConfig;
+ break;
case 'f':
force = 1;
break;
@@ -190,39 +194,38 @@ void
identify_card(pciConfigPtr pcr, int verbose)
{
- int i = 0;
+ int i, j;
int foundit = 0;
+ int foundvendor = 0;
SymTabRec *pvnd;
pciVendorDeviceInfo *pvd;
pciVendorDevFuncInfo *vdf = vendorDeviceFuncInfo;
- pciVendorCardInfo *dummy;
+ pciVendorCardInfo *pvc;
- xf86SetupScanPci(&pvnd,&pvd,&dummy);
+ xf86SetupScanPci(&pvnd,&pvd,&pvc);
printf("\npci bus 0x%x cardnum 0x%02x function 0x%04x: vendor 0x%04x device 0x%04x\n",
pcr->busnum, pcr->devnum, pcr->funcnum,
pcr->pci_vendor, pcr->pci_device);
- while (pvnd[i].name != (char *)NULL)
- if (pvnd[i++].token == pcr->pci_vendor)
- printf(" %s ", pvnd[i-1].name);
+ for (i = 0; pvnd[i].name; i++) {
+ if (pvnd[i].token == pcr->pci_vendor) {
+ printf(" %s ", pvnd[i].name);
+ break;
+ }
+ }
- i = 0;
-
- while (pvd[i].VendorID) {
- int j = 0;
- while (pvd[i].Device[j].DeviceName != (char *)NULL) {
+ for (i = 0; pvd[i].VendorID && pvd[i].VendorID != pcr->pci_vendor; i++)
+ ;
+ if (pvd[i].VendorID) {
+ for (j = 0; pvd[i].Device[j].DeviceName; j++) {
if (pvd[i].Device[j].DeviceID == pcr->pci_device) {
printf("%s", pvd[i].Device[j].DeviceName);
foundit = 1;
break;
}
- j++;
}
- if (foundit)
- break;
- i++;
}
if (!foundit)
@@ -230,26 +233,56 @@ identify_card(pciConfigPtr pcr, int verbose)
else {
printf("\n");
if (verbose) {
- while(vdf[i].Vendor) {
+ for (i = 0; vdf[i].Vendor; i++) {
if (vdf[i].Vendor == pcr->pci_vendor) {
- int j = 0;
- while(vdf[i].Device[j].DeviceID) {
+ for (j = 0; vdf[i].Device[j].DeviceID; j++) {
if (vdf[i].Device[j].DeviceID == pcr->pci_device) {
vdf[i].Device[j].func(pcr);
return;
}
- j++;
}
break;
}
- i++;
}
}
}
- if (verbose) {
- printf(" CardVendor 0x%04x card 0x%04x\n",
+ if (verbose && !(pcr->pci_header_type & 0x7f) &&
+ (pcr->pci_subsys_vendor != 0 || pcr->pci_subsys_card != 0)) {
+ foundit = 0;
+ foundvendor = 0;
+ printf(" CardVendor 0x%04x card 0x%04x",
pcr->pci_subsys_vendor, pcr->pci_subsys_card);
+ for (i = 0; pvnd[i].name; i++) {
+ if (pvnd[i].token == pcr->pci_subsys_vendor) {
+ printf(" (%s", pvnd[i].name);
+ foundvendor = 1;
+ break;
+ }
+ }
+
+ for (i = 0; pvc[i].VendorID && pvc[i].VendorID != pcr->pci_subsys_vendor; i++)
+ ;
+ if (pvc[i].VendorID) {
+ for (j = 0; pvc[i].Device[j].CardName; j++) {
+ if (pvc[i].Device[j].SubsystemID == pcr->pci_subsys_card) {
+ printf(" %s)", pvc[i].Device[j].CardName);
+ foundit = 1;
+ break;
+ }
+ }
+ }
+ if (!foundit) {
+ if (!foundvendor)
+ printf(" (");
+ else
+ printf(", ");
+ printf("Card unknown)");
+ }
+ printf("\n");
+ }
+
+ if (verbose) {
if (pcr->pci_status_command)
printf(" STATUS 0x%04x COMMAND 0x%04x\n",
pcr->pci_status, pcr->pci_command);
@@ -283,41 +316,53 @@ print_default_class(pciConfigPtr pcr)
pcr->pci_bist, pcr->pci_header_type, pcr->pci_latency_timer,
pcr->pci_cache_line_size);
if (pcr->pci_base0)
- printf(" BASE0 0x%08x addr 0x%08x %s\n",
+ printf(" BASE0 0x%08x addr 0x%08x %s%s%s\n",
(int)pcr->pci_base0,(int)(pcr->pci_base0
& (pcr->pci_base0 & 0x1 ?
0xFFFFFFFC : 0xFFFFFFF0)),
- pcr->pci_base0 & 0x1 ? "I/O" : "MEM");
+ pcr->pci_base0 & 0x1 ? "I/O" : "MEM",
+ ((pcr->pci_base0 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base0 & 0x7) == 0x4) ? " 64BIT" : "");
if (pcr->pci_base1)
- printf(" BASE1 0x%08x addr 0x%08x %s\n",
+ printf(" BASE1 0x%08x addr 0x%08x %s%s%s\n",
(int)pcr->pci_base1, (int)(pcr->pci_base1
& (pcr->pci_base1 & 0x1 ?
0xFFFFFFFC : 0xFFFFFFF0)),
- pcr->pci_base1 & 0x1 ? "I/O" : "MEM");
+ pcr->pci_base1 & 0x1 ? "I/O" : "MEM",
+ ((pcr->pci_base1 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base1 & 0x7) == 0x4) ? " 64BIT" : "");
if (pcr->pci_base2)
- printf(" BASE2 0x%08x addr 0x%08x %s\n",
+ printf(" BASE2 0x%08x addr 0x%08x %s%s%s\n",
(int)pcr->pci_base2, (int)(pcr->pci_base2
& (pcr->pci_base2 & 0x1 ?
0xFFFFFFFC : 0xFFFFFFF0)),
- pcr->pci_base2 & 0x1 ? "I/O" : "MEM");
+ pcr->pci_base2 & 0x1 ? "I/O" : "MEM",
+ ((pcr->pci_base2 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base2 & 0x7) == 0x4) ? " 64BIT" : "");
if (pcr->pci_base3)
- printf(" BASE3 0x%08x addr 0x%08x %s\n",
+ printf(" BASE3 0x%08x addr 0x%08x %s%s%s\n",
(int)pcr->pci_base3, (int)(pcr->pci_base3
& (pcr->pci_base3 & 0x1 ?
0xFFFFFFFC : 0xFFFFFFF0)),
- pcr->pci_base3 & 0x1 ? "I/O" : "MEM");
+ pcr->pci_base3 & 0x1 ? "I/O" : "MEM",
+ ((pcr->pci_base3 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base3 & 0x7) == 0x4) ? " 64BIT" : "");
if (pcr->pci_base4)
- printf(" BASE4 0x%08x addr 0x%08x %s\n",
+ printf(" BASE4 0x%08x addr 0x%08x %s%s%s\n",
(int)pcr->pci_base4, (int)(pcr->pci_base4
& (pcr->pci_base4 & 0x1 ?
0xFFFFFFFC : 0xFFFFFFF0)),
- pcr->pci_base4 & 0x1 ? "I/O" : "MEM");
+ pcr->pci_base4 & 0x1 ? "I/O" : "MEM",
+ ((pcr->pci_base4 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base4 & 0x7) == 0x4) ? " 64BIT" : "");
if (pcr->pci_base5)
- printf(" BASE5 0x%08x addr 0x%08x %s\n",
+ printf(" BASE5 0x%08x addr 0x%08x %s%s%s\n",
(int)pcr->pci_base5, (int)(pcr->pci_base5
& (pcr->pci_base5 & 0x1 ?
0xFFFFFFFC : 0xFFFFFFF0)),
- pcr->pci_base5 & 0x1 ? "I/O" : "MEM");
+ pcr->pci_base5 & 0x1 ? "I/O" : "MEM",
+ ((pcr->pci_base5 & 0x9) == 0x8) ? " PREFETCHABLE" :"",
+ ((pcr->pci_base5 & 0x7) == 0x4) ? " 64BIT" : "");
if (pcr->pci_baserom)
printf(" BASEROM 0x%08x addr 0x%08x %sdecode-enabled\n",
(int)pcr->pci_baserom, (int)(pcr->pci_baserom & 0xFFFF8000),
@@ -379,6 +424,8 @@ print_mach64(pciConfigPtr pcr)
{
CARD32 sparse_io = 0;
+ printf(" CardVendor 0x%04x card 0x%04x\n",
+ pcr->pci_subsys_vendor, pcr->pci_subsys_card);
if (pcr->pci_status_command)
printf(" STATUS 0x%04x COMMAND 0x%04x\n",
pcr->pci_status, pcr->pci_command);
@@ -430,6 +477,8 @@ print_mach64(pciConfigPtr pcr)
void
print_i128(pciConfigPtr pcr)
{
+ printf(" CardVendor 0x%04x card 0x%04x\n",
+ pcr->pci_subsys_vendor, pcr->pci_subsys_card);
if (pcr->pci_status_command)
printf(" STATUS 0x%04x COMMAND 0x%04x\n",
pcr->pci_status, pcr->pci_command);
diff --git a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c
index 85f8094e7..620e99b84 100644
--- a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c
+++ b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c,v 1.11 2000/01/21 02:30:02 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.c,v 1.15 2000/07/01 01:40:46 martin Exp $ */
/* all driver need this */
#include "xf86.h"
@@ -266,13 +266,15 @@ static struct fb2pci_entry {
{ FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128RK },
{ FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128RL },
{ FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128PF },
+ { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128LE },
+ { FB_ACCEL_ATI_RAGE128, PCI_VENDOR_ATI, PCI_CHIP_RAGE128LF },
{ FB_ACCEL_3DFX_BANSHEE, PCI_VENDOR_3DFX, PCI_CHIP_VOODOO3 },
};
#define FB2PCICOUNT (sizeof(fb2pci_map)/sizeof(struct fb2pci_entry))
/* try to find the framebuffer device for a given PCI device */
static int
-fbdev_open_pci(pciVideoPtr pPci)
+fbdev_open_pci(pciVideoPtr pPci, char **namep)
{
struct fb_fix_screeninfo fix;
char filename[16];
@@ -299,45 +301,60 @@ fbdev_open_pci(pciVideoPtr pPci)
close(fd);
continue;
}
+ if (namep) {
+ *namep = xnfalloc(16);
+ xf86strncpy(*namep,fix.id,16);
+ }
return fd;
}
+ if (namep)
+ *namep = NULL;
return -1;
}
static int
-fbdev_open(char *dev)
+fbdev_open(char *dev, char** namep)
{
struct fb_con2fbmap c2m;
+ struct fb_fix_screeninfo fix;
char fbdev[16];
int fd;
/* try argument (from XF86Config) first */
- if (NULL != dev)
- return open(dev,O_RDWR,0);
-
- /* second: environment variable */
- dev = getenv("FRAMEBUFFER");
- if (NULL != dev)
- return open(dev,O_RDWR,0);
-
- /* last try: default device */
- if (-1 == (fd = open("/dev/fb0",O_RDWR,0)))
+ if ((NULL == dev) || ((fd = open(dev,O_RDWR,0)) == -1)) {
+ /* second: environment variable */
+ dev = getenv("FRAMEBUFFER");
+ if ((NULL == dev) || ((fd = open(dev,O_RDWR,0)) == -1)) {
+ /* last try: default device */
+ if (-1 == (fd = open("/dev/fb0",O_RDWR,0)))
+ return -1;
+ }
+ }
+ if (namep) {
+ if (-1 == ioctl(fd,FBIOGET_FSCREENINFO,(void*)(&fix))) {
+ *namep = NULL;
return -1;
-
+ } else {
+ if (namep) {
+ *namep = xnfalloc(16);
+ xf86strncpy(*namep,fix.id,16);
+ }
+ }
+ }
return fd;
}
/* -------------------------------------------------------------------- */
Bool
-fbdevHWProbe(pciVideoPtr pPci, char *device)
+fbdevHWProbe(pciVideoPtr pPci, char *device,char **namep)
{
int fd;
if (pPci)
- fd = fbdev_open_pci(pPci);
+ fd = fbdev_open_pci(pPci,namep);
else
- fd = fbdev_open(device);
+ fd = fbdev_open(device,namep);
if (-1 == fd)
return FALSE;
@@ -357,9 +374,9 @@ fbdevHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device)
/* open device */
if (pPci)
- fPtr->fd = fbdev_open_pci(pPci);
+ fPtr->fd = fbdev_open_pci(pPci,NULL);
else
- fPtr->fd = fbdev_open(device);
+ fPtr->fd = fbdev_open(device,NULL);
if (-1 == fPtr->fd)
return FALSE;
diff --git a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp
index c0807fe6a..778703b7f 100644
--- a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp
+++ b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp
@@ -1,5 +1,5 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp,v 1.1 1999/04/04 08:46:22 dawes Exp $
-.TH FBDEVHW __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.cpp,v 1.2 2000/06/14 02:13:16 dawes Exp $
+.TH FBDEVHW __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
fbdevhw \- os-specific submodule for framebuffer device access
.SH DESCRIPTION
diff --git a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h
index 37c305b90..a55edc81f 100644
--- a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h
+++ b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h,v 1.5 1999/07/18 03:27:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhw.h,v 1.6 2000/04/17 16:30:10 eich Exp $ */
#define FBDEVHW_PACKED_PIXELS 0 /* Packed Pixels */
#define FBDEVHW_PLANES 1 /* Non interleaved planes */
@@ -9,7 +9,7 @@
Bool fbdevHWGetRec(ScrnInfoPtr pScrn);
void fbdevHWFreeRec(ScrnInfoPtr pScrn);
-Bool fbdevHWProbe(pciVideoPtr pPci, char *device);
+Bool fbdevHWProbe(pciVideoPtr pPci, char *device, char **namep);
Bool fbdevHWInit(ScrnInfoPtr pScrn, pciVideoPtr pPci, char *device);
char* fbdevHWGetName(ScrnInfoPtr pScrn);
diff --git a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c
index 6f8d3eccf..502c6975c 100644
--- a/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c
+++ b/xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c,v 1.6 1999/07/18 08:14:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/fbdevhw/fbdevhwstub.c,v 1.7 2000/05/18 16:29:58 dawes Exp $ */
#include "xf86.h"
#include "xf86cmap.h"
@@ -20,7 +20,7 @@ fbdevHWFreeRec(ScrnInfoPtr pScrn)
Bool
-fbdevHWProbe(pciVideoPtr pPci, char *device)
+fbdevHWProbe(pciVideoPtr pPci, char *device, char **namep)
{
return FALSE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c
index 5cd25bd60..e82520f2e 100644
--- a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c
+++ b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c
@@ -6,7 +6,7 @@
* (c) 1998 Gerd Knorr <kraxel@cs.tu-berlin.de>
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c,v 1.6 1999/06/12 15:37:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.c,v 1.7 2000/06/13 02:28:35 dawes Exp $ */
#if 1
#include "misc.h"
@@ -38,17 +38,25 @@ typedef void *Pointer;
#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
@@ -60,6 +68,29 @@ I2CUDelay(I2CBusPtr b, int usec)
for (i = usec * bogo_usec; i > 0; i--)
/* (perhaps hw delay action) */;
}
+#else
+static void
+I2CUDelay(I2CBusPtr b, int usec)
+{
+ long b_secs, b_usecs;
+ long a_secs, a_usecs;
+ long d_secs, d_usecs;
+ long diff;
+
+ if (usec > 0) {
+ xf86getsecs(&b_secs, &b_usecs);
+ do {
+ /* It would be nice to use {xf86}usleep,
+ * but usleep (1) takes >10000 usec !
+ */
+ xf86getsecs(&a_secs, &a_usecs);
+ d_secs = (a_secs - b_secs);
+ d_usecs = (a_usecs - b_usecs);
+ diff = d_secs*1000000 + d_usecs;
+ } while (diff>0 && diff<usec);
+ }
+}
+#endif
/* Most drivers will register just with GetBits/PutBits functions.
* The following functions implement a software I2C protocol
diff --git a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h
index 1bb60562d..25c735058 100644
--- a/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h
+++ b/xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h
@@ -2,10 +2,12 @@
* Copyright (C) 1998 Itai Nahshon, Michael Schimek
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.4 1999/04/11 13:11:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/i2c/xf86i2c.h,v 1.5 2000/04/14 12:16:06 tsi Exp $ */
#ifndef _XF86I2C_H
#define _XF86I2C_H
+#include "miscstruct.h"
+
typedef unsigned char I2CByte;
typedef unsigned short I2CSlaveAddr;
diff --git a/xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp b/xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp
index 55b8870cd..ddf710e77 100644
--- a/xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp
+++ b/xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp
@@ -1,19 +1,18 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp,v 1.1 2000/03/03 01:05:48 dawes Exp $
-.TH DYNAPRO __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/dynapro/dynapro.cpp,v 1.4 2000/06/14 02:13:17 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH DYNAPRO __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
dynapro \- Dynapro input driver
.SH SYNOPSIS
-.B "Section ""InputDevice"""
-.br
-.BI " Identifier """ idevname """"
-.br
-.B " Driver ""dynapro"""
-.br
-.BI " Option ""Device"" """ devpath """"
-.br
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" idevname \*q
+.B " Driver \*qdynapro\*q"
+.BI " Option \*qDevice\*q \*q" devpath \*q
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B dynapro
is an XFree86 input driver for Dynapro devices...
@@ -32,6 +31,6 @@ section only covers configuration details specific to this driver.
.PP
Config details...
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__).
.SH AUTHORS
Authors include...
diff --git a/xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile b/xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile
index 514197c3e..35c9dbda9 100644
--- a/xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile,v 1.2 1999/08/14 10:50:00 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/Imakefile,v 1.3 2000/05/23 04:47:47 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -21,6 +21,11 @@ ObjectModuleTarget($(DRIVER),$(OBJS))
InstallObjectModule($(DRIVER),$(MODULEDIR),input)
+#if !defined(XF86DriverSDK)
+CppManTarget($(DRIVER),)
+InstallModuleManPage($(DRIVER))
+#endif
+
DependTarget()
InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input)
diff --git a/xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp b/xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp
new file mode 100644
index 000000000..58c01e3b9
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp
@@ -0,0 +1,40 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/elographics.cpp,v 1.2 2000/06/14 02:13:17 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH ELOGRAPHICS __drivermansuffix__ "Version 4.0.1" "XFree86"
+.SH NAME
+elographics \- Elographics input driver
+.SH SYNOPSIS
+.B "Section \*qInputDevice\*q"
+.br
+.BI " Identifier \*q" idevname \*q
+.br
+.B " Driver \*qelographics\*q"
+.br
+.BI " Option \*qDevice\*q \*q" devpath \*q
+.br
+\ \ ...
+.br
+.B EndSection
+.SH DESCRIPTION
+.B elographics
+is an XFree86 input driver for Elographics devices...
+.PP
+The
+.B elographics
+driver functions as a pointer input device, and may be used as the
+X server's core pointer.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+What is supported...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details and for options that can be used with all input drivers. This
+section only covers configuration details specific to this driver.
+.PP
+Config details...
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+.SH AUTHORS
+Authors include...
+ Patrick Lecoanet
diff --git a/xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c b/xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c
index 22db1c557..f4f5c4ca5 100644
--- a/xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c
+++ b/xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c
@@ -22,7 +22,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c,v 1.7 1999/12/13 23:38:13 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/input/elographics/xf86Elo.c,v 1.10 2000/06/07 22:03:09 tsi Exp $ */
/*
*******************************************************************************
@@ -292,12 +292,10 @@ static int debug_level = 0;
#undef read
#undef write
#undef close
-#undef strdup
#define SYSCALL(call) call
#define read(fd, ptr, num) xf86ReadSerial(fd, ptr, num)
#define write(fd, ptr, num) xf86WriteSerial(fd, ptr, num)
#define close(fd) xf86CloseSerial(fd)
-#define strdup(str) xf86strdup(str)
#endif
@@ -1745,7 +1743,7 @@ xf86EloInit(InputDriverPtr drv,
#ifdef XFree86LOADER
static
#endif
-InputDriverRec ELO = {
+InputDriverRec ELOGRAPHICS = {
1, /* driver version */
"elographics", /* driver name */
NULL, /* identify */
@@ -1755,13 +1753,14 @@ InputDriverRec ELO = {
0 /* ref count */
};
+#ifdef XFree86LOADER
static pointer
Plug(pointer module,
pointer options,
int *errmaj,
int *errmin)
{
- xf86AddInputDriver(&ELO, module, 0);
+ xf86AddInputDriver(&ELOGRAPHICS, module, 0);
return module;
}
@@ -1792,4 +1791,5 @@ static XF86ModuleVersionInfo version_rec = {
*/
XF86ModuleData elographicsModuleData = { &version_rec, Plug, Unplug };
+#endif
#endif /* XFREE86_V4 */
diff --git a/xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp b/xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp
index dab66ca60..ff163e5c2 100644
--- a/xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp
+++ b/xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp,v 1.1 2000/03/03 01:05:49 dawes Exp $
-.TH KEYBOARD __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/keyboard/keyboard.cpp,v 1.4 2000/06/14 02:13:17 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH KEYBOARD __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
keyboard \- Keyboard input driver
.SH SYNOPSIS
-.B "Section ""InputDevice"""
-.br
-.BI " Identifier """ idevname """"
-.br
-.B " Driver ""keyboard"""
-.br
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" idevname \*q
+.B " Driver \*qkeyboard\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B keyboard
is an XFree86 input driver for keyboards. The driver supports the standard
@@ -32,7 +32,7 @@ The following driver
.B Options
are supported:
.TP 7
-.BI "Option ""Protocol"" """ string """
+.BI "Option \*qProtocol\*q \*q" string \*q
Specify the mouse protocol. Valid protocol types include:
.PP
.RS 12
@@ -43,7 +43,7 @@ Standard, Xqueue.
Not all protocols are supported on all platforms. Default: "Standard".
.RE
.TP 7
-.BI "Option ""AutoRepeat"" """ "delay rate" """
+.BI "Option \*qAutoRepeat\*q \*q" "delay rate" \*q
sets the auto repeat behaviour for the keyboard. This is not implemented
on all platforms.
.I delay
@@ -51,18 +51,18 @@ is the time in milliseconds before a key starts repeating.
.I rate
is the number of times a key repeats per second. Default: "500 30".
.TP 7
-.BI "Option ""XLeds"" """ ledlist """
+.BI "Option \*qXLeds\*q \*q" ledlist \*q
makes the keyboard LEDs specified in
.I ledlist
available for client use instead of their traditional function
(Scroll Lock, Caps Lock and Num Lock). The numbers in the list are
in the range 1 to 3. Default: empty list.
.TP 7
-.BI "Option ""XkbDisable"" """ boolean """
+.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.
.TP 7
-.BI "Option ""XkbRules"" """ rules """
+.BI "Option \*qXkbRules\*q \*q" rules \*q
specifies which XKB rules file to use for interpreting the
.BR XkbModel ,
.BR XkbLayout ,
@@ -72,21 +72,21 @@ and
settings. Default: "xfree86" for most platforms, but "xfree98" for the
Japanese PC-98 platforms.
.TP 7
-.BI "Option ""XkbModel"" """ modelname """
+.BI "Option \*qXkbModel\*q \*q" modelname \*q
specifies the XKB keyboard model name. Default: "pc101" for most platforms,
but "pc98" for the Japanese PC-98 platforms, and "pc101_sol8x86" for
Solaris 8 on x86.
.TP 7
-.BI "Option ""XkbLayout"" """ layoutname """
+.BI "Option \*qXkbLayout\*q \*q" layoutname \*q
specifies the XKB keyboard layout name. This is usually the country or
language type of the keyboard. Default: "us" for most platforms, but
"nec/jp" for the Japanese PC-98 platforms.
.TP 7
-.BI "Option ""XkbVariant"" """ variants """
+.BI "Option \*qXkbVariant\*q \*q" variants \*q
specifies the XKB keyboard variant components. These can be used to
enhance the keyboard layout details. Default: not set.
.TP 7
-.BI "Option ""XkbOptions"" """ options """
+.BI "Option \*qXkbOptions\*q \*q" options \*q
specifies the XKB keyboard option components. These can be used to
enhance the keyboard behaviour. Default: not set.
.PP
@@ -94,4 +94,4 @@ Some other XKB-related options are available, but they are incompatible
with the ones listed above and are not recommended, so they are not
documented here.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__).
diff --git a/xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp b/xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp
index 3507b8f50..c29ebd7bb 100644
--- a/xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp
+++ b/xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp
@@ -1,19 +1,18 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp,v 1.1 2000/03/03 01:05:49 dawes Exp $
-.TH MICROTOUCH __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/microtouch/microtouch.cpp,v 1.4 2000/06/14 02:13:18 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH MICROTOUCH __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
microtouch \- MicroTouch input driver
.SH SYNOPSIS
-.B "Section ""InputDevice"""
-.br
-.BI " Identifier """ idevname """"
-.br
-.B " Driver ""microtouch"""
-.br
-.BI " Option ""Device"" """ devpath """"
-.br
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" idevname \*q
+.B " Driver \*qmicrotouch\*q"
+.BI " Option \*qDevice\*q \*q" devpath \*q
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B microtouch
is an XFree86 input driver for MicroTouch devices...
@@ -32,6 +31,6 @@ section only covers configuration details specific to this driver.
.PP
Config details...
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__).
.SH AUTHORS
Authors include...
diff --git a/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c b/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c
index 04afed9f1..6e9d3369c 100644
--- a/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c
+++ b/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c,v 1.28 2000/03/06 22:59:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.c,v 1.33 2000/06/28 07:51:50 keithp Exp $ */
/*
*
* Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
@@ -60,6 +60,7 @@
#include "xf86_ansic.h"
#include "xisb.h"
#include "mouse.h"
+#include "mousePriv.h"
#include "mipointer.h"
static InputInfoPtr MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags);
@@ -76,8 +77,6 @@ static void MouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl);
static void MousePostEvent(InputInfoPtr pInfo, int buttons,
int dx, int dy, int dz, int dw);
static void MouseReadInput(InputInfoPtr pInfo);
-/* XXX This is temporary. */
-const char * xf86ProtocolIDToName(ProtocolID id);
#undef MOUSE
InputDriverRec MOUSE = {
@@ -199,7 +198,7 @@ static MouseProtocolRec mouseProtocols[] = {
{ NULL, MSE_NONE, NULL, PROT_UNKNOWN }
};
-static ProtocolID
+static MouseProtocolID
ProtocolNameToID(const char *name)
{
int i;
@@ -211,7 +210,7 @@ ProtocolNameToID(const char *name)
}
static const char *
-ProtocolIDToName(ProtocolID id)
+ProtocolIDToName(MouseProtocolID id)
{
int i;
@@ -231,13 +230,19 @@ ProtocolIDToName(ProtocolID id)
}
const char *
-xf86ProtocolIDToName(ProtocolID id)
+xf86MouseProtocolIDToName(MouseProtocolID id)
{
return ProtocolIDToName(id);
}
+MouseProtocolID
+xf86MouseProtocolNameToID(const char *name)
+{
+ return ProtocolNameToID(name);
+}
+
static int
-ProtocolIDToClass(ProtocolID id)
+ProtocolIDToClass(MouseProtocolID id)
{
int i;
@@ -255,7 +260,7 @@ ProtocolIDToClass(ProtocolID id)
}
static MouseProtocolPtr
-GetProtocol(ProtocolID id) {
+GetProtocol(MouseProtocolID id) {
int i;
switch (id) {
@@ -414,7 +419,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
MouseDevPtr pMse;
MessageType from = X_DEFAULT;
const char *protocol;
- ProtocolID protocolID;
+ MouseProtocolID protocolID;
MouseProtocolPtr pProto;
if (!InitProtocols())
@@ -492,12 +497,15 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
pMse->protocol = protocol;
pMse->protocolID = protocolID;
pMse->class = ProtocolIDToClass(protocolID);
- pMse->automatic = (protocolID == PROT_AUTO);
/* Collect the options, and process the common options. */
xf86CollectInputOptions(pInfo, pProto->defaults, NULL);
xf86ProcessCommonOptions(pInfo, pInfo->options);
+ /* XXX should handle this OS dependency elsewhere. */
+#ifndef __OS2ELF__
+ /* OS/2 has a mouse handled by the OS - it cannot fail here */
+
/* Check if the device can be opened. */
pInfo->fd = xf86OpenSerial(pInfo->options);
if (pInfo->fd == -1) {
@@ -511,6 +519,7 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
}
}
xf86CloseSerial(pInfo->fd);
+#endif
pInfo->fd = -1;
pMse->CommonOptions(pInfo);
@@ -547,8 +556,8 @@ MousePreInit(InputDriverPtr drv, IDevPtr dev, int flags)
}
/*
- * This array is indexed by the ProtocolID values, so the order of the entries
- * must match that of the ProtocolID enum in mouse.h.
+ * This array is indexed by the MouseProtocolID values, so the order of the entries
+ * must match that of the MouseProtocolID enum in mouse.h.
*/
static unsigned char proto[PROT_NUMPROTOS][8] = {
/* --header-- ---data--- packet -4th-byte- mouse */
@@ -635,14 +644,17 @@ SetupMouse(InputInfoPtr pInfo)
int protoPara[8] = {-1, -1, -1, -1, -1, -1, -1, -1};
const char *name = NULL;
const char *s;
+ Bool automatic = FALSE;
unsigned char c;
- ProtocolID protocolID = PROT_UNKNOWN;
pointer options;
pMse = pInfo->private;
-
/* Handle the "Auto" protocol. */
- if (pMse->automatic) {
+ if (pMse->protocolID == PROT_AUTO) {
+ MouseProtocolID protocolID = PROT_UNKNOWN;
+
+ automatic = TRUE;
+
/* Check if the OS has a detection mechanism. */
if (osInfo->SetupAuto) {
name = osInfo->SetupAuto(pInfo, protoPara);
@@ -681,19 +693,20 @@ SetupMouse(InputInfoPtr pInfo)
}
}
memcpy(pMse->protoPara, proto[pMse->protocolID], sizeof(pMse->protoPara));
- if (pMse->automatic && name) {
- /* Possible protoPara overrides from SetupAuto. */
- for (i = 0; i < sizeof(pMse->protoPara); i++)
- if (protoPara[i] != -1)
- pMse->protoPara[i] = protoPara[i];
- }
-
- if (pMse->automatic && !name) {
- xf86Msg(X_ERROR, "%s: cannot determine the mouse protocol\n",
- pInfo->name);
- return FALSE;
+ if (automatic) {
+
+ if (name) {
+ /* Possible protoPara overrides from SetupAuto. */
+ for (i = 0; i < sizeof(pMse->protoPara); i++)
+ if (protoPara[i] != -1)
+ pMse->protoPara[i] = protoPara[i];
+ } else {
+ xf86Msg(X_ERROR, "%s: cannot determine the mouse protocol\n",
+ pInfo->name);
+ return FALSE;
+ }
}
-
+
/* Set the port parameters. */
xf86SetSerial(pInfo->fd, pInfo->options);
param = NULL;
@@ -1434,7 +1447,7 @@ MouseProc(DeviceIntPtr device, int what)
InputInfoPtr pInfo;
MouseDevPtr pMse;
unsigned char map[MSE_MAXBUTTONS + 1];
- int i;
+ int i, blocked;
pInfo = device->public.devicePrivate;
pMse = pInfo->private;
@@ -1496,8 +1509,16 @@ MouseProc(DeviceIntPtr device, int what)
pMse->lastButtons = 0;
pMse->emulateState = 0;
device->public.on = TRUE;
+ /*
+ * send button up events for sanity. If no button down is pending
+ * xf86PostButtonEvent() will discard them. So we are on the safe side.
+ */
+ blocked = xf86BlockSIGIO ();
+ for (i = 1; i <= 5; i++)
+ xf86PostButtonEvent(device,0,i,0,0,0);
+ xf86UnblockSIGIO (blocked);
break;
-
+
case DEVICE_OFF:
case DEVICE_CLOSE:
if (pInfo->fd != -1) {
diff --git a/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp b/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp
index 9c3dfce4d..d71323380 100644
--- a/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp
+++ b/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp
@@ -1,21 +1,19 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp,v 1.1 2000/03/03 01:05:50 dawes Exp $
-.TH MOUSE __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.cpp,v 1.4 2000/06/14 02:13:18 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH MOUSE __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
mouse \- Mouse input driver
.SH SYNOPSIS
-.B "Section ""InputDevice"""
-.br
-.BI " Identifier """ idevname """"
-.br
-.B " Driver ""mouse"""
-.br
-.BI " Option ""Protocol"" """ protoname """"
-.br
-.BI " Option ""Device"" """ devpath """"
-.br
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" idevname \*q
+.B " Driver \*qmouse\*q"
+.BI " Option \*qProtocol\*q \*q" protoname \*q
+.BI " Option \*qDevice\*q \*q" devpath \*q
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B mouse
is an XFree86 input driver for mice. The driver supports most available
@@ -52,7 +50,7 @@ The following driver
.B Options
are supported:
.TP 7
-.BI "Option ""Protocol"" """ string """
+.BI "Option \*qProtocol\*q \*q" string \*q
Specify the mouse protocol. Valid protocol types include:
.PP
.RS 12
@@ -66,37 +64,38 @@ NetMousePS/2, NetScrollPS/2, BusMouse, SysMouse, WSMouse, USB, Xqueue.
Not all protocols are supported on all platforms. The "Auto" platform
specifies that protocol auto-detection should be attempted. There is no
default protocol setting, and specifying this option is mandatory.
+.RE
.TP 7
-.BI "Option ""Device"" """ string """
+.BI "Option \*qDevice\*q \*q" string \*q
Specifies the device through which the mouse can be accessed. A common
setting is "/dev/mouse", which is often a symbolic link to the real
device. This option is mandatory, and there is no default setting.
.TP 7
-.BI "Option ""Buttons"" """ integer """
+.BI "Option \*qButtons\*q \*q" integer \*q
Specifies the number of mouse buttons. In cases where the number of buttons
cannot be auto-detected, the default value is 3.
.TP 7
-.BI "Option ""Emulate3Buttons"" """ boolean """
+.BI "Option \*qEmulate3Buttons\*q \*q" boolean \*q
Enable/disable the emulation of the third (middle) mouse button for mice
which only have two physical buttons. The third button is emulated by
pressing both buttons simultaneously. Default: off
.TP 7
-.BI "Option ""Emulate3Timeout"" """ integer """
+.BI "Option \*qEmulate3Timeout\*q \*q" integer \*q
Sets the timeout (in milliseconds) that the driver waits before decicing
if two buttons where pressed "simultaneously" when 3 button emulation is
enabled. Default: 50.
.TP 7
-.BI "Option ""ChordMiddle"" """ boolean """
+.BI "Option \*qChordMiddle\*q \*q" boolean \*q
Enable/disable handling of mice that send left+right events when the middle
button is used. Default: off.
.TP 7
-.BI "Option ""ZAxisMapping"" ""X"""
+.BI "Option \*qZAxisMapping\*q \*qX\*q"
.TP 7
-.BI "Option ""ZAxisMapping"" ""Y"""
+.BI "Option \*qZAxisMapping\*q \*qY\*q"
.TP 7
-.BI "Option ""ZAxisMapping"" """ "N1 N2" """
+.BI "Option \*qZAxisMapping\*q \*q" "N1 N2" \*q
.TP 7
-.BI "Option ""ZAxisMapping"" """ "N1 N2 N3 N4" """
+.BI "Option \*qZAxisMapping\*q \*q" "N1 N2 N3 N4" \*q
Set the mapping for the Z axis (wheel) motion to buttons or another axis
.RB ( X
or
@@ -112,33 +111,33 @@ of the second wheel mapped respectively to buttons number
and
.IR N4 .
.TP 7
-.BI "Option ""FlipXY"" """ boolean """
+.BI "Option \*qFlipXY\*q \*q" boolean \*q
Enable/disable swapping the X and Y axes. Default: off.
.TP 7
-.BI "Option ""SampleRate"" """ integer """
+.BI "Option \*qSampleRate\*q \*q" integer \*q
Sets the number of motion/button events the mouse sends per second. Setting
this is only supported for some mice, including some Logitech mice and
some PS/2 mice on some platforms. Default: whatever the mouse is
already set to.
.TP 7
-.BI "Option ""Resolution"" """ integer """
+.BI "Option \*qResolution\*q \*q" integer \*q
Sets the resolution of the device in counts per inch. Setting this is
only supported for some mice, including some PS/2 mice on some platforms.
Default: whatever the mouse is already set to.
.TP 7
-.BI "Option ""ClearDTR"" """ boolean """
+.BI "Option \*qClearDTR\*q \*q" boolean \*q
Enable/disable clearing the DTR line on the serial port used by the mouse.
Some dual-protocol mice require the DTR line to be cleared to operate
in the non-default protocol. This option is for serial mice only.
Default: off.
.TP 7
-.BI "Option ""ClearRTS"" """ boolean """
+.BI "Option \*qClearRTS\*q \*q" boolean \*q
Enable/disable clearing the RTS line on the serial port used by the mouse.
Some dual-protocol mice require the RTS line to be cleared to operate
in the non-default protocol. This option is for serial mice only.
Default: off.
.TP 7
-.BI "Option ""BaudRate"" """ integer """
+.BI "Option \*qBaudRate\*q \*q" integer \*q
Set the baud rate to use for communicating with a serial mouse. This
option should rarely be required because the default is correct for almost
all situations. Valid values include: 300, 1200, 2400, 4800, 9600, 19200.
@@ -148,5 +147,5 @@ There are some other options that may be used to control various parameters
for serial port communication, but they are not documented here because
the driver sets them correctly for each mouse protocol type.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1),
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__),
README.mouse.
diff --git a/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h b/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h
index 71a64221d..dd000e08d 100644
--- a/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h
+++ b/xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h
@@ -1,15 +1,13 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h,v 1.8 2000/02/10 22:33:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mouse.h,v 1.10 2000/04/19 15:48:35 tsi Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
*/
-#ifndef _X_MOUSE_H
-#define _X_MOUSE_H
+#ifndef MOUSE_H_
+#define MOUSE_H_
-/* Private interface for the mouse driver. */
-
-/* Protocol IDs. These are for internal use only. */
+/* Mouse Protocol IDs. */
typedef enum {
PROT_UNKNOWN = -2,
PROT_UNSUP = -1, /* protocol is not supported */
@@ -35,20 +33,9 @@ typedef enum {
PROT_AUTO,
PROT_SYSMOUSE,
PROT_NUMPROTOS /* This must always be last. */
-} ProtocolID;
-
-typedef struct {
- const char * name;
- int class;
- const char ** defaults;
- ProtocolID id;
-} MouseProtocolRec, *MouseProtocolPtr;
-
-/* mouse proto flags */
-#define MPF_NONE 0x00
-#define MPF_SAFE 0x01
+} MouseProtocolID;
-/* pnp.c */
-int MouseGetPnpProtocol(InputInfoPtr pInfo);
+const char * xf86MouseProtocolIDToName(MouseProtocolID id);
+MouseProtocolID xf86MouseProtocolNameToID(const char *name);
-#endif /* _X_MOUSE_H */
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/input/mouse/mousePriv.h b/xc/programs/Xserver/hw/xfree86/input/mouse/mousePriv.h
new file mode 100644
index 000000000..a5a43ea4c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/input/mouse/mousePriv.h
@@ -0,0 +1,27 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mouse/mousePriv.h,v 1.5 2000/05/31 07:15:06 eich Exp $ */
+/*
+ * Copyright (c) 1997-1999 by The XFree86 Project, Inc.
+ */
+
+#ifndef _X_MOUSEPRIV_H
+#define _X_MOUSEPRIV_H
+
+#include "mouse.h"
+#include "xf86Xinput.h"
+/* Private interface for the mouse driver. */
+
+typedef struct {
+ const char * name;
+ int class;
+ const char ** defaults;
+ MouseProtocolID id;
+} MouseProtocolRec, *MouseProtocolPtr;
+
+/* mouse proto flags */
+#define MPF_NONE 0x00
+#define MPF_SAFE 0x01
+
+/* pnp.c */
+int MouseGetPnpProtocol(InputInfoPtr pInfo);
+
+#endif /* _X_MOUSE_H */
diff --git a/xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile b/xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile
index 073ef10dc..380c7ff23 100644
--- a/xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile,v 1.2 1999/08/14 10:50:02 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/Imakefile,v 1.3 2000/05/23 04:47:47 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -21,6 +21,11 @@ ObjectModuleTarget($(DRIVER),$(OBJS))
InstallObjectModule($(DRIVER),$(MODULEDIR),input)
+#if !defined(XF86DriverSDK)
+CppManTarget($(DRIVER),)
+InstallModuleManPage($(DRIVER))
+#endif
+
DependTarget()
InstallDriverSDKObjectModule($(DRIVER),$(DRIVERSDKMODULEDIR),input)
diff --git a/xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp b/xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp
new file mode 100644
index 000000000..936a44d13
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp
@@ -0,0 +1,40 @@
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/mutouch.cpp,v 1.2 2000/06/14 02:13:18 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH MUTOUCH __drivermansuffix__ "Version 4.0.1" "XFree86"
+.SH NAME
+mutouch \- Microtouch input driver
+.SH SYNOPSIS
+.B "Section \*qInputDevice\*q"
+.br
+.BI " Identifier \*q" idevname \*q
+.br
+.B " Driver \*qmutouch\*q"
+.br
+.BI " Option \*qDevice\*q \*q" devpath \*q
+.br
+\ \ ...
+.br
+.B EndSection
+.SH DESCRIPTION
+.B mutouch
+is an XFree86 input driver for Microtouch devices...
+.PP
+The
+.B mutouch
+driver functions as a pointer input device, and may be used as the
+X server's core pointer.
+THIS MAN PAGE NEEDS TO BE FILLED IN.
+.SH SUPPORTED HARDWARE
+What is supported...
+.SH CONFIGURATION DETAILS
+Please refer to XF86Config(__filemansuffix__) for general configuration
+details and for options that can be used with all input drivers. This
+section only covers configuration details specific to this driver.
+.PP
+Config details...
+.SH "SEE ALSO"
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+.SH AUTHORS
+Authors include...
+ Patrick Lecoanet
diff --git a/xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c b/xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c
index ae407c7fd..9f0fc9f8c 100644
--- a/xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c
+++ b/xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c
@@ -21,7 +21,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c,v 1.9 1999/12/13 23:38:14 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/input/mutouch/xf86MuTouch.c,v 1.12 2000/06/07 22:03:10 tsi Exp $ */
/*
*******************************************************************************
@@ -291,14 +291,10 @@ static int debug_level = 0;
#undef read
#undef write
#undef close
-#undef strdup
-#undef strcmp
#define SYSCALL(call) call
#define read(fd, ptr, num) xf86ReadSerial(fd, ptr, num)
#define write(fd, ptr, num) xf86WriteSerial(fd, ptr, num)
#define close(fd) xf86CloseSerial(fd)
-#define strdup(str) xf86strdup(str)
-#define strcmp(str1, str2) xf86strcmp(str1, str2)
#endif
@@ -1843,7 +1839,7 @@ xf86MuTInit(InputDriverPtr drv,
#ifdef XFree86LOADER
static
#endif
-InputDriverRec MUT = {
+InputDriverRec MUTOUCH = {
1, /* driver version */
"mutouch", /* driver name */
NULL, /* identify */
@@ -1853,13 +1849,14 @@ InputDriverRec MUT = {
0 /* ref count */
};
+#ifdef XFree86LOADER
static pointer
Plug(pointer module,
pointer options,
int *errmaj,
int *errmin)
{
- xf86AddInputDriver(&MUT, module, 0);
+ xf86AddInputDriver(&MUTOUCH, module, 0);
return module;
}
@@ -1889,5 +1886,6 @@ static XF86ModuleVersionInfo version_rec = {
* Do not change it.
*/
XF86ModuleData mutouchModuleData = { &version_rec, Plug, Unplug };
+#endif
#endif /* XFREE86_V4 */
diff --git a/xc/programs/Xserver/hw/xfree86/input/void/void.cpp b/xc/programs/Xserver/hw/xfree86/input/void/void.cpp
index 9a321faf9..0a6b756a1 100644
--- a/xc/programs/Xserver/hw/xfree86/input/void/void.cpp
+++ b/xc/programs/Xserver/hw/xfree86/input/void/void.cpp
@@ -1,17 +1,17 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/void/void.cpp,v 1.1 2000/03/03 01:05:50 dawes Exp $
-.TH VOID __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/void/void.cpp,v 1.4 2000/06/14 02:13:19 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH VOID __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
void \- null input driver
.SH SYNOPSIS
-.B "Section ""InputDevice"""
-.br
-.BI " Identifier """ idevname """"
-.br
-.B " Driver ""void"""
-.br
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" idevname \*q
+.B " Driver \*qvoid\*q"
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B void
is an dummy/null XFree86 input driver. It doesn't connect to any
@@ -24,6 +24,6 @@ Please refer to XF86Config(__filemansuffix__) for general configuration
details and for options that can be used with all input drivers. This
driver doesn't have any configuration options in addition to those.
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__).
.SH AUTHORS
Authors include...
diff --git a/xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp b/xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp
index a346b4f7c..57c7bdf7e 100644
--- a/xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp
+++ b/xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp
@@ -1,19 +1,18 @@
-.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp,v 1.1 2000/03/03 01:05:51 dawes Exp $
-.TH WACOM __drivermansuffix__ "Version 4.0" "XFree86"
+.\" $XFree86: xc/programs/Xserver/hw/xfree86/input/wacom/wacom.cpp,v 1.4 2000/06/14 02:13:19 dawes Exp $
+.\" shorthand for double quote that works everywhere.
+.ds q \N'34'
+.TH WACOM __drivermansuffix__ "Version 4.0.1" "XFree86"
.SH NAME
wacom \- Wacom input driver
.SH SYNOPSIS
-.B "Section ""InputDevice"""
-.br
-.BI " Identifier """ idevname """"
-.br
-.B " Driver ""wacom"""
-.br
-.BI " Option ""Device"" """ devpath """"
-.br
+.nf
+.B "Section \*qInputDevice\*q"
+.BI " Identifier \*q" idevname \*q
+.B " Driver \*qwacom\*q"
+.BI " Option \*qDevice\*q \*q" devpath \*q
\ \ ...
-.br
.B EndSection
+.fi
.SH DESCRIPTION
.B wacom
is an XFree86 input driver for Wacom devices...
@@ -32,6 +31,6 @@ section only covers configuration details specific to this driver.
.PP
Config details...
.SH "SEE ALSO"
-XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(1).
+XFree86(1), XF86Config(__filemansuffix__), xf86config(1), Xserver(1), X(__miscmansuffix__).
.SH AUTHORS
Authors include...
diff --git a/xc/programs/Xserver/hw/xfree86/int10/Imakefile b/xc/programs/Xserver/hw/xfree86/int10/Imakefile
index dab002c0b..c8160fdaf 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/int10/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/int10/Imakefile,v 1.6 2000/02/29 03:09:24 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/int10/Imakefile,v 1.9 2000/04/17 16:30:11 eich Exp $
/* An OS-independent INT10 module/library */
@@ -16,7 +16,7 @@ X86TOPDIR = $(TOP)/extras/x86emu
X86SRCDIR = $(X86TOPDIR)/src/x86emu
X86EMUINCLUDES = -I$(X86TOPDIR)/include -I$(X86SRCDIR)
-#if !defined(X86EMU_LIBPATH)
+# if !defined(X86EMU_LIBPATH)
X86EMUSRCS = debug.c decode.c fpu.c ops.c ops2.c prim_ops.c sys.c
X86EMUOBJS = debug.o decode.o fpu.o ops.o ops2.o prim_ops.o sys.o
@@ -28,16 +28,16 @@ LinkSourceFile(ops2.c,$(X86SRCDIR))
LinkSourceFile(prim_ops.c,$(X86SRCDIR))
LinkSourceFile(sys.c,$(X86SRCDIR))
-#else
+# else
BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu)
X86EMUOBJS = x86emu.o
-#endif
+# endif
X86EMUDEFINES = -D__DRIVER__ -DFORCE_POST -D_CEXPORT= -DNO_LONG_LONG
-#if defined(i386Architecture)
+# if defined(i386Architecture)
ARCHDEFINES = -D_PC
-#endif
+# endif
INT10DEFINES = -D_X86EMU $(ARCHDEFINES)
@@ -55,9 +55,11 @@ INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
DEFINES = $(X86EMUDEFINES) $(INT10DEFINES)
+ModuleObjectRule()
LibraryModuleTarget(int10,$(OBJS))
InstallLibraryModule(int10,$(MODULEDIR),.)
DependTarget()
+InstallDriverSDKNonExecFile(xf86int10.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/hw/xfree86/int10/generic.c b/xc/programs/Xserver/hw/xfree86/int10/generic.c
index 5caf043f7..af12efe23 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/generic.c
+++ b/xc/programs/Xserver/hw/xfree86/int10/generic.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/generic.c,v 1.3 2000/02/18 16:23:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/generic.c,v 1.9 2000/06/07 22:03:10 tsi Exp $ */
/*
* XFree86 int10 module
* execute BIOS int 10h calls in x86 real mode environment
@@ -14,6 +14,8 @@
#include "xf86int10.h"
#include "int10Defines.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);
@@ -28,10 +30,11 @@ static void write_l(xf86Int10InfoPtr pInt,int addr, CARD32 val);
typedef struct {
int shift;
- int pagesize_1;
int entries;
+ void* base;
void* vRam;
- memType *alloc_rec;
+ void* sysMem;
+ char* alloc;
} genericInt10Priv;
#define INTPriv(x) ((genericInt10Priv*)x->private)
@@ -47,8 +50,6 @@ int10MemRec genericMem = {
static void MapVRam(xf86Int10InfoPtr pInt);
static void UnmapVRam(xf86Int10InfoPtr pInt);
-static void setupTable(xf86Int10InfoPtr pInt, memType address,
- int loc,int size);
static void *sysMem = NULL;
@@ -57,11 +58,8 @@ xf86InitInt10(int entityIndex)
{
xf86Int10InfoPtr pInt;
int screen;
- void* intMem;
- void* vbiosMem;
- int pagesize;
- int entries;
- int shift;
+ void* base = 0;
+ void* vbiosMem = 0;
legacyVGARec vga;
screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
@@ -74,18 +72,11 @@ xf86InitInt10(int entityIndex)
if (!xf86Int10ExecSetup(pInt))
goto error0;
pInt->mem = &genericMem;
- pagesize = xf86getpagesize();
pInt->private = (pointer)xnfcalloc(1,sizeof(genericInt10Priv));
- entries = SYS_SIZE / pagesize;
-
+ INTPriv(pInt)->alloc =
+ (pointer)xnfcalloc(1,sizeof(ALLOC_ENTRIES(getpagesize())));
pInt->scrnIndex = screen;
- INTPriv(pInt)->pagesize_1 = pagesize - 1;
- INTPriv(pInt)->entries = entries;
- INTPriv(pInt)->alloc_rec =
- xnfcalloc(1,sizeof(memType) * entries);
- for (shift = 0 ; (pagesize >> shift) ; shift++) {};
- shift -= 1;
- INTPriv(pInt)->shift = shift;
+ base = INTPriv(pInt)->base = xnfalloc(0xf0000);
/*
* we need to map video RAM MMIO as some chipsets map mmio
@@ -93,54 +84,43 @@ xf86InitInt10(int entityIndex)
*/
MapVRam(pInt);
- intMem = xnfalloc(pagesize);
- setupTable(pInt,(memType)intMem,0,pagesize);
- vbiosMem = xnfalloc(V_BIOS_SIZE);
-
#ifdef _PC
if (!sysMem)
sysMem = xf86MapVidMem(screen,VIDMEM_FRAMEBUFFER,SYS_BIOS,BIOS_SIZE);
- setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE);
- if (xf86ReadBIOS(0,0,(unsigned char *)intMem,LOW_PAGE_SIZE) < 0) {
+ INTPriv(pInt)->sysMem = sysMem;
+
+ if (xf86ReadBIOS(0,0,(unsigned char *)base,LOW_PAGE_SIZE) < 0) {
xf86DrvMsg(screen,X_ERROR,"Cannot read int vect\n");
goto error1;
}
if (xf86IsEntityPrimary(entityIndex)) {
- int size;
int cs = MEM_RW(pInt,((0x10<<2)+2));
- xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segmant is: 0x%x\n",cs);
- if (xf86ReadBIOS(cs << 4,0,(unsigned char *)vbiosMem,
- 0x10) < 0) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (1)\n");
- goto error1;
- }
- if (!((*(CARD8*)vbiosMem == 0x55)
- && (*((CARD8*)vbiosMem + 1) == 0xAA))) {
- xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
- goto error1;
+
+ vbiosMem = (unsigned char *)base + (cs << 4);
+ if (!int10_read_bios(screen,cs,vbiosMem)) {
+ cs = MEM_RW(pInt,((0x42<<2)+2));
+ vbiosMem = (unsigned char *)base + (cs << 4);
+ if (!int10_read_bios(screen,cs,vbiosMem)) {
+ cs = V_BIOS >> 4;
+ vbiosMem = (unsigned char *)base + (cs << 4);
+ if (!int10_read_bios(screen,cs,vbiosMem)) {
+ xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
+ goto error1;
+ }
+ }
}
+ xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segment is: 0x%x\n",cs);
- size = *((CARD8*)vbiosMem + 2) * 512;
- if (xf86ReadBIOS(cs << 4,0,vbiosMem, size) < 0) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (2)\n");
- goto error1;
- }
- if (bios_checksum(vbiosMem,size)) {
- xf86DrvMsg(screen,X_ERROR,"Bad checksum of V_BIOS \n");
- goto error1;
- }
-
- setupTable(pInt,(memType)vbiosMem,cs<<4,size);
set_return_trap(pInt);
pInt->BIOSseg = cs;
} else {
reset_int_vect(pInt);
set_return_trap(pInt);
+ vbiosMem = (unsigned char *)base + V_BIOS;
if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) {
xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3)\n");
goto error1;
}
- setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE);
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0xe6;
LockLegacyVGA(screen, &vga);
@@ -152,14 +132,14 @@ xf86InitInt10(int entityIndex)
sysMem = xnfalloc(BIOS_SIZE);
setup_system_bios((memType)sysMem);
}
- setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE);
+ INTPriv(pInt)->sysMem = sysMem;
setup_int_vect(pInt);
set_return_trap(pInt);
+ vbiosMem = (unsigned char *)base + V_BIOS;
if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) {
xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n");
goto error1;
}
- setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE);
pInt->BIOSseg = V_BIOS >> 4;
pInt->num = 0xe6;
LockLegacyVGA(screen, &vga);
@@ -169,10 +149,9 @@ xf86InitInt10(int entityIndex)
return pInt;
error1:
- xfree(vbiosMem);
- xfree(intMem);
+ xfree(base);
UnmapVRam(pInt);
- xfree(INTPriv(pInt)->alloc_rec);
+ xfree(INTPriv(pInt)->alloc);
xfree(pInt->private);
error0:
xfree(pInt);
@@ -184,7 +163,7 @@ static void
MapVRam(xf86Int10InfoPtr pInt)
{
int screen = pInt->scrnIndex;
- int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
INTPriv(pInt)->vRam = xf86MapVidMem(screen,VIDMEM_MMIO,V_RAM,size);
@@ -194,7 +173,7 @@ static void
UnmapVRam(xf86Int10InfoPtr pInt)
{
int screen = pInt->scrnIndex;
- int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int pagesize = getpagesize();
int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
xf86UnMapVidMem(screen,INTPriv(pInt)->vRam,size);
@@ -209,17 +188,13 @@ MapCurrentInt10(xf86Int10InfoPtr pInt)
void
xf86FreeInt10(xf86Int10InfoPtr pInt)
{
- int pagesize;
-
if (!pInt)
return;
- pagesize = INTPriv(pInt)->pagesize_1 + 1;
if (Int10Current == pInt)
Int10Current = NULL;
- xfree(INTPriv(pInt)->alloc_rec[V_BIOS/pagesize]);
- xfree(INTPriv(pInt)->alloc_rec[0]);
+ xfree(INTPriv(pInt)->base);
UnmapVRam(pInt);
- xfree(INTPriv(pInt)->alloc_rec);
+ xfree(INTPriv(pInt)->alloc);
xfree(pInt->private);
xfree(pInt);
}
@@ -227,15 +202,14 @@ xf86FreeInt10(xf86Int10InfoPtr pInt)
void *
xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off)
{
- void* addr;
- int pagesize = INTPriv(pInt)->pagesize_1 + 1;
- int num_pages = INTPriv(pInt)->entries;
+ int pagesize = getpagesize();
+ int num_pages = ALLOC_ENTRIES(pagesize);
int i,j;
-
+
for (i=0;i<num_pages - num;i++) {
- if (INTPriv(pInt)->alloc_rec[i] == 0) {
+ if (INTPriv(pInt)->alloc[i] == 0) {
for (j=i;j < num + i;j++)
- if ((INTPriv(pInt)->alloc_rec[j] != 0))
+ if (INTPriv(pInt)->alloc[j] != 0)
break;
if (j == num + i)
break;
@@ -245,134 +219,103 @@ xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off)
}
if (i == num_pages - num)
return NULL;
+
+ for (j = i; j < i + num; j++)
+ INTPriv(pInt)->alloc[j] = 1;
- *off = i * pagesize;
- addr = xnfalloc(pagesize * num);
- setupTable(pInt,(memType)addr,*off,pagesize * num);
+ *off = (i + 1) * pagesize;
- return addr;
+ return (void *)
+ ((char*)INTPriv(pInt)->base + (i + 1) * pagesize);
}
void
xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
{
- int num_pages = INTPriv(pInt)->entries;
- int i,j;
- for (i = 0;i<num_pages - num; i++)
- if (INTPriv(pInt)->alloc_rec[i]==(memType)pbase) {
- for (j = 0; j < num; j++)
- INTPriv(pInt)->alloc_rec[i] = 0;
- break;
- }
- xfree(pbase);
- return;
+ int pagesize = getpagesize();
+ int first = ((unsigned long)pbase
+ - (unsigned long)INTPriv(pInt)->base)
+ / pagesize - 1;
+ int i;
+
+ for (i = first; i < first + num; i++)
+ INTPriv(pInt)->alloc[i] = 0;
}
-static void
-setupTable(xf86Int10InfoPtr pInt, memType address,int loc,int size)
-{
- int pagesize = INTPriv(pInt)->pagesize_1 + 1;
- int i,j,num;
-
- i = loc / pagesize;
- num = (size + pagesize - 1)/ pagesize; /* round up to the nearest page */
- /* boudary if size is not */
- /* multiple of pagesize */
- for (j = 0; j<num; j++) {
- INTPriv(pInt)->alloc_rec[i+j] = address;
- address += pagesize;
- }
-}
-
-#define OFF(addr) \
- ((addr) & (INTPriv(pInt)->pagesize_1))
-#define SHIFT \
- (INTPriv(pInt)->shift)
-#define BASE(addr,shift) \
- (INTPriv(pInt)->alloc_rec[addr >> shift])
-#define V_ADDR(addr,shift,off) \
- (BASE(addr,shift) + (off))
-#define VRAM_ADDR(addr) (addr - 0xA0000)
+#define OFF(addr) ((addr) & 0xffff)
+#define SYS(addr) ((addr) >= SYS_BIOS)
+#define V_ADDR(addr) \
+ (SYS(addr) ? ((char*)INTPriv(pInt)->sysMem) + (addr - SYS_BIOS) \
+ : ((char*)(INTPriv(pInt)->base) + addr))
+#define VRAM_ADDR(addr) (addr - V_RAM)
#define VRAM_BASE (INTPriv(pInt)->vRam)
-#define VRAM(addr) ((addr >= 0xA0000) && (addr <= 0xBFFFF))
-#define V_ADDR_RB(addr,shift,off) \
+#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,shift,off)
-#define V_ADDR_RW(addr,shift,off) \
+ : *(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,shift,off))
-#define V_ADDR_RL(addr,shift,off) \
+ : 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,shift,off))
+ : ldl_u((pointer)V_ADDR(addr))
-#define V_ADDR_WB(addr,shift,off,val) \
+#define V_ADDR_WB(addr,val) \
if(VRAM(addr)) \
MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR(addr),val); \
else \
- *(CARD8*) V_ADDR(addr,shift,off) = val;
-#define V_ADDR_WW(addr,shift,off,val) \
+ *(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,shift,off)));
+ stw_u((val),(pointer)(V_ADDR(addr)));
-#define V_ADDR_WL(addr,shift,off,val) \
+#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,shift,off)));
+ stl_u(val,(pointer)(V_ADDR(addr)));
static CARD8
read_b(xf86Int10InfoPtr pInt, int addr)
{
- if (!BASE(addr,SHIFT)) return 0xff;
-
- return V_ADDR_RB(addr,SHIFT,OFF(addr));
+ return V_ADDR_RB(addr);
}
static CARD16
read_w(xf86Int10InfoPtr pInt, int addr)
{
- int shift = SHIFT;
- int off = OFF(addr);
-
- if (!BASE(addr,shift)) return 0xffff;
-
#if X_BYTE_ORDER == X_BIG_ENDIAN
- return ((V_ADDR_RB(addr,shift,off))
- || ((V_ADDR_RB(addr,shift,off + 1)) << 8));
+ return ((V_ADDR_RB(addr))
+ || ((V_ADDR_RB(addr + 1)) << 8));
#else
if (OFF(addr + 1) > 0) {
- return V_ADDR_RW(addr,SHIFT,OFF(addr));
- } else {
- return ((V_ADDR_RB(addr,shift,off + 1))
- || ((V_ADDR_RB(addr,shift,off)) << 8));
- }
+ return V_ADDR_RW(addr);
+ } else
+ return ((V_ADDR_RB(addr + 1))
+ || ((V_ADDR_RB(addr)) << 8));
+
#endif
}
static CARD32
read_l(xf86Int10InfoPtr pInt, int addr)
{
- int shift = SHIFT;
- int off = OFF(addr);
-
- if (!BASE(addr,shift)) return 0xffffffff;
-
#if X_BYTE_ORDER == X_BIG_ENDIAN
- return ((V_ADDR_RB(addr,shift,off))
- || ((V_ADDR_RB(addr,shift,off + 1)) << 8)
- || ((V_ADDR_RB(addr,shift,off + 2)) << 16)
- || ((V_ADDR_RB(addr,shift,off + 3)) << 24));
+ return ((V_ADDR_RB(addr))
+ || ((V_ADDR_RB(addr + 1)) << 8)
+ || ((V_ADDR_RB(addr + 2)) << 16)
+ || ((V_ADDR_RB(addr + 3)) << 24));
#else
- if (OFF(addr + 3) > 2) {
- return V_ADDR_RL(addr,SHIFT,OFF(addr));
+ if (OFF(addr + 3) > 2) {
+ return V_ADDR_RL(addr);
} else {
- return ((V_ADDR_RB(addr,shift,off + 3))
- || ((V_ADDR_RB(addr,shift,off + 2)) << 8)
- || ((V_ADDR_RB(addr,shift,off + 1)) << 16)
- || ((V_ADDR_RB(addr,shift,off)) << 24));
+ return ((V_ADDR_RB(addr + 3))
+ || ((V_ADDR_RB(addr + 2)) << 8)
+ || ((V_ADDR_RB(addr + 1)) << 16)
+ || ((V_ADDR_RB(addr)) << 24));
}
#endif
}
@@ -380,28 +323,21 @@ read_l(xf86Int10InfoPtr pInt, int addr)
static void
write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
{
- if (!BASE(addr,SHIFT)) return;
-
- V_ADDR_WB(addr,SHIFT,OFF(addr),val);
+ V_ADDR_WB(addr,val);
}
static void
write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
{
- int shift = SHIFT;
- int off = OFF(addr);
-
- if (!BASE(addr,shift)) return;
-
#if X_BYTE_ORDER == X_BIG_ENDIAN
- V_ADDR_WB(addr,shift,off,val);
- V_ADDR_WB(addr,shift,off + 1,val >> 8);
+ V_ADDR_WB(addr,val);
+ V_ADDR_WB(addr + 1,val >> 8);
#else
if (OFF(addr + 1) > 0) {
- V_ADDR_WW(addr,shift,OFF(addr),val);
+ V_ADDR_WW(addr,val);
} else {
- V_ADDR_WB(addr,shift,off + 1,val);
- V_ADDR_WB(addr,shift,off,val >> 8);
+ V_ADDR_WB(addr + 1,val);
+ V_ADDR_WB(addr,val >> 8);
}
#endif
}
@@ -409,23 +345,19 @@ write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
static void
write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
{
- int shift = SHIFT;
- int off = OFF(addr);
- if (!BASE(addr,shift)) return;
-
#if X_BYTE_ORDER == X_BIG_ENDIAN
- V_ADDR_WB(addr,shift,off,val);
- V_ADDR_WB(addr,shift,off + 1, val >> 8);
- V_ADDR_WB(addr,shift,off + 2, val >> 16);
- V_ADDR_WB(addr,shift,off + 3, val >> 24);
+ 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);
#else
if (OFF(addr + 3) > 2) {
- V_ADDR_WL(addr,shift,OFF(addr),val);
+ V_ADDR_WL(addr,val);
} else {
- V_ADDR_WB(addr,shift,off + 3, val);
- V_ADDR_WB(addr,shift,off + 2, val >> 8);
- V_ADDR_WB(addr,shift,off + 1, val >> 16);
- V_ADDR_WB(addr,shift,off, val >> 24);
+ V_ADDR_WB(addr + 3, val);
+ V_ADDR_WB(addr + 2, val >> 8);
+ V_ADDR_WB(addr + 1, val >> 16);
+ V_ADDR_WB(addr, val >> 24);
}
#endif
}
@@ -433,5 +365,13 @@ write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
pointer
xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
{
- return (pointer) V_ADDR(addr,SHIFT,OFF(addr));
+ return (pointer) V_ADDR(addr);
}
+
+
+
+
+
+
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c b/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c
index efac37e07..437f88efd 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c
+++ b/xc/programs/Xserver/hw/xfree86/int10/helper_exec.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c,v 1.2 2000/02/08 13:13:25 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_exec.c,v 1.4 2000/05/31 07:15:06 eich Exp $ */
/*
* XFree86 int10 module
* execute BIOS int 10h calls in x86 real mode environment
@@ -7,14 +7,21 @@
* Part of this is based on code taken form DOSEMU
* (C) Copyright 1992, ..., 1999 the "DOSEMU-Development-Team"
*/
+
+/*
+ * To debug port accesses define PRINT_PORT.
+ * Note! You also have to comment out ioperm()
+ * in xf86EnableIO(). Otherwise we won't trap
+ * on PIO.
+ */
#include "xf86.h"
#include "xf86str.h"
+#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86Pci.h"
#define _INT10_PRIVATE
#include "int10Defines.h"
#include "xf86int10.h"
-#include "xf86_ansic.h"
#ifndef _PC
static int pciCfg1in(CARD16 addr, CARD32 *val);
@@ -30,12 +37,11 @@ setup_int(xf86Int10InfoPtr pInt)
MapCurrentInt10(pInt);
Int10Current = pInt;
}
-
X86_EAX = (CARD32) pInt->ax;
X86_EBX = (CARD32) pInt->bx;
X86_ECX = (CARD32) pInt->cx;
X86_EDX = (CARD32) pInt->dx;
- X86_EDX = (CARD32) pInt->si;
+ X86_ESI = (CARD32) pInt->si;
X86_EDI = (CARD32) pInt->di;
X86_ES = (CARD32) pInt->es;
X86_EBP = 0;
@@ -46,7 +52,8 @@ setup_int(xf86Int10InfoPtr pInt)
X86_DS = 0x40; /* standard pc ds */
X86_FS = 0;
X86_GS = 0;
- X86_EFLAGS |= (X86_VIF_MASK | X86_VIP_MASK | X86_IF_MASK | 2);
+ X86_EFLAGS = (X86_IF_MASK | X86_IOPL_MASK);
+
}
void
@@ -62,6 +69,8 @@ finish_int(xf86Int10InfoPtr pInt)
}
#define SEG_ADR(type, seg, reg) type((seg << 4) \
+ + (X86_##reg))
+#define SEG_EADR(type, seg, reg) type((seg << 4) \
+ (X86_E##reg))
#ifndef _X86EMU
/* get the linear address */
@@ -113,7 +122,7 @@ vm86_GP_fault(xf86Int10InfoPtr pInt)
/* 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_ADR((CARD32),X86_ES,DI),
+ 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++;
@@ -224,6 +233,7 @@ vm86_GP_fault(xf86Int10InfoPtr pInt)
return TRUE;
}
#endif
+
/* general software interrupt handler */
CARD32
getIntVect(xf86Int10InfoPtr pInt,int num)
@@ -246,9 +256,9 @@ run_bios_int(int num, xf86Int10InfoPtr pInt)
/* check if bios vector is initialized */
if (MEM_RW(pInt,(num<<2)+2) == 0xF000) { /* SYS_BIOS_SEG ?*/
#ifdef PRINT_INT
- ErrorF("card BIOS not loaded\n");
+ ErrorF("card BIOS not loaded\n");
#endif
- return 0;
+ return 0;
}
#endif
#ifdef PRINT_INT
diff --git a/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c b/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c
index 8a8bebfee..68bc8bbd8 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c
+++ b/xc/programs/Xserver/hw/xfree86/int10/helper_mem.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c,v 1.2 2000/02/08 13:13:26 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/helper_mem.c,v 1.6 2000/06/13 02:28:35 dawes Exp $ */
/*
* XFree86 int10 module
* execute BIOS int 10h calls in x86 real mode environment
@@ -6,12 +6,13 @@
*/
#include "xf86.h"
#include "xf86str.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86Pci.h"
#define _INT10_PRIVATE
#include "int10Defines.h"
#include "xf86int10.h"
-#include "xf86_ansic.h"
#define REG pInt
@@ -24,7 +25,7 @@ static OptionInfoRec INT10Options[] = {
{ -1, NULL, OPTV_NONE, {0}, FALSE },
};
-
+#define nINT10Options (sizeof(INT10Options) / sizeof(INT10Options[0]))
#ifdef DEBUG
void
@@ -151,11 +152,48 @@ int10skip(ScrnInfoPtr pScrn, int entityIndex)
EntityInfoPtr pEnt = xf86GetEntityInfo(entityIndex);
if (pEnt->device && pEnt->device->options) {
- xf86ProcessOptions(pScrn->scrnIndex, pEnt->device->options,
- INT10Options);
- xf86GetOptValBool(INT10Options, OPT_NOINT10, &noint10);
+ OptionInfoRec options[nINT10Options];
+
+ (void)memcpy(options, INT10Options, sizeof(INT10Options));
+ xf86ProcessOptions(pScrn->scrnIndex, pEnt->device->options, options);
+ xf86GetOptValBool(options, OPT_NOINT10, &noint10);
}
xfree(pEnt);
return noint10;
}
+
+
+Bool
+int10_read_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem)
+{
+ int size;
+
+ if (xf86IsPc98())
+ return FALSE;
+
+ if (xf86ReadBIOS(codeSeg << 4,0,(unsigned char *)vbiosMem, 0x10) < 0) {
+ xf86DrvMsg(scrnIndex,X_WARNING,"Cannot read V_BIOS (1)\n");
+ return FALSE;
+ }
+
+ if (!((*(CARD8*)vbiosMem == 0x55) && (*((CARD8*)vbiosMem+1) == 0xAA)))
+ return FALSE;
+
+ size = *((CARD8*)vbiosMem + 2) * 512;
+
+ if ((size + (codeSeg << 4)) > SYS_BIOS)
+ return FALSE;
+
+ if (xf86ReadBIOS(codeSeg << 4,0,vbiosMem, size) < 0) {
+ xf86DrvMsg(scrnIndex,X_ERROR,"Cannot read V_BIOS (2)\n");
+ return FALSE;
+ }
+ if (bios_checksum(vbiosMem,size)) {
+ xf86DrvMsg(scrnIndex,X_ERROR,"Bad checksum of V_BIOS \n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
diff --git a/xc/programs/Xserver/hw/xfree86/int10/xf86int10.c b/xc/programs/Xserver/hw/xfree86/int10/xf86int10.c
index c54176a04..8dd45b188 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/xf86int10.c
+++ b/xc/programs/Xserver/hw/xfree86/int10/xf86int10.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.c,v 1.4 2000/02/15 02:00:13 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.c,v 1.5 2000/04/04 19:25:18 dawes Exp $ */
/*
* XFree86 int10 module
* execute BIOS int 10h calls in x86 real mode environment
@@ -7,6 +7,7 @@
#include "xf86.h"
#include "xf86str.h"
+#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86Pci.h"
#define _INT10_PRIVATE
diff --git a/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h b/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h
index f0d23064c..733da37b9 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h
+++ b/xc/programs/Xserver/hw/xfree86/int10/xf86int10.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h,v 1.3 2000/02/13 02:17:19 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86int10.h,v 1.5 2000/04/17 16:30:11 eich Exp $ */
/*
* XFree86 int10 module
@@ -9,6 +9,9 @@
#ifndef _XF86INT10_H
#define _XF86INT10_H
+#include "Xmd.h"
+#include "Xdefs.h"
+
#define SEG_ADDR(x) ((x>>4) & 0xF000)
#define SEG_OFF(x) (x & 0xFFFF)
@@ -162,6 +165,8 @@ int setup_system_bios(unsigned long base_addr);
void reset_int_vect(xf86Int10InfoPtr pInt);
void set_return_trap(xf86Int10InfoPtr pInt);
Bool int10skip(ScrnInfoPtr pScrn, int entityIndex);
+Bool int10_read_bios(int scrnIndex, int codeSeg, unsigned char* vbiosMem);
+
#ifdef DEBUG
void dprint(unsigned long start, unsigned long size);
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c b/xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c
index 3dc84bc78..5d5d2f73d 100644
--- a/xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c
+++ b/xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c,v 1.6 2000/02/18 16:23:23 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/int10/xf86x86emu.c,v 1.7 2000/04/04 19:25:18 dawes Exp $ */
/*
* XFree86 int10 module
* execute BIOS int 10h calls in x86 real mode environment
@@ -7,9 +7,9 @@
#include <x86emu.h>
#include "xf86.h"
#include "xf86str.h"
+#include "xf86_ansic.h"
#include "compiler.h"
#include "xf86_OSproc.h"
-#include "xf86_ansic.h"
#include "xf86Pci.h"
#include "xf86_libc.h"
#define _INT10_PRIVATE
diff --git a/xc/programs/Xserver/hw/xfree86/loader/dixsym.c b/xc/programs/Xserver/hw/xfree86/loader/dixsym.c
index 05e9c4c05..b77083571 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/dixsym.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/dixsym.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.30 2000/03/05 23:47:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/dixsym.c,v 1.32 2000/04/24 00:19:16 mvojkovi Exp $ */
/*
@@ -93,6 +93,7 @@ LOOKUP dixLookupTab[] = {
SYMVAR(dispatchException)
SYMVAR(isItTimeToYield)
SYMVAR(ClientStateCallback)
+ SYMVAR(ServerGrabCallback)
/* dixfonts.c */
SYMFUNC(CloseFont)
SYMFUNC(FontToXError)
@@ -192,6 +193,7 @@ LOOKUP dixLookupTab[] = {
SYMFUNC(AllocateWindowPrivate)
SYMFUNC(AllocateWindowPrivateIndex)
SYMFUNC(AllocateScreenPrivateIndex)
+ SYMFUNC(AllocateColormapPrivateIndex)
/* resource.c */
SYMFUNC(AddResource)
SYMFUNC(ChangeResourceValue)
diff --git a/xc/programs/Xserver/hw/xfree86/loader/elfloader.c b/xc/programs/Xserver/hw/xfree86/loader/elfloader.c
index 0a41d78b8..284ad62f0 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/elfloader.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/elfloader.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.23 1999/12/13 23:56:38 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/elfloader.c,v 1.24 2000/05/18 00:33:19 dawes Exp $ */
/*
*
@@ -1236,7 +1236,7 @@ ELFDEBUG( "*dest32=%8.8x\n", *dest32 );
#else
/* Linux PPC */
case R_PPC_ADDR32: /* 1 */
- dest32=(unsigned long *)(secp+rel->r_offset);
+ dest32=(unsigned int *)(secp+rel->r_offset);
symval=ElfGetSymbolValue(elffile,ELF_R_SYM(rel->r_info));
#ifdef ELFDEBUG
ELFDEBUG( "R_PPC_ADDR32\t" );
@@ -1328,7 +1328,7 @@ ELFDEBUG( "*dest32=%8.8x\n", *dest32 );
#endif
break;
case R_PPC_REL24: /* 10 */
- dest32=(unsigned long *)(secp+rel->r_offset);
+ dest32=(unsigned int *)(secp+rel->r_offset);
#ifdef ELFDEBUG
ELFDEBUG( "R_PPC_REL24 %s\t", ElfGetSymbolName(elffile,ELF_R_SYM(rel->r_info)) );
ELFDEBUG( "secp=%x\t", secp );
@@ -1370,7 +1370,7 @@ ELFDEBUG( "*dest32=%8.8x\n", *dest32 );
#endif
break;
case R_PPC_REL32: /* 26 */
- dest32=(unsigned long *)(secp+rel->r_offset);
+ dest32=(unsigned int *)(secp+rel->r_offset);
#ifdef ELFDEBUG
ELFDEBUG( "R_PPC_REL32\t" );
ELFDEBUG( "secp=%x\t", secp );
diff --git a/xc/programs/Xserver/hw/xfree86/loader/extsym.c b/xc/programs/Xserver/hw/xfree86/loader/extsym.c
index 98441ad28..2715acd8d 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/extsym.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/extsym.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.3 2000/01/06 20:10:04 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/extsym.c,v 1.4 2000/03/30 18:20:58 mvojkovi Exp $ */
/*
*
@@ -41,6 +41,11 @@ 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
LOOKUP extLookupTab[] = {
@@ -50,11 +55,16 @@ LOOKUP extLookupTab[] = {
SYMVAR(ShmSegType)
#ifdef PANORAMIX
+ SYMFUNC(XineramaRegisterConnectionBlockCallback)
+ SYMFUNC(XineramaDeleteResource)
SYMVAR(noPanoramiXExtension)
SYMVAR(PanoramiXNumScreens)
SYMVAR(panoramiXdataPtr)
SYMVAR(XRT_WINDOW)
SYMVAR(XRT_PIXMAP)
+ SYMVAR(XRT_GC)
+ SYMVAR(XRT_COLORMAP)
+ SYMVAR(XRC_DRAWABLE)
#endif
{ 0, 0 },
diff --git a/xc/programs/Xserver/hw/xfree86/loader/loader.c b/xc/programs/Xserver/hw/xfree86/loader/loader.c
index 9b8c9d819..430dda83f 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/loader.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/loader.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.38 1999/12/28 13:47:43 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loader.c,v 1.41 2000/04/17 16:30:12 eich Exp $ */
/*
*
@@ -69,7 +69,7 @@ int check_unresolved_sema = 0;
#endif
#ifdef __EMX__
-void * os2loader_calloc(size_t,size_t);
+void * os2ldcalloc(size_t,size_t);
#endif
#ifdef HANDLE_IN_HASH_ENTRY
@@ -381,7 +381,7 @@ _LoaderFileToMem(int fd, unsigned long offset,int size, char *label)
if( (ptr=xf86loadercalloc(size,1)) == NULL )
FatalError("_LoaderFileToMem() malloc failed\n" );
#else
- if( (ptr=os2loader_calloc(size,1)) == NULL )
+ if( (ptr=os2ldcalloc(size,1)) == NULL )
FatalError("_LoaderFileToMem() malloc failed\n" );
#endif
@@ -391,6 +391,15 @@ _LoaderFileToMem(int fd, unsigned long offset,int size, char *label)
if(read(fd,ptr,size)!=size)
FatalError("\n_LoaderFileToMem() read() failed: %s\n",strerror(errno));
+#if defined(linux) && defined(__powerpc__)
+ {
+ int i;
+ for (i = 0; i < size; i += 16)
+ ppc_flush_icache(ptr+i);
+ ppc_flush_icache(ptr+size-1);
+ }
+#endif
+
#ifdef DEBUGMEM
ErrorF("=%lx\n",ptr);
#endif
@@ -1158,10 +1167,18 @@ LoaderCheckUnresolved(int delay_flag )
}
void
+xf86LoaderTrap()
+{
+}
+
+void
LoaderDefaultFunc(void)
{
ErrorF("\n\n\tThis should not happen!\n"
"\tAn unresolved function was called!\n");
+
+ xf86LoaderTrap();
+
FatalError("\n");
}
diff --git a/xc/programs/Xserver/hw/xfree86/loader/loadmod.c b/xc/programs/Xserver/hw/xfree86/loader/loadmod.c
index 180eecb8f..30d485b61 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/loadmod.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/loadmod.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.50 2000/01/25 18:37:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/loadmod.c,v 1.53 2000/06/07 02:13:03 dawes Exp $ */
/*
*
@@ -182,12 +182,12 @@ LoaderSetPath(const char *path)
/* Standard set of module subdirectories to search, in order of preference */
static const char *stdSubdirs[] =
{
- "",
"drivers/",
"input/",
"extensions/",
"fonts/",
"internal/",
+ "",
NULL
};
@@ -386,12 +386,14 @@ FindModule (const char *module, const char *dir, const char **subdirlist,
#endif
if (strlen(dirpath) > PATH_MAX)
return NULL;
+ /*xf86Msg(X_INFO,"OS2DIAG: FindModule: dirpath=%s\n",dirpath);*/
for (s = subdirs; *s; s++) {
- if ((dirlen = strlen(dir) + strlen(*s)) > PATH_MAX)
+ if ((dirlen = strlen(dirpath) + strlen(*s)) > PATH_MAX)
continue;
strcpy(buf, dirpath);
strcat(buf, *s);
+ /*xf86Msg(X_INFO,"OS2DIAG: FindModule: buf=%s\n",buf);*/
fp = buf + dirlen;
if (stat(buf, &stat_buf) == 0 && S_ISDIR(stat_buf.st_mode) &&
(d = opendir(buf))) {
@@ -411,6 +413,7 @@ FindModule (const char *module, const char *dir, const char **subdirlist,
len = match[1].rm_eo - match[1].rm_so;
if (len == strlen(module) &&
strncmp(module, dp->d_name + match[1].rm_so, len) == 0) {
+ /*xf86Msg(X_INFO,"OS2DIAG: matching %s\n",buf);*/
name = buf;
break;
}
@@ -721,35 +724,6 @@ LoadSubModule(ModuleDescPtr parent, const char *module,
return submod;
}
-#if 0
-void
-LoadExtension (ExtensionModule *e)
-{
- int i;
-
- if (e == NULL)
- return;
- xf86MsgVerb(X_INFO, 2, "Loading extension %s\n", e->name);
-
- for (i = 0; extension[i].name != NULL; i++)
- {
- if (strcmp (extension[i].name, e->name) == 0)
- {
- extension[i].initFunc = e->initFunc;
- extension[i].disablePtr = e->disablePtr;
- if (e->setupFunc != NULL)
- e->setupFunc();
- break;
- }
- }
- if (extension[i].name == NULL)
- {
- xf86MsgVerb(X_WARNING, 0,
- "Extension \"%s\" is not recognised\n", e->name);
- }
-}
-#endif
-
ModuleDescPtr
DuplicateModule(ModuleDescPtr mod, ModuleDescPtr parent)
{
@@ -837,6 +811,7 @@ LoadModule (const char *module, const char *path, const char **subdirlist,
int noncanonical = 0;
char *m = NULL;
+ /*xf86Msg(X_INFO,"OS2DIAG: LoadModule: %s\n",module);*/
xf86MsgVerb(X_INFO, 3, "LoadModule: \"%s\"", module);
patterns = InitPatterns(patternlist);
diff --git a/xc/programs/Xserver/hw/xfree86/loader/misym.c b/xc/programs/Xserver/hw/xfree86/loader/misym.c
index 191d135cf..9c25951f9 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/misym.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/misym.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.29 2000/02/11 06:34:45 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/misym.c,v 1.31 2000/05/18 23:21:41 dawes Exp $ */
/*
*
@@ -79,6 +79,7 @@ LOOKUP miLookupTab[] = {
SYMFUNC(miImageGlyphBlt)
SYMFUNC(miPolyGlyphBlt)
SYMFUNC(miFillPolygon)
+ SYMFUNC(miFillConvexPoly)
SYMFUNC(miPolySegment)
SYMFUNC(miZeroLine)
SYMFUNC(miWideLine)
@@ -159,6 +160,7 @@ LOOKUP miLookupTab[] = {
SYMFUNC(miOverlayCollectUnderlayRegions)
SYMFUNC(miInitOverlay)
SYMFUNC(miOverlayComputeCompositeClip)
+ SYMFUNC(miOverlaySetRootClip)
SYMVAR(miZeroLineScreenIndex)
SYMVAR(miSpritePointerFuncs)
SYMVAR(miPointerScreenIndex)
diff --git a/xc/programs/Xserver/hw/xfree86/loader/os2funcs.c b/xc/programs/Xserver/hw/xfree86/loader/os2funcs.c
index 3e66788b3..0a16ca626 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/os2funcs.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/os2funcs.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/os2funcs.c,v 1.4 1997/03/10 10:12:22 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/os2funcs.c,v 1.5 2000/04/05 18:13:50 dawes Exp $ */
/*
* (c) Copyright 1997 by Sebastien Marineau
* <marineau@genie.uottawa.ca>
@@ -39,110 +39,143 @@
#include <sys/types.h>
#include <umalloc.h>
#include "os.h"
-
-#define RESERVED_BLOCKS 512 /* reserve 2MB memory for modules */
-
-void *os2loader_AddToHeap(Heap_t, size_t *, int *);
-void os2loader_RemoveFromHeap(Heap_t, void *, size_t);
-
-PVOID os2loader_CommitedTop;
-PVOID os2loader_baseAddress;
-Heap_t os2loader_heapAddress;
-int os2loader_TotalCommitedBlocks;
-
-void *os2loader_calloc(size_t num_elem, size_t size_elem){
-APIRET rc;
-int ret;
-static BOOL FirstTime=TRUE;
-void *allocMem;
-
-if(FirstTime){
- rc=DosAllocMem(&os2loader_baseAddress,RESERVED_BLOCKS * 4096,
- PAG_READ | PAG_WRITE | PAG_EXECUTE);
- if(rc!=0) {
- ErrorF("OS/2AllocMem: Could not create heap for module loading\n");
- return(NULL);
+#include "xf86str.h"
+
+#define RESERVED_BLOCKS 4096 /* reserve 16MB memory for modules */
+
+void *os2ldAddToHeap(Heap_t, size_t *, int *);
+void os2ldRemoveFromHeap(Heap_t, void *, size_t);
+
+PVOID os2ldCommitedTop;
+PVOID os2ldBase;
+Heap_t os2ldHeap;
+int os2ldTotalCommitedBlocks;
+static BOOL FirstTime = TRUE;
+
+void *os2ldcalloc(size_t num_elem, size_t size_elem) {
+ APIRET rc;
+ int ret;
+
+ if (FirstTime) {
+ if ((rc=DosAllocMem(&os2ldBase,RESERVED_BLOCKS * 4096,
+ PAG_READ | PAG_WRITE | PAG_EXECUTE)) != 0) {
+ xf86Msg(X_ERROR,
+ "OS2LD: DosAllocMem failed, rc=%d\n",
+ rc);
+ return NULL;
}
-/* Now commit the first 128Kb, the rest will be done dynamically */
- rc=DosSetMem(os2loader_baseAddress,32*4096, PAG_DEFAULT | PAG_COMMIT);
- if(rc!=0) {
- ErrorF("OS/2AllocMem: Could not commit heap memory!\n");
- DosFreeMem(os2loader_baseAddress);
- return(NULL);
+ /* Now commit the first 128Kb, the rest will
+ * be done dynamically */
+ if ((rc=DosSetMem(os2ldBase,
+ 32*4096,
+ PAG_DEFAULT | PAG_COMMIT)) != 0) {
+ xf86Msg(X_ERROR,
+ "OS2LD: DosSetMem failed, rc=%d\n",rc);
+ DosFreeMem(os2ldBase);
+ return NULL;
}
- os2loader_CommitedTop=os2loader_baseAddress + 32*4096;
- os2loader_TotalCommitedBlocks=32;
- ErrorF("OS2Alloc: allocated mem for heap, rc=%d, addr=%p\n",rc,os2loader_baseAddress);
-
- if((os2loader_heapAddress=_ucreate(os2loader_baseAddress,32*4096,_BLOCK_CLEAN,
- _HEAP_REGULAR,os2loader_AddToHeap, os2loader_RemoveFromHeap))==NULL){
- ErrorF("OS/2AllocMem: Could not create heap for loadable modules\n");
- DosFreeMem(os2loader_baseAddress);
- return(NULL);
+ os2ldCommitedTop = os2ldBase + 32*4096;
+ os2ldTotalCommitedBlocks = 32;
+#ifdef DEBUG
+ xf86Msg(X_INFO,
+ "OS2LD: Initial heap at addr=%p\n",
+ os2ldBase);
+#endif
+
+ if ((os2ldHeap=_ucreate(os2ldBase,
+ 32*4096, _BLOCK_CLEAN,
+ _HEAP_REGULAR, os2ldAddToHeap,
+ os2ldRemoveFromHeap)) == NULL) {
+ xf86Msg(X_ERROR,
+ "OS2LD: heap creation failed\n");
+ DosFreeMem(os2ldBase);
+ return NULL;
}
- ret=_uopen(os2loader_heapAddress);
- if(ret!=0){
- ErrorF("OS/2AllocMem: Could not open heap for loadable modules\n");
- ret=_udestroy(os2loader_heapAddress,_FORCE);
- DosFreeMem(os2loader_baseAddress);
- return(NULL);
+ if ((ret=_uopen(os2ldHeap)) != 0) {
+ xf86Msg(X_ERROR,
+ "OS2LD: heap open failed\n");
+ ret = _udestroy(os2ldHeap,_FORCE);
+ DosFreeMem(os2ldBase);
+ return(NULL);
}
- FirstTime=FALSE;
- ErrorF("OS/2: done creating heap, addr=%p\n",os2loader_heapAddress);
+
+ FirstTime = FALSE;
+
+#ifdef DEBUG
+ xf86Msg(X_INFO,"OS2LD: Created module heap at addr=%p\n",
+ os2ldHeap);
+#endif
}
-allocMem=_ucalloc(os2loader_heapAddress,num_elem,size_elem);
-return(allocMem);
+ return _ucalloc(os2ldHeap,num_elem,size_elem);
}
-
-void *os2loader_AddToHeap(Heap_t H, size_t *new_size, int *PCLEAN)
+void *os2ldAddToHeap(Heap_t H, size_t *new_size, int *PCLEAN)
{
-PVOID NewBase;
-long adjusted_size;
-long blocks;
-APIRET rc;
-
- if(H != os2loader_heapAddress){
- ErrorF("OS/2: Tried to grow an inexistant heap, p=%08x\n",H);
- return (NULL);
- }
- NewBase=os2loader_CommitedTop;
- adjusted_size = (*new_size/65536) * 65536;
- if((*new_size % 65536)> 0 ) adjusted_size += 65536;
- blocks=adjusted_size / 4096;
- if((os2loader_TotalCommitedBlocks + blocks)>RESERVED_BLOCKS){
- ErrorF("OS/2 GrowHeap: Could not allocate any more memory for module loading!\n");
- ErrorF("Total reserved memory of %ld bytes is exhausted\n",RESERVED_BLOCKS * 4096);
- return(NULL);
- }
- rc = DosSetMem(NewBase, adjusted_size, PAG_DEFAULT | PAG_COMMIT);
- if(rc!=0) {
- ErrorF("OS/2 GrowHeap: Could not grow heap! Requested size %d, \n", adjusted_size);
- return(NULL);
+ PVOID NewBase;
+ long adjusted_size;
+ long blocks;
+ APIRET rc;
+
+ if (H != os2ldHeap) {
+ xf86Msg(X_ERROR,
+ "OS2LD: Heap corruption in GrowHeap, p=%08x\n",H);
+ return NULL;
}
- os2loader_CommitedTop+=adjusted_size;
- os2loader_TotalCommitedBlocks += blocks;
- *PCLEAN = _BLOCK_CLEAN;
- *new_size=adjusted_size;
- ErrorF("OS/2: Added %d bytes to heap, addr %08x\n",adjusted_size, NewBase);
- return(NewBase);
+ NewBase = os2ldCommitedTop;
+ adjusted_size = (*new_size/65536) * 65536;
+ if ((*new_size % 65536) > 0)
+ adjusted_size += 65536;
+ blocks = adjusted_size / 4096;
+
+ if ((os2ldTotalCommitedBlocks + blocks) > RESERVED_BLOCKS) {
+ xf86Msg(X_ERROR,
+ "OS2LD: Out of memory in GrowHeap\n");
+ xf86Msg(X_ERROR,
+ "OS2LD: Max available memory is of %ld bytes\n",
+ RESERVED_BLOCKS * 4096);
+ return NULL;
+ }
+ if ((rc=DosSetMem(NewBase, adjusted_size, PAG_DEFAULT | PAG_COMMIT)) != 0) {
+ xf86Msg(X_ERROR,
+ "OS2LD: DosSetMem failed in GrowHeap, size req'd=%d, rc=%d\n",
+ adjusted_size,
+ rc);
+ return NULL;
+ }
+
+ os2ldCommitedTop += adjusted_size;
+ os2ldTotalCommitedBlocks += blocks;
+ *PCLEAN = _BLOCK_CLEAN;
+ *new_size = adjusted_size;
+#ifdef DEBUG
+ xf86Msg(X_INFO,"OS2LD: Heap extended by %d bytes, addr=%p\n",
+ adjusted_size, NewBase);
+#endif
+ return NewBase;
}
-void os2loader_RemoveFromHeap(Heap_t H, void *memory, size_t size)
+void os2ldRemoveFromHeap(Heap_t H, void *memory, size_t size)
{
- if(H != os2loader_heapAddress){
- ErrorF("OS/2: Tried to shrink an inexistant heap, p=%08x\n",H);
- return;
- }
-/* Currently we do nothing, as we do not keep track of the commited memory */
-ErrorF("OS/2: module heap requests that heap memory be deallocated. Request ignored\n");
-
-/* Only handle it if it is the base address */
- if(memory == os2loader_baseAddress) {
- DosFreeMem(os2loader_baseAddress);
- ErrorF("OS/2: total heap area was deallocated\n");
- }
+ if (H != os2ldHeap) {
+ xf86Msg(X_ERROR,
+ "OS2LD: Heap corruption in ShrinkHeap, p=%08x\n",H);
+ return;
+ }
+
+ /* Currently we do nothing, as we do not keep track of the
+ * commited memory */
+
+
+ /* Only handle it if it is the base address */
+ if (memory == os2ldBase) {
+ DosFreeMem(os2ldBase);
+#ifdef DEBUG
+ xf86Msg(X_INFO,"OS2LD: total heap area deallocated\n");
+#endif
+ os2ldBase = 0;
+ FirstTime = TRUE;
+ }
}
diff --git a/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c b/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c
index d91457078..d48a5ce5c 100644
--- a/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c
+++ b/xc/programs/Xserver/hw/xfree86/loader/xf86sym.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.134 2000/03/01 16:01:30 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/loader/xf86sym.c,v 1.155 2000/06/30 19:06:58 keithp Exp $ */
/*
*
@@ -53,8 +53,13 @@
#include "xisb.h"
#include "xf86Priv.h"
#include "vbe.h"
+#include "xf86sbusBus.h"
-extern xf86MonPtr ConfiguredMonitor;
+#ifdef __FreeBSD__
+/* XXX used in drmOpen(). This should change to use a less os-specific
+ * method. */
+int sysctlbyname(const char*, void *, size_t *, void *, size_t);
+#endif
/* XXX Should get all of these from elsewhere */
#if defined (PowerMAX_OS)
@@ -75,6 +80,7 @@ extern unsigned long inl(unsigned int a);
#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);
@@ -137,7 +143,12 @@ LOOKUP SparcLookupTab[] = {
#if defined(__powerpc__) && (defined(Lynx) || defined(linux))
void eieio();
+void _restf14();
void _restf17();
+void _restf18();
+void _restf19();
+void _restf20();
+void _restf22();
void _restf23();
void _restf24();
void _restf25();
@@ -145,7 +156,12 @@ 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();
@@ -231,6 +247,7 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86GetSerialModemState)
SYMFUNC(xf86SerialModemSetBits)
SYMFUNC(xf86SerialModemClearBits)
+ SYMFUNC(xf86LoadKernelModule)
SYMFUNC(xf86OSMouseInit)
#ifdef XINPUT
@@ -247,7 +264,7 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86CheckPciSlot)
SYMFUNC(xf86ClaimPciSlot)
SYMFUNC(xf86GetPciVideoInfo)
- SYMFUNC(xf86GetEntityForPciInfo)
+ SYMFUNC(xf86GetPciEntity)
SYMFUNC(xf86GetPciConfigInfo)
SYMFUNC(xf86SetPciVideo)
SYMFUNC(xf86ClaimIsaSlot)
@@ -260,10 +277,17 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86IsPrimaryIsa)
SYMFUNC(xf86CheckPciGAType)
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)
@@ -284,10 +308,23 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86FindPciClass)
SYMFUNC(xf86RegisterStateChangeNotificationCallback)
SYMFUNC(xf86DeregisterStateChangeNotificationCallback)
+ SYMFUNC(xf86NoSharedResources)
#ifdef async
SYMFUNC(xf86QueueAsyncEvent)
#endif
-
+ /* 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)
@@ -305,6 +342,7 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(DGAAvailable)
SYMFUNC(DGAActive)
SYMFUNC(DGASetMode)
+ SYMFUNC(DGASetInputMode)
SYMFUNC(DGASelectInput)
SYMFUNC(DGAGetViewportStatus)
SYMFUNC(DGASetViewport)
@@ -384,7 +422,9 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86GetAllowMouseOpenFail)
SYMFUNC(xf86IsPc98)
SYMFUNC(xf86GetClocks)
+ SYMFUNC(xf86LoadDrvSubModule)
SYMFUNC(xf86LoadSubModule)
+ SYMFUNC(xf86UnloadSubModule)
SYMFUNC(xf86LoaderCheckSymbol)
SYMFUNC(xf86LoaderReqSymLists)
SYMFUNC(xf86LoaderReqSymbols)
@@ -396,6 +436,8 @@ LOOKUP xfree86LookupTab[] = {
/* SYMFUNC(xf86NewSerialNumber) */
SYMFUNC(xf86FindXvOptions)
SYMFUNC(xf86GetOS)
+ SYMFUNC(xf86ConfigPciEntity)
+ SYMFUNC(xf86ConfigIsaEntity)
SYMFUNC(xf86ConfigActivePciEntity)
SYMFUNC(xf86ConfigActiveIsaEntity)
SYMFUNC(xf86ConfigPciEntityInactive)
@@ -404,6 +446,23 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86RegisterRootWindowProperty)
SYMFUNC(xf86IsUnblank)
+#ifdef __sparc__
+ /* 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)
@@ -472,6 +531,7 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86FBManagerRunning)
SYMFUNC(xf86QueryLargestOffscreenArea)
SYMFUNC(xf86PurgeUnlockedOffscreenAreas)
+ SYMFUNC(xf86RegisterOffscreenManager)
/* xf86cmap.c */
SYMFUNC(xf86HandleColormaps)
@@ -481,6 +541,9 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86XVRegisterGenericAdaptorDriver)
SYMFUNC(xf86XVListGenericAdaptors)
SYMFUNC(xf86XVRegisterOffscreenImages)
+ SYMFUNC(xf86XVQueryOffscreenImages)
+ SYMFUNC(xf86XVAllocateVideoAdaptorRec)
+ SYMFUNC(xf86XVFreeVideoAdaptorRec)
/* xf86VidMode.c */
SYMFUNC(VidModeExtensionInit)
@@ -521,6 +584,7 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(MiscExtGetKbdValue)
SYMFUNC(MiscExtSetKbdValue)
SYMFUNC(MiscExtCreateStruct)
+ SYMFUNC(MiscExtDestroyStruct)
SYMFUNC(MiscExtApply)
#endif
@@ -778,6 +842,8 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(xf86fstat)
SYMFUNC(xf86access)
SYMFUNC(xf86geteuid)
+ SYMFUNC(xf86getegid)
+ SYMFUNC(xf86getpid)
SYMFUNC(xf86mknod)
SYMFUNC(xf86chmod)
SYMFUNC(xf86chown)
@@ -795,6 +861,9 @@ LOOKUP xfree86LookupTab[] = {
of the X server) easier. */
SYMFUNC(xf86InstallSIGIOHandler)
SYMFUNC(xf86RemoveSIGIOHandler)
+#ifdef __alpha__
+ SYMFUNC(_bus_base)
+#endif
#endif
SYMFUNC(xf86BlockSIGIO)
SYMFUNC(xf86UnblockSIGIO)
@@ -864,7 +933,12 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(testinx2)
SYMFUNC(testinx)
#if defined(Lynx)
+ SYMFUNC(_restf14)
SYMFUNC(_restf17)
+ SYMFUNC(_restf18)
+ SYMFUNC(_restf19)
+ SYMFUNC(_restf20)
+ SYMFUNC(_restf22)
SYMFUNC(_restf23)
SYMFUNC(_restf24)
SYMFUNC(_restf25)
@@ -872,7 +946,12 @@ LOOKUP xfree86LookupTab[] = {
SYMFUNC(_restf27)
SYMFUNC(_restf28)
SYMFUNC(_restf29)
+ SYMFUNC(_savef14)
SYMFUNC(_savef17)
+ SYMFUNC(_savef18)
+ SYMFUNC(_savef19)
+ SYMFUNC(_savef20)
+ SYMFUNC(_savef22)
SYMFUNC(_savef23)
SYMFUNC(_savef24)
SYMFUNC(_savef25)
@@ -891,6 +970,10 @@ LOOKUP xfree86LookupTab[] = {
#endif
#endif
+#ifdef __FreeBSD__
+ SYMFUNC(sysctlbyname)
+#endif
+
/*
* and now some variables
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/Imakefile
index 7041d435a..91a9b8706 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.37 2000/02/22 01:02:34 mvojkovi Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/Imakefile,v 3.41 2000/06/30 17:15:17 dawes Exp $
@@ -13,7 +13,8 @@ XCOMM $XConsortium: Imakefile /main/9 1996/10/25 15:38:46 kaleb $
#if defined(i386Architecture) || defined(ia64Architecture) || \
(defined(LinuxArchitecture) && defined(AlphaArchitecture)) || \
(defined(FreeBSDArchitecture) && defined(AlphaArchitecture)) || \
- defined(PpcArchitecture) || defined(SparcArchitecture)
+ defined(PpcArchitecture) || defined(SparcArchitecture) || \
+ (defined(LinuxArchitecture) && defined(MipsArchitecture))
BUS_SUBDIR = bus
#endif
@@ -62,7 +63,7 @@ OS_SUBDIR = lynxos
#endif
#if defined(i386BsdArchitecture) || defined(AlphaBsdArchitecture)
-# if defined(BSD386Architecture)
+# if defined(BSDOSArchitecture)
OS_SUBDIR = bsdi
# else
OS_SUBDIR = bsd
@@ -100,6 +101,7 @@ OS_SUBDIR = sco
#if BuildXF86DRI && !DoLoadableServer
DRM_SRC = $(OS_SUBDIR)/drm/?*.c
DRM_OBJ = $(OS_SUBDIR)/drm/?*.o
+DRM_DONES = $(OS_SUBDIR)/drm/DONE
#endif
SUBDIRS = $(OS_SUBDIR) $(BUS_SUBDIR) misc vbe
@@ -107,7 +109,7 @@ SUBDIRS = $(OS_SUBDIR) $(BUS_SUBDIR) misc vbe
SRCS = $(OS_SUBDIR)/?*.c $(BUS_SUBDIR)/?*.c misc/?*.c vbe/?*.c $(DRM_SRC)
OBJS = $(OS_SUBDIR)/?*.o $(BUS_SUBDIR)/?*.o misc/?*.o vbe/?*.o $(DRM_OBJ)
-DONES = $(OS_SUBDIR)/DONE $(BUS_SUBDIR)/DONE misc/DONE vbe/DONE
+DONES = $(OS_SUBDIR)/DONE $(BUS_SUBDIR)/DONE misc/DONE vbe/DONE $(DRM_DONES)
#if HasParallelMake
MakeMutex($(SUBDIRS) $(OBJS) $(DONES))
@@ -128,6 +130,7 @@ ForceSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
InstallDriverSDKNonExecFile(xf86_OSproc.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(xf86_OSlib.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86_ansic.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86_libc.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(xf86drm.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile
index e4deae416..86518badb 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile,v 3.2 1999/07/10 07:24:47 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/amoeba/Imakefile,v 3.4 2000/06/27 14:27:29 tsi Exp $
@@ -12,10 +12,10 @@ IOSRC = inout.S
IOOBJ = inout.o
#endif
-SRCS = am_init.c am_video.c am_io.c mapVT_noop.c ioperm_noop.c \
- VTsw_noop.c $(IOSRC)
-OBJS = am_init.o am_video.o am_io.o mapVT_noop.o ioperm_noop.o \
- VTsw_noop.o $(IOOBJ)
+SRCS = am_init.c am_video.c am_io.c ioperm_noop.c \
+ VTsw_noop.c $(IOSRC) kmod_noop.c
+OBJS = am_init.o am_video.o am_io.o ioperm_noop.o \
+ VTsw_noop.o $(IOOBJ) kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -24,9 +24,9 @@ SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
NormalAsmObjectRule()
-ObjectFromSpecialSource(mapVT_noop,../shared/mapVT_noop,/**/)
ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/)
ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
+ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
#if AckToolset
ObjectFromSpecialAsmSource(inout,../shared/inout,/**/)
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile
index b0ec00a5e..424ff2cca 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile
@@ -4,7 +4,7 @@ XCOMM $XConsortium: Imakefile /main/12 1996/10/27 11:06:35 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.41 2000/03/05 16:59:16 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/Imakefile,v 3.43 2000/06/23 19:51:01 dawes Exp $
#include <Server.tmpl>
@@ -43,6 +43,11 @@ IOPERM_OBJ = ioperm_noop.o
# endif
#endif
+#if BuildXF86DRI
+DRI_SRC = sigio.c
+DRI_OBJ = sigio.o
+#endif
+
MOUSESRC = bsd_mouse.c
MOUSEOBJ = bsd_mouse.o
@@ -68,6 +73,14 @@ APMSRC = pm_noop.c
APMOBJ = pm_noop.o
#endif
+#if defined(FreeBSDArchitecture) && (OSMajorVersion > 2)
+KMODSRC = bsd_kmod.c
+KMODOBJ = bsd_kmod.o
+#else
+KMODSRC = kmod_noop.c
+KMODOBJ = kmod_noop.o
+#endif
+
#if defined(i386Architecture) || defined(ia64Architecture)
RES_SRC=stdResource.c
RES_OBJ=stdResource.o
@@ -84,12 +97,12 @@ AXP_OBJ=bsd_ev56.o
SRCS = bsd_init.c bsd_video.c bsd_io.c bsd_VTsw.c \
libc_wrapper.c $(IOPERM_SRC) std_kbdEv.c posix_tty.c $(MOUSESRC) \
$(RES_SRC) stdPci.c vidmem.c $(JOYSTICK_SRC) sigio.c $(APMSRC) \
- $(AXP_SRC)
+ $(AXP_SRC) $(KMODSRC)
OBJS = bsd_init.o bsd_video.o bsd_io.o bsd_VTsw.o \
libc_wrapper.o $(IOPERM_OBJ) std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
$(RES_OBJ) stdPci.o vidmem.o $(JOYSTICK_OBJ) sigio.o $(APMOBJ) \
- $(AXP_OBJ)
+ $(AXP_OBJ) $(KMODOBJ)
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi -I$(APINCLUDES) \
@@ -114,6 +127,14 @@ SpecialObjectRule(bsd_ev56.o, bsd_ev56.c, -mcpu=ev56)
SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
+#if BuildXF86DRI
+#define IHaveSubdirs
+SUBDIRS = drm
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
#if BuildXInputExt
# if DoLoadableServer
# if JoystickSupport
@@ -136,6 +157,7 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(vidmem.c,../shared)
LinkSourceFile(sigio.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c
new file mode 100644
index 000000000..2f5578412
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/bsd_kmod.c
@@ -0,0 +1,25 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/linker.h>
+
+#include "xf86_OSproc.h"
+#include "xf86_ansic.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
+ */
+int xf86LoadKernelModule(const char *modName)
+{
+ if (kldload(modName))
+ return 1;
+ else
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile
new file mode 100644
index 000000000..675425659
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile
@@ -0,0 +1,41 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/Imakefile,v 1.1 2000/06/17 00:03:27 martin Exp $
+XCOMM $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.7 1999/09/14 19:55:15 faith Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+MSRC = drmmodule.c
+MOBJ = drmmodule.o
+#endif
+
+#if BuildXF86DRI
+#if HasMTRRSupport
+MTRR_DEFINES = -DHAS_MTRR_SUPPORT
+#endif
+
+SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c $(MSRC)
+OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o $(MOBJ)
+
+
+INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+ -I$(XINCLUDESRC) -I$(EXTINCSRC) -I../.. -Ikernel
+
+DEFINES = $(MTRR_DEFINES) $(GLX_DEFINES)
+
+ModuleObjectRule()
+LibraryModuleTarget(drm,$(OBJS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(drm,$(MODULEDIR),freebsd)
+
+#define IHaveSubdirs
+SUBDIRS = kernel
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
+
+
+
+InstallDriverSDKLibraryModule(drm,$(DRIVERSDKMODULEDIR),freebsd)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c
new file mode 100644
index 000000000..5a420efc1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c
@@ -0,0 +1,56 @@
+/* drmmodule.c -- Module initialization
+ * Created: Fri Jun 4 09:05:48 1999 by faith@precisioninsight.com
+ * Revised: Fri Jun 4 09:09:22 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c,v 1.1 1999/06/07 13:01:42 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/drmmodule.c,v 1.1 2000/06/17 00:03:27 martin Exp $
+ *
+ */
+
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(drmSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "drm",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ 1, 0, 0,
+ ABI_CLASS_EXTENSION,
+ ABI_EXTENSION_VERSION,
+ MOD_CLASS_NONE,
+ {0,0,0,0}
+};
+
+XF86ModuleData drmModuleData = { &VersRec, drmSetup, NULL };
+
+static pointer
+drmSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ return (void *)1;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile
new file mode 100644
index 000000000..7d33c205b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile
@@ -0,0 +1,31 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Imakefile,v 1.1 2000/06/17 00:03:28 martin Exp $
+XCOMM $PI$
+
+#include <Server.tmpl>
+
+LinkSourceFile(xf86drm.c,..)
+LinkSourceFile(xf86drmHash.c,..)
+LinkSourceFile(xf86drmRandom.c,..)
+LinkSourceFile(xf86drmSL.c,..)
+LinkSourceFile(xf86drm.h,$(XF86OSSRC))
+LinkSourceFile(xf86_OSproc.h,$(XF86OSSRC))
+LinkSourceFile(sigio.c,$(XF86OSSRC)/shared)
+
+XCOMM This is a kludge until we determine how best to build the
+XCOMM kernel-specific device driver. This allows us to continue
+XCOMM to maintain the single Makefile.bsd with kernel-specific
+XCOMM support. Later, we can move to a different Imakefile.
+
+#if BuildXF86DRI && BuildXF86DRM
+all::
+ $(MAKE) -f Makefile.bsd
+
+install::
+ $(MAKE) -f Makefile.bsd install
+#else
+all::
+ echo 'Use "make -f Makefile.bsd" to manually build drm.o'
+#endif
+
+clean::
+ $(MAKE) -f Makefile.bsd clean
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Makefile.bsd b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Makefile.bsd
new file mode 100644
index 000000000..ff26c7628
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/Makefile.bsd
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+SUBDIR = drm tdfx gamma
+
+.include <bsd.subdir.mk>
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h
new file mode 100644
index 000000000..ddad1be7e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm.h
@@ -0,0 +1,362 @@
+/* drm.h -- Header for Direct Rendering Manager -*- c -*-
+ * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * Acknowledgements:
+ * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
+ *
+ */
+
+#ifndef _DRM_H_
+#define _DRM_H_
+
+#include <sys/ioccom.h> /* For _IO* macros */
+
+#define DRM_DEV_DRM "/dev/drm"
+#define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
+#define DRM_DEV_UID 0
+#define DRM_DEV_GID 0
+
+
+#define DRM_NAME "drm" /* Name in kernel, /dev */
+#define DRM_MIN_ORDER 5 /* At least 2^5 bytes = 32 bytes */
+#define DRM_MAX_ORDER 22 /* Up to 2^22 bytes = 4MB */
+#define DRM_RAM_PERCENT 10 /* How much system ram can we lock? */
+
+#define _DRM_LOCK_HELD 0x80000000 /* Hardware lock is held */
+#define _DRM_LOCK_CONT 0x40000000 /* Hardware lock is contended */
+#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)
+#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)
+#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
+
+typedef unsigned long drm_handle_t;
+typedef unsigned int drm_context_t;
+typedef unsigned int drm_drawable_t;
+typedef unsigned int drm_magic_t;
+
+/* Warning: If you change this structure, make sure you change
+ * XF86DRIClipRectRec in the server as well */
+
+typedef struct drm_clip_rect {
+ unsigned short x1;
+ unsigned short y1;
+ unsigned short x2;
+ unsigned short y2;
+} drm_clip_rect_t;
+
+/* Seperate include files for the i810/mga/r128 specific structures */
+#include "mga_drm.h"
+#include "i810_drm.h"
+#include "r128_drm.h"
+
+typedef struct drm_version {
+ int version_major; /* Major version */
+ int version_minor; /* Minor version */
+ int version_patchlevel;/* Patch level */
+ size_t name_len; /* Length of name buffer */
+ char *name; /* Name of driver */
+ size_t date_len; /* Length of date buffer */
+ char *date; /* User-space buffer to hold date */
+ size_t desc_len; /* Length of desc buffer */
+ char *desc; /* User-space buffer to hold desc */
+} drm_version_t;
+
+typedef struct drm_unique {
+ size_t unique_len; /* Length of unique */
+ char *unique; /* Unique name for driver instantiation */
+} drm_unique_t;
+
+typedef struct drm_list {
+ int count; /* Length of user-space structures */
+ drm_version_t *version;
+} drm_list_t;
+
+typedef struct drm_block {
+ int unused;
+} drm_block_t;
+
+typedef struct drm_control {
+ enum {
+ DRM_ADD_COMMAND,
+ DRM_RM_COMMAND,
+ DRM_INST_HANDLER,
+ DRM_UNINST_HANDLER
+ } func;
+ int irq;
+} drm_control_t;
+
+typedef enum drm_map_type {
+ _DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */
+ _DRM_REGISTERS = 1, /* no caching, no core dump */
+ _DRM_SHM = 2, /* shared, cached */
+ _DRM_AGP = 3 /* AGP/GART */
+} drm_map_type_t;
+
+typedef enum drm_map_flags {
+ _DRM_RESTRICTED = 0x01, /* Cannot be mapped to user-virtual */
+ _DRM_READ_ONLY = 0x02,
+ _DRM_LOCKED = 0x04, /* shared, cached, locked */
+ _DRM_KERNEL = 0x08, /* kernel requires access */
+ _DRM_WRITE_COMBINING = 0x10, /* use write-combining if available */
+ _DRM_CONTAINS_LOCK = 0x20 /* SHM page that contains lock */
+} drm_map_flags_t;
+
+typedef struct drm_map {
+ unsigned long offset; /* Requested physical address (0 for SAREA)*/
+ unsigned long size; /* Requested physical size (bytes) */
+ drm_map_type_t type; /* Type of memory to map */
+ drm_map_flags_t flags; /* Flags */
+ void *handle; /* User-space: "Handle" to pass to mmap */
+ /* Kernel-space: kernel-virtual address */
+ int mtrr; /* MTRR slot used */
+ /* Private data */
+} drm_map_t;
+
+typedef enum drm_lock_flags {
+ _DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
+ _DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
+ _DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
+ _DRM_LOCK_FLUSH_ALL = 0x08, /* Flush all DMA queues first */
+ /* These *HALT* flags aren't supported yet
+ -- they will be used to support the
+ full-screen DGA-like mode. */
+ _DRM_HALT_ALL_QUEUES = 0x10, /* Halt all current and future queues */
+ _DRM_HALT_CUR_QUEUES = 0x20 /* Halt all current queues */
+} drm_lock_flags_t;
+
+typedef struct drm_lock {
+ int context;
+ drm_lock_flags_t flags;
+} drm_lock_t;
+
+typedef enum drm_dma_flags { /* These values *MUST* match xf86drm.h */
+ /* Flags for DMA buffer dispatch */
+ _DRM_DMA_BLOCK = 0x01, /* Block until buffer dispatched.
+ Note, the buffer may not yet have
+ been processed by the hardware --
+ getting a hardware lock with the
+ hardware quiescent will ensure
+ that the buffer has been
+ processed. */
+ _DRM_DMA_WHILE_LOCKED = 0x02, /* Dispatch while lock held */
+ _DRM_DMA_PRIORITY = 0x04, /* High priority dispatch */
+
+ /* Flags for DMA buffer request */
+ _DRM_DMA_WAIT = 0x10, /* Wait for free buffers */
+ _DRM_DMA_SMALLER_OK = 0x20, /* Smaller-than-requested buffers ok */
+ _DRM_DMA_LARGER_OK = 0x40 /* Larger-than-requested buffers ok */
+} drm_dma_flags_t;
+
+typedef struct drm_buf_desc {
+ int count; /* Number of buffers of this size */
+ int size; /* Size in bytes */
+ int low_mark; /* Low water mark */
+ int high_mark; /* High water mark */
+ enum {
+ _DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */
+ _DRM_AGP_BUFFER = 0x02 /* Buffer is in agp space */
+ } flags;
+ unsigned long agp_start; /* Start address of where the agp buffers
+ * are in the agp aperture */
+} drm_buf_desc_t;
+
+typedef struct drm_buf_info {
+ int count; /* Entries in list */
+ drm_buf_desc_t *list;
+} drm_buf_info_t;
+
+typedef struct drm_buf_free {
+ int count;
+ int *list;
+} drm_buf_free_t;
+
+typedef struct drm_buf_pub {
+ int idx; /* Index into master buflist */
+ int total; /* Buffer size */
+ int used; /* Amount of buffer in use (for DMA) */
+ void *address; /* Address of buffer */
+} drm_buf_pub_t;
+
+typedef struct drm_buf_map {
+ int count; /* Length of buflist */
+ void *virtual; /* Mmaped area in user-virtual */
+ drm_buf_pub_t *list; /* Buffer information */
+} drm_buf_map_t;
+
+typedef struct drm_dma {
+ /* Indices here refer to the offset into
+ buflist in drm_buf_get_t. */
+ int context; /* Context handle */
+ int send_count; /* Number of buffers to send */
+ int *send_indices; /* List of handles to buffers */
+ int *send_sizes; /* Lengths of data to send */
+ drm_dma_flags_t flags; /* Flags */
+ int request_count; /* Number of buffers requested */
+ int request_size; /* Desired size for buffers */
+ int *request_indices; /* Buffer information */
+ int *request_sizes;
+ int granted_count; /* Number of buffers granted */
+} drm_dma_t;
+
+typedef enum {
+ _DRM_CONTEXT_PRESERVED = 0x01,
+ _DRM_CONTEXT_2DONLY = 0x02
+} drm_ctx_flags_t;
+
+typedef struct drm_ctx {
+ drm_context_t handle;
+ drm_ctx_flags_t flags;
+} drm_ctx_t;
+
+typedef struct drm_ctx_res {
+ int count;
+ drm_ctx_t *contexts;
+} drm_ctx_res_t;
+
+typedef struct drm_draw {
+ drm_drawable_t handle;
+} drm_draw_t;
+
+typedef struct drm_auth {
+ drm_magic_t magic;
+} drm_auth_t;
+
+typedef struct drm_irq_busid {
+ int irq;
+ int busnum;
+ int devnum;
+ int funcnum;
+} drm_irq_busid_t;
+
+typedef struct drm_agp_mode {
+ unsigned long mode;
+} drm_agp_mode_t;
+
+ /* For drm_agp_alloc -- allocated a buffer */
+typedef struct drm_agp_buffer {
+ unsigned long size; /* In bytes -- will round to page boundary */
+ unsigned long handle; /* Used for BIND/UNBIND ioctls */
+ unsigned long type; /* Type of memory to allocate */
+ unsigned long physical; /* Physical used by i810 */
+} drm_agp_buffer_t;
+
+ /* For drm_agp_bind */
+typedef struct drm_agp_binding {
+ unsigned long handle; /* From drm_agp_buffer */
+ unsigned long offset; /* In bytes -- will round to page boundary */
+} drm_agp_binding_t;
+
+typedef struct drm_agp_info {
+ int agp_version_major;
+ int agp_version_minor;
+ unsigned long mode;
+ unsigned long aperture_base; /* physical address */
+ unsigned long aperture_size; /* bytes */
+ unsigned long memory_allowed; /* bytes */
+ unsigned long memory_used;
+
+ /* PCI information */
+ unsigned short id_vendor;
+ unsigned short id_device;
+} drm_agp_info_t;
+
+#define DRM_IOCTL_BASE 'd'
+#define DRM_IOCTL_NR(n) ((n) & 0xff)
+#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
+#define DRM_IOR(nr,size) _IOR(DRM_IOCTL_BASE,nr,size)
+#define DRM_IOW(nr,size) _IOW(DRM_IOCTL_BASE,nr,size)
+#define DRM_IOWR(nr,size) _IOWR(DRM_IOCTL_BASE,nr,size)
+
+
+#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
+#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
+#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t)
+#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
+
+#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
+#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, drm_auth_t)
+#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, drm_block_t)
+#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, drm_block_t)
+#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, drm_control_t)
+#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, drm_map_t)
+#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, drm_buf_desc_t)
+#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, drm_buf_desc_t)
+#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, drm_buf_info_t)
+#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, drm_buf_map_t)
+#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, drm_buf_free_t)
+
+#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, drm_ctx_t)
+#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, drm_ctx_t)
+#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, drm_ctx_t)
+#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, drm_ctx_t)
+#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, drm_ctx_t)
+#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, drm_ctx_t)
+#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, drm_ctx_res_t)
+#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, drm_draw_t)
+#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, drm_draw_t)
+#define DRM_IOCTL_DMA DRM_IOWR(0x29, drm_dma_t)
+#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, drm_lock_t)
+#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
+#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)
+
+#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
+#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
+#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t)
+#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t)
+#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t)
+#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t)
+#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t)
+#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t)
+
+/* Mga specific ioctls */
+#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
+#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t)
+#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t)
+#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x43, drm_mga_iload_t)
+#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x44, drm_mga_vertex_t)
+#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x45, drm_lock_t )
+#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t)
+
+/* I810 specific ioctls */
+#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t)
+#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t)
+#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t)
+#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43)
+#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44)
+#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t)
+#define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46)
+
+/* Rage 128 specific ioctls */
+#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
+#define DRM_IOCTL_R128_RESET DRM_IO( 0x41)
+#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42)
+#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43)
+#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t)
+#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t)
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/Makefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/Makefile
new file mode 100644
index 000000000..d9c4a3715
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+KMOD = drm
+SRCS = init.c memory.c auth.c context.c drawable.c bufs.c \
+ lists.c lock.c ioctl.c fops.c vm.c dma.c sysctl.c \
+ agpsupport.c ctxbitmap.c
+SRCS += device_if.h bus_if.h pci_if.h
+CFLAGS += ${DEBUG_FLAGS} -I..
+
+@:
+ ln -sf /sys @
+
+machine:
+ ln -sf /sys/i386/include machine
+
+.include <bsd.kmod.mk>
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/agpsupport.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/agpsupport.c
new file mode 100644
index 000000000..f399171e1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/agpsupport.c
@@ -0,0 +1,270 @@
+/* agpsupport.c -- DRM support for AGP/GART backend
+ * Created: Mon Dec 13 09:56:45 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+#ifdef DRM_AGP
+
+#include <pci/agpvar.h>
+
+MODULE_DEPEND(drm, agp, 1, 1, 1);
+
+int
+drm_agp_info(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ struct agp_info *kern;
+ drm_agp_info_t info;
+
+ if (!dev->agp->acquired) return EINVAL;
+
+ kern = &dev->agp->info;
+ agp_get_info(dev->agp->agpdev, kern);
+ info.agp_version_major = 1;
+ info.agp_version_minor = 0;
+ info.mode = kern->ai_mode;
+ info.aperture_base = kern->ai_aperture_base;
+ info.aperture_size = kern->ai_aperture_size;
+ info.memory_allowed = kern->ai_memory_allowed;
+ info.memory_used = kern->ai_memory_used;
+ info.id_vendor = kern->ai_devid & 0xffff;
+ info.id_device = kern->ai_devid >> 16;
+
+ *(drm_agp_info_t *) data = info;
+ return 0;
+}
+
+int
+drm_agp_acquire(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int retcode;
+
+ if (dev->agp->acquired) return EINVAL;
+ retcode = agp_acquire(dev->agp->agpdev);
+ if (retcode) return retcode;
+ dev->agp->acquired = 1;
+ return 0;
+}
+
+int
+drm_agp_release(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+
+ if (!dev->agp->acquired) return EINVAL;
+ agp_release(dev->agp->agpdev);
+ dev->agp->acquired = 0;
+ return 0;
+
+}
+
+int
+drm_agp_enable(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_agp_mode_t mode;
+
+ if (!dev->agp->acquired) return EINVAL;
+
+ mode = *(drm_agp_mode_t *) data;
+
+ dev->agp->mode = mode.mode;
+ agp_enable(dev->agp->agpdev, mode.mode);
+ dev->agp->base = dev->agp->info.ai_aperture_base;
+ dev->agp->enabled = 1;
+ return 0;
+}
+
+int drm_agp_alloc(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_agp_buffer_t request;
+ drm_agp_mem_t *entry;
+ void *handle;
+ unsigned long pages;
+ u_int32_t type;
+ struct agp_memory_info info;
+
+ if (!dev->agp->acquired) return EINVAL;
+
+ request = *(drm_agp_buffer_t *) data;
+
+ if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
+ return ENOMEM;
+
+ memset(entry, 0, sizeof(*entry));
+
+ pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
+ type = (u_int32_t) request.type;
+
+ if (!(handle = drm_alloc_agp(pages, type))) {
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ return ENOMEM;
+ }
+
+ entry->handle = handle;
+ entry->bound = 0;
+ entry->pages = pages;
+ entry->prev = NULL;
+ entry->next = dev->agp->memory;
+ if (dev->agp->memory) dev->agp->memory->prev = entry;
+ dev->agp->memory = entry;
+
+ agp_memory_info(dev->agp->agpdev, entry->handle, &info);
+
+ request.handle = (unsigned long) entry->handle;
+ request.physical = info.ami_physical;
+
+ *(drm_agp_buffer_t *) data = request;
+
+ return 0;
+}
+
+static drm_agp_mem_t *
+drm_agp_lookup_entry(drm_device_t *dev, void *handle)
+{
+ drm_agp_mem_t *entry;
+
+ for (entry = dev->agp->memory; entry; entry = entry->next) {
+ if (entry->handle == handle) return entry;
+ }
+ return NULL;
+}
+
+int
+drm_agp_unbind(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_agp_binding_t request;
+ drm_agp_mem_t *entry;
+
+ if (!dev->agp->acquired) return EINVAL;
+ request = *(drm_agp_binding_t *) data;
+ if (!(entry = drm_agp_lookup_entry(dev, (void *) request.handle)))
+ return EINVAL;
+ if (!entry->bound) return EINVAL;
+ return drm_unbind_agp(entry->handle);
+}
+
+int drm_agp_bind(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_agp_binding_t request;
+ drm_agp_mem_t *entry;
+ int retcode;
+ int page;
+
+ if (!dev->agp->acquired) return EINVAL;
+ request = *(drm_agp_binding_t *) data;
+ if (!(entry = drm_agp_lookup_entry(dev, (void *) request.handle)))
+ return EINVAL;
+ if (entry->bound) return EINVAL;
+ page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE;
+ if ((retcode = drm_bind_agp(entry->handle, page))) return retcode;
+ entry->bound = dev->agp->base + (page << PAGE_SHIFT);
+ return 0;
+}
+
+int drm_agp_free(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_agp_buffer_t request;
+ drm_agp_mem_t *entry;
+
+ if (!dev->agp->acquired) return EINVAL;
+ request = *(drm_agp_buffer_t *) data;
+ if (!(entry = drm_agp_lookup_entry(dev, (void*) request.handle)))
+ return EINVAL;
+ if (entry->bound) drm_unbind_agp(entry->handle);
+
+ if (entry->prev) entry->prev->next = entry->next;
+ else dev->agp->memory = entry->next;
+ if (entry->next) entry->next->prev = entry->prev;
+ drm_free_agp(entry->handle, entry->pages);
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ return 0;
+}
+
+drm_agp_head_t *drm_agp_init(void)
+{
+ device_t agpdev;
+ drm_agp_head_t *head = NULL;
+ int agp_available = 1;
+
+ agpdev = agp_find_device();
+ if (!agpdev)
+ agp_available = 0;
+
+ DRM_DEBUG("agp_available = %d\n", agp_available);
+
+ if (agp_available) {
+ if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
+ return NULL;
+ memset((void *)head, 0, sizeof(*head));
+ head->agpdev = agpdev;
+ agp_get_info(agpdev, &head->info);
+ head->memory = NULL;
+#if 0 /* bogus */
+ switch (head->agp_info.chipset) {
+ case INTEL_GENERIC: head->chipset = "Intel"; break;
+ case INTEL_LX: head->chipset = "Intel 440LX"; break;
+ case INTEL_BX: head->chipset = "Intel 440BX"; break;
+ case INTEL_GX: head->chipset = "Intel 440GX"; break;
+ case INTEL_I810: head->chipset = "Intel i810"; break;
+ case VIA_GENERIC: head->chipset = "VIA"; break;
+ case VIA_VP3: head->chipset = "VIA VP3"; break;
+ case VIA_MVP3: head->chipset = "VIA MVP3"; break;
+ case VIA_APOLLO_PRO: head->chipset = "VIA Apollo Pro"; break;
+ case SIS_GENERIC: head->chipset = "SiS"; break;
+ case AMD_GENERIC: head->chipset = "AMD"; break;
+ case AMD_IRONGATE: head->chipset = "AMD Irongate"; break;
+ case ALI_GENERIC: head->chipset = "ALi"; break;
+ case ALI_M1541: head->chipset = "ALi M1541"; break;
+ default:
+ }
+#endif
+ DRM_INFO("AGP at 0x%08x %dMB\n",
+ head->info.ai_aperture_base,
+ head->info.ai_aperture_size >> 20);
+ }
+ return head;
+}
+
+#endif /* DRM_AGP */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/auth.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/auth.c
new file mode 100644
index 000000000..a26990112
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/auth.c
@@ -0,0 +1,168 @@
+/* auth.c -- IOCTLs for authentication -*- c -*-
+ * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+static int drm_hash_magic(drm_magic_t magic)
+{
+ return magic & (DRM_HASH_SIZE-1);
+}
+
+static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
+{
+ drm_file_t *retval = NULL;
+ drm_magic_entry_t *pt;
+ int hash = drm_hash_magic(magic);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
+ if (pt->priv->authenticated) continue;
+ if (pt->magic == magic) {
+ retval = pt->priv;
+ break;
+ }
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ return retval;
+}
+
+int drm_add_magic(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
+{
+ int hash;
+ drm_magic_entry_t *entry;
+
+ DRM_DEBUG("%d\n", magic);
+
+ hash = drm_hash_magic(magic);
+ entry = drm_alloc(sizeof(*entry), DRM_MEM_MAGIC);
+ if (!entry) return ENOMEM;
+ entry->magic = magic;
+ entry->priv = priv;
+ entry->next = NULL;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ if (dev->magiclist[hash].tail) {
+ dev->magiclist[hash].tail->next = entry;
+ dev->magiclist[hash].tail = entry;
+ } else {
+ dev->magiclist[hash].head = entry;
+ dev->magiclist[hash].tail = entry;
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ return 0;
+}
+
+int drm_remove_magic(drm_device_t *dev, drm_magic_t magic)
+{
+ drm_magic_entry_t *prev = NULL;
+ drm_magic_entry_t *pt;
+ int hash;
+
+ DRM_DEBUG("%d\n", magic);
+ hash = drm_hash_magic(magic);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
+ if (pt->magic == magic) {
+ if (dev->magiclist[hash].head == pt) {
+ dev->magiclist[hash].head = pt->next;
+ }
+ if (dev->magiclist[hash].tail == pt) {
+ dev->magiclist[hash].tail = prev;
+ }
+ if (prev) {
+ prev->next = pt->next;
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return 0;
+ }
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+
+ return EINVAL;
+}
+
+int drm_getmagic(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ static drm_magic_t sequence = 0;
+#if 0
+ static struct simplelock lock; /* XXX */
+#endif
+ drm_device_t *dev = kdev->si_drv1;
+ drm_file_t *priv;
+ drm_auth_t auth;
+
+ /* Find unique magic */
+ priv = drm_find_file_by_proc(dev, p);
+ if (!priv) {
+ DRM_DEBUG("can't find file structure\n");
+ return EINVAL;
+ }
+ if (priv->magic) {
+ auth.magic = priv->magic;
+ } else {
+ simple_lock(&lock);
+ do {
+ if (!sequence) ++sequence; /* reserve 0 */
+ auth.magic = sequence++;
+ } while (drm_find_file(dev, auth.magic));
+ simple_unlock(&lock);
+ priv->magic = auth.magic;
+ drm_add_magic(dev, priv, auth.magic);
+ }
+
+ DRM_DEBUG("%u\n", auth.magic);
+ *(drm_auth_t *) data = auth;
+ return 0;
+}
+
+int drm_authmagic(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_auth_t auth;
+ drm_file_t *file;
+
+ auth = *(drm_auth_t *) data;
+ DRM_DEBUG("%u\n", auth.magic);
+ if ((file = drm_find_file(dev, auth.magic))) {
+ file->authenticated = 1;
+ drm_remove_magic(dev, auth.magic);
+ return 0;
+ }
+ return EINVAL;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/bufs.c
new file mode 100644
index 000000000..f283bab21
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/bufs.c
@@ -0,0 +1,500 @@
+/* bufs.c -- IOCTLs to manage buffers -*- c -*-
+ * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include <sys/mman.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_map.h>
+
+ /* Compute order. Can be made faster. */
+int drm_order(unsigned long size)
+{
+ int order;
+ unsigned long tmp;
+
+ for (order = 0, tmp = size; tmp >>= 1; ++order);
+ if (size & ~(1 << order)) ++order;
+ return order;
+}
+
+int drm_addmap(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_map_t *map;
+
+ if (!(dev->flags & (FREAD|FWRITE)))
+ return EACCES; /* Require read/write */
+
+ map = drm_alloc(sizeof(*map), DRM_MEM_MAPS);
+ if (!map) return ENOMEM;
+ *map = *(drm_map_t *) data;
+
+ DRM_DEBUG("offset = 0x%08lx, size = 0x%08lx, type = %d\n",
+ map->offset, map->size, map->type);
+ if ((map->offset & (PAGE_SIZE-1)) || (map->size & (PAGE_SIZE-1))) {
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ DRM_DEBUG("offset or size not page aligned\n");
+ return EINVAL;
+ }
+ map->mtrr = -1;
+ map->handle = 0;
+
+ switch (map->type) {
+ case _DRM_REGISTERS:
+ case _DRM_FRAME_BUFFER:
+ if (map->offset + map->size < map->offset
+ /* || map->offset < virt_to_phys(high_memory) */) {
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ DRM_DEBUG("bad frame buffer size\n");
+ return EINVAL;
+ }
+#ifdef CONFIG_MTRR
+ if (map->type == _DRM_FRAME_BUFFER
+ || (map->flags & _DRM_WRITE_COMBINING)) {
+ map->mtrr = mtrr_add(map->offset, map->size,
+ MTRR_TYPE_WRCOMB, 1);
+ }
+#endif
+ map->handle = drm_ioremap(map->offset, map->size);
+ break;
+
+
+ case _DRM_SHM:
+ DRM_DEBUG("%ld %d\n", map->size, drm_order(map->size));
+ map->handle = (void *)drm_alloc_pages(drm_order(map->size)
+ - PAGE_SHIFT,
+ DRM_MEM_SAREA);
+ if (!map->handle) {
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ return ENOMEM;
+ }
+ map->offset = (unsigned long)map->handle;
+ if (map->flags & _DRM_CONTAINS_LOCK) {
+ dev->lock.hw_lock = map->handle; /* Pointer to lock */
+ }
+ break;
+#ifdef DRM_AGP
+ case _DRM_AGP:
+ map->offset = map->offset + dev->agp->base;
+ break;
+#endif
+ default:
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ DRM_DEBUG("bad type\n");
+ return EINVAL;
+ }
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ if (dev->maplist) {
+ ++dev->map_count;
+ dev->maplist = drm_realloc(dev->maplist,
+ (dev->map_count-1)
+ * sizeof(*dev->maplist),
+ dev->map_count
+ * sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ } else {
+ dev->map_count = 1;
+ dev->maplist = drm_alloc(dev->map_count*sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ }
+ dev->maplist[dev->map_count-1] = map;
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ *(drm_map_t *) data = *map;
+ if (map->type != _DRM_SHM)
+ ((drm_map_t *)data)->handle = (void *) map->offset;
+
+ return 0;
+}
+
+int drm_addbufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ int count;
+ int order;
+ int size;
+ int total;
+ int page_order;
+ drm_buf_entry_t *entry;
+ unsigned long page;
+ drm_buf_t *buf;
+ int alignment;
+ unsigned long offset;
+ int i;
+ int byte_count;
+ int page_count;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_desc_t *) data;
+
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+
+ DRM_DEBUG("count = %d, size = %d (%d), order = %d, queue_count = %d\n",
+ request.count, request.size, size, order, dev->queue_count);
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return EINVAL;
+ if (dev->queue_count) return EBUSY; /* Not while in use */
+
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? round_page(size) :size;
+ page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
+ total = PAGE_SIZE << page_order;
+
+ simple_lock(&dev->count_lock);
+ if (dev->buf_use) {
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ atomic_inc(&dev->buf_alloc);
+ simple_unlock(&dev->count_lock);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ entry = &dma->bufs[order];
+ if (entry->buf_count) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM; /* May only call once for each order */
+ }
+
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ if (!entry->buflist) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM;
+ }
+ memset(entry->buflist, 0, count * sizeof(*entry->buflist));
+
+ entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
+ DRM_MEM_SEGS);
+ if (!entry->seglist) {
+ drm_free(entry->buflist,
+ count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM;
+ }
+ memset(entry->seglist, 0, count * sizeof(*entry->seglist));
+
+ dma->pagelist = drm_realloc(dma->pagelist,
+ dma->page_count * sizeof(*dma->pagelist),
+ (dma->page_count + (count << page_order))
+ * sizeof(*dma->pagelist),
+ DRM_MEM_PAGES);
+ DRM_DEBUG("pagelist: %d entries\n",
+ dma->page_count + (count << page_order));
+
+
+ entry->buf_size = size;
+ entry->page_order = page_order;
+ byte_count = 0;
+ page_count = 0;
+ while (entry->buf_count < count) {
+ if (!(page = drm_alloc_pages(page_order, DRM_MEM_DMA))) break;
+ entry->seglist[entry->seg_count++] = page;
+ for (i = 0; i < (1 << page_order); i++) {
+ DRM_DEBUG("page %d @ 0x%08lx\n",
+ dma->page_count + page_count,
+ page + PAGE_SIZE * i);
+ dma->pagelist[dma->page_count + page_count++]
+ = page + PAGE_SIZE * i;
+ }
+ for (offset = 0;
+ offset + size <= total && entry->buf_count < count;
+ offset += alignment, ++entry->buf_count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+ buf->offset = (dma->byte_count + byte_count + offset);
+ buf->address = (void *)(page + offset);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ buf->dma_wait = 0;
+ buf->pid = 0;
+#if DRM_DMA_HISTOGRAM
+ timespecclear(&buf->time_queued);
+ timespecclear(&buf->time_dispatched);
+ timespecclear(&buf->time_completed);
+ timespecclear(&buf->time_freed);
+#endif
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
+ }
+ byte_count += PAGE_SIZE << page_order;
+ }
+
+ dma->buflist = drm_realloc(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ (dma->buf_count + entry->buf_count)
+ * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
+ dma->buflist[i] = &entry->buflist[i - dma->buf_count];
+
+ dma->buf_count += entry->buf_count;
+ dma->seg_count += entry->seg_count;
+ dma->page_count += entry->seg_count << page_order;
+ dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
+
+ drm_freelist_create(&entry->freelist, entry->buf_count);
+ for (i = 0; i < entry->buf_count; i++) {
+ drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
+ }
+
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ request.count = entry->buf_count;
+ request.size = size;
+
+ *(drm_buf_desc_t *) data = request;
+
+ atomic_dec(&dev->buf_alloc);
+ return 0;
+}
+
+int drm_infobufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_info_t request;
+ int i;
+ int count;
+
+ if (!dma) return EINVAL;
+
+ simple_lock(&dev->count_lock);
+ if (atomic_read(&dev->buf_alloc)) {
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ ++dev->buf_use; /* Can't allocate more after this call */
+ simple_unlock(&dev->count_lock);
+
+ request = *(drm_buf_info_t *) data;
+
+ for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) {
+ if (dma->bufs[i].buf_count) ++count;
+ }
+
+ DRM_DEBUG("count = %d\n", count);
+
+ if (request.count >= count) {
+ for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) {
+ if (dma->bufs[i].buf_count) {
+ int error;
+ error = copyout(&dma->bufs[i].buf_count,
+ &request.list[count].count,
+ sizeof(dma->bufs[0]
+ .buf_count));
+ if (error) return error;
+ error = copyout(&dma->bufs[i].buf_size,
+ &request.list[count].size,
+ sizeof(dma->bufs[0].buf_size));
+ if (error) return error;
+ error = copyout(&dma->bufs[i]
+ .freelist.low_mark,
+ &request.list[count].low_mark,
+ sizeof(dma->bufs[0]
+ .freelist.low_mark));
+ if (error) return error;
+ error = copyout(&dma->bufs[i]
+ .freelist.high_mark,
+ &request.list[count].high_mark,
+ sizeof(dma->bufs[0]
+ .freelist.high_mark));
+ if (error) return error;
+ DRM_DEBUG("%d %d %d %d %d\n",
+ i,
+ dma->bufs[i].buf_count,
+ dma->bufs[i].buf_size,
+ dma->bufs[i].freelist.low_mark,
+ dma->bufs[i].freelist.high_mark);
+ ++count;
+ }
+ }
+ }
+ request.count = count;
+
+ *(drm_buf_info_t *) data = request;
+
+ return 0;
+}
+
+int drm_markbufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ int order;
+ drm_buf_entry_t *entry;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_desc_t *) data;
+
+ DRM_DEBUG("%d, %d, %d\n",
+ request.size, request.low_mark, request.high_mark);
+ order = drm_order(request.size);
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return EINVAL;
+ entry = &dma->bufs[order];
+
+ if (request.low_mark < 0 || request.low_mark > entry->buf_count)
+ return EINVAL;
+ if (request.high_mark < 0 || request.high_mark > entry->buf_count)
+ return EINVAL;
+
+ entry->freelist.low_mark = request.low_mark;
+ entry->freelist.high_mark = request.high_mark;
+
+ return 0;
+}
+
+int drm_freebufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_free_t request;
+ int i;
+ int idx;
+ int error;
+ drm_buf_t *buf;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_free_t *) data;
+
+ DRM_DEBUG("%d\n", request.count);
+ for (i = 0; i < request.count; i++) {
+ error = copyin(&request.list[i], &idx, sizeof(idx));
+ if (error)
+ return error;
+ if (idx < 0 || idx >= dma->buf_count) {
+ DRM_ERROR("Index %d (of %d max)\n",
+ idx, dma->buf_count - 1);
+ return EINVAL;
+ }
+ buf = dma->buflist[idx];
+ if (buf->pid != p->p_pid) {
+ DRM_ERROR("Process %d freeing buffer owned by %d\n",
+ p->p_pid, buf->pid);
+ return EINVAL;
+ }
+ drm_free_buffer(dev, buf);
+ }
+
+ return 0;
+}
+
+int drm_mapbufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ const int zero = 0;
+ vm_offset_t virtual;
+ vm_offset_t address;
+ drm_buf_map_t request;
+ int i;
+
+ if (!dma) return EINVAL;
+
+ DRM_DEBUG("\n");
+
+ simple_lock(&dev->count_lock);
+ if (atomic_read(&dev->buf_alloc)) {
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ ++dev->buf_use; /* Can't allocate more after this call */
+ simple_unlock(&dev->count_lock);
+
+ request = *(drm_buf_map_t *) data;
+
+ if (request.count >= dma->buf_count) {
+ virtual = 0;
+ retcode = vm_mmap(&p->p_vmspace->vm_map,
+ &virtual,
+ round_page(dma->byte_count),
+ PROT_READ|PROT_WRITE, VM_PROT_ALL,
+ MAP_SHARED,
+ SLIST_FIRST(&kdev->si_hlist),
+ 0);
+ if (retcode)
+ goto done;
+
+ request.virtual = (void *)virtual;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ retcode = copyout(&dma->buflist[i]->idx,
+ &request.list[i].idx,
+ sizeof(request.list[0].idx));
+ if (retcode) goto done;
+ retcode = copyout(&dma->buflist[i]->total,
+ &request.list[i].total,
+ sizeof(request.list[0].total));
+ if (retcode) goto done;
+ retcode = copyout(&zero,
+ &request.list[i].used,
+ sizeof(request.list[0].used));
+ if (retcode) goto done;
+ address = virtual + dma->buflist[i]->offset;
+ retcode = copyout(&address,
+ &request.list[i].address,
+ sizeof(address));
+ if (retcode) goto done;
+ }
+ }
+done:
+ request.count = dma->buf_count;
+ DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
+
+ *(drm_buf_map_t *) data = request;
+
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/context.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/context.c
new file mode 100644
index 000000000..70510f006
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/context.c
@@ -0,0 +1,297 @@
+/* context.c -- IOCTLs for contexts and DMA queues -*- c -*-
+ * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+static int drm_init_queue(drm_device_t *dev, drm_queue_t *q, drm_ctx_t *ctx)
+{
+ DRM_DEBUG("\n");
+
+ if (atomic_read(&q->use_count) != 1
+ || atomic_read(&q->finalization)
+ || atomic_read(&q->block_count)) {
+ DRM_ERROR("New queue is already in use: u%d f%d b%d\n",
+ atomic_read(&q->use_count),
+ atomic_read(&q->finalization),
+ atomic_read(&q->block_count));
+ }
+
+ atomic_set(&q->finalization, 0);
+ atomic_set(&q->block_count, 0);
+ atomic_set(&q->block_read, 0);
+ atomic_set(&q->block_write, 0);
+ atomic_set(&q->total_queued, 0);
+ atomic_set(&q->total_flushed, 0);
+ atomic_set(&q->total_locks, 0);
+
+ q->write_queue = 0;
+ q->read_queue = 0;
+ q->flush_queue = 0;
+
+ q->flags = ctx->flags;
+
+ drm_waitlist_create(&q->waitlist, dev->dma->buf_count);
+
+ return 0;
+}
+
+
+/* drm_alloc_queue:
+PRE: 1) dev->queuelist[0..dev->queue_count] is allocated and will not
+ disappear (so all deallocation must be done after IOCTLs are off)
+ 2) dev->queue_count < dev->queue_slots
+ 3) dev->queuelist[i].use_count == 0 and
+ dev->queuelist[i].finalization == 0 if i not in use
+POST: 1) dev->queuelist[i].use_count == 1
+ 2) dev->queue_count < dev->queue_slots */
+
+static int drm_alloc_queue(drm_device_t *dev)
+{
+ int i;
+ drm_queue_t *queue;
+ int oldslots;
+ int newslots;
+ /* Check for a free queue */
+ for (i = 0; i < dev->queue_count; i++) {
+ atomic_inc(&dev->queuelist[i]->use_count);
+ if (atomic_read(&dev->queuelist[i]->use_count) == 1
+ && !atomic_read(&dev->queuelist[i]->finalization)) {
+ DRM_DEBUG("%d (free)\n", i);
+ return i;
+ }
+ atomic_dec(&dev->queuelist[i]->use_count);
+ }
+ /* Allocate a new queue */
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+
+ queue = drm_alloc(sizeof(*queue), DRM_MEM_QUEUES);
+ memset(queue, 0, sizeof(*queue));
+ atomic_set(&queue->use_count, 1);
+
+ ++dev->queue_count;
+ if (dev->queue_count >= dev->queue_slots) {
+ oldslots = dev->queue_slots * sizeof(*dev->queuelist);
+ if (!dev->queue_slots) dev->queue_slots = 1;
+ dev->queue_slots *= 2;
+ newslots = dev->queue_slots * sizeof(*dev->queuelist);
+
+ dev->queuelist = drm_realloc(dev->queuelist,
+ oldslots,
+ newslots,
+ DRM_MEM_QUEUES);
+ if (!dev->queuelist) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ DRM_DEBUG("out of memory\n");
+ return -ENOMEM;
+ }
+ }
+ dev->queuelist[dev->queue_count-1] = queue;
+
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ DRM_DEBUG("%d (new)\n", dev->queue_count - 1);
+ return dev->queue_count - 1;
+}
+
+int drm_resctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t ctx;
+ int i;
+ int error;
+
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
+ res = *(drm_ctx_res_t *) data;
+ if (res.count >= DRM_RESERVED_CONTEXTS) {
+ memset(&ctx, 0, sizeof(ctx));
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ ctx.handle = i;
+ error = copyout(&i, &res.contexts[i],
+ sizeof(i));
+ if (error) return error;
+ }
+ }
+ res.count = DRM_RESERVED_CONTEXTS;
+ *(drm_ctx_res_t *) data = res;
+ return 0;
+}
+
+
+int drm_addctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ if ((ctx.handle = drm_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
+ /* Init kernel's context and get a new one. */
+ drm_init_queue(dev, dev->queuelist[ctx.handle], &ctx);
+ ctx.handle = drm_alloc_queue(dev);
+ }
+ drm_init_queue(dev, dev->queuelist[ctx.handle], &ctx);
+ DRM_DEBUG("%d\n", ctx.handle);
+ *(drm_ctx_t *) data = ctx;
+ return 0;
+}
+
+int drm_modctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+ drm_queue_t *q;
+
+ ctx = *(drm_ctx_t *) data;
+
+ DRM_DEBUG("%d\n", ctx.handle);
+
+ if (ctx.handle < 0 || ctx.handle >= dev->queue_count) return -EINVAL;
+ q = dev->queuelist[ctx.handle];
+
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->use_count) == 1) {
+ /* No longer in use */
+ atomic_dec(&q->use_count);
+ return -EINVAL;
+ }
+
+ if (DRM_BUFCOUNT(&q->waitlist)) {
+ atomic_dec(&q->use_count);
+ return -EBUSY;
+ }
+
+ q->flags = ctx.flags;
+
+ atomic_dec(&q->use_count);
+ return 0;
+}
+
+int drm_getctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+ drm_queue_t *q;
+
+ ctx = *(drm_ctx_t *) data;
+
+ DRM_DEBUG("%d\n", ctx.handle);
+
+ if (ctx.handle >= dev->queue_count) return -EINVAL;
+ q = dev->queuelist[ctx.handle];
+
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->use_count) == 1) {
+ /* No longer in use */
+ atomic_dec(&q->use_count);
+ return -EINVAL;
+ }
+
+ ctx.flags = q->flags;
+ atomic_dec(&q->use_count);
+
+ *(drm_ctx_t *) data = ctx;
+
+ return 0;
+}
+
+int drm_switchctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ return drm_context_switch(dev, dev->last_context, ctx.handle);
+}
+
+int drm_newctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ drm_context_switch_complete(dev, ctx.handle);
+
+ return 0;
+}
+
+int drm_rmctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+ drm_queue_t *q;
+ drm_buf_t *buf;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+
+ if (ctx.handle >= dev->queue_count) return -EINVAL;
+ q = dev->queuelist[ctx.handle];
+
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->use_count) == 1) {
+ /* No longer in use */
+ atomic_dec(&q->use_count);
+ return -EINVAL;
+ }
+
+ atomic_inc(&q->finalization); /* Mark queue in finalization state */
+ atomic_sub(2, &q->use_count); /* Mark queue as unused (pending
+ finalization) */
+
+ /* Wait while interrupt servicing is in progress */
+ while (test_and_set_bit(0, &dev->interrupt_flag)) {
+ int never;
+ int error = tsleep(&never, PZERO|PCATCH, "drmrc", 1);
+ if (error) {
+ clear_bit(0, &dev->interrupt_flag);
+ return error;
+ }
+ }
+ /* Remove queued buffers */
+ while ((buf = drm_waitlist_get(&q->waitlist))) {
+ drm_free_buffer(dev, buf);
+ }
+ clear_bit(0, &dev->interrupt_flag);
+
+ /* Wakeup blocked processes */
+ wakeup(&q->read_queue);
+ wakeup(&q->write_queue);
+ wakeup(&q->flush_queue);
+
+ /* Finalization over. Queue is made
+ available when both use_count and
+ finalization become 0, which won't
+ happen until all the waiting processes
+ stop waiting. */
+ atomic_dec(&q->finalization);
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ctxbitmap.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ctxbitmap.c
new file mode 100644
index 000000000..851b75827
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ctxbitmap.c
@@ -0,0 +1,85 @@
+/* ctxbitmap.c -- Context bitmap management
+ * Created: Thu Jan 6 03:56:42 2000 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Jeff Hartmann <jhartmann@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle)
+{
+ if (ctx_handle < 0) goto failed;
+
+ if (ctx_handle < DRM_MAX_CTXBITMAP) {
+ clear_bit(ctx_handle, dev->ctx_bitmap);
+ return;
+ }
+failed:
+ DRM_ERROR("Attempt to free invalid context handle: %d\n",
+ ctx_handle);
+ return;
+}
+
+int drm_ctxbitmap_next(drm_device_t *dev)
+{
+ int bit;
+
+ bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
+ if (bit < DRM_MAX_CTXBITMAP) {
+ set_bit(bit, dev->ctx_bitmap);
+ DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit);
+ return bit;
+ }
+ return -1;
+}
+
+int drm_ctxbitmap_init(drm_device_t *dev)
+{
+ int i;
+ int temp;
+
+ dev->ctx_bitmap = (u_int32_t *) drm_alloc(PAGE_SIZE,
+ DRM_MEM_CTXBITMAP);
+ if(dev->ctx_bitmap == NULL) {
+ return -ENOMEM;
+ }
+ memset((void *) dev->ctx_bitmap, 0, PAGE_SIZE);
+ for(i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ temp = drm_ctxbitmap_next(dev);
+ DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp);
+ }
+
+ return 0;
+}
+
+void drm_ctxbitmap_cleanup(drm_device_t *dev)
+{
+ drm_free((void *)dev->ctx_bitmap, PAGE_SIZE,
+ DRM_MEM_CTXBITMAP);
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/dma.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/dma.c
new file mode 100644
index 000000000..93b0d0c78
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/dma.c
@@ -0,0 +1,543 @@
+/* dma.c -- DMA IOCTL and function support -*- c -*-
+ * Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinuxa.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+void drm_dma_setup(drm_device_t *dev)
+{
+ int i;
+
+ dev->dma = drm_alloc(sizeof(*dev->dma), DRM_MEM_DRIVER);
+ memset(dev->dma, 0, sizeof(*dev->dma));
+ for (i = 0; i <= DRM_MAX_ORDER; i++)
+ memset(&dev->dma->bufs[i], 0, sizeof(dev->dma->bufs[0]));
+}
+
+void drm_dma_takedown(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i, j;
+
+ if (!dma) return;
+
+ /* Clear dma buffers */
+ for (i = 0; i <= DRM_MAX_ORDER; i++) {
+ if (dma->bufs[i].seg_count) {
+ DRM_DEBUG("order %d: buf_count = %d,"
+ " seg_count = %d\n",
+ i,
+ dma->bufs[i].buf_count,
+ dma->bufs[i].seg_count);
+ for (j = 0; j < dma->bufs[i].seg_count; j++) {
+ drm_free_pages(dma->bufs[i].seglist[j],
+ dma->bufs[i].page_order,
+ DRM_MEM_DMA);
+ }
+ drm_free(dma->bufs[i].seglist,
+ dma->bufs[i].seg_count
+ * sizeof(*dma->bufs[0].seglist),
+ DRM_MEM_SEGS);
+ }
+ if(dma->bufs[i].buf_count) {
+ for(j = 0; j < dma->bufs[i].buf_count; j++) {
+ if(dma->bufs[i].buflist[j].dev_private) {
+ drm_free(dma->bufs[i].buflist[j].dev_private,
+ dma->bufs[i].buflist[j].dev_priv_size,
+ DRM_MEM_BUFS);
+ }
+ }
+ drm_free(dma->bufs[i].buflist,
+ dma->bufs[i].buf_count *
+ sizeof(*dma->bufs[0].buflist),
+ DRM_MEM_BUFS);
+ drm_freelist_destroy(&dma->bufs[i].freelist);
+ }
+ }
+
+ if (dma->buflist) {
+ drm_free(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ }
+
+ if (dma->pagelist) {
+ drm_free(dma->pagelist,
+ dma->page_count * sizeof(*dma->pagelist),
+ DRM_MEM_PAGES);
+ }
+ drm_free(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
+ dev->dma = NULL;
+}
+
+#if DRM_DMA_HISTOGRAM
+/* This is slow, but is useful for debugging. */
+int drm_histogram_slot(struct timespec *ts)
+{
+ long count = ts->tv_sec * 1000 + ts->tv_nsec / 1000000;
+ int value = DRM_DMA_HISTOGRAM_INITIAL;
+ int slot;
+
+ for (slot = 0;
+ slot < DRM_DMA_HISTOGRAM_SLOTS;
+ ++slot, value = DRM_DMA_HISTOGRAM_NEXT(value)) {
+ if (count < value) return slot;
+ }
+ return DRM_DMA_HISTOGRAM_SLOTS - 1;
+}
+
+void drm_histogram_compute(drm_device_t *dev, drm_buf_t *buf)
+{
+ struct timespec queued_to_dispatched;
+ struct timespec dispatched_to_completed;
+ struct timespec completed_to_freed;
+ int q2d, d2c, c2f, q2c, q2f;
+
+ if (timespecisset(&buf->time_queued)) {
+ queued_to_dispatched = buf->time_dispatched;
+ timespecsub(&queued_to_dispatched, &buf->time_queued);
+ dispatched_to_completed = buf->time_completed;
+ timespecsub(&dispatched_to_completed, &buf->time_dispatched);
+ completed_to_freed = buf->time_freed;
+ timespecsub(&completed_to_freed, &buf->time_completed);
+
+ q2d = drm_histogram_slot(&queued_to_dispatched);
+ d2c = drm_histogram_slot(&dispatched_to_completed);
+ c2f = drm_histogram_slot(&completed_to_freed);
+
+ timespecadd(&queued_to_dispatched, &dispatched_to_completed);
+ q2c = drm_histogram_slot(&queued_to_dispatched);
+ timespecadd(&queued_to_dispatched, &completed_to_freed);
+ q2f = drm_histogram_slot(&queued_to_dispatched);
+
+ atomic_inc(&dev->histo.total);
+ atomic_inc(&dev->histo.queued_to_dispatched[q2d]);
+ atomic_inc(&dev->histo.dispatched_to_completed[d2c]);
+ atomic_inc(&dev->histo.completed_to_freed[c2f]);
+
+ atomic_inc(&dev->histo.queued_to_completed[q2c]);
+ atomic_inc(&dev->histo.queued_to_freed[q2f]);
+
+ }
+ timespecclear(&buf->time_queued);
+ timespecclear(&buf->time_dispatched);
+ timespecclear(&buf->time_completed);
+ timespecclear(&buf->time_freed);
+}
+#endif
+
+void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
+{
+ drm_device_dma_t *dma = dev->dma;
+
+ if (!buf) return;
+
+ buf->waiting = 0;
+ buf->pending = 0;
+ buf->pid = 0;
+ buf->used = 0;
+#if DRM_DMA_HISTOGRAMxx
+ buf->time_completed = get_cycles();
+#endif
+ if (buf->dma_wait) {
+ buf->dma_wait = 0;
+ wakeup(&buf->dma_wait);
+ } else {
+ /* If processes are waiting, the last one
+ to wake will put the buffer on the free
+ list. If no processes are waiting, we
+ put the buffer on the freelist here. */
+ drm_freelist_put(dev, &dma->bufs[buf->order].freelist, buf);
+ }
+}
+
+void drm_reclaim_buffers(drm_device_t *dev, pid_t pid)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ if (!dma) return;
+ for (i = 0; i < dma->buf_count; i++) {
+ if (dma->buflist[i]->pid == pid) {
+ switch (dma->buflist[i]->list) {
+ case DRM_LIST_NONE:
+ drm_free_buffer(dev, dma->buflist[i]);
+ break;
+ case DRM_LIST_WAIT:
+ dma->buflist[i]->list = DRM_LIST_RECLAIM;
+ break;
+ default:
+ /* Buffer already on hardware. */
+ break;
+ }
+ }
+ }
+}
+
+int drm_context_switch(drm_device_t *dev, int old, int new)
+{
+ char buf[64];
+ drm_queue_t *q;
+
+ atomic_inc(&dev->total_ctx);
+
+ if (test_and_set_bit(0, &dev->context_flag)) {
+ DRM_ERROR("Reentering -- FIXME\n");
+ return EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&dev->ctx_start);
+#endif
+
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
+
+ if (new >= dev->queue_count) {
+ clear_bit(0, &dev->context_flag);
+ return EINVAL;
+ }
+
+ if (new == dev->last_context) {
+ clear_bit(0, &dev->context_flag);
+ return 0;
+ }
+
+ q = dev->queuelist[new];
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->use_count) == 1) {
+ atomic_dec(&q->use_count);
+ clear_bit(0, &dev->context_flag);
+ return EINVAL;
+ }
+
+ if (drm_flags & DRM_FLAG_NOCTX) {
+ drm_context_switch_complete(dev, new);
+ } else {
+ sprintf(buf, "C %d %d\n", old, new);
+ drm_write_string(dev, buf);
+ }
+
+ atomic_dec(&q->use_count);
+
+ return 0;
+}
+
+int drm_context_switch_complete(drm_device_t *dev, int new)
+{
+ drm_device_dma_t *dma = dev->dma;
+
+ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
+ dev->last_switch = ticks;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Lock isn't held after context switch\n");
+ }
+
+ if (!dma || !(dma->next_buffer && dma->next_buffer->while_locked)) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("Cannot free lock\n");
+ }
+ }
+
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &dev->ctx_start);
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(&ts)]);
+ }
+#endif
+ clear_bit(0, &dev->context_flag);
+ wakeup(&dev->context_wait);
+
+ return 0;
+}
+
+void drm_clear_next_buffer(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+
+ dma->next_buffer = NULL;
+ if (dma->next_queue && !DRM_BUFCOUNT(&dma->next_queue->waitlist)) {
+ wakeup(&dma->next_queue->flush_queue);
+ }
+ dma->next_queue = NULL;
+}
+
+
+int drm_select_queue(drm_device_t *dev, void (*wrapper)(void *))
+{
+ int i;
+ int candidate = -1;
+ int j = ticks;
+
+ if (!dev) {
+ DRM_ERROR("No device\n");
+ return -1;
+ }
+ if (!dev->queuelist || !dev->queuelist[DRM_KERNEL_CONTEXT]) {
+ /* This only happens between the time the
+ interrupt is initialized and the time
+ the queues are initialized. */
+ return -1;
+ }
+
+ /* Doing "while locked" DMA? */
+ if (DRM_WAITCOUNT(dev, DRM_KERNEL_CONTEXT)) {
+ return DRM_KERNEL_CONTEXT;
+ }
+
+ /* If there are buffers on the last_context
+ queue, and we have not been executing
+ this context very long, continue to
+ execute this context. */
+ if (dev->last_switch <= j
+ && dev->last_switch + DRM_TIME_SLICE > j
+ && DRM_WAITCOUNT(dev, dev->last_context)) {
+ return dev->last_context;
+ }
+
+ /* Otherwise, find a candidate */
+ for (i = dev->last_checked + 1; i < dev->queue_count; i++) {
+ if (DRM_WAITCOUNT(dev, i)) {
+ candidate = dev->last_checked = i;
+ break;
+ }
+ }
+
+ if (candidate < 0) {
+ for (i = 0; i < dev->queue_count; i++) {
+ if (DRM_WAITCOUNT(dev, i)) {
+ candidate = dev->last_checked = i;
+ break;
+ }
+ }
+ }
+
+ if (wrapper
+ && candidate >= 0
+ && candidate != dev->last_context
+ && dev->last_switch <= j
+ && dev->last_switch + DRM_TIME_SLICE > j) {
+ int s = splclock();
+ if (dev->timer.c_time != dev->last_switch + DRM_TIME_SLICE) {
+ callout_reset(&dev->timer,
+ dev->last_switch + DRM_TIME_SLICE - j,
+ wrapper,
+ dev);
+ }
+ splx(s);
+ return -1;
+ }
+
+ return candidate;
+}
+
+
+int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *d)
+{
+ int i;
+ drm_queue_t *q;
+ drm_buf_t *buf;
+ int idx;
+ int while_locked = 0;
+ drm_device_dma_t *dma = dev->dma;
+ int error;
+
+ DRM_DEBUG("%d\n", d->send_count);
+
+ if (d->flags & _DRM_DMA_WHILE_LOCKED) {
+ int context = dev->lock.hw_lock->lock;
+
+ if (!_DRM_LOCK_IS_HELD(context)) {
+ DRM_ERROR("No lock held during \"while locked\""
+ " request\n");
+ return EINVAL;
+ }
+ if (d->context != _DRM_LOCKING_CONTEXT(context)
+ && _DRM_LOCKING_CONTEXT(context) != DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Lock held by %d while %d makes"
+ " \"while locked\" request\n",
+ _DRM_LOCKING_CONTEXT(context),
+ d->context);
+ return EINVAL;
+ }
+ q = dev->queuelist[DRM_KERNEL_CONTEXT];
+ while_locked = 1;
+ } else {
+ q = dev->queuelist[d->context];
+ }
+
+
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->block_write)) {
+ atomic_inc(&q->block_count);
+ for (;;) {
+ if (!atomic_read(&q->block_write)) break;
+ error = tsleep(&q->block_write, PZERO|PCATCH,
+ "dmawr", 0);
+ if (error) {
+ atomic_dec(&q->use_count);
+ return error;
+ }
+ }
+ atomic_dec(&q->block_count);
+ }
+
+ for (i = 0; i < d->send_count; i++) {
+ idx = d->send_indices[i];
+ if (idx < 0 || idx >= dma->buf_count) {
+ atomic_dec(&q->use_count);
+ DRM_ERROR("Index %d (of %d max)\n",
+ d->send_indices[i], dma->buf_count - 1);
+ return EINVAL;
+ }
+ buf = dma->buflist[ idx ];
+ if (buf->pid != curproc->p_pid) {
+ atomic_dec(&q->use_count);
+ DRM_ERROR("Process %d using buffer owned by %d\n",
+ curproc->p_pid, buf->pid);
+ return EINVAL;
+ }
+ if (buf->list != DRM_LIST_NONE) {
+ atomic_dec(&q->use_count);
+ DRM_ERROR("Process %d using buffer %d on list %d\n",
+ curproc->p_pid, buf->idx, buf->list);
+ }
+ buf->used = d->send_sizes[i];
+ buf->while_locked = while_locked;
+ buf->context = d->context;
+ if (!buf->used) {
+ DRM_ERROR("Queueing 0 length buffer\n");
+ }
+ if (buf->pending) {
+ atomic_dec(&q->use_count);
+ DRM_ERROR("Queueing pending buffer:"
+ " buffer %d, offset %d\n",
+ d->send_indices[i], i);
+ return EINVAL;
+ }
+ if (buf->waiting) {
+ atomic_dec(&q->use_count);
+ DRM_ERROR("Queueing waiting buffer:"
+ " buffer %d, offset %d\n",
+ d->send_indices[i], i);
+ return EINVAL;
+ }
+ buf->waiting = 1;
+ if (atomic_read(&q->use_count) == 1
+ || atomic_read(&q->finalization)) {
+ drm_free_buffer(dev, buf);
+ } else {
+ drm_waitlist_put(&q->waitlist, buf);
+ atomic_inc(&q->total_queued);
+ }
+ }
+ atomic_dec(&q->use_count);
+
+ return 0;
+}
+
+static int drm_dma_get_buffers_of_order(drm_device_t *dev, drm_dma_t *d,
+ int order)
+{
+ int i;
+ int error;
+ drm_buf_t *buf;
+ drm_device_dma_t *dma = dev->dma;
+
+ for (i = d->granted_count; i < d->request_count; i++) {
+ buf = drm_freelist_get(&dma->bufs[order].freelist,
+ d->flags & _DRM_DMA_WAIT);
+ if (!buf) break;
+ if (buf->pending || buf->waiting) {
+ DRM_ERROR("Free buffer %d in use by %d (w%d, p%d)\n",
+ buf->idx,
+ buf->pid,
+ buf->waiting,
+ buf->pending);
+ }
+ buf->pid = curproc->p_pid;
+ error = copyout(&buf->idx,
+ &d->request_indices[i],
+ sizeof(buf->idx));
+ if (error)
+ return error;
+ error = copyout(&buf->total,
+ &d->request_sizes[i],
+ sizeof(buf->total));
+ if (error)
+ return error;
+ ++d->granted_count;
+ }
+ return 0;
+}
+
+
+int drm_dma_get_buffers(drm_device_t *dev, drm_dma_t *dma)
+{
+ int order;
+ int retcode = 0;
+ int tmp_order;
+
+ order = drm_order(dma->request_size);
+
+ dma->granted_count = 0;
+ retcode = drm_dma_get_buffers_of_order(dev, dma, order);
+
+ if (dma->granted_count < dma->request_count
+ && (dma->flags & _DRM_DMA_SMALLER_OK)) {
+ for (tmp_order = order - 1;
+ !retcode
+ && dma->granted_count < dma->request_count
+ && tmp_order >= DRM_MIN_ORDER;
+ --tmp_order) {
+
+ retcode = drm_dma_get_buffers_of_order(dev, dma,
+ tmp_order);
+ }
+ }
+
+ if (dma->granted_count < dma->request_count
+ && (dma->flags & _DRM_DMA_LARGER_OK)) {
+ for (tmp_order = order + 1;
+ !retcode
+ && dma->granted_count < dma->request_count
+ && tmp_order <= DRM_MAX_ORDER;
+ ++tmp_order) {
+
+ retcode = drm_dma_get_buffers_of_order(dev, dma,
+ tmp_order);
+ }
+ }
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drawable.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drawable.c
new file mode 100644
index 000000000..d15ea617d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drawable.c
@@ -0,0 +1,50 @@
+/* drawable.c -- IOCTLs for drawables -*- c -*-
+ * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+int drm_adddraw(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_draw_t draw;
+
+ draw.handle = 0; /* NOOP */
+ DRM_DEBUG("%d\n", draw.handle);
+ *(drm_draw_t *) data = draw;
+ return 0;
+}
+
+int drm_rmdraw(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ return 0; /* NOOP */
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drmstat.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drmstat.c
new file mode 100644
index 000000000..48fb1b161
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drmstat.c
@@ -0,0 +1,418 @@
+/* drmstat.c -- DRM device status and testing program
+ * Created: Tue Jan 5 08:19:24 1999 by faith@precisioninsight.com
+ * Revised: Sun Aug 1 11:02:00 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c,v 1.28 1999/08/04 18:12:11 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/drmstat.c,v 1.1 2000/06/17 00:03:30 martin Exp $
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/mman.h>
+#include <strings.h>
+#include <errno.h>
+#include <signal.h>
+#include <fcntl.h>
+#include "xf86drm.h"
+
+int sigio_fd;
+
+static double usec(struct timeval *end, struct timeval *start)
+{
+ double e = end->tv_sec * 1000000 + end->tv_usec;
+ double s = start->tv_sec * 1000000 + start->tv_usec;
+
+ return e - s;
+}
+
+static void getversion(int fd)
+{
+ drmVersionPtr version;
+
+ version = drmGetVersion(fd);
+ if (version) {
+ printf( "Name: %s\n", version->name ? version->name : "?" );
+ printf( " Version: %d.%d.%d\n",
+ version->version_major,
+ version->version_minor,
+ version->version_patchlevel );
+ printf( " Date: %s\n", version->date ? version->date : "?" );
+ printf( " Desc: %s\n", version->desc ? version->desc : "?" );
+ drmFreeVersion(version);
+ } else {
+ printf( "No driver available\n" );
+ }
+}
+
+void handler(int fd, void *oldctx, void *newctx)
+{
+ printf("Got fd %d\n", fd);
+}
+
+void process_sigio(char *device)
+{
+ int fd;
+
+printf("%s\n", device);
+ if ((fd = open(device, 0)) < 0) {
+printf("%d\n", errno);
+ drmError(-errno, __FUNCTION__);
+ exit(1);
+ }
+
+ sigio_fd = fd;
+ drmInstallSIGIOHandler(fd, handler);
+ for (;;) sleep(60);
+}
+
+int main(int argc, char **argv)
+{
+ int c;
+ int r = 0;
+ int fd = -1;
+ drmHandle handle;
+ void *address;
+ char *pt;
+ unsigned long count;
+ unsigned long offset;
+ unsigned long size;
+ drmContext context;
+ int loops;
+ char buf[1024];
+ int i;
+ drmBufInfoPtr info;
+ drmBufMapPtr bufs;
+ drmLockPtr lock;
+ int secs;
+
+ while ((c = getopt(argc, argv,
+ "lc:vo:O:f:s:w:W:b:r:R:P:L:C:XS:B:F:")) != EOF)
+ switch (c) {
+ case 'F':
+ count = strtoul(optarg, NULL, 0);
+ if (!fork()) {
+ dup(fd);
+ sleep(count);
+ }
+ close(fd);
+ break;
+ case 'v': getversion(fd); break;
+ case 'X':
+ if ((r = drmCreateContext(fd, &context))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ printf( "Got %d\n", context);
+ break;
+ case 'S':
+ process_sigio(optarg);
+ break;
+ case 'C':
+ if ((r = drmSwitchToContext(fd, strtoul(optarg, NULL, 0)))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ break;
+ case 'c':
+ if ((r = drmSetBusid(fd,optarg))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ break;
+ case 'o':
+ if ((fd = drmOpen(optarg, NULL)) < 0) {
+ drmError(fd, argv[0]);
+ return 1;
+ }
+ break;
+ case 'O':
+ if ((fd = drmOpen(NULL, optarg)) < 0) {
+ drmError(fd, argv[0]);
+ return 1;
+ }
+ break;
+ case 'B': /* Test buffer allocation */
+ count = strtoul(optarg, &pt, 0);
+ size = strtoul(pt+1, &pt, 0);
+ secs = strtoul(pt+1, NULL, 0);
+ {
+ drmDMAReq dma;
+ int *indices, *sizes;
+
+ indices = alloca(sizeof(*indices) * count);
+ sizes = alloca(sizeof(*sizes) * count);
+ dma.context = context;
+ dma.send_count = 0;
+ dma.request_count = count;
+ dma.request_size = size;
+ dma.request_list = indices;
+ dma.request_sizes = sizes;
+ dma.flags = DRM_DMA_WAIT;
+ if ((r = drmDMA(fd, &dma))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ for (i = 0; i < dma.granted_count; i++) {
+ printf("%5d: index = %d, size = %d\n",
+ i, dma.request_list[i], dma.request_sizes[i]);
+ }
+ sleep(secs);
+ drmFreeBufs(fd, dma.granted_count, indices);
+ }
+ break;
+ case 'b':
+ count = strtoul(optarg, &pt, 0);
+ size = strtoul(pt+1, NULL, 0);
+ if ((r = drmAddBufs(fd, count, size, 0, 0)) < 0) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ if (!(info = drmGetBufInfo(fd))) {
+ drmError(0, argv[0]);
+ return 1;
+ }
+ for (i = 0; i < info->count; i++) {
+ printf("%5d buffers of size %6d (low = %d, high = %d)\n",
+ info->list[i].count,
+ info->list[i].size,
+ info->list[i].low_mark,
+ info->list[i].high_mark);
+ }
+ if ((r = drmMarkBufs(fd, 0.50, 0.80))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ if (!(info = drmGetBufInfo(fd))) {
+ drmError(0, argv[0]);
+ return 1;
+ }
+ for (i = 0; i < info->count; i++) {
+ printf("%5d buffers of size %6d (low = %d, high = %d)\n",
+ info->list[i].count,
+ info->list[i].size,
+ info->list[i].low_mark,
+ info->list[i].high_mark);
+ }
+ printf("===== /proc/drm/1/meminfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/meminfo");
+ system(buf);
+#if 1
+ if (!(bufs = drmMapBufs(fd))) {
+ drmError(0, argv[0]);
+ return 1;
+ }
+ printf("===============================\n");
+ printf( "%d bufs\n", bufs->count);
+ for (i = 0; i < bufs->count; i++) {
+ printf( " %4d: %8d bytes at %p\n",
+ i,
+ bufs->list[i].total,
+ bufs->list[i].address);
+ }
+ printf("===== /proc/drm/1/vmainfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/vmainfo");
+ system(buf);
+#endif
+ break;
+ case 'f':
+ offset = strtoul(optarg, &pt, 0);
+ size = strtoul(pt+1, NULL, 0);
+ handle = 0;
+ if ((r = drmAddMap(fd, offset, size,
+ DRM_FRAME_BUFFER, 0, &handle))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ printf("0x%08lx:0x%04lx added\n", offset, size);
+ printf("===== /proc/drm/1/meminfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/meminfo");
+ system(buf);
+ break;
+ case 'r':
+ case 'R':
+ offset = strtoul(optarg, &pt, 0);
+ size = strtoul(pt+1, NULL, 0);
+ handle = 0;
+ if ((r = drmAddMap(fd, offset, size,
+ DRM_REGISTERS,
+ c == 'R' ? DRM_READ_ONLY : 0,
+ &handle))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ printf("0x%08lx:0x%04lx added\n", offset, size);
+ printf("===== /proc/drm/1/meminfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/meminfo");
+ system(buf);
+ break;
+ case 's':
+ size = strtoul(optarg, &pt, 0);
+ handle = 0;
+ if ((r = drmAddMap(fd, 0, size,
+ DRM_SHM, DRM_CONTAINS_LOCK,
+ &handle))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ printf("0x%04lx byte shm added at 0x%08lx\n", size, handle);
+ sprintf(buf, "sysctl hw.graphics.0.vm");
+ system(buf);
+ break;
+ case 'P':
+ offset = strtoul(optarg, &pt, 0);
+ size = strtoul(pt+1, NULL, 0);
+ address = NULL;
+ if ((r = drmMap(fd, offset, size, &address))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ printf("0x%08lx:0x%04lx mapped at %p for pid %d\n",
+ offset, size, address, getpid());
+ printf("===== hw.graphics.0.vma =====\n");
+ sprintf(buf, "sysctl hw.graphics.0.vma");
+ system(buf);
+ mprotect((void *)offset, size, PROT_READ);
+ printf("===== hw.graphics.0.vma =====\n");
+ sprintf(buf, "sysctl hw.graphics.0.vma");
+ system(buf);
+ break;
+ case 'w':
+ case 'W':
+ offset = strtoul(optarg, &pt, 0);
+ size = strtoul(pt+1, NULL, 0);
+ address = NULL;
+ if ((r = drmMap(fd, offset, size, &address))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ printf("0x%08lx:0x%04lx mapped at %p for pid %d\n",
+ offset, size, address, getpid());
+ printf("===== /proc/%d/maps =====\n", getpid());
+ sprintf(buf, "cat /proc/%d/maps", getpid());
+ system(buf);
+ printf("===== /proc/drm/1/meminfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/meminfo");
+ system(buf);
+ printf("===== /proc/drm/1/vmainfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/vmainfo");
+ system(buf);
+ printf("===== READING =====\n");
+ for (i = 0; i < 0x10; i++)
+ printf("%02x ", (unsigned int)((unsigned char *)address)[i]);
+ printf("\n");
+ if (c == 'w') {
+ printf("===== WRITING =====\n");
+ for (i = 0; i < size; i+=2) {
+ ((char *)address)[i] = i & 0xff;
+ ((char *)address)[i+1] = i & 0xff;
+ }
+ }
+ printf("===== READING =====\n");
+ for (i = 0; i < 0x10; i++)
+ printf("%02x ", (unsigned int)((unsigned char *)address)[i]);
+ printf("\n");
+ printf("===== /proc/drm/1/vmainfo =====\n");
+ sprintf(buf, "cat /proc/drm/1/vmainfo");
+ system(buf);
+ break;
+ case 'L':
+ context = strtoul(optarg, &pt, 0);
+ offset = strtoul(pt+1, &pt, 0);
+ size = strtoul(pt+1, &pt, 0);
+ loops = strtoul(pt+1, NULL, 0);
+ address = NULL;
+ if ((r = drmMap(fd, offset, size, &address))) {
+ drmError(r, argv[0]);
+ return 1;
+ }
+ lock = address;
+#if 1
+ {
+ int counter = 0;
+ struct timeval loop_start, loop_end;
+ struct timeval lock_start, lock_end;
+ double wt;
+#define HISTOSIZE 9
+ int histo[HISTOSIZE];
+ int output = 0;
+ int fast = 0;
+
+ if (loops < 0) {
+ loops = -loops;
+ ++output;
+ }
+
+ for (i = 0; i < HISTOSIZE; i++) histo[i] = 0;
+
+ gettimeofday(&loop_start, NULL);
+ for (i = 0; i < loops; i++) {
+ gettimeofday(&lock_start, NULL);
+ DRM_LIGHT_LOCK_COUNT(fd,lock,context,fast);
+ gettimeofday(&lock_end, NULL);
+ DRM_UNLOCK(fd,lock,context);
+ ++counter;
+ wt = usec(&lock_end, &lock_start);
+ if (wt <= 2.5) ++histo[8];
+ if (wt < 5.0) ++histo[0];
+ else if (wt < 50.0) ++histo[1];
+ else if (wt < 500.0) ++histo[2];
+ else if (wt < 5000.0) ++histo[3];
+ else if (wt < 50000.0) ++histo[4];
+ else if (wt < 500000.0) ++histo[5];
+ else if (wt < 5000000.0) ++histo[6];
+ else ++histo[7];
+ if (output) printf( "%.2f uSec, %d fast\n", wt, fast);
+ }
+ gettimeofday(&loop_end, NULL);
+ printf( "Average wait time = %.2f usec, %d fast\n",
+ usec(&loop_end, &loop_start) / counter, fast);
+ printf( "%9d <= 2.5 uS\n", histo[8]);
+ printf( "%9d < 5 uS\n", histo[0]);
+ printf( "%9d < 50 uS\n", histo[1]);
+ printf( "%9d < 500 uS\n", histo[2]);
+ printf( "%9d < 5000 uS\n", histo[3]);
+ printf( "%9d < 50000 uS\n", histo[4]);
+ printf( "%9d < 500000 uS\n", histo[5]);
+ printf( "%9d < 5000000 uS\n", histo[6]);
+ printf( "%9d >= 5000000 uS\n", histo[7]);
+ }
+#else
+ printf( "before lock: 0x%08x\n", lock->lock);
+ printf( "lock: 0x%08x\n", lock->lock);
+ sleep(5);
+ printf( "unlock: 0x%08x\n", lock->lock);
+#endif
+ break;
+ default:
+ fprintf( stderr, "Usage: drmstat [options]\n" );
+ return 1;
+ }
+
+ return r;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/fops.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/fops.c
new file mode 100644
index 000000000..ad8c86a68
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/fops.c
@@ -0,0 +1,261 @@
+/* fops.c -- File operations for DRM -*- c -*-
+ * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include <sys/signalvar.h>
+#include <sys/poll.h>
+
+drm_file_t *drm_find_file_by_proc(drm_device_t *dev, struct proc *p)
+{
+ uid_t uid = p->p_cred->p_svuid;
+ pid_t pid = p->p_pid;
+ drm_file_t *priv;
+
+ TAILQ_FOREACH(priv, &dev->files, link)
+ if (priv->pid == pid && priv->uid == uid)
+ return priv;
+ return NULL;
+}
+
+
+/* drm_open is called whenever a process opens /dev/drm. */
+
+int drm_open_helper(dev_t kdev, int flags, int fmt, struct proc *p,
+ drm_device_t *dev)
+{
+ int m = minor(kdev);
+ drm_file_t *priv;
+
+ if (flags & O_EXCL)
+ return EBUSY; /* No exclusive opens */
+
+ dev->flags = flags;
+
+ DRM_DEBUG("pid = %d, device = %p, minor = %d\n",
+ p->p_pid, dev->device, m);
+
+ priv = drm_find_file_by_proc(dev, p);
+ if (priv) {
+ priv->refs++;
+ } else {
+ priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
+ memset(priv, 0, sizeof(*priv));
+ priv->uid = p->p_cred->p_svuid;
+ priv->pid = p->p_pid;
+ priv->refs = 1;
+ priv->minor = m;
+ priv->devXX = dev;
+ priv->ioctl_count = 0;
+ priv->authenticated = !suser(p);
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, p);
+ TAILQ_INSERT_TAIL(&dev->files, priv, link);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, p);
+ }
+
+ kdev->si_drv1 = dev;
+
+ return 0;
+}
+
+int drm_write(dev_t kdev, struct uio *uio, int ioflag)
+{
+ struct proc *p = curproc;
+ drm_device_t *dev = kdev->si_drv1;
+
+ DRM_DEBUG("pid = %d, device = %p, open_count = %d\n",
+ p->p_pid, dev->device, dev->open_count);
+ return 0;
+}
+
+/* drm_release is called whenever a process closes /dev/drm*. */
+
+int drm_close(dev_t kdev, int fflag, int devtype, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_file_t *priv;
+
+ DRM_DEBUG("pid = %d, device = %p, open_count = %d\n",
+ p->p_pid, dev->device, dev->open_count);
+
+ priv = drm_find_file_by_proc(dev, p);
+ if (!priv) {
+ DRM_DEBUG("can't find authenticator\n");
+ return EINVAL;
+ }
+
+ if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
+ && dev->lock.pid == p->p_pid) {
+ DRM_ERROR("Process %d dead, freeing lock for context %d\n",
+ p->p_pid,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ drm_lock_free(dev,
+ &dev->lock.hw_lock->lock,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+
+ /* FIXME: may require heavy-handed reset of
+ hardware at this point, possibly
+ processed via a callback to the X
+ server. */
+ }
+ drm_reclaim_buffers(dev, priv->pid);
+
+ funsetown(dev->buf_sigio);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, p);
+ priv = drm_find_file_by_proc(dev, p);
+ if (priv) {
+ priv->refs--;
+ if (!priv->refs) {
+ TAILQ_REMOVE(&dev->files, priv, link);
+ drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
+ }
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, p);
+
+ return 0;
+}
+
+/* The drm_read and drm_write_string code (especially that which manages
+ the circular buffer), is based on Alessandro Rubini's LINUX DEVICE
+ DRIVERS (Cambridge: O'Reilly, 1998), pages 111-113. */
+
+ssize_t drm_read(dev_t kdev, struct uio *uio, int ioflag)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int left;
+ int avail;
+ int send;
+ int cur;
+ int error = 0;
+
+ DRM_DEBUG("%p, %p\n", dev->buf_rp, dev->buf_wp);
+
+ while (dev->buf_rp == dev->buf_wp) {
+ DRM_DEBUG(" sleeping\n");
+ if (dev->flags & FASYNC) {
+ return EWOULDBLOCK;
+ }
+ error = tsleep(&dev->buf_rp, PZERO|PCATCH, "drmrd", 0);
+ if (error) {
+ DRM_DEBUG(" interrupted\n");
+ return error;
+ }
+ DRM_DEBUG(" awake\n");
+ }
+
+ left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
+ avail = DRM_BSZ - left;
+ send = DRM_MIN(avail, uio->uio_resid);
+
+ while (send) {
+ if (dev->buf_wp > dev->buf_rp) {
+ cur = DRM_MIN(send, dev->buf_wp - dev->buf_rp);
+ } else {
+ cur = DRM_MIN(send, dev->buf_end - dev->buf_rp);
+ }
+ error = uiomove(dev->buf_rp, cur, uio);
+ if (error)
+ break;
+ dev->buf_rp += cur;
+ if (dev->buf_rp == dev->buf_end) dev->buf_rp = dev->buf;
+ send -= cur;
+ }
+
+ wakeup(&dev->buf_wp);
+
+ return error;
+}
+
+int drm_write_string(drm_device_t *dev, const char *s)
+{
+ int left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
+ int send = strlen(s);
+ int count;
+
+ DRM_DEBUG("%d left, %d to send (%p, %p)\n",
+ left, send, dev->buf_rp, dev->buf_wp);
+
+ if (left == 1 || dev->buf_wp != dev->buf_rp) {
+ DRM_ERROR("Buffer not empty (%d left, wp = %p, rp = %p)\n",
+ left,
+ dev->buf_wp,
+ dev->buf_rp);
+ }
+
+ while (send) {
+ if (dev->buf_wp >= dev->buf_rp) {
+ count = DRM_MIN(send, dev->buf_end - dev->buf_wp);
+ if (count == left) --count; /* Leave a hole */
+ } else {
+ count = DRM_MIN(send, dev->buf_rp - dev->buf_wp - 1);
+ }
+ strncpy(dev->buf_wp, s, count);
+ dev->buf_wp += count;
+ if (dev->buf_wp == dev->buf_end) dev->buf_wp = dev->buf;
+ send -= count;
+ }
+
+ if (dev->buf_selecting) {
+ dev->buf_selecting = 0;
+ selwakeup(&dev->buf_sel);
+ }
+
+ DRM_DEBUG("dev->buf_sigio=%p\n", dev->buf_sigio);
+ if (dev->buf_sigio) {
+ DRM_DEBUG("dev->buf_sigio->sio_pgid=%d\n", dev->buf_sigio->sio_pgid);
+ pgsigio(dev->buf_sigio, SIGIO, 0);
+ }
+
+ DRM_DEBUG("waking\n");
+ wakeup(&dev->buf_rp);
+ return 0;
+}
+
+int drm_poll(dev_t kdev, int events, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int s;
+ int revents = 0;
+
+ s = spldrm();
+ if (events & (POLLIN | POLLRDNORM)) {
+ int left = (dev->buf_rp + DRM_BSZ - dev->buf_wp) % DRM_BSZ;
+ if (left > 0)
+ revents |= events & (POLLIN | POLLRDNORM);
+ else
+ selrecord(p, &dev->buf_sel);
+ }
+ splx(s);
+
+ return revents;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/init.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/init.c
new file mode 100644
index 000000000..99ff70c01
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/init.c
@@ -0,0 +1,100 @@
+/* init.c -- Setup/Cleanup for DRM -*- c -*-
+ * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+MODULE_VERSION(drm, 1);
+
+int drm_flags = 0;
+
+/* drm_parse_option parses a single option. See description for
+ drm_parse_drm for details. */
+
+static void drm_parse_option(char *s)
+{
+ char *c, *r;
+
+ DRM_DEBUG("\"%s\"\n", s);
+ if (!s || !*s) return;
+ for (c = s; *c && *c != ':'; c++); /* find : or \0 */
+ if (*c) r = c + 1; else r = NULL; /* remember remainder */
+ *c = '\0'; /* terminate */
+ if (!strcmp(s, "noctx")) {
+ drm_flags |= DRM_FLAG_NOCTX;
+ DRM_INFO("Server-mediated context switching OFF\n");
+ return;
+ }
+ if (!strcmp(s, "debug")) {
+ drm_flags |= DRM_FLAG_DEBUG;
+ DRM_INFO("Debug messages ON\n");
+ return;
+ }
+ DRM_ERROR("\"%s\" is not a valid option\n", s);
+ return;
+}
+
+/* drm_parse_options parse the insmod "drm=" options, or the command-line
+ * options passed to the kernel via LILO. The grammar of the format is as
+ * follows:
+ *
+ * drm ::= 'drm=' option_list
+ * option_list ::= option [ ';' option_list ]
+ * option ::= 'device:' major
+ * | 'debug'
+ * | 'noctx'
+ * major ::= INTEGER
+ *
+ * Note that 's' contains option_list without the 'drm=' part.
+ *
+ * device=major,minor specifies the device number used for /dev/drm
+ * if major == 0 then the misc device is used
+ * if major == 0 and minor == 0 then dynamic misc allocation is used
+ * debug=on specifies that debugging messages will be printk'd
+ * debug=trace specifies that each function call will be logged via printk
+ * debug=off turns off all debugging options
+ *
+ */
+
+void drm_parse_options(char *s)
+{
+ char *h, *t, *n;
+
+ DRM_DEBUG("\"%s\"\n", s ?: "");
+ if (!s || !*s) return;
+
+ for (h = t = n = s; h && *h; h = n) {
+ for (; *t && *t != ';'; t++); /* find ; or \0 */
+ if (*t) n = t + 1; else n = NULL; /* remember next */
+ *t = '\0'; /* terminate */
+ drm_parse_option(h); /* parse */
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ioctl.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ioctl.c
new file mode 100644
index 000000000..656baffd8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/ioctl.c
@@ -0,0 +1,120 @@
+/* ioctl.c -- IOCTL processing for DRM -*- c -*-
+ * Created: Fri Jan 8 09:01:26 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include <sys/bus.h>
+#include <pci/pcivar.h>
+
+int
+drm_irq_busid(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_irq_busid_t id;
+ devclass_t pci;
+ device_t bus, dev;
+ device_t *kids;
+ int error, i, num_kids;
+
+ id = *(drm_irq_busid_t *) data;
+ pci = devclass_find("pci");
+ if (!pci)
+ return ENOENT;
+ bus = devclass_get_device(pci, id.busnum);
+ if (!bus)
+ return ENOENT;
+ error = device_get_children(bus, &kids, &num_kids);
+ if (error)
+ return error;
+
+ dev = 0;
+ for (i = 0; i < num_kids; i++) {
+ dev = kids[i];
+ if (pci_get_slot(dev) == id.devnum
+ && pci_get_function(dev) == id.funcnum)
+ break;
+ }
+
+ free(kids, M_TEMP);
+
+ if (i != num_kids)
+ id.irq = pci_get_irq(dev);
+ else
+ id.irq = 0;
+
+ DRM_DEBUG("%d:%d:%d => IRQ %d\n",
+ id.busnum, id.devnum, id.funcnum, id.irq);
+ *(drm_irq_busid_t *) data = id;
+
+ return 0;
+}
+
+int
+drm_getunique(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_unique_t u;
+ int error;
+
+ u = *(drm_unique_t *) data;
+ if (u.unique_len >= dev->unique_len) {
+ error = copyout(dev->unique, u.unique, dev->unique_len);
+ if (error)
+ return error;
+ }
+ u.unique_len = dev->unique_len;
+ *(drm_unique_t *) data = u;
+ return 0;
+}
+
+int
+drm_setunique(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_unique_t u;
+ int error;
+
+ if (dev->unique_len || dev->unique) return EBUSY;
+
+ u = *(drm_unique_t *) data;
+
+ dev->unique_len = u.unique_len;
+ dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER);
+ error = copyin(u.unique, dev->unique, dev->unique_len);
+ if (error)
+ return error;
+ dev->unique[dev->unique_len] = '\0';
+
+ dev->devname = drm_alloc(strlen(dev->name) + strlen(dev->unique) + 2,
+ DRM_MEM_DRIVER);
+ sprintf(dev->devname, "%s@%s", dev->name, dev->unique);
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lists.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lists.c
new file mode 100644
index 000000000..61becaa12
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lists.c
@@ -0,0 +1,258 @@
+/* lists.c -- Buffer list handling routines -*- c -*-
+ * Created: Mon Apr 19 20:54:22 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+int drm_waitlist_create(drm_waitlist_t *bl, int count)
+{
+ DRM_DEBUG("%d\n", count);
+ if (bl->count) return EINVAL;
+
+ bl->count = count;
+ bl->bufs = drm_alloc((bl->count + 2) * sizeof(*bl->bufs),
+ DRM_MEM_BUFLISTS);
+ bl->rp = bl->bufs;
+ bl->wp = bl->bufs;
+ bl->end = &bl->bufs[bl->count+1];
+ simple_lock_init(&bl->write_lock);
+ simple_lock_init(&bl->read_lock);
+ return 0;
+}
+
+int drm_waitlist_destroy(drm_waitlist_t *bl)
+{
+ DRM_DEBUG("\n");
+ if (bl->rp != bl->wp) return EINVAL;
+ if (bl->bufs) drm_free(bl->bufs,
+ (bl->count + 2) * sizeof(*bl->bufs),
+ DRM_MEM_BUFLISTS);
+ bl->count = 0;
+ bl->bufs = NULL;
+ bl->rp = NULL;
+ bl->wp = NULL;
+ bl->end = NULL;
+ return 0;
+}
+
+int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf)
+{
+ int left;
+ int s;
+
+ left = DRM_LEFTCOUNT(bl);
+ DRM_DEBUG("put %d (%d left, rp = %p, wp = %p)\n",
+ buf->idx, left, bl->rp, bl->wp);
+ if (!left) {
+ DRM_ERROR("Overflow while adding buffer %d from pid %d\n",
+ buf->idx, buf->pid);
+ return EINVAL;
+ }
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&buf->time_queued);
+#endif
+ buf->list = DRM_LIST_WAIT;
+
+ simple_lock(&bl->write_lock);
+ s = spldrm();
+ *bl->wp = buf;
+ if (++bl->wp >= bl->end) bl->wp = bl->bufs;
+ splx(s);
+ simple_unlock(&bl->write_lock);
+
+ return 0;
+}
+
+drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl)
+{
+ drm_buf_t *buf;
+ int s;
+
+ simple_lock(&bl->read_lock);
+ s = spldrm();
+ buf = *bl->rp;
+ if (bl->rp == bl->wp) {
+ splx(s);
+ simple_unlock(&bl->read_lock);
+ return NULL;
+ }
+ if (++bl->rp >= bl->end) bl->rp = bl->bufs;
+ splx(s);
+ simple_unlock(&bl->read_lock);
+
+ DRM_DEBUG("get %d\n", buf->idx);
+ return buf;
+}
+
+int drm_freelist_create(drm_freelist_t *bl, int count)
+{
+ DRM_DEBUG("\n");
+ atomic_set(&bl->count, 0);
+ bl->next = NULL;
+ bl->waiting = 0;
+ bl->low_mark = 0;
+ bl->high_mark = 0;
+ atomic_set(&bl->wfh, 0);
+ ++bl->initialized;
+ return 0;
+}
+
+int drm_freelist_destroy(drm_freelist_t *bl)
+{
+ DRM_DEBUG("\n");
+ atomic_set(&bl->count, 0);
+ bl->next = NULL;
+ return 0;
+}
+
+int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf)
+{
+ unsigned int old;
+ unsigned int new;
+ char failed;
+ int count = 0;
+ drm_device_dma_t *dma = dev->dma;
+
+ if (!dma) {
+ DRM_ERROR("No DMA support\n");
+ return 1;
+ }
+
+ if (buf->waiting || buf->pending || buf->list == DRM_LIST_FREE) {
+ DRM_ERROR("Freed buffer %d: w%d, p%d, l%d\n",
+ buf->idx, buf->waiting, buf->pending, buf->list);
+ }
+ DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n",
+ buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh),
+ buf->waiting, buf->pending);
+ if (!bl) return 1;
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&buf->time_freed);
+ drm_histogram_compute(dev, buf);
+#endif
+ buf->list = DRM_LIST_FREE;
+ do {
+ old = (unsigned long)bl->next;
+ buf->next = (void *)old;
+ new = (unsigned long)buf;
+ _DRM_CAS(&bl->next, old, new, failed);
+ if (++count > DRM_LOOPING_LIMIT) {
+ DRM_ERROR("Looping\n");
+ return 1;
+ }
+ } while (failed);
+ atomic_inc(&bl->count);
+ if (atomic_read(&bl->count) > dma->buf_count) {
+ DRM_ERROR("%d of %d buffers free after addition of %d\n",
+ atomic_read(&bl->count), dma->buf_count, buf->idx);
+ return 1;
+ }
+ /* Check for high water mark */
+ if (atomic_read(&bl->wfh) && atomic_read(&bl->count)>=bl->high_mark) {
+ atomic_set(&bl->wfh, 0);
+ if (bl->waiting)
+ wakeup(&bl->waiting);
+ }
+ return 0;
+}
+
+static drm_buf_t *drm_freelist_try(drm_freelist_t *bl)
+{
+ unsigned int old;
+ unsigned int new;
+ char failed;
+ drm_buf_t *buf;
+ int count = 0;
+
+ if (!bl) return NULL;
+
+ /* Get buffer */
+ do {
+ old = (unsigned int)bl->next;
+ if (!old) {
+ return NULL;
+ }
+ new = (unsigned long)bl->next->next;
+ _DRM_CAS(&bl->next, old, new, failed);
+ if (++count > DRM_LOOPING_LIMIT) {
+ DRM_ERROR("Looping\n");
+ return NULL;
+ }
+ } while (failed);
+ atomic_dec(&bl->count);
+
+ buf = (drm_buf_t *)old;
+ buf->next = NULL;
+ buf->list = DRM_LIST_NONE;
+ DRM_DEBUG("%d, count = %d, wfh = %d, w%d, p%d\n",
+ buf->idx, atomic_read(&bl->count), atomic_read(&bl->wfh),
+ buf->waiting, buf->pending);
+ if (buf->waiting || buf->pending) {
+ DRM_ERROR("Free buffer %d: w%d, p%d, l%d\n",
+ buf->idx, buf->waiting, buf->pending, buf->list);
+ }
+
+ return buf;
+}
+
+drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block)
+{
+ drm_buf_t *buf = NULL;
+ int error;
+
+ if (!bl || !bl->initialized) return NULL;
+
+ /* Check for low water mark */
+ if (atomic_read(&bl->count) <= bl->low_mark) /* Became low */
+ atomic_set(&bl->wfh, 1);
+ if (atomic_read(&bl->wfh)) {
+ DRM_DEBUG("Block = %d, count = %d, wfh = %d\n",
+ block, atomic_read(&bl->count),
+ atomic_read(&bl->wfh));
+ if (block) {
+ atomic_inc(&bl->waiting);
+ for (;;) {
+ if (!atomic_read(&bl->wfh)
+ && (buf = drm_freelist_try(bl))) break;
+ error = tsleep(&bl->waiting, PZERO|PCATCH,
+ "drmfg", 0);
+ if (error)
+ break;
+ }
+ atomic_dec(&bl->waiting);
+ }
+ return buf;
+ }
+
+ DRM_DEBUG("Count = %d, wfh = %d\n",
+ atomic_read(&bl->count), atomic_read(&bl->wfh));
+ return drm_freelist_try(bl);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lock.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lock.c
new file mode 100644
index 000000000..1affcd1d0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/lock.c
@@ -0,0 +1,220 @@
+/* lock.c -- IOCTLs for locking -*- c -*-
+ * Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+int
+drm_block(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ DRM_DEBUG("\n");
+ return 0;
+}
+
+int
+drm_unblock(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ DRM_DEBUG("\n");
+ return 0;
+}
+
+int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
+{
+ unsigned int old;
+ unsigned int new;
+ char failed;
+
+ DRM_DEBUG("%d attempts\n", context);
+ do {
+ old = *lock;
+ if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT;
+ else new = context | _DRM_LOCK_HELD;
+ _DRM_CAS(lock, old, new, failed);
+ } while (failed);
+ if (_DRM_LOCKING_CONTEXT(old) == context) {
+ if (old & _DRM_LOCK_HELD) {
+ if (context != DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("%d holds heavyweight lock\n",
+ context);
+ }
+ return 0;
+ }
+ }
+ if (new == (context | _DRM_LOCK_HELD)) {
+ /* Have lock */
+ DRM_DEBUG("%d\n", context);
+ return 1;
+ }
+ DRM_DEBUG("%d unable to get lock held by %d\n",
+ context, _DRM_LOCKING_CONTEXT(old));
+ return 0;
+}
+
+/* This takes a lock forcibly and hands it to context. Should ONLY be used
+ inside *_unlock to give lock to kernel before calling *_dma_schedule. */
+int drm_lock_transfer(drm_device_t *dev,
+ __volatile__ unsigned int *lock, unsigned int context)
+{
+ unsigned int old;
+ unsigned int new;
+ char failed;
+
+ dev->lock.pid = 0;
+ do {
+ old = *lock;
+ new = context | _DRM_LOCK_HELD;
+ _DRM_CAS(lock, old, new, failed);
+ } while (failed);
+ DRM_DEBUG("%d => %d\n", _DRM_LOCKING_CONTEXT(old), context);
+ return 1;
+}
+
+int drm_lock_free(drm_device_t *dev,
+ __volatile__ unsigned int *lock, unsigned int context)
+{
+ unsigned int old;
+ unsigned int new;
+ char failed;
+ pid_t pid = dev->lock.pid;
+
+ DRM_DEBUG("%d\n", context);
+ dev->lock.pid = 0;
+ do {
+ old = *lock;
+ new = 0;
+ _DRM_CAS(lock, old, new, failed);
+ } while (failed);
+ if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) {
+ DRM_ERROR("%d freed heavyweight lock held by %d (pid %d)\n",
+ context,
+ _DRM_LOCKING_CONTEXT(old),
+ pid);
+ return 1;
+ }
+ wakeup(&dev->lock.lock_queue);
+ return 0;
+}
+
+static int drm_flush_queue(drm_device_t *dev, int context)
+{
+ int ret = 0;
+ int error;
+ drm_queue_t *q = dev->queuelist[context];
+
+ DRM_DEBUG("\n");
+
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->use_count) > 1) {
+ atomic_inc(&q->block_write);
+ atomic_inc(&q->block_count);
+ error = tsleep(&q->flush_queue, PCATCH|PZERO, "drmfq", 0);
+ if (error)
+ return error;
+ atomic_dec(&q->block_count);
+ }
+ atomic_dec(&q->use_count);
+ atomic_inc(&q->total_flushed);
+
+ /* NOTE: block_write is still incremented!
+ Use drm_flush_unlock_queue to decrement. */
+ return ret;
+}
+
+static int drm_flush_unblock_queue(drm_device_t *dev, int context)
+{
+ drm_queue_t *q = dev->queuelist[context];
+
+ DRM_DEBUG("\n");
+
+ atomic_inc(&q->use_count);
+ if (atomic_read(&q->use_count) > 1) {
+ if (atomic_read(&q->block_write)) {
+ atomic_dec(&q->block_write);
+ wakeup(&q->write_queue);
+ }
+ }
+ atomic_dec(&q->use_count);
+ return 0;
+}
+
+int drm_flush_block_and_flush(drm_device_t *dev, int context,
+ drm_lock_flags_t flags)
+{
+ int ret = 0;
+ int i;
+
+ DRM_DEBUG("\n");
+
+ if (flags & _DRM_LOCK_FLUSH) {
+ ret = drm_flush_queue(dev, DRM_KERNEL_CONTEXT);
+ if (!ret) ret = drm_flush_queue(dev, context);
+ }
+ if (flags & _DRM_LOCK_FLUSH_ALL) {
+ for (i = 0; !ret && i < dev->queue_count; i++) {
+ ret = drm_flush_queue(dev, i);
+ }
+ }
+ return ret;
+}
+
+int drm_flush_unblock(drm_device_t *dev, int context, drm_lock_flags_t flags)
+{
+ int ret = 0;
+ int i;
+
+ DRM_DEBUG("\n");
+
+ if (flags & _DRM_LOCK_FLUSH) {
+ ret = drm_flush_unblock_queue(dev, DRM_KERNEL_CONTEXT);
+ if (!ret) ret = drm_flush_unblock_queue(dev, context);
+ }
+ if (flags & _DRM_LOCK_FLUSH_ALL) {
+ for (i = 0; !ret && i < dev->queue_count; i++) {
+ ret = drm_flush_unblock_queue(dev, i);
+ }
+ }
+
+ return ret;
+}
+
+int drm_finish(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int ret = 0;
+ drm_lock_t lock;
+
+ DRM_DEBUG("\n");
+
+ lock = *(drm_lock_t *) data;
+ ret = drm_flush_block_and_flush(dev, lock.context, lock.flags);
+ drm_flush_unblock(dev, lock.context, lock.flags);
+ return ret;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/memory.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/memory.c
new file mode 100644
index 000000000..81c1b1a04
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/memory.c
@@ -0,0 +1,458 @@
+/* memory.c -- Memory management wrappers for DRM -*- c -*-
+ * Created: Thu Feb 4 14:00:34 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#ifdef DRM_AGP
+#include <sys/agpio.h>
+#endif
+
+MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures");
+
+typedef struct drm_mem_stats {
+ const char *name;
+ int succeed_count;
+ int free_count;
+ int fail_count;
+ unsigned long bytes_allocated;
+ unsigned long bytes_freed;
+} drm_mem_stats_t;
+
+#ifdef SMP
+static struct simplelock drm_mem_lock;
+#endif
+static unsigned long drm_ram_available = 0;
+static unsigned long drm_ram_used = 0;
+static drm_mem_stats_t drm_mem_stats[] = {
+ [DRM_MEM_DMA] = { "dmabufs" },
+ [DRM_MEM_SAREA] = { "sareas" },
+ [DRM_MEM_DRIVER] = { "driver" },
+ [DRM_MEM_MAGIC] = { "magic" },
+ [DRM_MEM_IOCTLS] = { "ioctltab" },
+ [DRM_MEM_MAPS] = { "maplist" },
+ [DRM_MEM_VMAS] = { "vmalist" },
+ [DRM_MEM_BUFS] = { "buflist" },
+ [DRM_MEM_SEGS] = { "seglist" },
+ [DRM_MEM_PAGES] = { "pagelist" },
+ [DRM_MEM_FILES] = { "files" },
+ [DRM_MEM_QUEUES] = { "queues" },
+ [DRM_MEM_CMDS] = { "commands" },
+ [DRM_MEM_MAPPINGS] = { "mappings" },
+ [DRM_MEM_BUFLISTS] = { "buflists" },
+ [DRM_MEM_AGPLISTS] = { "agplist" },
+ [DRM_MEM_TOTALAGP] = { "totalagp" },
+ [DRM_MEM_BOUNDAGP] = { "boundagp" },
+ [DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
+ { NULL, 0, } /* Last entry must be null */
+};
+
+void drm_mem_init(void)
+{
+ drm_mem_stats_t *mem;
+
+ for (mem = drm_mem_stats; mem->name; ++mem) {
+ mem->succeed_count = 0;
+ mem->free_count = 0;
+ mem->fail_count = 0;
+ mem->bytes_allocated = 0;
+ mem->bytes_freed = 0;
+ }
+
+ drm_ram_available = 0; /* si.totalram; */
+ drm_ram_used = 0;
+}
+
+/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
+
+static int _drm_mem_info SYSCTL_HANDLER_ARGS
+{
+ drm_mem_stats_t *pt;
+ char buf[128];
+ int error;
+
+ DRM_SYSCTL_PRINT(" total counts "
+ " | outstanding \n");
+ DRM_SYSCTL_PRINT("type alloc freed fail bytes freed"
+ " | allocs bytes\n\n");
+ DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu |\n",
+ "system", 0, 0, 0, drm_ram_available);
+ DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu |\n",
+ "locked", 0, 0, 0, drm_ram_used);
+ DRM_SYSCTL_PRINT("\n");
+ for (pt = drm_mem_stats; pt->name; pt++) {
+ DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
+ pt->name,
+ pt->succeed_count,
+ pt->free_count,
+ pt->fail_count,
+ pt->bytes_allocated,
+ pt->bytes_freed,
+ pt->succeed_count - pt->free_count,
+ (long)pt->bytes_allocated
+ - (long)pt->bytes_freed);
+ }
+ SYSCTL_OUT(req, "", 1);
+
+ return 0;
+}
+
+int drm_mem_info SYSCTL_HANDLER_ARGS
+{
+ int ret;
+
+ simple_lock(&drm_mem_lock);
+ ret = _drm_mem_info(oidp, arg1, arg2, req);
+ simple_unlock(&drm_mem_lock);
+ return ret;
+}
+
+void *drm_alloc(size_t size, int area)
+{
+ void *pt;
+
+ if (!size) {
+ DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
+ return NULL;
+ }
+
+ if (!(pt = malloc(size, M_DRM, M_NOWAIT))) {
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[area].fail_count;
+ simple_unlock(&drm_mem_lock);
+ return NULL;
+ }
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[area].succeed_count;
+ drm_mem_stats[area].bytes_allocated += size;
+ simple_unlock(&drm_mem_lock);
+ return pt;
+}
+
+void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
+{
+ void *pt;
+
+ if (!(pt = drm_alloc(size, area))) return NULL;
+ if (oldpt && oldsize) {
+ memcpy(pt, oldpt, oldsize);
+ drm_free(oldpt, oldsize, area);
+ }
+ return pt;
+}
+
+char *drm_strdup(const char *s, int area)
+{
+ char *pt;
+ int length = s ? strlen(s) : 0;
+
+ if (!(pt = drm_alloc(length+1, area))) return NULL;
+ strcpy(pt, s);
+ return pt;
+}
+
+void drm_strfree(char *s, int area)
+{
+ unsigned int size;
+
+ if (!s) return;
+
+ size = 1 + (s ? strlen(s) : 0);
+ drm_free((void *)s, size, area);
+}
+
+void drm_free(void *pt, size_t size, int area)
+{
+ int alloc_count;
+ int free_count;
+
+ if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
+ else free(pt, M_DRM);
+ simple_lock(&drm_mem_lock);
+ drm_mem_stats[area].bytes_freed += size;
+ free_count = ++drm_mem_stats[area].free_count;
+ alloc_count = drm_mem_stats[area].succeed_count;
+ simple_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+}
+
+unsigned long drm_alloc_pages(int order, int area)
+{
+ vm_offset_t address;
+ unsigned long bytes = PAGE_SIZE << order;
+ unsigned long addr;
+ unsigned int sz;
+
+ simple_lock(&drm_mem_lock);
+ if (drm_ram_used > +(DRM_RAM_PERCENT * drm_ram_available) / 100) {
+ simple_unlock(&drm_mem_lock);
+ return 0;
+ }
+ simple_unlock(&drm_mem_lock);
+
+ address = (vm_offset_t) contigmalloc(1<<order, M_DRM, M_WAITOK, 0, ~0, 1, 0);
+ if (!address) {
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[area].fail_count;
+ simple_unlock(&drm_mem_lock);
+ return 0;
+ }
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[area].succeed_count;
+ drm_mem_stats[area].bytes_allocated += bytes;
+ drm_ram_used += bytes;
+ simple_unlock(&drm_mem_lock);
+
+
+ /* Zero outside the lock */
+ memset((void *)address, 0, bytes);
+
+ /* Reserve */
+ for (addr = address, sz = bytes;
+ sz > 0;
+ addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+ /* mem_map_reserve(MAP_NR(addr));*/
+ }
+
+ return address;
+}
+
+void drm_free_pages(unsigned long address, int order, int area)
+{
+ unsigned long bytes = PAGE_SIZE << order;
+ int alloc_count;
+ int free_count;
+ unsigned long addr;
+ unsigned int sz;
+
+ if (!address) {
+ DRM_MEM_ERROR(area, "Attempt to free address 0\n");
+ } else {
+ /* Unreserve */
+ for (addr = address, sz = bytes;
+ sz > 0;
+ addr += PAGE_SIZE, sz -= PAGE_SIZE) {
+ /* mem_map_unreserve(MAP_NR(addr));*/
+ }
+ contigfree((void *) address, bytes, M_DRM);
+ }
+
+ simple_lock(&drm_mem_lock);
+ free_count = ++drm_mem_stats[area].free_count;
+ alloc_count = drm_mem_stats[area].succeed_count;
+ drm_mem_stats[area].bytes_freed += bytes;
+ drm_ram_used -= bytes;
+ simple_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(area,
+ "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+}
+
+void *drm_ioremap(unsigned long offset, unsigned long size)
+{
+ void *pt;
+
+ if (!size) {
+ DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+ "Mapping 0 bytes at 0x%08lx\n", offset);
+ return NULL;
+ }
+
+ if (!(pt = pmap_mapdev(offset, size))) {
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_MAPPINGS].fail_count;
+ simple_unlock(&drm_mem_lock);
+ return NULL;
+ }
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
+ drm_mem_stats[DRM_MEM_MAPPINGS].bytes_allocated += size;
+ simple_unlock(&drm_mem_lock);
+ return pt;
+}
+
+void drm_ioremapfree(void *pt, unsigned long size)
+{
+ int alloc_count;
+ int free_count;
+
+ if (!pt)
+ DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+ "Attempt to free NULL pointer\n");
+ else
+ pmap_unmapdev((vm_offset_t) pt, size);
+
+ simple_lock(&drm_mem_lock);
+ drm_mem_stats[DRM_MEM_MAPPINGS].bytes_freed += size;
+ free_count = ++drm_mem_stats[DRM_MEM_MAPPINGS].free_count;
+ alloc_count = drm_mem_stats[DRM_MEM_MAPPINGS].succeed_count;
+ simple_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
+ "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+}
+
+#ifdef DRM_AGP
+void *drm_alloc_agp(int pages, u_int32_t type)
+{
+ device_t dev = agp_find_device();
+ void *handle;
+
+ if (!dev)
+ return NULL;
+
+ if (!pages) {
+ DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
+ return NULL;
+ }
+
+ if ((handle = agp_alloc_memory(dev, type, pages << AGP_PAGE_SHIFT))) {
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated
+ += pages << PAGE_SHIFT;
+ simple_unlock(&drm_mem_lock);
+ return handle;
+ }
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count;
+ simple_unlock(&drm_mem_lock);
+ return NULL;
+}
+
+int drm_free_agp(void *handle, int pages)
+{
+ device_t dev = agp_find_device();
+ int alloc_count;
+ int free_count;
+ int retval = EINVAL;
+
+ if (!dev)
+ return EINVAL;
+
+ if (!handle) {
+ DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+ "Attempt to free NULL AGP handle\n");
+ return retval;
+ }
+
+ agp_free_memory(dev, handle);
+ simple_lock(&drm_mem_lock);
+ free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count;
+ alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_TOTALAGP].bytes_freed
+ += pages << PAGE_SHIFT;
+ simple_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+ "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+ return 0;
+}
+
+int drm_bind_agp(void *handle, unsigned int start)
+{
+ device_t dev = agp_find_device();
+ int retcode = EINVAL;
+ struct agp_memory_info info;
+
+ DRM_DEBUG("drm_bind_agp called\n");
+
+ if (!dev)
+ return EINVAL;
+
+ if (!handle) {
+ DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+ "Attempt to bind NULL AGP handle\n");
+ return retcode;
+ }
+
+ if (!(retcode = agp_bind_memory(dev, handle,
+ start << AGP_PAGE_SHIFT))) {
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
+ agp_memory_info(dev, handle, &info);
+ drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated
+ += info.ami_size;
+ simple_unlock(&drm_mem_lock);
+ DRM_DEBUG("drm_agp.bind_memory: retcode %d\n", retcode);
+ return retcode;
+ }
+ simple_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count;
+ simple_unlock(&drm_mem_lock);
+ return retcode;
+}
+
+int drm_unbind_agp(void *handle)
+{
+ device_t dev = agp_find_device();
+ int alloc_count;
+ int free_count;
+ int retcode = EINVAL;
+ struct agp_memory_info info;
+
+ if (!dev)
+ return EINVAL;
+
+ if (!handle) {
+ DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+ "Attempt to unbind NULL AGP handle\n");
+ return retcode;
+ }
+
+
+ agp_memory_info(dev, handle, &info);
+ if ((retcode = agp_unbind_memory(dev, handle)))
+ return retcode;
+ simple_lock(&drm_mem_lock);
+ free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count;
+ alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed += info.ami_size;
+ simple_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+ "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+ return retcode;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/proc.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/proc.c
new file mode 100644
index 000000000..3f6616ef7
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/proc.c
@@ -0,0 +1,568 @@
+/* proc.c -- /proc support for DRM -*- c -*-
+ * Created: Mon Jan 11 09:48:47 1999 by faith@precisioninsight.com
+ * Revised: Fri Aug 20 11:31:48 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c,v 1.4 1999/08/20 15:36:46 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/proc.c,v 1.1 2000/06/17 00:03:30 martin Exp $
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+static struct proc_dir_entry *drm_root = NULL;
+static struct proc_dir_entry *drm_dev_root = NULL;
+static char drm_slot_name[64];
+
+static int drm_name_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+static int drm_vm_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+static int drm_clients_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+static int drm_queues_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+static int drm_bufs_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+#if DRM_DEBUG_CODE
+static int drm_vma_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+#endif
+#if DRM_DMA_HISTOGRAM
+static int drm_histo_info(char *buf, char **start, off_t offset,
+ int len, int *eof, void *data);
+#endif
+
+struct drm_proc_list {
+ const char *name;
+ int (*f)(char *, char **, off_t, int, int *, void *);
+} drm_proc_list[] = {
+ { "name", drm_name_info },
+ { "mem", drm_mem_info },
+ { "vm", drm_vm_info },
+ { "clients", drm_clients_info },
+ { "queues", drm_queues_info },
+ { "bufs", drm_bufs_info },
+#if DRM_DEBUG_CODE
+ { "vma", drm_vma_info },
+#endif
+#if DRM_DMA_HISTOGRAM
+ { "histo", drm_histo_info },
+#endif
+};
+#define DRM_PROC_ENTRIES (sizeof(drm_proc_list)/sizeof(drm_proc_list[0]))
+
+int drm_proc_init(drm_device_t *dev)
+{
+ struct proc_dir_entry *ent;
+ int i, j;
+
+ drm_root = create_proc_entry("graphics", S_IFDIR, NULL);
+ if (!drm_root) {
+ DRM_ERROR("Cannot create /proc/graphics\n");
+ return -1;
+ }
+
+ /* Instead of doing this search, we should
+ add some global support for /proc/graphics. */
+ for (i = 0; i < 8; i++) {
+ sprintf(drm_slot_name, "graphics/%d", i);
+ drm_dev_root = create_proc_entry(drm_slot_name, S_IFDIR, NULL);
+ if (!drm_dev_root) {
+ DRM_ERROR("Cannot create /proc/%s\n", drm_slot_name);
+ remove_proc_entry("graphics", NULL);
+ }
+ if (drm_dev_root->nlink == 2) break;
+ drm_dev_root = NULL;
+ }
+ if (!drm_dev_root) {
+ DRM_ERROR("Cannot find slot in /proc/graphics\n");
+ return -1;
+ }
+
+ for (i = 0; i < DRM_PROC_ENTRIES; i++) {
+ ent = create_proc_entry(drm_proc_list[i].name,
+ S_IFREG|S_IRUGO, drm_dev_root);
+ if (!ent) {
+ DRM_ERROR("Cannot create /proc/%s/%s\n",
+ drm_slot_name, drm_proc_list[i].name);
+ for (j = 0; j < i; j++)
+ remove_proc_entry(drm_proc_list[i].name,
+ drm_dev_root);
+ remove_proc_entry(drm_slot_name, NULL);
+ remove_proc_entry("graphics", NULL);
+ return -1;
+ }
+ ent->read_proc = drm_proc_list[i].f;
+ ent->data = dev;
+ }
+
+ return 0;
+}
+
+
+int drm_proc_cleanup(void)
+{
+ int i;
+
+ if (drm_root) {
+ if (drm_dev_root) {
+ for (i = 0; i < DRM_PROC_ENTRIES; i++) {
+ remove_proc_entry(drm_proc_list[i].name,
+ drm_dev_root);
+ }
+ remove_proc_entry(drm_slot_name, NULL);
+ }
+ remove_proc_entry("graphics", NULL);
+ remove_proc_entry(DRM_NAME, NULL);
+ }
+ drm_root = drm_dev_root = NULL;
+ return 0;
+}
+
+static int drm_name_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+
+ if (dev->unique) {
+ DRM_PROC_PRINT("%s 0x%x %s\n",
+ dev->name, dev->device, dev->unique);
+ } else {
+ DRM_PROC_PRINT("%s 0x%x\n", dev->name, dev->device);
+ }
+ return len;
+}
+
+static int _drm_vm_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ drm_map_t *map;
+ const char *types[] = { "FB", "REG", "SHM" };
+ const char *type;
+ int i;
+
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+ DRM_PROC_PRINT("slot offset size type flags "
+ "address mtrr\n\n");
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ if (map->type < 0 || map->type > 2) type = "??";
+ else type = types[map->type];
+ DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ",
+ i,
+ map->offset,
+ map->size,
+ type,
+ map->flags,
+ (unsigned long)map->handle);
+ if (map->mtrr < 0) {
+ DRM_PROC_PRINT("none\n");
+ } else {
+ DRM_PROC_PRINT("%4d\n", map->mtrr);
+ }
+ }
+
+ return len;
+}
+
+static int drm_vm_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int ret;
+
+ down(&dev->struct_sem);
+ ret = _drm_vm_info(buf, start, offset, len, eof, data);
+ up(&dev->struct_sem);
+ return ret;
+}
+
+
+static int _drm_queues_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int i;
+ drm_queue_t *q;
+
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+ DRM_PROC_PRINT(" ctx/flags use fin"
+ " blk/rw/rwf wait flushed queued"
+ " locks\n\n");
+ for (i = 0; i < dev->queue_count; i++) {
+ q = dev->queuelist[i];
+ atomic_inc(&q->use_count);
+ DRM_PROC_PRINT_RET(atomic_dec(&q->use_count),
+ "%5d/0x%03x %5d %5d"
+ " %5d/%c%c/%c%c%c %5d %10d %10d %10d\n",
+ i,
+ q->flags,
+ atomic_read(&q->use_count),
+ atomic_read(&q->finalization),
+ atomic_read(&q->block_count),
+ atomic_read(&q->block_read) ? 'r' : '-',
+ atomic_read(&q->block_write) ? 'w' : '-',
+ waitqueue_active(&q->read_queue) ? 'r':'-',
+ waitqueue_active(&q->write_queue) ? 'w':'-',
+ waitqueue_active(&q->flush_queue) ? 'f':'-',
+ DRM_BUFCOUNT(&q->waitlist),
+ atomic_read(&q->total_flushed),
+ atomic_read(&q->total_queued),
+ atomic_read(&q->total_locks));
+ atomic_dec(&q->use_count);
+ }
+
+ return len;
+}
+
+static int drm_queues_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int ret;
+
+ down(&dev->struct_sem);
+ ret = _drm_queues_info(buf, start, offset, len, eof, data);
+ up(&dev->struct_sem);
+ return ret;
+}
+
+/* drm_bufs_info is called whenever a process reads
+ /dev/drm/<dev>/bufs. */
+
+static int _drm_bufs_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ if (!dma) return 0;
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+ DRM_PROC_PRINT(" o size count free segs pages kB\n\n");
+ for (i = 0; i <= DRM_MAX_ORDER; i++) {
+ if (dma->bufs[i].buf_count)
+ DRM_PROC_PRINT("%2d %8d %5d %5d %5d %5d %5ld\n",
+ i,
+ dma->bufs[i].buf_size,
+ dma->bufs[i].buf_count,
+ atomic_read(&dma->bufs[i]
+ .freelist.count),
+ dma->bufs[i].seg_count,
+ dma->bufs[i].seg_count
+ *(1 << dma->bufs[i].page_order),
+ (dma->bufs[i].seg_count
+ * (1 << dma->bufs[i].page_order))
+ * PAGE_SIZE / 1024);
+ }
+ DRM_PROC_PRINT("\n");
+ for (i = 0; i < dma->buf_count; i++) {
+ if (i && !(i%32)) DRM_PROC_PRINT("\n");
+ DRM_PROC_PRINT(" %d", dma->buflist[i]->list);
+ }
+ DRM_PROC_PRINT("\n");
+
+ return len;
+}
+
+static int drm_bufs_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int ret;
+
+ down(&dev->struct_sem);
+ ret = _drm_bufs_info(buf, start, offset, len, eof, data);
+ up(&dev->struct_sem);
+ return ret;
+}
+
+
+static int _drm_clients_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ drm_file_t *priv;
+
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+ DRM_PROC_PRINT("a dev pid uid magic ioctls\n\n");
+ for (priv = dev->file_first; priv; priv = priv->next) {
+ DRM_PROC_PRINT("%c %3d %5d %5d %10u %10lu\n",
+ priv->authenticated ? 'y' : 'n',
+ priv->minor,
+ priv->pid,
+ priv->uid,
+ priv->magic,
+ priv->ioctl_count);
+ }
+
+ return len;
+}
+
+static int drm_clients_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int ret;
+
+ down(&dev->struct_sem);
+ ret = _drm_clients_info(buf, start, offset, len, eof, data);
+ up(&dev->struct_sem);
+ return ret;
+}
+
+#if DRM_DEBUG_CODE
+
+static int _drm_vma_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ drm_vma_entry_t *pt;
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *pte;
+ unsigned long i;
+ struct vm_area_struct *vma;
+ unsigned long address;
+#if defined(__i386__)
+ unsigned int pgprot;
+#endif
+
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+ DRM_PROC_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n",
+ atomic_read(&dev->vma_count),
+ high_memory, virt_to_phys(high_memory));
+ for (pt = dev->vmalist; pt; pt = pt->next) {
+ if (!(vma = pt->vma)) continue;
+ DRM_PROC_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx",
+ pt->pid,
+ vma->vm_start,
+ vma->vm_end,
+ vma->vm_flags & VM_READ ? 'r' : '-',
+ vma->vm_flags & VM_WRITE ? 'w' : '-',
+ vma->vm_flags & VM_EXEC ? 'x' : '-',
+ vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
+ vma->vm_flags & VM_LOCKED ? 'l' : '-',
+ vma->vm_flags & VM_IO ? 'i' : '-',
+ vma->vm_offset );
+#if defined(__i386__)
+ pgprot = pgprot_val(vma->vm_page_prot);
+ DRM_PROC_PRINT(" %c%c%c%c%c%c%c%c%c",
+ pgprot & _PAGE_PRESENT ? 'p' : '-',
+ pgprot & _PAGE_RW ? 'w' : 'r',
+ pgprot & _PAGE_USER ? 'u' : 's',
+ pgprot & _PAGE_PWT ? 't' : 'b',
+ pgprot & _PAGE_PCD ? 'u' : 'c',
+ pgprot & _PAGE_ACCESSED ? 'a' : '-',
+ pgprot & _PAGE_DIRTY ? 'd' : '-',
+ pgprot & _PAGE_4M ? 'm' : 'k',
+ pgprot & _PAGE_GLOBAL ? 'g' : 'l' );
+#endif
+ DRM_PROC_PRINT("\n");
+ for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) {
+ pgd = pgd_offset(vma->vm_mm, i);
+ pmd = pmd_offset(pgd, i);
+ pte = pte_offset(pmd, i);
+ if (pte_present(*pte)) {
+ address = __pa(pte_page(*pte))
+ + (i & (PAGE_SIZE-1));
+ DRM_PROC_PRINT(" 0x%08lx -> 0x%08lx"
+ " %c%c%c%c%c\n",
+ i,
+ address,
+ pte_read(*pte) ? 'r' : '-',
+ pte_write(*pte) ? 'w' : '-',
+ pte_exec(*pte) ? 'x' : '-',
+ pte_dirty(*pte) ? 'd' : '-',
+ pte_young(*pte) ? 'a' : '-' );
+ } else {
+ DRM_PROC_PRINT(" 0x%08lx\n", i);
+ }
+ }
+ }
+
+ return len;
+}
+
+static int drm_vma_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int ret;
+
+ down(&dev->struct_sem);
+ ret = _drm_vma_info(buf, start, offset, len, eof, data);
+ up(&dev->struct_sem);
+ return ret;
+}
+#endif
+
+
+#if DRM_DMA_HISTOGRAM
+static int _drm_histo_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+ unsigned long slot_value = DRM_DMA_HISTOGRAM_INITIAL;
+ unsigned long prev_value = 0;
+ drm_buf_t *buffer;
+
+ if (offset > 0) return 0; /* no partial requests */
+ len = 0;
+ *eof = 1;
+
+ DRM_PROC_PRINT("general statistics:\n");
+ DRM_PROC_PRINT("total %10u\n", atomic_read(&dev->histo.total));
+ DRM_PROC_PRINT("open %10u\n", atomic_read(&dev->total_open));
+ DRM_PROC_PRINT("close %10u\n", atomic_read(&dev->total_close));
+ DRM_PROC_PRINT("ioctl %10u\n", atomic_read(&dev->total_ioctl));
+ DRM_PROC_PRINT("irq %10u\n", atomic_read(&dev->total_irq));
+ DRM_PROC_PRINT("ctx %10u\n", atomic_read(&dev->total_ctx));
+
+ DRM_PROC_PRINT("\nlock statistics:\n");
+ DRM_PROC_PRINT("locks %10u\n", atomic_read(&dev->total_locks));
+ DRM_PROC_PRINT("unlocks %10u\n", atomic_read(&dev->total_unlocks));
+ DRM_PROC_PRINT("contends %10u\n", atomic_read(&dev->total_contends));
+ DRM_PROC_PRINT("sleeps %10u\n", atomic_read(&dev->total_sleeps));
+
+
+ if (dma) {
+ DRM_PROC_PRINT("\ndma statistics:\n");
+ DRM_PROC_PRINT("prio %10u\n",
+ atomic_read(&dma->total_prio));
+ DRM_PROC_PRINT("bytes %10u\n",
+ atomic_read(&dma->total_bytes));
+ DRM_PROC_PRINT("dmas %10u\n",
+ atomic_read(&dma->total_dmas));
+ DRM_PROC_PRINT("missed:\n");
+ DRM_PROC_PRINT(" dma %10u\n",
+ atomic_read(&dma->total_missed_dma));
+ DRM_PROC_PRINT(" lock %10u\n",
+ atomic_read(&dma->total_missed_lock));
+ DRM_PROC_PRINT(" free %10u\n",
+ atomic_read(&dma->total_missed_free));
+ DRM_PROC_PRINT(" sched %10u\n",
+ atomic_read(&dma->total_missed_sched));
+ DRM_PROC_PRINT("tried %10u\n",
+ atomic_read(&dma->total_tried));
+ DRM_PROC_PRINT("hit %10u\n",
+ atomic_read(&dma->total_hit));
+ DRM_PROC_PRINT("lost %10u\n",
+ atomic_read(&dma->total_lost));
+
+ buffer = dma->next_buffer;
+ if (buffer) {
+ DRM_PROC_PRINT("next_buffer %7d\n", buffer->idx);
+ } else {
+ DRM_PROC_PRINT("next_buffer none\n");
+ }
+ buffer = dma->this_buffer;
+ if (buffer) {
+ DRM_PROC_PRINT("this_buffer %7d\n", buffer->idx);
+ } else {
+ DRM_PROC_PRINT("this_buffer none\n");
+ }
+ }
+
+
+ DRM_PROC_PRINT("\nvalues:\n");
+ if (dev->lock.hw_lock) {
+ DRM_PROC_PRINT("lock 0x%08x\n",
+ dev->lock.hw_lock->lock);
+ } else {
+ DRM_PROC_PRINT("lock none\n");
+ }
+ DRM_PROC_PRINT("context_flag 0x%08x\n", dev->context_flag);
+ DRM_PROC_PRINT("interrupt_flag 0x%08x\n", dev->interrupt_flag);
+ DRM_PROC_PRINT("dma_flag 0x%08x\n", dev->dma_flag);
+
+ DRM_PROC_PRINT("queue_count %10d\n", dev->queue_count);
+ DRM_PROC_PRINT("last_context %10d\n", dev->last_context);
+ DRM_PROC_PRINT("last_switch %10lu\n", dev->last_switch);
+ DRM_PROC_PRINT("last_checked %10d\n", dev->last_checked);
+
+
+ DRM_PROC_PRINT("\n q2d d2c c2f"
+ " q2c q2f dma sch"
+ " ctx lacq lhld\n\n");
+ for (i = 0; i < DRM_DMA_HISTOGRAM_SLOTS; i++) {
+ DRM_PROC_PRINT("%s %10lu %10u %10u %10u %10u %10u"
+ " %10u %10u %10u %10u %10u\n",
+ i == DRM_DMA_HISTOGRAM_SLOTS - 1 ? ">=" : "< ",
+ i == DRM_DMA_HISTOGRAM_SLOTS - 1
+ ? prev_value : slot_value ,
+
+ atomic_read(&dev->histo
+ .queued_to_dispatched[i]),
+ atomic_read(&dev->histo
+ .dispatched_to_completed[i]),
+ atomic_read(&dev->histo
+ .completed_to_freed[i]),
+
+ atomic_read(&dev->histo
+ .queued_to_completed[i]),
+ atomic_read(&dev->histo
+ .queued_to_freed[i]),
+ atomic_read(&dev->histo.dma[i]),
+ atomic_read(&dev->histo.schedule[i]),
+ atomic_read(&dev->histo.ctx[i]),
+ atomic_read(&dev->histo.lacq[i]),
+ atomic_read(&dev->histo.lhld[i]));
+ prev_value = slot_value;
+ slot_value = DRM_DMA_HISTOGRAM_NEXT(slot_value);
+ }
+ return len;
+}
+
+static int drm_histo_info(char *buf, char **start, off_t offset, int len,
+ int *eof, void *data)
+{
+ drm_device_t *dev = (drm_device_t *)data;
+ int ret;
+
+ down(&dev->struct_sem);
+ ret = _drm_histo_info(buf, start, offset, len, eof, data);
+ up(&dev->struct_sem);
+ return ret;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/sysctl.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/sysctl.c
new file mode 100644
index 000000000..a890abac4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/sysctl.c
@@ -0,0 +1,554 @@
+/* proc.c -- /proc support for DRM -*- c -*-
+ * Created: Mon Jan 11 09:48:47 1999 by faith@precisioninsight.com
+ * Revised: Fri Aug 20 11:31:48 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.
+ *
+ * $PI$
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/sysctl.c,v 1.1 2000/06/17 00:03:31 martin Exp $
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include <sys/sysctl.h>
+
+SYSCTL_NODE(_hw, OID_AUTO, dri, CTLFLAG_RW, 0, "DRI Graphics");
+
+static int drm_name_info SYSCTL_HANDLER_ARGS;
+static int drm_vm_info SYSCTL_HANDLER_ARGS;
+static int drm_clients_info SYSCTL_HANDLER_ARGS;
+static int drm_queues_info SYSCTL_HANDLER_ARGS;
+static int drm_bufs_info SYSCTL_HANDLER_ARGS;
+#if DRM_DEBUG_CODExx
+static int drm_vma_info SYSCTL_HANDLER_ARGS;
+#endif
+#if DRM_DMA_HISTOGRAM
+static int drm_histo_info SYSCTL_HANDLER_ARGS;
+#endif
+
+struct drm_sysctl_list {
+ const char *name;
+ int (*f) SYSCTL_HANDLER_ARGS;
+} drm_sysctl_list[] = {
+ { "name", drm_name_info },
+ { "mem", drm_mem_info },
+ { "vm", drm_vm_info },
+ { "clients", drm_clients_info },
+ { "queues", drm_queues_info },
+ { "bufs", drm_bufs_info },
+#if DRM_DEBUG_CODExx
+ { "vma", drm_vma_info },
+#endif
+#if DRM_DMA_HISTOGRAM
+ { "histo", drm_histo_info },
+#endif
+};
+#define DRM_SYSCTL_ENTRIES (sizeof(drm_sysctl_list)/sizeof(drm_sysctl_list[0]))
+
+struct drm_sysctl_info {
+ struct sysctl_oid oids[DRM_SYSCTL_ENTRIES + 1];
+ struct sysctl_oid_list list;
+ char name[2];
+};
+
+int drm_sysctl_init(drm_device_t *dev)
+{
+ struct drm_sysctl_info *info;
+ struct sysctl_oid *oid;
+ struct sysctl_oid *top;
+ int i;
+
+ /* Find the next free slot under hw.graphics */
+ i = 0;
+ SLIST_FOREACH(oid, &sysctl__hw_dri_children, oid_link) {
+ if (i <= oid->oid_arg2)
+ i = oid->oid_arg2 + 1;
+ }
+
+ info = drm_alloc(sizeof *info, DRM_MEM_DRIVER);
+ dev->sysctl = info;
+
+ /* Construct the node under hw.graphics */
+ info->name[0] = '0' + i;
+ info->name[1] = 0;
+ oid = &info->oids[DRM_SYSCTL_ENTRIES];
+ bzero(oid, sizeof(*oid));
+ oid->oid_parent = &sysctl__hw_dri_children;
+ oid->oid_number = OID_AUTO;
+ oid->oid_kind = CTLTYPE_NODE | CTLFLAG_RW;
+ oid->oid_arg1 = &info->list;
+ oid->oid_arg2 = i;
+ oid->oid_name = info->name;
+ oid->oid_handler = 0;
+ oid->oid_fmt = "N";
+ SLIST_INIT(&info->list);
+ sysctl_register_oid(oid);
+ top = oid;
+
+ for (i = 0; i < DRM_SYSCTL_ENTRIES; i++) {
+ oid = &info->oids[i];
+ bzero(oid, sizeof(*oid));
+ oid->oid_parent = top->oid_arg1;
+ oid->oid_number = OID_AUTO;
+ oid->oid_kind = CTLTYPE_INT | CTLFLAG_RD;
+ oid->oid_arg1 = dev;
+ oid->oid_arg2 = 0;
+ oid->oid_name = drm_sysctl_list[i].name;
+ oid->oid_handler = drm_sysctl_list[i].f;
+ oid->oid_fmt = "A";
+ sysctl_register_oid(oid);
+ }
+
+ return 0;
+}
+
+int drm_sysctl_cleanup(drm_device_t *dev)
+{
+ int i;
+
+ DRM_DEBUG("dev->sysctl=%p\n", dev->sysctl);
+ for (i = 0; i < DRM_SYSCTL_ENTRIES + 1; i++)
+ sysctl_unregister_oid(&dev->sysctl->oids[i]);
+
+ drm_free(dev->sysctl, sizeof *dev->sysctl, DRM_MEM_DRIVER);
+ dev->sysctl = NULL;
+
+ return 0;
+}
+
+static int drm_name_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ char buf[128];
+ int error;
+
+ if (dev->unique) {
+ DRM_SYSCTL_PRINT("%s 0x%x %s\n",
+ dev->name, dev2udev(dev->devnode), dev->unique);
+ } else {
+ DRM_SYSCTL_PRINT("%s 0x%x\n", dev->name, dev2udev(dev->devnode));
+ }
+
+ SYSCTL_OUT(req, "", 1);
+
+ return 0;
+}
+
+static int _drm_vm_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ drm_map_t *map;
+ const char *types[] = { "FB", "REG", "SHM" };
+ const char *type;
+ int i;
+ char buf[128];
+ int error;
+
+ DRM_SYSCTL_PRINT("slot offset size type flags "
+ "address mtrr\n\n");
+ error = SYSCTL_OUT(req, buf, strlen(buf));
+ if (error) return error;
+
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ if (map->type < 0 || map->type > 2) type = "??";
+ else type = types[map->type];
+ DRM_SYSCTL_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ",
+ i,
+ map->offset,
+ map->size,
+ type,
+ map->flags,
+ (unsigned long)map->handle);
+ if (map->mtrr < 0) {
+ DRM_SYSCTL_PRINT("none\n");
+ } else {
+ DRM_SYSCTL_PRINT("%4d\n", map->mtrr);
+ }
+ }
+ SYSCTL_OUT(req, "", 1);
+
+ return 0;
+}
+
+static int drm_vm_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int ret;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ ret = _drm_vm_info(oidp, arg1, arg2, req);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ return ret;
+}
+
+
+static int _drm_queues_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int i;
+ drm_queue_t *q;
+ char buf[128];
+ int error;
+
+ DRM_SYSCTL_PRINT(" ctx/flags use fin"
+ " blk/rw/rwf wait flushed queued"
+ " locks\n\n");
+ for (i = 0; i < dev->queue_count; i++) {
+ q = dev->queuelist[i];
+ atomic_inc(&q->use_count);
+ DRM_SYSCTL_PRINT_RET(atomic_dec(&q->use_count),
+ "%5d/0x%03x %5d %5d"
+ " %5d/%c%c/%c%c%c %5d %10d %10d %10d\n",
+ i,
+ q->flags,
+ atomic_read(&q->use_count),
+ atomic_read(&q->finalization),
+ atomic_read(&q->block_count),
+ atomic_read(&q->block_read) ? 'r' : '-',
+ atomic_read(&q->block_write) ? 'w' : '-',
+ q->read_queue ? 'r':'-',
+ q->write_queue ? 'w':'-',
+ q->flush_queue ? 'f':'-',
+ DRM_BUFCOUNT(&q->waitlist),
+ atomic_read(&q->total_flushed),
+ atomic_read(&q->total_queued),
+ atomic_read(&q->total_locks));
+ atomic_dec(&q->use_count);
+ }
+
+ SYSCTL_OUT(req, "", 1);
+ return 0;
+}
+
+static int drm_queues_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int ret;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ ret = _drm_queues_info(oidp, arg1, arg2, req);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return ret;
+}
+
+/* drm_bufs_info is called whenever a process reads
+ hw.dri.0.bufs. */
+
+static int _drm_bufs_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+ char buf[128];
+ int error;
+
+ if (!dma) return 0;
+ DRM_SYSCTL_PRINT(" o size count free segs pages kB\n\n");
+ for (i = 0; i <= DRM_MAX_ORDER; i++) {
+ if (dma->bufs[i].buf_count)
+ DRM_SYSCTL_PRINT("%2d %8d %5d %5d %5d %5d %5d\n",
+ i,
+ dma->bufs[i].buf_size,
+ dma->bufs[i].buf_count,
+ atomic_read(&dma->bufs[i]
+ .freelist.count),
+ dma->bufs[i].seg_count,
+ dma->bufs[i].seg_count
+ *(1 << dma->bufs[i].page_order),
+ (dma->bufs[i].seg_count
+ * (1 << dma->bufs[i].page_order))
+ * PAGE_SIZE / 1024);
+ }
+ DRM_SYSCTL_PRINT("\n");
+ for (i = 0; i < dma->buf_count; i++) {
+ if (i && !(i%32)) DRM_SYSCTL_PRINT("\n");
+ DRM_SYSCTL_PRINT(" %d", dma->buflist[i]->list);
+ }
+ DRM_SYSCTL_PRINT("\n");
+
+ SYSCTL_OUT(req, "", 1);
+ return 0;
+}
+
+static int drm_bufs_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int ret;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ ret = _drm_bufs_info(oidp, arg1, arg2, req);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return ret;
+}
+
+
+static int _drm_clients_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ drm_file_t *priv;
+ char buf[128];
+ int error;
+
+ DRM_SYSCTL_PRINT("a dev pid uid magic ioctls\n\n");
+ TAILQ_FOREACH(priv, &dev->files, link) {
+ DRM_SYSCTL_PRINT("%c %3d %5d %5d %10u %10lu\n",
+ priv->authenticated ? 'y' : 'n',
+ priv->minor,
+ priv->pid,
+ priv->uid,
+ priv->magic,
+ priv->ioctl_count);
+ }
+
+ SYSCTL_OUT(req, "", 1);
+ return 0;
+}
+
+static int drm_clients_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int ret;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ ret = _drm_clients_info(oidp, arg1, arg2, req);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return ret;
+}
+
+#if DRM_DEBUG_CODExx
+
+static int _drm_vma_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ drm_vma_entry_t *pt;
+ pgd_t *pgd;
+ pmd_t *pmd;
+ pte_t *pte;
+ unsigned long i;
+ struct vm_area_struct *vma;
+ unsigned long address;
+#if defined(__i386__)
+ unsigned int pgprot;
+#endif
+ char buf[128];
+ int error;
+
+ DRM_SYSCTL_PRINT("vma use count: %d, high_memory = %p, 0x%08lx\n",
+ atomic_read(&dev->vma_count),
+ high_memory, virt_to_phys(high_memory));
+ for (pt = dev->vmalist; pt; pt = pt->next) {
+ if (!(vma = pt->vma)) continue;
+ DRM_SYSCTL_PRINT("\n%5d 0x%08lx-0x%08lx %c%c%c%c%c%c 0x%08lx",
+ pt->pid,
+ vma->vm_start,
+ vma->vm_end,
+ vma->vm_flags & VM_READ ? 'r' : '-',
+ vma->vm_flags & VM_WRITE ? 'w' : '-',
+ vma->vm_flags & VM_EXEC ? 'x' : '-',
+ vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
+ vma->vm_flags & VM_LOCKED ? 'l' : '-',
+ vma->vm_flags & VM_IO ? 'i' : '-',
+ vma->vm_offset );
+#if defined(__i386__)
+ pgprot = pgprot_val(vma->vm_page_prot);
+ DRM_SYSCTL_PRINT(" %c%c%c%c%c%c%c%c%c",
+ pgprot & _PAGE_PRESENT ? 'p' : '-',
+ pgprot & _PAGE_RW ? 'w' : 'r',
+ pgprot & _PAGE_USER ? 'u' : 's',
+ pgprot & _PAGE_PWT ? 't' : 'b',
+ pgprot & _PAGE_PCD ? 'u' : 'c',
+ pgprot & _PAGE_ACCESSED ? 'a' : '-',
+ pgprot & _PAGE_DIRTY ? 'd' : '-',
+ pgprot & _PAGE_4M ? 'm' : 'k',
+ pgprot & _PAGE_GLOBAL ? 'g' : 'l' );
+#endif
+ DRM_SYSCTL_PRINT("\n");
+ for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) {
+ pgd = pgd_offset(vma->vm_mm, i);
+ pmd = pmd_offset(pgd, i);
+ pte = pte_offset(pmd, i);
+ if (pte_present(*pte)) {
+ address = __pa(pte_page(*pte))
+ + (i & (PAGE_SIZE-1));
+ DRM_SYSCTL_PRINT(" 0x%08lx -> 0x%08lx"
+ " %c%c%c%c%c\n",
+ i,
+ address,
+ pte_read(*pte) ? 'r' : '-',
+ pte_write(*pte) ? 'w' : '-',
+ pte_exec(*pte) ? 'x' : '-',
+ pte_dirty(*pte) ? 'd' : '-',
+ pte_young(*pte) ? 'a' : '-' );
+ } else {
+ DRM_SYSCTL_PRINT(" 0x%08lx\n", i);
+ }
+ }
+ }
+
+ SYSCTL_OUT(req, "", 1);
+ return 0;
+}
+
+static int drm_vma_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int ret;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ ret = _drm_vma_info(oidp, arg1, arg2, req);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return ret;
+}
+#endif
+
+
+#if DRM_DMA_HISTOGRAM
+static int _drm_histo_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+ unsigned long slot_value = DRM_DMA_HISTOGRAM_INITIAL;
+ unsigned long prev_value = 0;
+ drm_buf_t *buffer;
+ char buf[128];
+ int error;
+
+ DRM_SYSCTL_PRINT("general statistics:\n");
+ DRM_SYSCTL_PRINT("total %10u\n", atomic_read(&dev->histo.total));
+ DRM_SYSCTL_PRINT("open %10u\n", atomic_read(&dev->total_open));
+ DRM_SYSCTL_PRINT("close %10u\n", atomic_read(&dev->total_close));
+ DRM_SYSCTL_PRINT("ioctl %10u\n", atomic_read(&dev->total_ioctl));
+ DRM_SYSCTL_PRINT("irq %10u\n", atomic_read(&dev->total_irq));
+ DRM_SYSCTL_PRINT("ctx %10u\n", atomic_read(&dev->total_ctx));
+
+ DRM_SYSCTL_PRINT("\nlock statistics:\n");
+ DRM_SYSCTL_PRINT("locks %10u\n", atomic_read(&dev->total_locks));
+ DRM_SYSCTL_PRINT("unlocks %10u\n", atomic_read(&dev->total_unlocks));
+ DRM_SYSCTL_PRINT("contends %10u\n", atomic_read(&dev->total_contends));
+ DRM_SYSCTL_PRINT("sleeps %10u\n", atomic_read(&dev->total_sleeps));
+
+
+ if (dma) {
+ DRM_SYSCTL_PRINT("\ndma statistics:\n");
+ DRM_SYSCTL_PRINT("prio %10u\n",
+ atomic_read(&dma->total_prio));
+ DRM_SYSCTL_PRINT("bytes %10u\n",
+ atomic_read(&dma->total_bytes));
+ DRM_SYSCTL_PRINT("dmas %10u\n",
+ atomic_read(&dma->total_dmas));
+ DRM_SYSCTL_PRINT("missed:\n");
+ DRM_SYSCTL_PRINT(" dma %10u\n",
+ atomic_read(&dma->total_missed_dma));
+ DRM_SYSCTL_PRINT(" lock %10u\n",
+ atomic_read(&dma->total_missed_lock));
+ DRM_SYSCTL_PRINT(" free %10u\n",
+ atomic_read(&dma->total_missed_free));
+ DRM_SYSCTL_PRINT(" sched %10u\n",
+ atomic_read(&dma->total_missed_sched));
+ DRM_SYSCTL_PRINT("tried %10u\n",
+ atomic_read(&dma->total_tried));
+ DRM_SYSCTL_PRINT("hit %10u\n",
+ atomic_read(&dma->total_hit));
+ DRM_SYSCTL_PRINT("lost %10u\n",
+ atomic_read(&dma->total_lost));
+
+ buffer = dma->next_buffer;
+ if (buffer) {
+ DRM_SYSCTL_PRINT("next_buffer %7d\n", buffer->idx);
+ } else {
+ DRM_SYSCTL_PRINT("next_buffer none\n");
+ }
+ buffer = dma->this_buffer;
+ if (buffer) {
+ DRM_SYSCTL_PRINT("this_buffer %7d\n", buffer->idx);
+ } else {
+ DRM_SYSCTL_PRINT("this_buffer none\n");
+ }
+ }
+
+
+ DRM_SYSCTL_PRINT("\nvalues:\n");
+ if (dev->lock.hw_lock) {
+ DRM_SYSCTL_PRINT("lock 0x%08x\n",
+ dev->lock.hw_lock->lock);
+ } else {
+ DRM_SYSCTL_PRINT("lock none\n");
+ }
+ DRM_SYSCTL_PRINT("context_flag 0x%08x\n", dev->context_flag);
+ DRM_SYSCTL_PRINT("interrupt_flag 0x%08x\n", dev->interrupt_flag);
+ DRM_SYSCTL_PRINT("dma_flag 0x%08x\n", dev->dma_flag);
+
+ DRM_SYSCTL_PRINT("queue_count %10d\n", dev->queue_count);
+ DRM_SYSCTL_PRINT("last_context %10d\n", dev->last_context);
+ DRM_SYSCTL_PRINT("last_switch %10u\n", dev->last_switch);
+ DRM_SYSCTL_PRINT("last_checked %10d\n", dev->last_checked);
+
+
+ DRM_SYSCTL_PRINT("\n q2d d2c c2f"
+ " q2c q2f dma sch"
+ " ctx lacq lhld\n\n");
+ for (i = 0; i < DRM_DMA_HISTOGRAM_SLOTS; i++) {
+ DRM_SYSCTL_PRINT("%s %10lu %10u %10u %10u %10u %10u"
+ " %10u %10u %10u %10u %10u\n",
+ i == DRM_DMA_HISTOGRAM_SLOTS - 1 ? ">=" : "< ",
+ i == DRM_DMA_HISTOGRAM_SLOTS - 1
+ ? prev_value : slot_value ,
+
+ atomic_read(&dev->histo
+ .queued_to_dispatched[i]),
+ atomic_read(&dev->histo
+ .dispatched_to_completed[i]),
+ atomic_read(&dev->histo
+ .completed_to_freed[i]),
+
+ atomic_read(&dev->histo
+ .queued_to_completed[i]),
+ atomic_read(&dev->histo
+ .queued_to_freed[i]),
+ atomic_read(&dev->histo.dma[i]),
+ atomic_read(&dev->histo.schedule[i]),
+ atomic_read(&dev->histo.ctx[i]),
+ atomic_read(&dev->histo.lacq[i]),
+ atomic_read(&dev->histo.lhld[i]));
+ prev_value = slot_value;
+ slot_value = DRM_DMA_HISTOGRAM_NEXT(slot_value);
+ }
+ SYSCTL_OUT(req, "", 1);
+ return 0;
+}
+
+static int drm_histo_info SYSCTL_HANDLER_ARGS
+{
+ drm_device_t *dev = arg1;
+ int ret;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ ret = _drm_histo_info(oidp, arg1, arg2, req);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return ret;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/vm.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/vm.c
new file mode 100644
index 000000000..00e66f3ef
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drm/vm.c
@@ -0,0 +1,104 @@
+/* vm.c -- Memory mapping for DRM -*- c -*-
+ * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+static int drm_dma_mmap(dev_t kdev, vm_offset_t offset, int prot)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ unsigned long physical;
+ unsigned long page;
+
+ if (!dma) return -1; /* Error */
+ if (!dma->pagelist) return -1; /* Nothing allocated */
+
+ page = offset >> PAGE_SHIFT;
+ physical = dma->pagelist[page];
+
+ DRM_DEBUG("0x%08x (page %lu) => 0x%08lx\n", offset, page, physical);
+ return atop(physical);
+}
+
+int drm_mmap(dev_t kdev, vm_offset_t offset, int prot)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_map_t *map = NULL;
+ int i;
+
+ /* DRM_DEBUG("offset = 0x%x\n", offset); */
+
+ if (dev->dma
+ && offset >= 0
+ && offset < ptoa(dev->dma->page_count))
+ return drm_dma_mmap(kdev, offset, prot);
+
+ /* A sequential search of a linked list is
+ fine here because: 1) there will only be
+ about 5-10 entries in the list and, 2) a
+ DRI client only has to do this mapping
+ once, so it doesn't have to be optimized
+ for performance, even if the list was a
+ bit longer. */
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ /* DRM_DEBUG("considering 0x%x..0x%x\n", map->offset, map->offset + map->size - 1); */
+ if (offset >= map->offset
+ && offset < map->offset + map->size) break;
+ }
+
+ if (i >= dev->map_count) {
+ DRM_DEBUG("can't find map\n");
+ return -1;
+ }
+ if (!map || ((map->flags&_DRM_RESTRICTED) && suser(curproc))) {
+ DRM_DEBUG("restricted map\n");
+ return -1;
+ }
+
+ switch (map->type) {
+ case _DRM_FRAME_BUFFER:
+ case _DRM_REGISTERS:
+ case _DRM_AGP:
+ return atop(offset);
+ case _DRM_SHM:
+ return atop(vtophys(offset));
+ default:
+ return -1; /* This should never happen. */
+ }
+ DRM_DEBUG("bailing out\n");
+
+ return -1;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h
new file mode 100644
index 000000000..b62aff08d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h
@@ -0,0 +1,723 @@
+/* drmP.h -- Private header for Direct Rendering Manager -*- c -*-
+ * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
+ * Revised: Tue Oct 12 08:51:07 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h,v 1.58 1999/08/30 13:05:00 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h,v 1.1 2000/06/17 00:03:28 martin Exp $
+ *
+ */
+
+#ifndef _DRM_P_H_
+#define _DRM_P_H_
+
+#ifdef _KERNEL
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/malloc.h>
+#include <sys/kernel.h>
+#include <sys/module.h>
+#include <sys/systm.h>
+#include <sys/conf.h>
+#include <sys/stat.h>
+#include <sys/proc.h>
+#include <sys/lock.h>
+#include <sys/fcntl.h>
+#include <sys/uio.h>
+#include <sys/filio.h>
+#include <sys/sysctl.h>
+#include <sys/select.h>
+#include <sys/bus.h>
+#if __FreeBSD_version >= 500005
+#include <sys/taskqueue.h>
+#endif
+
+#if __FreeBSD_version >= 500006
+#define DRM_AGP
+#endif
+
+#ifdef DRM_AGP
+#include <pci/agpvar.h>
+#endif
+
+#include "drm.h"
+
+typedef u_int32_t atomic_t;
+typedef u_int32_t cycles_t;
+typedef u_int32_t spinlock_t;
+#define atomic_set(p, v) (*(p) = (v))
+#define atomic_read(p) (*(p))
+#define atomic_inc(p) atomic_add_int(p, 1)
+#define atomic_dec(p) atomic_subtract_int(p, 1)
+#define atomic_add(n, p) atomic_add_int(p, n)
+#define atomic_sub(n, p) atomic_subtract_int(p, n)
+
+/* Fake this */
+static __inline u_int32_t
+test_and_set_bit(int b, volatile u_int32_t *p)
+{
+ int s = splhigh();
+ u_int32_t m = 1<<b;
+ u_int32_t r = *p & m;
+ *p |= m;
+ splx(s);
+ return r;
+}
+
+static __inline void
+clear_bit(int b, volatile u_int32_t *p)
+{
+ atomic_clear_int(p + (b >> 5), 1 << (b & 0x1f));
+}
+
+static __inline void
+set_bit(int b, volatile u_int32_t *p)
+{
+ atomic_set_int(p + (b >> 5), 1 << (b & 0x1f));
+}
+
+static __inline int
+test_bit(int b, volatile u_int32_t *p)
+{
+ return p[b >> 5] & (1 << (b & 0x1f));
+}
+
+static __inline int
+find_first_zero_bit(volatile u_int32_t *p, int max)
+{
+ int b;
+
+ for (b = 0; b < max; b += 32) {
+ if (p[b >> 5] != ~0) {
+ for (;;) {
+ if ((p[b >> 5] & (1 << (b & 0x1f))) == 0)
+ return b;
+ b++;
+ }
+ }
+ }
+ return max;
+}
+
+#define spldrm() spltty()
+
+#define memset(p, v, s) bzero(p, s)
+
+/*
+ * Fake out the module macros for versions of FreeBSD where they don't
+ * exist.
+ */
+#if __FreeBSD_version < 500002
+
+#define MODULE_VERSION(a,b) struct __hack
+#define MODULE_DEPEND(a,b,c,d,e) struct __hack
+
+#endif
+
+#define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
+ also include looping detection. */
+#define DRM_DMA_HISTOGRAM 1 /* Make histogram of DMA latency. */
+
+#define DRM_HASH_SIZE 16 /* Size of key hash table */
+#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
+#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
+#define DRM_LOOPING_LIMIT 5000000
+#define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
+#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
+#define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
+
+#define DRM_FLAG_DEBUG 0x01
+#define DRM_FLAG_NOCTX 0x02
+
+#define DRM_MEM_DMA 0
+#define DRM_MEM_SAREA 1
+#define DRM_MEM_DRIVER 2
+#define DRM_MEM_MAGIC 3
+#define DRM_MEM_IOCTLS 4
+#define DRM_MEM_MAPS 5
+#define DRM_MEM_VMAS 6
+#define DRM_MEM_BUFS 7
+#define DRM_MEM_SEGS 8
+#define DRM_MEM_PAGES 9
+#define DRM_MEM_FILES 10
+#define DRM_MEM_QUEUES 11
+#define DRM_MEM_CMDS 12
+#define DRM_MEM_MAPPINGS 13
+#define DRM_MEM_BUFLISTS 14
+#define DRM_MEM_AGPLISTS 15
+#define DRM_MEM_TOTALAGP 16
+#define DRM_MEM_BOUNDAGP 17
+#define DRM_MEM_CTXBITMAP 18
+
+#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
+
+ /* Backward compatibility section */
+#ifndef _PAGE_PWT
+ /* The name of _PAGE_WT was changed to
+ _PAGE_PWT in Linux 2.2.6 */
+#define _PAGE_PWT _PAGE_WT
+#endif
+
+#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
+#define _DRM_CAS(lock,old,new,__ret) \
+ do { \
+ int __dummy; /* Can't mark eax as clobbered */ \
+ __asm__ __volatile__( \
+ "lock ; cmpxchg %4,%1\n\t" \
+ "setnz %0" \
+ : "=d" (__ret), \
+ "=m" (__drm_dummy_lock(lock)), \
+ "=a" (__dummy) \
+ : "2" (old), \
+ "r" (new)); \
+ } while (0)
+
+
+
+ /* Macros to make printk easier */
+#define DRM_ERROR(fmt, arg...) \
+ printf("error: " "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg)
+#define DRM_MEM_ERROR(area, fmt, arg...) \
+ printf("error: " "[" DRM_NAME ":" __FUNCTION__ ":%s] *ERROR* " fmt , \
+ drm_mem_stats[area].name , ##arg)
+#define DRM_INFO(fmt, arg...) printf("info: " "[" DRM_NAME "] " fmt , ##arg)
+
+#if DRM_DEBUG_CODE
+#define DRM_DEBUG(fmt, arg...) \
+ do { \
+ if (drm_flags&DRM_FLAG_DEBUG) \
+ printf("[" DRM_NAME ":" __FUNCTION__ "] " fmt , \
+ ##arg); \
+ } while (0)
+#else
+#define DRM_DEBUG(fmt, arg...) do { } while (0)
+#endif
+
+#define DRM_PROC_LIMIT (PAGE_SIZE-80)
+
+#define DRM_SYSCTL_PRINT(fmt, arg...) \
+ snprintf(buf, sizeof(buf), fmt, ##arg); \
+ error = SYSCTL_OUT(req, buf, strlen(buf)); \
+ if (error) return error;
+
+#define DRM_SYSCTL_PRINT_RET(ret, fmt, arg...) \
+ snprintf(buf, sizeof(buf), fmt, ##arg); \
+ error = SYSCTL_OUT(req, buf, strlen(buf)); \
+ if (error) { ret; return error; }
+
+ /* Internal types and structures */
+#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
+#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
+#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
+
+#define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
+#define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
+#define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
+
+typedef struct drm_ioctl_desc {
+ d_ioctl_t *func;
+ int auth_needed;
+ int root_only;
+} drm_ioctl_desc_t;
+
+typedef struct drm_devstate {
+ pid_t owner; /* X server pid holding x_lock */
+
+} drm_devstate_t;
+
+typedef struct drm_magic_entry {
+ drm_magic_t magic;
+ struct drm_file *priv;
+ struct drm_magic_entry *next;
+} drm_magic_entry_t;
+
+typedef struct drm_magic_head {
+ struct drm_magic_entry *head;
+ struct drm_magic_entry *tail;
+} drm_magic_head_t;
+
+typedef struct drm_vma_entry {
+ struct vm_area_struct *vma;
+ struct drm_vma_entry *next;
+ pid_t pid;
+} drm_vma_entry_t;
+
+typedef struct drm_buf {
+ int idx; /* Index into master buflist */
+ int total; /* Buffer size */
+ int order; /* log-base-2(total) */
+ int used; /* Amount of buffer in use (for DMA) */
+ unsigned long offset; /* Byte offset (used internally) */
+ void *address; /* Address of buffer */
+ unsigned long bus_address; /* Bus address of buffer */
+ struct drm_buf *next; /* Kernel-only: used for free list */
+ __volatile__ int waiting; /* On kernel DMA queue */
+ __volatile__ int pending; /* On hardware DMA queue */
+ int dma_wait; /* Processes waiting */
+ pid_t pid; /* PID of holding process */
+ int context; /* Kernel queue for this buffer */
+ int while_locked;/* Dispatch this buffer while locked */
+ enum {
+ DRM_LIST_NONE = 0,
+ DRM_LIST_FREE = 1,
+ DRM_LIST_WAIT = 2,
+ DRM_LIST_PEND = 3,
+ DRM_LIST_PRIO = 4,
+ DRM_LIST_RECLAIM = 5
+ } list; /* Which list we're on */
+
+ void *dev_private;
+ int dev_priv_size;
+
+#if DRM_DMA_HISTOGRAM
+ struct timespec time_queued; /* Queued to kernel DMA queue */
+ struct timespec time_dispatched; /* Dispatched to hardware */
+ struct timespec time_completed; /* Completed by hardware */
+ struct timespec time_freed; /* Back on freelist */
+#endif
+} drm_buf_t;
+
+#if DRM_DMA_HISTOGRAM
+#define DRM_DMA_HISTOGRAM_SLOTS 9
+#define DRM_DMA_HISTOGRAM_INITIAL 10
+#define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
+typedef struct drm_histogram {
+ atomic_t total;
+
+ atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
+
+ atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
+
+ atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS];
+ atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS];
+} drm_histogram_t;
+#endif
+
+ /* bufs is one longer than it has to be */
+typedef struct drm_waitlist {
+ int count; /* Number of possible buffers */
+ drm_buf_t **bufs; /* List of pointers to buffers */
+ drm_buf_t **rp; /* Read pointer */
+ drm_buf_t **wp; /* Write pointer */
+ drm_buf_t **end; /* End pointer */
+ spinlock_t read_lock;
+ spinlock_t write_lock;
+} drm_waitlist_t;
+
+typedef struct drm_freelist {
+ int initialized; /* Freelist in use */
+ atomic_t count; /* Number of free buffers */
+ drm_buf_t *next; /* End pointer */
+
+ int waiting; /* Processes waiting on free bufs */
+ int low_mark; /* Low water mark */
+ int high_mark; /* High water mark */
+ atomic_t wfh; /* If waiting for high mark */
+} drm_freelist_t;
+
+typedef struct drm_buf_entry {
+ int buf_size;
+ int buf_count;
+ drm_buf_t *buflist;
+ int seg_count;
+ int page_order;
+ unsigned long *seglist;
+
+ drm_freelist_t freelist;
+} drm_buf_entry_t;
+
+typedef struct drm_hw_lock {
+ __volatile__ unsigned int lock;
+ char padding[60]; /* Pad to cache line */
+} drm_hw_lock_t;
+
+typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
+typedef struct drm_file {
+ TAILQ_ENTRY(drm_file) link;
+ int authenticated;
+ int minor;
+ pid_t pid;
+ uid_t uid;
+ int refs;
+ drm_magic_t magic;
+ unsigned long ioctl_count;
+ struct drm_device *devXX;
+} drm_file_t;
+
+
+typedef struct drm_queue {
+ atomic_t use_count; /* Outstanding uses (+1) */
+ atomic_t finalization; /* Finalization in progress */
+ atomic_t block_count; /* Count of processes waiting */
+ atomic_t block_read; /* Queue blocked for reads */
+ int read_queue; /* Processes waiting on block_read */
+ atomic_t block_write; /* Queue blocked for writes */
+ int write_queue; /* Processes waiting on block_write */
+ atomic_t total_queued; /* Total queued statistic */
+ atomic_t total_flushed;/* Total flushes statistic */
+ atomic_t total_locks; /* Total locks statistics */
+ drm_ctx_flags_t flags; /* Context preserving and 2D-only */
+ drm_waitlist_t waitlist; /* Pending buffers */
+ int flush_queue; /* Processes waiting until flush */
+} drm_queue_t;
+
+typedef struct drm_lock_data {
+ drm_hw_lock_t *hw_lock; /* Hardware lock */
+ pid_t pid; /* PID of lock holder (0=kernel) */
+ int lock_queue; /* Queue of blocked processes */
+ unsigned long lock_time; /* Time of last lock in jiffies */
+} drm_lock_data_t;
+
+typedef struct drm_device_dma {
+ /* Performance Counters */
+ atomic_t total_prio; /* Total DRM_DMA_PRIORITY */
+ atomic_t total_bytes; /* Total bytes DMA'd */
+ atomic_t total_dmas; /* Total DMA buffers dispatched */
+
+ atomic_t total_missed_dma; /* Missed drm_do_dma */
+ atomic_t total_missed_lock; /* Missed lock in drm_do_dma */
+ atomic_t total_missed_free; /* Missed drm_free_this_buffer */
+ atomic_t total_missed_sched;/* Missed drm_dma_schedule */
+
+ atomic_t total_tried; /* Tried next_buffer */
+ atomic_t total_hit; /* Sent next_buffer */
+ atomic_t total_lost; /* Lost interrupt */
+
+ drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
+ int buf_count;
+ drm_buf_t **buflist; /* Vector of pointers info bufs */
+ int seg_count;
+ int page_count;
+ vm_offset_t *pagelist;
+ unsigned long byte_count;
+ enum {
+ _DRM_DMA_USE_AGP = 0x01
+ } flags;
+
+ /* DMA support */
+ drm_buf_t *this_buffer; /* Buffer being sent */
+ drm_buf_t *next_buffer; /* Selected buffer to send */
+ drm_queue_t *next_queue; /* Queue from which buffer selected*/
+ int waiting; /* Processes waiting on free bufs */
+} drm_device_dma_t;
+
+#ifdef DRM_AGP
+
+typedef struct drm_agp_mem {
+ void *handle;
+ unsigned long bound; /* address */
+ int pages;
+ struct drm_agp_mem *prev;
+ struct drm_agp_mem *next;
+} drm_agp_mem_t;
+
+typedef struct drm_agp_head {
+ device_t agpdev;
+ struct agp_info info;
+ const char *chipset;
+ drm_agp_mem_t *memory;
+ unsigned long mode;
+ int enabled;
+ int acquired;
+ unsigned long base;
+ int agp_mtrr;
+} drm_agp_head_t;
+
+#endif
+
+typedef struct drm_device {
+ const char *name; /* Simple driver name */
+ char *unique; /* Unique identifier: e.g., busid */
+ int unique_len; /* Length of unique field */
+ device_t device; /* Device instance from newbus */
+ dev_t devnode; /* Device number for mknod */
+ char *devname; /* For /proc/interrupts */
+
+ int blocked; /* Blocked due to VC switch? */
+ int flags; /* Flags to open(2) */
+ int writable; /* Opened with FWRITE */
+ struct proc_dir_entry *root; /* Root for this device's entries */
+
+ /* Locks */
+ struct simplelock count_lock; /* For inuse, open_count, buf_use */
+ struct lock dev_lock; /* For others */
+
+ /* Usage Counters */
+ int open_count; /* Outstanding files open */
+ atomic_t ioctl_count; /* Outstanding IOCTLs pending */
+ atomic_t vma_count; /* Outstanding vma areas open */
+ int buf_use; /* Buffers in use -- cannot alloc */
+ atomic_t buf_alloc; /* Buffer allocation in progress */
+
+ /* Performance Counters */
+ atomic_t total_open;
+ atomic_t total_close;
+ atomic_t total_ioctl;
+ atomic_t total_irq; /* Total interruptions */
+ atomic_t total_ctx; /* Total context switches */
+
+ atomic_t total_locks;
+ atomic_t total_unlocks;
+ atomic_t total_contends;
+ atomic_t total_sleeps;
+
+ /* Authentication */
+ drm_file_list_t files;
+ drm_magic_head_t magiclist[DRM_HASH_SIZE];
+
+ /* Memory management */
+ drm_map_t **maplist; /* Vector of pointers to regions */
+ int map_count; /* Number of mappable regions */
+
+ drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
+ drm_lock_data_t lock; /* Information on hardware lock */
+
+ /* DMA queues (contexts) */
+ int queue_count; /* Number of active DMA queues */
+ int queue_reserved; /* Number of reserved DMA queues */
+ int queue_slots; /* Actual length of queuelist */
+ drm_queue_t **queuelist; /* Vector of pointers to DMA queues */
+ drm_device_dma_t *dma; /* Optional pointer for DMA support */
+
+ /* Context support */
+ struct resource *irq; /* Interrupt used by board */
+ void *irqh; /* Handle from bus_setup_intr */
+ __volatile__ int context_flag; /* Context swapping flag */
+ __volatile__ int interrupt_flag;/* Interruption handler flag */
+ __volatile__ int dma_flag; /* DMA dispatch flag */
+ struct callout timer; /* Timer for delaying ctx switch */
+ int context_wait; /* Processes waiting on ctx switch */
+ int last_checked; /* Last context checked for DMA */
+ int last_context; /* Last current context */
+ int last_switch; /* Time at last context switch */
+#if __FreeBSD_version >= 500005
+ struct task task;
+#endif
+ struct timespec ctx_start;
+ struct timespec lck_start;
+#if DRM_DMA_HISTOGRAM
+ drm_histogram_t histo;
+#endif
+
+ /* Callback to X server for context switch
+ and for heavy-handed reset. */
+ char buf[DRM_BSZ]; /* Output buffer */
+ char *buf_rp; /* Read pointer */
+ char *buf_wp; /* Write pointer */
+ char *buf_end; /* End pointer */
+ struct sigio *buf_sigio; /* Processes waiting for SIGIO */
+ struct selinfo buf_sel; /* Workspace for select/poll */
+ int buf_readers; /* Processes waiting to read */
+ int buf_writers; /* Processes waiting to ctx switch */
+ int buf_selecting; /* True if poll sleeper */
+
+ /* Sysctl support */
+ struct drm_sysctl_info *sysctl;
+
+#ifdef DRM_AGP
+ drm_agp_head_t *agp;
+#endif
+ u_int32_t *ctx_bitmap;
+ void *dev_private;
+} drm_device_t;
+
+
+ /* Internal function definitions */
+
+ /* Misc. support (init.c) */
+extern int drm_flags;
+extern void drm_parse_options(char *s);
+
+
+ /* Device support (fops.c) */
+extern drm_file_t *drm_find_file_by_proc(drm_device_t *dev, struct proc *p);
+extern int drm_open_helper(dev_t kdev, int flags, int fmt, struct proc *p,
+ drm_device_t *dev);
+extern d_close_t drm_close;
+extern d_read_t drm_read;
+extern d_write_t drm_write;
+extern d_poll_t drm_poll;
+extern int drm_fsetown(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p);
+extern int drm_fgetown(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p);
+extern int drm_write_string(drm_device_t *dev, const char *s);
+
+#if 0
+ /* Mapping support (vm.c) */
+extern unsigned long drm_vm_nopage(struct vm_area_struct *vma,
+ unsigned long address,
+ int write_access);
+extern unsigned long drm_vm_shm_nopage(struct vm_area_struct *vma,
+ unsigned long address,
+ int write_access);
+extern unsigned long drm_vm_dma_nopage(struct vm_area_struct *vma,
+ unsigned long address,
+ int write_access);
+extern void drm_vm_open(struct vm_area_struct *vma);
+extern void drm_vm_close(struct vm_area_struct *vma);
+extern int drm_mmap_dma(struct file *filp,
+ struct vm_area_struct *vma);
+#endif
+extern d_mmap_t drm_mmap;
+
+ /* Proc support (proc.c) */
+extern int drm_sysctl_init(drm_device_t *dev);
+extern int drm_sysctl_cleanup(drm_device_t *dev);
+
+ /* Memory management support (memory.c) */
+extern void drm_mem_init(void);
+extern int drm_mem_info SYSCTL_HANDLER_ARGS;
+extern void *drm_alloc(size_t size, int area);
+extern void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
+ int area);
+extern char *drm_strdup(const char *s, int area);
+extern void drm_strfree(char *s, int area);
+extern void drm_free(void *pt, size_t size, int area);
+extern unsigned long drm_alloc_pages(int order, int area);
+extern void drm_free_pages(unsigned long address, int order,
+ int area);
+extern void *drm_ioremap(unsigned long offset, unsigned long size);
+extern void drm_ioremapfree(void *pt, unsigned long size);
+
+#ifdef DRM_AGP
+extern void *drm_alloc_agp(int pages, u_int32_t type);
+extern int drm_free_agp(void *handle, int pages);
+extern int drm_bind_agp(void *handle, unsigned int start);
+extern int drm_unbind_agp(void *handle);
+#endif
+
+ /* Buffer management support (bufs.c) */
+extern int drm_order(unsigned long size);
+extern d_ioctl_t drm_addmap;
+extern d_ioctl_t drm_addbufs;
+extern d_ioctl_t drm_infobufs;
+extern d_ioctl_t drm_markbufs;
+extern d_ioctl_t drm_freebufs;
+extern d_ioctl_t drm_mapbufs;
+
+
+ /* Buffer list management support (lists.c) */
+extern int drm_waitlist_create(drm_waitlist_t *bl, int count);
+extern int drm_waitlist_destroy(drm_waitlist_t *bl);
+extern int drm_waitlist_put(drm_waitlist_t *bl, drm_buf_t *buf);
+extern drm_buf_t *drm_waitlist_get(drm_waitlist_t *bl);
+
+extern int drm_freelist_create(drm_freelist_t *bl, int count);
+extern int drm_freelist_destroy(drm_freelist_t *bl);
+extern int drm_freelist_put(drm_device_t *dev, drm_freelist_t *bl,
+ drm_buf_t *buf);
+extern drm_buf_t *drm_freelist_get(drm_freelist_t *bl, int block);
+
+ /* DMA support (gen_dma.c) */
+extern void drm_dma_setup(drm_device_t *dev);
+extern void drm_dma_takedown(drm_device_t *dev);
+extern void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
+extern void drm_reclaim_buffers(drm_device_t *dev, pid_t pid);
+extern int drm_context_switch(drm_device_t *dev, int old, int new);
+extern int drm_context_switch_complete(drm_device_t *dev, int new);
+extern void drm_wakeup(drm_device_t *dev, drm_buf_t *buf);
+extern void drm_clear_next_buffer(drm_device_t *dev);
+extern int drm_select_queue(drm_device_t *dev,
+ void (*wrapper)(void *));
+extern int drm_dma_enqueue(drm_device_t *dev, drm_dma_t *dma);
+extern int drm_dma_get_buffers(drm_device_t *dev, drm_dma_t *dma);
+#if DRM_DMA_HISTOGRAM
+extern int drm_histogram_slot(struct timespec *ts);
+extern void drm_histogram_compute(drm_device_t *dev, drm_buf_t *buf);
+#endif
+
+
+ /* Misc. IOCTL support (ioctl.c) */
+extern d_ioctl_t drm_irq_busid;
+extern d_ioctl_t drm_getunique;
+extern d_ioctl_t drm_setunique;
+
+
+ /* Context IOCTL support (context.c) */
+extern d_ioctl_t drm_resctx;
+extern d_ioctl_t drm_addctx;
+extern d_ioctl_t drm_modctx;
+extern d_ioctl_t drm_getctx;
+extern d_ioctl_t drm_switchctx;
+extern d_ioctl_t drm_newctx;
+extern d_ioctl_t drm_rmctx;
+
+
+ /* Drawable IOCTL support (drawable.c) */
+extern d_ioctl_t drm_adddraw;
+extern d_ioctl_t drm_rmdraw;
+
+
+ /* Authentication IOCTL support (auth.c) */
+extern int drm_add_magic(drm_device_t *dev, drm_file_t *priv,
+ drm_magic_t magic);
+extern int drm_remove_magic(drm_device_t *dev, drm_magic_t magic);
+extern d_ioctl_t drm_getmagic;
+extern d_ioctl_t drm_authmagic;
+
+
+ /* Locking IOCTL support (lock.c) */
+extern d_ioctl_t drm_block;
+extern d_ioctl_t drm_unblock;
+extern int drm_lock_take(__volatile__ unsigned int *lock,
+ unsigned int context);
+extern int drm_lock_transfer(drm_device_t *dev,
+ __volatile__ unsigned int *lock,
+ unsigned int context);
+extern int drm_lock_free(drm_device_t *dev,
+ __volatile__ unsigned int *lock,
+ unsigned int context);
+extern d_ioctl_t drm_finish;
+extern int drm_flush_unblock(drm_device_t *dev, int context,
+ drm_lock_flags_t flags);
+extern int drm_flush_block_and_flush(drm_device_t *dev, int context,
+ drm_lock_flags_t flags);
+
+ /* Context Bitmap support (ctxbitmap.c) */
+extern int drm_ctxbitmap_init(drm_device_t *dev);
+extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
+extern int drm_ctxbitmap_next(drm_device_t *dev);
+extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
+
+#ifdef DRM_AGP
+ /* AGP/GART support (agpsupport.c) */
+extern drm_agp_head_t *drm_agp_init(void);
+extern d_ioctl_t drm_agp_acquire;
+extern d_ioctl_t drm_agp_release;
+extern d_ioctl_t drm_agp_enable;
+extern d_ioctl_t drm_agp_info;
+extern d_ioctl_t drm_agp_alloc;
+extern d_ioctl_t drm_agp_free;
+extern d_ioctl_t drm_agp_unbind;
+extern d_ioctl_t drm_agp_bind;
+#endif
+#endif
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/Makefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/Makefile
new file mode 100644
index 000000000..f5635910b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+KMOD = gamma
+SRCS = gamma_drv.c gamma_dma.c
+SRCS += device_if.h bus_if.h pci_if.h
+CFLAGS += ${DEBUG_FLAGS} -I..
+KMODDEPS = drm
+
+@:
+ ln -sf /sys @
+
+machine:
+ ln -sf /sys/i386/include machine
+
+.include <bsd.kmod.mk>
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_dma.c
new file mode 100644
index 000000000..07d8248b1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_dma.c
@@ -0,0 +1,824 @@
+/* gamma_dma.c -- DMA support for GMX 2000 -*- c -*-
+ * Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "gamma_drv.h"
+
+#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+/* WARNING!!! MAGIC NUMBER!!! The number of regions already added to the
+ kernel must be specified here. Currently, the number is 2. This must
+ match the order the X server uses for instantiating register regions ,
+ or must be passed in a new ioctl. */
+#define GAMMA_REG(reg) \
+ (2 \
+ + ((reg < 0x1000) \
+ ? 0 \
+ : ((reg < 0x10000) ? 1 : ((reg < 0x11000) ? 2 : 3))))
+
+#define GAMMA_OFF(reg) \
+ ((reg < 0x1000) \
+ ? reg \
+ : ((reg < 0x10000) \
+ ? (reg - 0x1000) \
+ : ((reg < 0x11000) \
+ ? (reg - 0x10000) \
+ : (reg - 0x11000))))
+
+#define GAMMA_BASE(reg) ((unsigned long)dev->maplist[GAMMA_REG(reg)]->handle)
+#define GAMMA_ADDR(reg) (GAMMA_BASE(reg) + GAMMA_OFF(reg))
+#define GAMMA_DEREF(reg) *(__volatile__ int *)GAMMA_ADDR(reg)
+#define GAMMA_READ(reg) GAMMA_DEREF(reg)
+#define GAMMA_WRITE(reg,val) do { GAMMA_DEREF(reg) = val; } while (0)
+
+#define GAMMA_BROADCASTMASK 0x9378
+#define GAMMA_COMMANDINTENABLE 0x0c48
+#define GAMMA_DMAADDRESS 0x0028
+#define GAMMA_DMACOUNT 0x0030
+#define GAMMA_FILTERMODE 0x8c00
+#define GAMMA_GCOMMANDINTFLAGS 0x0c50
+#define GAMMA_GCOMMANDMODE 0x0c40
+#define GAMMA_GCOMMANDSTATUS 0x0c60
+#define GAMMA_GDELAYTIMER 0x0c38
+#define GAMMA_GDMACONTROL 0x0060
+#define GAMMA_GINTENABLE 0x0808
+#define GAMMA_GINTFLAGS 0x0810
+#define GAMMA_INFIFOSPACE 0x0018
+#define GAMMA_OUTFIFOWORDS 0x0020
+#define GAMMA_OUTPUTFIFO 0x2000
+#define GAMMA_SYNC 0x8c40
+#define GAMMA_SYNC_TAG 0x0188
+
+static __inline void gamma_dma_dispatch(drm_device_t *dev,
+ vm_offset_t address,
+ vm_size_t length)
+{
+ GAMMA_WRITE(GAMMA_DMAADDRESS, vtophys(address));
+ while (GAMMA_READ(GAMMA_GCOMMANDSTATUS) != 4)
+ ;
+ GAMMA_WRITE(GAMMA_DMACOUNT, length / 4);
+}
+
+static __inline void gamma_dma_quiescent_single(drm_device_t *dev)
+{
+ while (GAMMA_READ(GAMMA_DMACOUNT))
+ ;
+ while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
+ ;
+
+ GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
+ GAMMA_WRITE(GAMMA_SYNC, 0);
+
+ do {
+ while (!GAMMA_READ(GAMMA_OUTFIFOWORDS))
+ ;
+ } while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
+}
+
+static __inline void gamma_dma_quiescent_dual(drm_device_t *dev)
+{
+ while (GAMMA_READ(GAMMA_DMACOUNT))
+ ;
+ while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
+ ;
+
+ GAMMA_WRITE(GAMMA_BROADCASTMASK, 3);
+
+ GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
+ GAMMA_WRITE(GAMMA_SYNC, 0);
+
+ /* Read from first MX */
+ do {
+ while (!GAMMA_READ(GAMMA_OUTFIFOWORDS))
+ ;
+ } while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
+
+ /* Read from second MX */
+ do {
+ while (!GAMMA_READ(GAMMA_OUTFIFOWORDS + 0x10000))
+ ;
+ } while (GAMMA_READ(GAMMA_OUTPUTFIFO + 0x10000) != GAMMA_SYNC_TAG);
+}
+
+static __inline void gamma_dma_ready(drm_device_t *dev)
+{
+ while (GAMMA_READ(GAMMA_DMACOUNT))
+ ;
+}
+
+static __inline int gamma_dma_is_ready(drm_device_t *dev)
+{
+ return !GAMMA_READ(GAMMA_DMACOUNT);
+}
+
+static void gamma_dma_service(void *arg)
+{
+ drm_device_t *dev = (drm_device_t *)arg;
+ drm_device_dma_t *dma = dev->dma;
+
+ atomic_inc(&dev->total_irq);
+ GAMMA_WRITE(GAMMA_GDELAYTIMER, 0xc350/2); /* 0x05S */
+ GAMMA_WRITE(GAMMA_GCOMMANDINTFLAGS, 8);
+ GAMMA_WRITE(GAMMA_GINTFLAGS, 0x2001);
+ if (gamma_dma_is_ready(dev)) {
+ /* Free previous buffer */
+ if (test_and_set_bit(0, &dev->dma_flag)) {
+ atomic_inc(&dma->total_missed_free);
+ return;
+ }
+ if (dma->this_buffer) {
+ drm_free_buffer(dev, dma->this_buffer);
+ dma->this_buffer = NULL;
+ }
+ clear_bit(0, &dev->dma_flag);
+
+#if 0
+ /* Dispatch new buffer */
+ queue_task(&dev->tq, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+#endif
+ }
+}
+
+/* Only called by gamma_dma_schedule. */
+static int gamma_do_dma(drm_device_t *dev, int locked)
+{
+ unsigned long address;
+ unsigned long length;
+ drm_buf_t *buf;
+ int retcode = 0;
+ drm_device_dma_t *dma = dev->dma;
+#if DRM_DMA_HISTOGRAM
+ struct timespec dma_start, dma_stop;
+#endif
+
+ if (test_and_set_bit(0, &dev->dma_flag)) {
+ atomic_inc(&dma->total_missed_dma);
+ return EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&dma_start);
+#endif
+
+ if (!dma->next_buffer) {
+ DRM_ERROR("No next_buffer\n");
+ clear_bit(0, &dev->dma_flag);
+ return EINVAL;
+ }
+
+ buf = dma->next_buffer;
+ address = (unsigned long)buf->address;
+ length = buf->used;
+
+ DRM_DEBUG("context %d, buffer %d (%ld bytes)\n",
+ buf->context, buf->idx, length);
+
+ if (buf->list == DRM_LIST_RECLAIM) {
+ drm_clear_next_buffer(dev);
+ drm_free_buffer(dev, buf);
+ clear_bit(0, &dev->dma_flag);
+ return EINVAL;
+ }
+
+ if (!length) {
+ DRM_ERROR("0 length buffer\n");
+ drm_clear_next_buffer(dev);
+ drm_free_buffer(dev, buf);
+ clear_bit(0, &dev->dma_flag);
+ return 0;
+ }
+
+ if (!gamma_dma_is_ready(dev)) {
+ clear_bit(0, &dev->dma_flag);
+ return EBUSY;
+ }
+
+ if (buf->while_locked) {
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Dispatching buffer %d from pid %d"
+ " \"while locked\", but no lock held\n",
+ buf->idx, buf->pid);
+ }
+ } else {
+ if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ atomic_inc(&dma->total_missed_lock);
+ clear_bit(0, &dev->dma_flag);
+ return EBUSY;
+ }
+ }
+
+ if (dev->last_context != buf->context
+ && !(dev->queuelist[buf->context]->flags
+ & _DRM_CONTEXT_PRESERVED)) {
+ /* PRE: dev->last_context != buf->context */
+ if (drm_context_switch(dev, dev->last_context, buf->context)) {
+ drm_clear_next_buffer(dev);
+ drm_free_buffer(dev, buf);
+ }
+ retcode = EBUSY;
+ goto cleanup;
+
+ /* POST: we will wait for the context
+ switch and will dispatch on a later call
+ when dev->last_context == buf->context.
+ NOTE WE HOLD THE LOCK THROUGHOUT THIS
+ TIME! */
+ }
+
+ drm_clear_next_buffer(dev);
+ buf->pending = 1;
+ buf->waiting = 0;
+ buf->list = DRM_LIST_PEND;
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&buf->time_dispatched);
+#endif
+
+ gamma_dma_dispatch(dev, address, length);
+ drm_free_buffer(dev, dma->this_buffer);
+ dma->this_buffer = buf;
+
+ atomic_add(length, &dma->total_bytes);
+ atomic_inc(&dma->total_dmas);
+
+ if (!buf->while_locked && !dev->context_flag && !locked) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+cleanup:
+
+ clear_bit(0, &dev->dma_flag);
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&dma_stop);
+ timespecsub(&dma_stop, &dma_start);
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(&dma_stop)]);
+#endif
+
+ return retcode;
+}
+
+static void gamma_dma_schedule_wrapper(void *dev)
+{
+ gamma_dma_schedule(dev, 0);
+}
+
+int gamma_dma_schedule(drm_device_t *dev, int locked)
+{
+ int next;
+ drm_queue_t *q;
+ drm_buf_t *buf;
+ int retcode = 0;
+ int processed = 0;
+ int missed;
+ int expire = 20;
+ drm_device_dma_t *dma = dev->dma;
+#if DRM_DMA_HISTOGRAM
+ struct timespec schedule_start;
+#endif
+
+ if (test_and_set_bit(0, &dev->interrupt_flag)) {
+ /* Not reentrant */
+ atomic_inc(&dma->total_missed_sched);
+ return EBUSY;
+ }
+ missed = atomic_read(&dma->total_missed_sched);
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&schedule_start);
+#endif
+
+again:
+ if (dev->context_flag) {
+ clear_bit(0, &dev->interrupt_flag);
+ return EBUSY;
+ }
+ if (dma->next_buffer) {
+ /* Unsent buffer that was previously
+ selected, but that couldn't be sent
+ because the lock could not be obtained
+ or the DMA engine wasn't ready. Try
+ again. */
+ atomic_inc(&dma->total_tried);
+ if (!(retcode = gamma_do_dma(dev, locked))) {
+ atomic_inc(&dma->total_hit);
+ ++processed;
+ }
+ } else {
+ do {
+ next = drm_select_queue(dev,
+ gamma_dma_schedule_wrapper);
+ if (next >= 0) {
+ q = dev->queuelist[next];
+ buf = drm_waitlist_get(&q->waitlist);
+ dma->next_buffer = buf;
+ dma->next_queue = q;
+ if (buf && buf->list == DRM_LIST_RECLAIM) {
+ drm_clear_next_buffer(dev);
+ drm_free_buffer(dev, buf);
+ }
+ }
+ } while (next >= 0 && !dma->next_buffer);
+ if (dma->next_buffer) {
+ if (!(retcode = gamma_do_dma(dev, locked))) {
+ ++processed;
+ }
+ }
+ }
+
+ if (--expire) {
+ if (missed != atomic_read(&dma->total_missed_sched)) {
+ atomic_inc(&dma->total_lost);
+ if (gamma_dma_is_ready(dev)) goto again;
+ }
+ if (processed && gamma_dma_is_ready(dev)) {
+ atomic_inc(&dma->total_lost);
+ processed = 0;
+ goto again;
+ }
+ }
+
+ clear_bit(0, &dev->interrupt_flag);
+
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &schedule_start);
+ atomic_inc(&dev->histo.schedule[drm_histogram_slot(&ts)]);
+ }
+#endif
+ return retcode;
+}
+
+static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d)
+{
+ struct proc *p = curproc;
+ unsigned long address;
+ unsigned long length;
+ int must_free = 0;
+ int retcode = 0;
+ int i;
+ int idx;
+ drm_buf_t *buf;
+ drm_buf_t *last_buf = NULL;
+ drm_device_dma_t *dma = dev->dma;
+ static int never;
+
+ /* Turn off interrupt handling */
+ while (test_and_set_bit(0, &dev->interrupt_flag)) {
+ retcode = tsleep(&never, PZERO|PCATCH, "gamp1", 1);
+ if (retcode)
+ return retcode;
+ }
+ if (!(d->flags & _DRM_DMA_WHILE_LOCKED)) {
+ while (!drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ retcode = tsleep(&never, PZERO|PCATCH, "gamp2", 1);
+ if (retcode)
+ return retcode;
+ }
+ ++must_free;
+ }
+ atomic_inc(&dma->total_prio);
+
+ for (i = 0; i < d->send_count; i++) {
+ idx = d->send_indices[i];
+ if (idx < 0 || idx >= dma->buf_count) {
+ DRM_ERROR("Index %d (of %d max)\n",
+ d->send_indices[i], dma->buf_count - 1);
+ continue;
+ }
+ buf = dma->buflist[ idx ];
+ if (buf->pid != p->p_pid) {
+ DRM_ERROR("Process %d using buffer owned by %d\n",
+ p->p_pid, buf->pid);
+ retcode = EINVAL;
+ goto cleanup;
+ }
+ if (buf->list != DRM_LIST_NONE) {
+ DRM_ERROR("Process %d using %d's buffer on list %d\n",
+ p->p_pid, buf->pid, buf->list);
+ retcode = EINVAL;
+ goto cleanup;
+ }
+ /* This isn't a race condition on
+ buf->list, since our concern is the
+ buffer reclaim during the time the
+ process closes the /dev/drm? handle, so
+ it can't also be doing DMA. */
+ buf->list = DRM_LIST_PRIO;
+ buf->used = d->send_sizes[i];
+ buf->context = d->context;
+ buf->while_locked = d->flags & _DRM_DMA_WHILE_LOCKED;
+ address = (unsigned long)buf->address;
+ length = buf->used;
+ if (!length) {
+ DRM_ERROR("0 length buffer\n");
+ }
+ if (buf->pending) {
+ DRM_ERROR("Sending pending buffer:"
+ " buffer %d, offset %d\n",
+ d->send_indices[i], i);
+ retcode = EINVAL;
+ goto cleanup;
+ }
+ if (buf->waiting) {
+ DRM_ERROR("Sending waiting buffer:"
+ " buffer %d, offset %d\n",
+ d->send_indices[i], i);
+ retcode = EINVAL;
+ goto cleanup;
+ }
+ buf->pending = 1;
+
+ if (dev->last_context != buf->context
+ && !(dev->queuelist[buf->context]->flags
+ & _DRM_CONTEXT_PRESERVED)) {
+ atomic_inc(&dev->context_wait);
+ /* PRE: dev->last_context != buf->context */
+ drm_context_switch(dev, dev->last_context,
+ buf->context);
+ /* POST: we will wait for the context
+ switch and will dispatch on a later call
+ when dev->last_context == buf->context.
+ NOTE WE HOLD THE LOCK THROUGHOUT THIS
+ TIME! */
+ retcode = tsleep(&dev->context_wait, PZERO|PCATCH,
+ "gamctx", 0);
+ atomic_dec(&dev->context_wait);
+ if (retcode)
+ goto cleanup;
+ if (dev->last_context != buf->context) {
+ DRM_ERROR("Context mismatch: %d %d\n",
+ dev->last_context,
+ buf->context);
+ }
+ }
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&buf->time_queued);
+ buf->time_dispatched = buf->time_queued;
+#endif
+ gamma_dma_dispatch(dev, address, length);
+ atomic_add(length, &dma->total_bytes);
+ atomic_inc(&dma->total_dmas);
+
+ if (last_buf) {
+ drm_free_buffer(dev, last_buf);
+ }
+ last_buf = buf;
+ }
+
+
+cleanup:
+ if (last_buf) {
+ gamma_dma_ready(dev);
+ drm_free_buffer(dev, last_buf);
+ }
+
+ if (must_free && !dev->context_flag) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+ clear_bit(0, &dev->interrupt_flag);
+ return retcode;
+}
+
+static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
+{
+ struct proc *p = curproc;
+ drm_buf_t *last_buf = NULL;
+ int retcode = 0;
+ drm_device_dma_t *dma = dev->dma;
+
+
+ if ((retcode = drm_dma_enqueue(dev, d))) {
+ return retcode;
+ }
+
+ gamma_dma_schedule(dev, 0);
+
+ if (d->flags & _DRM_DMA_BLOCK) {
+ last_buf = dma->buflist[d->send_indices[d->send_count-1]];
+ atomic_inc(&last_buf->dma_wait);
+ }
+
+ if (d->flags & _DRM_DMA_BLOCK) {
+ DRM_DEBUG("%d waiting\n", p->p_pid);
+ for (;;) {
+ retcode = tsleep(&last_buf->dma_wait, PZERO|PCATCH,
+ "gamdw", 0);
+ if (!last_buf->waiting
+ && !last_buf->pending)
+ break; /* finished */
+ if (retcode)
+ break;
+ }
+
+ DRM_DEBUG("%d running\n", p->p_pid);
+ atomic_dec(&last_buf->dma_wait);
+ if (!retcode
+ || (last_buf->list==DRM_LIST_PEND && !last_buf->pending)) {
+ if (!last_buf->dma_wait) {
+ drm_free_buffer(dev, last_buf);
+ }
+ }
+ if (retcode) {
+ DRM_ERROR("ctx%d w%d p%d c%d i%d l%d %d/%d\n",
+ d->context,
+ last_buf->waiting,
+ last_buf->pending,
+ DRM_WAITCOUNT(dev, d->context),
+ last_buf->idx,
+ last_buf->list,
+ last_buf->pid,
+ p->p_pid);
+ }
+ }
+ return retcode;
+}
+
+int gamma_dma(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ drm_dma_t d;
+
+ d = *(drm_dma_t *) data;
+ DRM_DEBUG("%d %d: %d send, %d req\n",
+ p->p_pid, d.context, d.send_count, d.request_count);
+
+ if (d.context == DRM_KERNEL_CONTEXT || d.context >= dev->queue_slots) {
+ DRM_ERROR("Process %d using context %d\n",
+ p->p_pid, d.context);
+ return EINVAL;
+ }
+ if (d.send_count < 0 || d.send_count > dma->buf_count) {
+ DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n",
+ p->p_pid, d.send_count, dma->buf_count);
+ return EINVAL;
+ }
+ if (d.request_count < 0 || d.request_count > dma->buf_count) {
+ DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
+ p->p_pid, d.request_count, dma->buf_count);
+ return EINVAL;
+ }
+
+ if (d.send_count) {
+ if (d.flags & _DRM_DMA_PRIORITY)
+ retcode = gamma_dma_priority(dev, &d);
+ else
+ retcode = gamma_dma_send_buffers(dev, &d);
+ }
+
+ d.granted_count = 0;
+
+ if (!retcode && d.request_count) {
+ retcode = drm_dma_get_buffers(dev, &d);
+ }
+
+ DRM_DEBUG("%d returning, granted = %d\n",
+ p->p_pid, d.granted_count);
+ *(drm_dma_t *) data = d;
+
+ return retcode;
+}
+
+int gamma_irq_install(drm_device_t *dev, int irq)
+{
+ int rid;
+ int retcode;
+
+ if (!irq) return EINVAL;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ if (dev->irq) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return EBUSY;
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ DRM_DEBUG("%d\n", irq);
+
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma_flag = 0;
+
+ dev->dma->next_buffer = NULL;
+ dev->dma->next_queue = NULL;
+ dev->dma->this_buffer = NULL;
+
+#if 0
+ dev->tq.next = NULL;
+ dev->tq.sync = 0;
+ dev->tq.routine = gamma_dma_schedule_tq_wrapper;
+ dev->tq.data = dev;
+#endif
+ /* Before installing handler */
+ GAMMA_WRITE(GAMMA_GCOMMANDMODE, 0);
+ GAMMA_WRITE(GAMMA_GDMACONTROL, 0);
+
+ /* Install handler */
+ rid = 0;
+ dev->irq = bus_alloc_resource(dev->device, SYS_RES_IRQ, &rid,
+ 0, ~0, 1, RF_SHAREABLE);
+ if (!dev->irq)
+ return ENOENT;
+
+ retcode = bus_setup_intr(dev->device, dev->irq, INTR_TYPE_TTY,
+ gamma_dma_service, dev, &dev->irqh);
+ if (retcode) {
+ bus_release_resource(dev->device, SYS_RES_IRQ, 0, dev->irq);
+ dev->irq = 0;
+ return retcode;
+ }
+
+ /* After installing handler */
+ GAMMA_WRITE(GAMMA_GINTENABLE, 0x2001);
+ GAMMA_WRITE(GAMMA_COMMANDINTENABLE, 0x0008);
+ GAMMA_WRITE(GAMMA_GDELAYTIMER, 0x39090);
+
+ return 0;
+}
+
+int gamma_irq_uninstall(drm_device_t *dev)
+{
+ if (!dev->irq)
+ return EINVAL;
+
+ DRM_DEBUG("%ld\n", rman_get_start(dev->irq));
+
+ GAMMA_WRITE(GAMMA_GDELAYTIMER, 0);
+ GAMMA_WRITE(GAMMA_COMMANDINTENABLE, 0);
+ GAMMA_WRITE(GAMMA_GINTENABLE, 0);
+
+ bus_teardown_intr(dev->device, dev->irq, dev->irqh);
+ bus_release_resource(dev->device, SYS_RES_IRQ, 0, dev->irq);
+ dev->irq = 0;
+
+ return 0;
+}
+
+
+int gamma_control(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_control_t ctl;
+ int retcode;
+
+ ctl = *(drm_control_t *) data;
+
+ switch (ctl.func) {
+ case DRM_INST_HANDLER:
+ if ((retcode = gamma_irq_install(dev, ctl.irq)))
+ return retcode;
+ break;
+ case DRM_UNINST_HANDLER:
+ if ((retcode = gamma_irq_uninstall(dev)))
+ return retcode;
+ break;
+ default:
+ return EINVAL;
+ }
+ return 0;
+}
+
+int gamma_lock(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int ret = 0;
+ drm_lock_t lock;
+ drm_queue_t *q;
+#if DRM_DMA_HISTOGRAM
+ struct timespec start;
+
+ getnanotime(&start);
+ dev->lck_start = start;
+#endif
+
+ lock = *(drm_lock_t *) data;
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ p->p_pid, lock.context);
+ return EINVAL;
+ }
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, p->p_pid, dev->lock.hw_lock->lock,
+ lock.flags);
+
+ if (lock.context < 0 || lock.context >= dev->queue_count)
+ return EINVAL;
+ q = dev->queuelist[lock.context];
+
+ ret = drm_flush_block_and_flush(dev, lock.context, lock.flags);
+
+ if (!ret) {
+ if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
+ != lock.context) {
+ long j = ticks - dev->lock.lock_time;
+
+ if (j > 0 && j <= DRM_LOCK_SLICE) {
+ /* Can't take lock if we just had it and
+ there is contention. */
+ static int never;
+ ret = tsleep(&never, PZERO|PCATCH,
+ "gaml1", j);
+ if (ret)
+ return ret;
+ }
+ }
+ atomic_inc(&dev->lock.lock_queue);
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ ret = EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ lock.context)) {
+ dev->lock.pid = p->p_pid;
+ dev->lock.lock_time = ticks;
+ atomic_inc(&dev->total_locks);
+ atomic_inc(&q->total_locks);
+ break; /* Got lock */
+ }
+
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ ret = tsleep(&dev->lock.lock_queue, PZERO|PCATCH,
+ "gaml2", 0);
+ if (ret)
+ break;
+ }
+ atomic_dec(&dev->lock.lock_queue);
+ }
+
+ drm_flush_unblock(dev, lock.context, lock.flags); /* cleanup phase */
+
+ if (!ret) {
+ if (lock.flags & _DRM_LOCK_READY)
+ gamma_dma_ready(dev);
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ if (gamma_found() == 1) {
+ gamma_dma_quiescent_single(dev);
+ } else {
+ gamma_dma_quiescent_dual(dev);
+ }
+ }
+ }
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &start);
+ atomic_inc(&dev->histo.lacq[drm_histogram_slot(&ts)]);
+ }
+#endif
+
+ return ret;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.c
new file mode 100644
index 000000000..8663a2ac0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.c
@@ -0,0 +1,629 @@
+/* gamma.c -- 3dlabs GMX 2000 driver -*- c -*-
+ * Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#include "drmP.h"
+#include "gamma_drv.h"
+
+#include <pci/pcivar.h>
+
+MODULE_DEPEND(gamma, drm, 1, 1, 1);
+
+#ifndef PCI_DEVICE_ID_3DLABS_GAMMA
+#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
+#endif
+#ifndef PCI_DEVICE_ID_3DLABS_MX
+#define PCI_DEVICE_ID_3DLABS_MX 0x0006
+#endif
+#ifndef PCI_VENDOR_ID_3DLABS
+#define PCI_VENDOR_ID_3DLABS 0x3d3d
+#endif
+
+static int gamma_init(device_t nbdev);
+static void gamma_cleanup(device_t nbdev);
+
+static int gamma_probe(device_t dev)
+{
+ const char *s = 0;
+
+ switch (pci_get_devid(dev)) {
+ case 0x00083d3d:
+ s = "3D Labs Gamma graphics accelerator";
+ break;
+
+ case 0x00063d3d:
+ s = "3D Labs MX graphics accelerator";
+ break;
+ }
+
+ if (s) {
+ device_set_desc(dev, s);
+ return 0;
+ }
+
+ return ENXIO;
+}
+
+static int gamma_attach(device_t dev)
+{
+ gamma_init(dev);
+ return 0;
+}
+
+static int gamma_detach(device_t dev)
+{
+ gamma_cleanup(dev);
+ return 0;
+}
+
+static device_method_t gamma_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, gamma_probe),
+ DEVMETHOD(device_attach, gamma_attach),
+ DEVMETHOD(device_detach, gamma_detach),
+
+ { 0, 0 }
+};
+
+static driver_t gamma_driver = {
+ "drm",
+ gamma_methods,
+ sizeof(drm_device_t),
+};
+
+static devclass_t gamma_devclass;
+#define GAMMA_SOFTC(unit) \
+ ((drm_device_t *) devclass_get_softc(gamma_devclass, unit))
+
+DRIVER_MODULE(if_gamma, pci, gamma_driver, gamma_devclass, 0, 0);
+
+#define GAMMA_NAME "gamma"
+#define GAMMA_DESC "3dlabs GMX 2000"
+#define GAMMA_DATE "20000606"
+#define GAMMA_MAJOR 1
+#define GAMMA_MINOR 0
+#define GAMMA_PATCHLEVEL 0
+
+#define CDEV_MAJOR 200
+
+static struct cdevsw gamma_cdevsw = {
+ /* open */ gamma_open,
+ /* close */ gamma_close,
+ /* read */ drm_read,
+ /* write */ drm_write,
+ /* ioctl */ gamma_ioctl,
+ /* poll */ nopoll,
+ /* mmap */ drm_mmap,
+ /* strategy */ nostrategy,
+ /* name */ "gamma",
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ D_TTY | D_TRACKCLOSE,
+ /* bmaj */ -1
+};
+
+static drm_ioctl_desc_t gamma_ioctls[] = {
+ [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { gamma_version, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { gamma_control, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { drm_addbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { drm_mapbufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { drm_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { drm_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { drm_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { drm_resctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { gamma_dma, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { gamma_lock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { gamma_unlock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
+};
+#define GAMMA_IOCTL_COUNT DRM_ARRAY_SIZE(gamma_ioctls)
+
+static int devices = 0;
+
+static int gamma_setup(drm_device_t *dev)
+{
+ int i;
+
+ device_busy(dev->device);
+
+ atomic_set(&dev->ioctl_count, 0);
+ atomic_set(&dev->vma_count, 0);
+ dev->buf_use = 0;
+ atomic_set(&dev->buf_alloc, 0);
+
+ drm_dma_setup(dev);
+
+ atomic_set(&dev->total_open, 0);
+ atomic_set(&dev->total_close, 0);
+ atomic_set(&dev->total_ioctl, 0);
+ atomic_set(&dev->total_irq, 0);
+ atomic_set(&dev->total_ctx, 0);
+ atomic_set(&dev->total_locks, 0);
+ atomic_set(&dev->total_unlocks, 0);
+ atomic_set(&dev->total_contends, 0);
+ atomic_set(&dev->total_sleeps, 0);
+
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ dev->magiclist[i].head = NULL;
+ dev->magiclist[i].tail = NULL;
+ }
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ dev->vmalist = NULL;
+ dev->lock.hw_lock = NULL;
+ dev->lock.lock_queue = 0;
+ dev->queue_count = 0;
+ dev->queue_reserved = 0;
+ dev->queue_slots = 0;
+ dev->queuelist = NULL;
+ dev->irq = 0;
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma_flag = 0;
+ dev->last_context = 0;
+ dev->last_switch = 0;
+ dev->last_checked = 0;
+ callout_init(&dev->timer);
+ dev->context_wait = 0;
+#if DRM_DMA_HISTO
+ memset(&dev->histo, 0, sizeof(dev->histo));
+#endif
+ timespecclear(&dev->ctx_start);
+ timespecclear(&dev->lck_start);
+
+ dev->buf_rp = dev->buf;
+ dev->buf_wp = dev->buf;
+ dev->buf_end = dev->buf + DRM_BSZ;
+ dev->buf_sigio = NULL;
+
+ DRM_DEBUG("\n");
+
+ /* The kernel's context could be created here, but is now created
+ in drm_dma_enqueue. This is more resource-efficient for
+ hardware that does not do DMA, but may mean that
+ drm_select_queue fails between the time the interrupt is
+ initialized and the time the queues are initialized. */
+
+ return 0;
+}
+
+
+static int
+gamma_takedown(drm_device_t *dev)
+{
+ int i;
+ drm_magic_entry_t *pt, *next;
+ drm_map_t *map;
+ drm_vma_entry_t *vma, *vma_next;
+
+ DRM_DEBUG("\n");
+
+ if (dev->irq) gamma_irq_uninstall(dev);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ callout_stop(&dev->timer);
+
+ if (dev->devname) {
+ drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
+ dev->devname = NULL;
+ }
+
+ if (dev->unique) {
+ drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
+ dev->unique = NULL;
+ dev->unique_len = 0;
+ }
+ /* Clear pid list */
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ for (pt = dev->magiclist[i].head; pt; pt = next) {
+ next = pt->next;
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ }
+ dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
+ }
+
+ /* Clear vma list (only built for debugging) */
+ if (dev->vmalist) {
+ for (vma = dev->vmalist; vma; vma = vma_next) {
+ vma_next = vma->next;
+ drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
+ }
+ dev->vmalist = NULL;
+ }
+
+ /* Clear map area and mtrr information */
+ if (dev->maplist) {
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ switch (map->type) {
+ case _DRM_REGISTERS:
+ case _DRM_FRAME_BUFFER:
+#ifdef CONFIG_MTRR
+ if (map->mtrr >= 0) {
+ int retcode;
+ retcode = mtrr_del(map->mtrr,
+ map->offset,
+ map->size);
+ DRM_DEBUG("mtrr_del = %d\n", retcode);
+ }
+#endif
+ drm_ioremapfree(map->handle, map->size);
+ break;
+ case _DRM_SHM:
+ drm_free_pages((unsigned long)map->handle,
+ drm_order(map->size)
+ - PAGE_SHIFT,
+ DRM_MEM_SAREA);
+ break;
+ case _DRM_AGP:
+ /* Do nothing here, because this is all
+ handled in the AGP/GART driver. */
+ break;
+ }
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ }
+ drm_free(dev->maplist,
+ dev->map_count * sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ }
+
+ if (dev->queuelist) {
+ for (i = 0; i < dev->queue_count; i++) {
+ drm_waitlist_destroy(&dev->queuelist[i]->waitlist);
+ if (dev->queuelist[i]) {
+ drm_free(dev->queuelist[i],
+ sizeof(*dev->queuelist[0]),
+ DRM_MEM_QUEUES);
+ dev->queuelist[i] = NULL;
+ }
+ }
+ drm_free(dev->queuelist,
+ dev->queue_slots * sizeof(*dev->queuelist),
+ DRM_MEM_QUEUES);
+ dev->queuelist = NULL;
+ }
+
+ drm_dma_takedown(dev);
+
+ dev->queue_count = 0;
+ if (dev->lock.hw_lock) {
+ dev->lock.hw_lock = NULL; /* SHM removed */
+ dev->lock.pid = 0;
+ wakeup(&dev->lock.lock_queue);
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ device_unbusy(dev->device);
+
+ return 0;
+}
+
+int gamma_found(void)
+{
+ return devices;
+}
+
+static int
+gamma_find_devices(device_t dev)
+{
+ device_t *children, child;
+ int nchildren, i;
+ int count = 0;
+
+ if (device_get_children(device_get_parent(dev), &children, &nchildren))
+ return 0;
+
+ for (i = 0; i < nchildren; i++) {
+ child = children[i];
+
+ if (pci_get_slot(dev) == pci_get_slot(child) &&
+ pci_get_vendor(child) == PCI_VENDOR_ID_3DLABS &&
+ pci_get_device(child) == PCI_DEVICE_ID_3DLABS_MX) {
+ count++;
+ }
+ }
+ free(children, M_TEMP);
+
+ /* we don't currently support more than two */
+ if (count > 2) count = 2;
+
+ return count;
+}
+
+/* gamma_init is called via gamma_attach at module load time */
+
+static int
+gamma_init(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ DRM_DEBUG("\n");
+
+ memset((void *)dev, 0, sizeof(*dev));
+ simple_lock_init(&dev->count_lock);
+ lockinit(&dev->dev_lock, PZERO, "drmlk", 0, 0);
+
+#if 0 /* XXX use getenv I guess */
+ drm_parse_options(gamma);
+#endif
+ devices = gamma_find_devices(nbdev);
+ if (devices == 0) return -1;
+
+#if 0
+ if ((retcode = misc_register(&gamma_misc))) {
+ DRM_ERROR("Cannot register \"%s\"\n", GAMMA_NAME);
+ return retcode;
+ }
+#endif
+ dev->device = nbdev;
+ dev->devnode = make_dev(&gamma_cdevsw,
+ device_get_unit(nbdev),
+ DRM_DEV_UID,
+ DRM_DEV_GID,
+ DRM_DEV_MODE,
+ GAMMA_NAME);
+ dev->name = GAMMA_NAME;
+
+ drm_mem_init();
+ drm_sysctl_init(dev);
+
+ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d with %d MX devices\n",
+ GAMMA_NAME,
+ GAMMA_MAJOR,
+ GAMMA_MINOR,
+ GAMMA_PATCHLEVEL,
+ GAMMA_DATE,
+ device_get_unit(nbdev),
+ devices);
+
+ return 0;
+}
+
+/* gamma_cleanup is called via gamma_detach at module unload time. */
+
+static void
+gamma_cleanup(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ DRM_DEBUG("\n");
+
+ drm_sysctl_cleanup(dev);
+#if 0
+ if (misc_deregister(&gamma_misc)) {
+ DRM_ERROR("Cannot unload module\n");
+ } else {
+ DRM_INFO("Module unloaded\n");
+ }
+#endif
+ device_busy(dev->device);
+ gamma_takedown(dev);
+}
+
+SYSUNINIT(gamma_cleanup, SI_SUB_DRIVERS, SI_ORDER_ANY, gamma_cleanup, 0);
+
+#if 0
+int gamma_version(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_version_t version;
+ int len;
+
+ copy_from_user_ret(&version,
+ (drm_version_t *)arg,
+ sizeof(version),
+ -EFAULT);
+
+#define DRM_COPY(name,value) \
+ len = strlen(value); \
+ if (len > name##_len) len = name##_len; \
+ name##_len = strlen(value); \
+ if (len && name) { \
+ copy_to_user_ret(name, value, len, -EFAULT); \
+ }
+
+ version.version_major = GAMMA_MAJOR;
+ version.version_minor = GAMMA_MINOR;
+ version.version_patchlevel = GAMMA_PATCHLEVEL;
+
+ DRM_COPY(version.name, GAMMA_NAME);
+ DRM_COPY(version.date, GAMMA_DATE);
+ DRM_COPY(version.desc, GAMMA_DESC);
+
+ copy_to_user_ret((drm_version_t *)arg,
+ &version,
+ sizeof(version),
+ -EFAULT);
+ return 0;
+}
+#endif
+
+int
+gamma_open(dev_t kdev, int flags, int fmt, struct proc *p)
+{
+ drm_device_t *dev = GAMMA_SOFTC(minor(kdev));
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+
+ device_busy(dev->device);
+ if (!(retcode = drm_open_helper(kdev, flags, fmt, p, dev))) {
+ atomic_inc(&dev->total_open);
+ simple_lock(&dev->count_lock);
+ if (!dev->open_count++) {
+ simple_unlock(&dev->count_lock);
+ retcode = gamma_setup(dev);
+ }
+ simple_unlock(&dev->count_lock);
+ }
+ device_unbusy(dev->device);
+
+ return retcode;
+}
+
+int
+gamma_close(dev_t kdev, int flags, int fmt, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+ if (!(retcode = drm_close(kdev, flags, fmt, p))) {
+ atomic_inc(&dev->total_close);
+ simple_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ simple_unlock(&dev->count_lock);
+ return gamma_takedown(dev);
+ }
+ simple_unlock(&dev->count_lock);
+ }
+ return retcode;
+}
+
+/* drm_ioctl is called whenever a process performs an ioctl on /dev/drm. */
+
+int
+gamma_ioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ int nr = DRM_IOCTL_NR(cmd);
+ drm_device_t *dev = kdev->si_drv1;
+ drm_file_t *priv;
+ int retcode = 0;
+ drm_ioctl_desc_t *ioctl;
+ d_ioctl_t *func;
+
+ priv = drm_find_file_by_proc(dev, p);
+ if (!priv) {
+ DRM_DEBUG("can't find authenticator\n");
+ return EINVAL;
+ }
+
+ atomic_inc(&dev->ioctl_count);
+ atomic_inc(&dev->total_ioctl);
+ ++priv->ioctl_count;
+
+ DRM_DEBUG("pid = %d, cmd = 0x%02lx, nr = 0x%02x, auth = %d\n",
+ p->p_pid, cmd, nr, priv->authenticated);
+
+ switch (cmd) {
+ case FIOSETOWN:
+ return fsetown(*(int *)data, &dev->buf_sigio);
+
+ case FIOGETOWN:
+ *(int *) data = fgetown(dev->buf_sigio);
+ return 0;
+ }
+
+ if (nr >= GAMMA_IOCTL_COUNT) {
+ retcode = EINVAL;
+ } else {
+ ioctl = &gamma_ioctls[nr];
+ func = ioctl->func;
+
+ if (!func) {
+ DRM_DEBUG("no function\n");
+ retcode = EINVAL;
+ } else if ((ioctl->root_only && suser(p))
+ || (ioctl->auth_needed && !priv->authenticated)) {
+ retcode = EACCES;
+ } else {
+ retcode = (func)(kdev, cmd, data, flags, p);
+ }
+ }
+
+ atomic_dec(&dev->ioctl_count);
+ return retcode;
+}
+
+int gamma_unlock(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_lock_t *lockp = (drm_lock_t *) data;
+
+ if (lockp->context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ p->p_pid, lockp->context);
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("%d frees lock (%d holds)\n",
+ lockp->context,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ atomic_inc(&dev->total_unlocks);
+ if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
+ atomic_inc(&dev->total_contends);
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
+ gamma_dma_schedule(dev, 1);
+ if (!dev->context_flag) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &dev->lck_start);
+ atomic_inc(&dev->histo.lhld[drm_histogram_slot(&ts)]);
+ }
+#endif
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.h
new file mode 100644
index 000000000..b7c6df5dc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/gamma/gamma_drv.h
@@ -0,0 +1,48 @@
+/* gamma_drv.h -- Private header for 3dlabs GMX 2000 driver -*- c -*-
+ * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#ifndef _GAMMA_DRV_H_
+#define _GAMMA_DRV_H_
+
+ /* gamma_drv.c */
+extern d_open_t gamma_open;
+extern d_close_t gamma_close;
+extern d_ioctl_t gamma_ioctl;
+extern d_ioctl_t gamma_version;
+extern d_ioctl_t gamma_dma;
+extern d_ioctl_t gamma_lock;
+extern d_ioctl_t gamma_unlock;
+extern d_ioctl_t gamma_control;
+
+ /* gamma_dma.c */
+extern int gamma_dma_schedule(drm_device_t *dev, int locked);
+extern int gamma_irq_install(drm_device_t *dev, int irq);
+extern int gamma_irq_uninstall(drm_device_t *dev);
+extern int gamma_found(void);
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h
new file mode 100644
index 000000000..4c8e09f6a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/i810_drm.h
@@ -0,0 +1,188 @@
+#ifndef _I810_DRM_H_
+#define _I810_DRM_H_
+
+/* WARNING: These defines must be the same as what the Xserver uses.
+ * if you change them, you must change the defines in the Xserver.
+ */
+
+#ifndef _I810_DEFINES_
+#define _I810_DEFINES_
+
+#define I810_DMA_BUF_ORDER 12
+#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
+#define I810_DMA_BUF_NR 256
+#define I810_NR_SAREA_CLIPRECTS 8
+
+/* Each region is a minimum of 64k, and there are at most 64 of them.
+ */
+#define I810_NR_TEX_REGIONS 64
+#define I810_LOG_MIN_TEX_REGION_SIZE 16
+#endif
+
+#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
+#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
+#define I810_UPLOAD_CTX 0x4
+#define I810_UPLOAD_BUFFERS 0x8
+#define I810_UPLOAD_TEX0 0x10
+#define I810_UPLOAD_TEX1 0x20
+#define I810_UPLOAD_CLIPRECTS 0x40
+
+
+/* Indices into buf.Setup where various bits of state are mirrored per
+ * context and per buffer. These can be fired at the card as a unit,
+ * or in a piecewise fashion as required.
+ */
+
+/* Destbuffer state
+ * - backbuffer linear offset and pitch -- invarient in the current dri
+ * - zbuffer linear offset and pitch -- also invarient
+ * - drawing origin in back and depth buffers.
+ *
+ * Keep the depth/back buffer state here to acommodate private buffers
+ * in the future.
+ */
+#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
+#define I810_DESTREG_DI1 1
+#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
+#define I810_DESTREG_DV1 3
+#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
+#define I810_DESTREG_DR1 5
+#define I810_DESTREG_DR2 6
+#define I810_DESTREG_DR3 7
+#define I810_DESTREG_DR4 8
+#define I810_DEST_SETUP_SIZE 10
+
+/* Context state
+ */
+#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
+#define I810_CTXREG_CF1 1
+#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
+#define I810_CTXREG_ST1 3
+#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
+#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
+#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
+#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
+#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
+#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
+#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
+#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
+#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
+#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
+#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
+#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
+#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
+#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
+#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
+#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
+#define I810_CTX_SETUP_SIZE 20
+
+/* Texture state (per tex unit)
+ */
+#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
+#define I810_TEXREG_MI1 1
+#define I810_TEXREG_MI2 2
+#define I810_TEXREG_MI3 3
+#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
+#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
+#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
+#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
+#define I810_TEX_SETUP_SIZE 8
+
+#define I810_FRONT 0x1
+#define I810_BACK 0x2
+#define I810_DEPTH 0x4
+
+
+typedef struct _drm_i810_init {
+ enum {
+ I810_INIT_DMA = 0x01,
+ I810_CLEANUP_DMA = 0x02
+ } func;
+ int ring_map_idx;
+ int buffer_map_idx;
+ int sarea_priv_offset;
+ unsigned int ring_start;
+ unsigned int ring_end;
+ unsigned int ring_size;
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+ unsigned int w;
+ unsigned int h;
+ unsigned int pitch;
+ unsigned int pitch_bits;
+} drm_i810_init_t;
+
+/* Warning: If you change the SAREA structure you must change the Xserver
+ * structure as well */
+
+typedef struct _drm_i810_tex_region {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} drm_i810_tex_region_t;
+
+typedef struct _drm_i810_sarea {
+ unsigned int ContextState[I810_CTX_SETUP_SIZE];
+ unsigned int BufferState[I810_DEST_SETUP_SIZE];
+ unsigned int TexState[2][I810_TEX_SETUP_SIZE];
+ unsigned int dirty;
+
+ unsigned int nbox;
+ drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS];
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+
+ drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS+1];
+ /* Last elt is sentinal */
+ int texAge; /* last time texture was uploaded */
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+ int ctxOwner; /* last context to upload state */
+
+ int vertex_prim;
+
+} drm_i810_sarea_t;
+
+typedef struct _drm_i810_clear {
+ int clear_color;
+ int clear_depth;
+ int flags;
+} drm_i810_clear_t;
+
+
+
+/* These may be placeholders if we have more cliprects than
+ * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
+ * false, indicating that the buffer will be dispatched again with a
+ * new set of cliprects.
+ */
+typedef struct _drm_i810_vertex {
+ int idx; /* buffer index */
+ int used; /* nr bytes in use */
+ int discard; /* client is finished with the buffer? */
+} drm_i810_vertex_t;
+
+typedef struct drm_i810_dma {
+ void *virtual;
+ int request_idx;
+ int request_size;
+ int granted;
+} drm_i810_dma_t;
+
+#endif /* _I810_DRM_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/Makefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/Makefile
new file mode 100644
index 000000000..226728b5f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/Makefile
@@ -0,0 +1,16 @@
+# $FreeBSD$
+
+KMOD = mga
+SRCS = mga_drv.c mga_context.c mga_state.c mga_bufs.c mga_dma.c
+SRCS += device_if.h bus_if.h pci_if.h
+CFLAGS += ${DEBUG_FLAGS} -I..
+KERN = /usr/src/sys
+KMODDEPS = drm
+
+@:
+ ln -sf /sys @
+
+machine:
+ ln -sf /sys/i386/include machine
+
+.include <bsd.kmod.mk>
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_bufs.c
new file mode 100644
index 000000000..4ae05181b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_bufs.c
@@ -0,0 +1,604 @@
+/* mga_bufs.c -- IOCTLs to manage buffers
+ * Created: Thu Jan 6 01:47:26 2000 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ *
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "mga_drv.h"
+#include <sys/mman.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+#include <vm/vm_extern.h>
+#include <vm/vm_map.h>
+
+
+static int
+mga_addbufs_agp(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ drm_buf_entry_t *entry;
+ drm_buf_t *buf;
+ unsigned long offset;
+ unsigned long agp_offset;
+ int count;
+ int order;
+ int size;
+ int alignment;
+ int page_order;
+ int total;
+ int byte_count;
+ int i;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_desc_t *) data;
+
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+ agp_offset = request.agp_start;
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? round_page(size) :size;
+ page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
+ total = PAGE_SIZE << page_order;
+ byte_count = 0;
+
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
+ DRM_DEBUG("byte_count: %d\n", byte_count);
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return EINVAL;
+ if (dev->queue_count) return EBUSY; /* Not while in use */
+ simple_lock(&dev->count_lock);
+ if (dev->buf_use) {
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ atomic_inc(&dev->buf_alloc);
+ simple_unlock(&dev->count_lock);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ entry = &dma->bufs[order];
+ if (entry->buf_count) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM; /* May only call once for each order */
+ }
+
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ if (!entry->buflist) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM;
+ }
+ memset(entry->buflist, 0, count * sizeof(*entry->buflist));
+
+ entry->buf_size = size;
+ entry->page_order = page_order;
+ offset = 0;
+
+
+ while(entry->buf_count < count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+
+ DRM_DEBUG("offset : %ld\n", offset);
+
+ buf->offset = offset; /* Hrm */
+ buf->bus_address = dev->agp->base + agp_offset + offset;
+ buf->address = (void *)(agp_offset + offset + dev->agp->base);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ buf->dma_wait = 0;
+ buf->pid = 0;
+
+ buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS);
+ buf->dev_priv_size = sizeof(drm_mga_buf_priv_t);
+
+#if DRM_DMA_HISTOGRAM
+ timespecclear(&buf->time_queued);
+ timespecclear(&buf->time_dispatched);
+ timespecclear(&buf->time_completed);
+ timespecclear(&buf->time_freed);
+#endif
+ offset = offset + alignment;
+ entry->buf_count++;
+ byte_count += PAGE_SIZE << page_order;
+
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
+ }
+
+ dma->buflist = drm_realloc(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ (dma->buf_count + entry->buf_count)
+ * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
+ dma->buflist[i] = &entry->buflist[i - dma->buf_count];
+
+ dma->buf_count += entry->buf_count;
+
+ DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
+
+ dma->byte_count += byte_count;
+
+ DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
+
+ drm_freelist_create(&entry->freelist, entry->buf_count);
+ for (i = 0; i < entry->buf_count; i++) {
+ drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
+ }
+
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ request.count = entry->buf_count;
+ request.size = size;
+
+ *(drm_buf_desc_t *) data = request;
+
+ atomic_dec(&dev->buf_alloc);
+
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
+ DRM_DEBUG("byte_count: %d\n", byte_count);
+
+ dma->flags = _DRM_DMA_USE_AGP;
+
+ DRM_DEBUG("dma->flags : %x\n", dma->flags);
+
+ return 0;
+}
+
+static int
+mga_addbufs_pci(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ int count;
+ int order;
+ int size;
+ int total;
+ int page_order;
+ drm_buf_entry_t *entry;
+ unsigned long page;
+ drm_buf_t *buf;
+ int alignment;
+ unsigned long offset;
+ int i;
+ int byte_count;
+ int page_count;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_desc_t *) data;
+
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+
+ DRM_DEBUG("count = %d, size = %d (%d), order = %d, queue_count = %d\n",
+ request.count, request.size, size, order, dev->queue_count);
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return EINVAL;
+ if (dev->queue_count) return EBUSY; /* Not while in use */
+
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? round_page(size) :size;
+ page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
+ total = PAGE_SIZE << page_order;
+
+ simple_lock(&dev->count_lock);
+ if (dev->buf_use) {
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ atomic_inc(&dev->buf_alloc);
+ simple_unlock(&dev->count_lock);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ entry = &dma->bufs[order];
+ if (entry->buf_count) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM; /* May only call once for each order */
+ }
+
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ if (!entry->buflist) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM;
+ }
+ memset(entry->buflist, 0, count * sizeof(*entry->buflist));
+
+ entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
+ DRM_MEM_SEGS);
+ if (!entry->seglist) {
+ drm_free(entry->buflist,
+ count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ atomic_dec(&dev->buf_alloc);
+ return ENOMEM;
+ }
+ memset(entry->seglist, 0, count * sizeof(*entry->seglist));
+
+ dma->pagelist = drm_realloc(dma->pagelist,
+ dma->page_count * sizeof(*dma->pagelist),
+ (dma->page_count + (count << page_order))
+ * sizeof(*dma->pagelist),
+ DRM_MEM_PAGES);
+ DRM_DEBUG("pagelist: %d entries\n",
+ dma->page_count + (count << page_order));
+
+
+ entry->buf_size = size;
+ entry->page_order = page_order;
+ byte_count = 0;
+ page_count = 0;
+ while (entry->buf_count < count) {
+ if (!(page = drm_alloc_pages(page_order, DRM_MEM_DMA))) break;
+ entry->seglist[entry->seg_count++] = page;
+ for (i = 0; i < (1 << page_order); i++) {
+ DRM_DEBUG("page %d @ 0x%08lx\n",
+ dma->page_count + page_count,
+ page + PAGE_SIZE * i);
+ dma->pagelist[dma->page_count + page_count++]
+ = page + PAGE_SIZE * i;
+ }
+ for (offset = 0;
+ offset + size <= total && entry->buf_count < count;
+ offset += alignment, ++entry->buf_count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+ buf->offset = (dma->byte_count + byte_count + offset);
+ buf->address = (void *)(page + offset);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ buf->dma_wait = 0;
+ buf->pid = 0;
+#if DRM_DMA_HISTOGRAM
+ timespecclear(&buf->time_queued);
+ timespecclear(&buf->time_dispatched);
+ timespecclear(&buf->time_completed);
+ timespecclear(&buf->time_freed);
+#endif
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
+ }
+ byte_count += PAGE_SIZE << page_order;
+ }
+
+ dma->buflist = drm_realloc(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ (dma->buf_count + entry->buf_count)
+ * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
+ dma->buflist[i] = &entry->buflist[i - dma->buf_count];
+
+ dma->buf_count += entry->buf_count;
+ dma->seg_count += entry->seg_count;
+ dma->page_count += entry->seg_count << page_order;
+ dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
+
+ drm_freelist_create(&entry->freelist, entry->buf_count);
+ for (i = 0; i < entry->buf_count; i++) {
+ drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
+ }
+
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ request.count = entry->buf_count;
+ request.size = size;
+
+ *(drm_buf_desc_t *) data = request;
+
+ atomic_dec(&dev->buf_alloc);
+ return 0;
+}
+
+int
+mga_addbufs(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_buf_desc_t request;
+
+ request = *(drm_buf_desc_t *) data;
+
+ if(request.flags & _DRM_AGP_BUFFER)
+ return mga_addbufs_agp(kdev, cmd, data, flags, p);
+ else
+ return mga_addbufs_pci(kdev, cmd, data, flags, p);
+}
+
+int
+mga_infobufs(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_info_t request;
+ int i;
+ int count;
+ int error;
+
+ if (!dma) return EINVAL;
+
+ simple_lock(&dev->count_lock);
+ if (atomic_read(&dev->buf_alloc)) {
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ ++dev->buf_use; /* Can't allocate more after this call */
+ simple_unlock(&dev->count_lock);
+
+ request = *(drm_buf_info_t *) data;
+
+ for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) {
+ if (dma->bufs[i].buf_count) ++count;
+ }
+
+ DRM_DEBUG("count = %d\n", count);
+
+ if (request.count >= count) {
+ for (i = 0, count = 0; i < DRM_MAX_ORDER+1; i++) {
+ if (dma->bufs[i].buf_count) {
+ error = copyout(&dma->bufs[i].buf_count,
+ &request.list[count].count,
+ sizeof(dma->bufs[0]
+ .buf_count));
+ if (error) return error;
+ error = copyout(&dma->bufs[i].buf_size,
+ &request.list[count].size,
+ sizeof(dma->bufs[0]
+ .buf_size));
+ if (error) return error;
+ error = copyout(&dma->bufs[i]
+ .freelist.low_mark,
+ &request.list[count].low_mark,
+ sizeof(dma->bufs[0]
+ .freelist.low_mark));
+ if (error) return error;
+ error = copyout(&dma->bufs[i]
+ .freelist.high_mark,
+ &request.list[count].high_mark,
+ sizeof(dma->bufs[0]
+ .freelist.high_mark));
+ if (error) return error;
+ DRM_DEBUG("%d %d %d %d %d\n",
+ i,
+ dma->bufs[i].buf_count,
+ dma->bufs[i].buf_size,
+ dma->bufs[i].freelist.low_mark,
+ dma->bufs[i].freelist.high_mark);
+ ++count;
+ }
+ }
+ }
+ request.count = count;
+
+ *(drm_buf_info_t *) data = request;
+
+ return 0;
+}
+
+int
+mga_markbufs(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ int order;
+ drm_buf_entry_t *entry;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_desc_t *) data;
+
+ DRM_DEBUG("%d, %d, %d\n",
+ request.size, request.low_mark, request.high_mark);
+ order = drm_order(request.size);
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return EINVAL;
+ entry = &dma->bufs[order];
+
+ if (request.low_mark < 0 || request.low_mark > entry->buf_count)
+ return EINVAL;
+ if (request.high_mark < 0 || request.high_mark > entry->buf_count)
+ return EINVAL;
+
+ entry->freelist.low_mark = request.low_mark;
+ entry->freelist.high_mark = request.high_mark;
+
+ return 0;
+}
+
+int
+mga_freebufs(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_free_t request;
+ int i;
+ int error;
+ int idx;
+ drm_buf_t *buf;
+
+ if (!dma) return EINVAL;
+
+ request = *(drm_buf_free_t *) data;
+
+ DRM_DEBUG("%d\n", request.count);
+ for (i = 0; i < request.count; i++) {
+ error = copyin(&request.list[i],
+ &idx,
+ sizeof(idx));
+ if (error) return error;
+ if (idx < 0 || idx >= dma->buf_count) {
+ DRM_ERROR("Index %d (of %d max)\n",
+ idx, dma->buf_count - 1);
+ return EINVAL;
+ }
+ buf = dma->buflist[idx];
+ if (buf->pid != p->p_pid) {
+ DRM_ERROR("Process %d freeing buffer owned by %d\n",
+ p->p_pid, buf->pid);
+ return EINVAL;
+ }
+ drm_free_buffer(dev, buf);
+ }
+
+ return 0;
+}
+
+int
+mga_mapbufs(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ const int zero = 0;
+ vm_offset_t virtual;
+ vm_offset_t address;
+ drm_buf_map_t request;
+ int i;
+
+ if (!dma) return EINVAL;
+
+ DRM_DEBUG("\n");
+
+ simple_lock(&dev->count_lock);
+ if (atomic_read(&dev->buf_alloc)) {
+ simple_unlock(&dev->count_lock);
+ DRM_DEBUG("Busy\n");
+ return EBUSY;
+ }
+ ++dev->buf_use; /* Can't allocate more after this call */
+ simple_unlock(&dev->count_lock);
+
+ request = *(drm_buf_map_t *) data;
+
+ DRM_DEBUG("mga_mapbufs\n");
+ DRM_DEBUG("dma->flags : %x\n", dma->flags);
+
+ if (request.count >= dma->buf_count) {
+ if(dma->flags & _DRM_DMA_USE_AGP) {
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_map_t *map = NULL;
+
+ map = dev->maplist[dev_priv->buffer_map_idx];
+ if (!map) {
+ DRM_DEBUG("map is null\n");
+ retcode = EINVAL;
+ goto done;
+ }
+
+ DRM_DEBUG("map->offset : %lx\n", map->offset);
+ DRM_DEBUG("map->size : %lx\n", map->size);
+ DRM_DEBUG("map->type : %d\n", map->type);
+ DRM_DEBUG("map->flags : %x\n", map->flags);
+ DRM_DEBUG("map->handle : %p\n", map->handle);
+ DRM_DEBUG("map->mtrr : %d\n", map->mtrr);
+ virtual = 0;
+ retcode = vm_mmap(&p->p_vmspace->vm_map,
+ &virtual,
+ map->size,
+ PROT_READ|PROT_WRITE, VM_PROT_ALL,
+ MAP_SHARED,
+ SLIST_FIRST(&kdev->si_hlist),
+ map->offset);
+ } else {
+ virtual = 0;
+ retcode = vm_mmap(&p->p_vmspace->vm_map,
+ &virtual,
+ round_page(dma->byte_count),
+ PROT_READ|PROT_WRITE, VM_PROT_ALL,
+ MAP_SHARED,
+ SLIST_FIRST(&kdev->si_hlist),
+ 0);
+ }
+ if (retcode) {
+ /* Real error */
+ DRM_DEBUG("mmap error\n");
+ goto done;
+ }
+ request.virtual = (void *)virtual;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ retcode = copyout(&dma->buflist[i]->idx,
+ &request.list[i].idx,
+ sizeof(request.list[0].idx));
+ if (retcode) goto done;
+ retcode = copyout(&dma->buflist[i]->total,
+ &request.list[i].total,
+ sizeof(request.list[0].total));
+ if (retcode) goto done;
+ retcode = copyout(&zero,
+ &request.list[i].used,
+ sizeof(request.list[0].used));
+ if (retcode) goto done;
+ address = virtual + dma->buflist[i]->offset;
+ retcode = copyout(&address,
+ &request.list[i].address,
+ sizeof(address));
+ if (retcode) goto done;
+ }
+ }
+ done:
+ request.count = dma->buf_count;
+ DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
+
+ *(drm_buf_map_t *) data = request;
+
+ DRM_DEBUG("retcode : %d\n", retcode);
+
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_context.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_context.c
new file mode 100644
index 000000000..63f1b42b1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_context.c
@@ -0,0 +1,196 @@
+/* mga_context.c -- IOCTLs for mga contexts
+ * Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "mga_drv.h"
+
+static int mga_alloc_queue(drm_device_t *dev)
+{
+ int temp = drm_ctxbitmap_next(dev);
+ DRM_DEBUG("mga_alloc_queue: %d\n", temp);
+ return temp;
+}
+
+int mga_context_switch(drm_device_t *dev, int old, int new)
+{
+ char buf[64];
+
+ atomic_inc(&dev->total_ctx);
+
+ if (test_and_set_bit(0, &dev->context_flag)) {
+ DRM_ERROR("Reentering -- FIXME\n");
+ return EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&dev->ctx_start);
+#endif
+
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
+
+ if (new == dev->last_context) {
+ clear_bit(0, &dev->context_flag);
+ return 0;
+ }
+
+ if (drm_flags & DRM_FLAG_NOCTX) {
+ mga_context_switch_complete(dev, new);
+ } else {
+ sprintf(buf, "C %d %d\n", old, new);
+ drm_write_string(dev, buf);
+ }
+
+ return 0;
+}
+
+int mga_context_switch_complete(drm_device_t *dev, int new)
+{
+ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
+ dev->last_switch = ticks;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Lock isn't held after context switch\n");
+ }
+
+ /* If a context switch is ever initiated
+ when the kernel holds the lock, release
+ that lock here. */
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &dev->lck_start);
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(&ts)]);
+ }
+#endif
+ clear_bit(0, &dev->context_flag);
+ wakeup(&dev->context_wait);
+
+ return 0;
+}
+
+int
+mga_resctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t ctx;
+ int i, error;
+
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
+ res = *(drm_ctx_res_t *) data;
+ if (res.count >= DRM_RESERVED_CONTEXTS) {
+ memset(&ctx, 0, sizeof(ctx));
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ ctx.handle = i;
+ error = copyout(&i, &res.contexts[i], sizeof(i));
+ if (error) return error;
+ }
+ }
+ res.count = DRM_RESERVED_CONTEXTS;
+ *(drm_ctx_res_t *) data = res;
+ return 0;
+}
+
+int
+mga_addctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ if ((ctx.handle = mga_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
+ /* Skip kernel's context and get a new one. */
+ ctx.handle = mga_alloc_queue(dev);
+ }
+ if (ctx.handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
+ /* Should this return EBUSY instead? */
+ return ENOMEM;
+ }
+ DRM_DEBUG("%d\n", ctx.handle);
+ *(drm_ctx_t *) data = ctx;
+ return 0;
+}
+
+int
+mga_modctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ /* This does nothing for the mga */
+ return 0;
+}
+
+int mga_getctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ /* This is 0, because we don't hanlde any context flags */
+ ctx.flags = 0;
+ *(drm_ctx_t *) data = ctx;
+ return 0;
+}
+
+int mga_switchctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ return mga_context_switch(dev, dev->last_context, ctx.handle);
+}
+
+int mga_newctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ mga_context_switch_complete(dev, ctx.handle);
+
+ return 0;
+}
+
+int mga_rmctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ if(ctx.handle != DRM_KERNEL_CONTEXT) {
+ drm_ctxbitmap_free(dev, ctx.handle);
+ }
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_dma.c
new file mode 100644
index 000000000..7055d28da
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_dma.c
@@ -0,0 +1,1106 @@
+/* mga_dma.c -- DMA support for mga g200/g400
+ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "mga_drv.h"
+
+#include <machine/bus.h>
+#include <machine/resource.h>
+#include <sys/rman.h>
+#include <vm/vm.h>
+#include <vm/pmap.h>
+
+#define MGA_REG(reg) 2
+#define MGA_BASE(reg) ((unsigned long) \
+ ((drm_device_t *)dev)->maplist[MGA_REG(reg)]->handle)
+#define MGA_ADDR(reg) (MGA_BASE(reg) + reg)
+#define MGA_DEREF(reg) *(__volatile__ int *)MGA_ADDR(reg)
+#define MGA_READ(reg) MGA_DEREF(reg)
+#define MGA_WRITE(reg,val) do { MGA_DEREF(reg) = val; } while (0)
+
+#define PDEA_pagpxfer_enable 0x2
+
+static int mga_flush_queue(drm_device_t *dev);
+
+static unsigned long mga_alloc_page(drm_device_t *dev)
+{
+ unsigned long address;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ address = (unsigned long) drm_alloc(PAGE_SIZE, DRM_MEM_DMA);
+ if(address == 0UL) {
+ return 0;
+ }
+
+ return address;
+}
+
+static void mga_free_page(drm_device_t *dev, unsigned long page)
+{
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(page == 0UL) {
+ return;
+ }
+ drm_free((void *) page, PAGE_SIZE, DRM_MEM_DMA);
+ return;
+}
+
+static void mga_delay(void)
+{
+ return;
+}
+
+void mga_flush_write_combine(void)
+{
+ int xchangeDummy;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ __asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy));
+ __asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;"
+ " movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;"
+ " pop %%eax" : /* no outputs */ : /* no inputs */ );
+}
+
+/* These are two age tags that will never be sent to
+ * the hardware */
+#define MGA_BUF_USED 0xffffffff
+#define MGA_BUF_FREE 0
+
+static int mga_freelist_init(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_freelist_t *item;
+ int i;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+ if(dev_priv->head == NULL) return ENOMEM;
+ memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t));
+ dev_priv->head->age = MGA_BUF_USED;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[ i ];
+ buf_priv = buf->dev_private;
+ item = drm_alloc(sizeof(drm_mga_freelist_t),
+ DRM_MEM_DRIVER);
+ if(item == NULL) return ENOMEM;
+ memset(item, 0, sizeof(drm_mga_freelist_t));
+ item->age = MGA_BUF_FREE;
+ item->prev = dev_priv->head;
+ item->next = dev_priv->head->next;
+ if(dev_priv->head->next != NULL)
+ dev_priv->head->next->prev = item;
+ if(item->next == NULL) dev_priv->tail = item;
+ item->buf = buf;
+ buf_priv->my_freelist = item;
+ buf_priv->discard = 0;
+ buf_priv->dispatched = 0;
+ dev_priv->head->next = item;
+ }
+
+ return 0;
+}
+
+static void mga_freelist_cleanup(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_freelist_t *item;
+ drm_mga_freelist_t *prev;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ item = dev_priv->head;
+ while(item) {
+ prev = item;
+ item = item->next;
+ drm_free(prev, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+ }
+
+ dev_priv->head = dev_priv->tail = NULL;
+}
+
+/* Frees dispatch lock */
+static __inline void mga_dma_quiescent(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned long end;
+ int i;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ end = ticks + (hz*3);
+ while(1) {
+ if(!test_and_set_bit(MGA_IN_DISPATCH,
+ &dev_priv->dispatch_status)) {
+ break;
+ }
+ if((signed)(end - ticks) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup\n");
+ goto out_nolock;
+ }
+ for (i = 0 ; i < 2000 ; i++) mga_delay();
+ }
+ end = ticks + (hz*3);
+ DRM_DEBUG("quiescent status : %x\n", MGA_READ(MGAREG_STATUS));
+ while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
+ if((signed)(end - ticks) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup\n");
+ goto out_status;
+ }
+ for (i = 0 ; i < 2000 ; i++) mga_delay();
+ }
+ sarea_priv->dirty |= MGA_DMA_FLUSH;
+
+out_status:
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+out_nolock:
+}
+
+static void mga_reset_freelist(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ int i;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[ i ];
+ buf_priv = buf->dev_private;
+ buf_priv->my_freelist->age = MGA_BUF_FREE;
+ }
+}
+
+/* Least recently used :
+ * These operations are not atomic b/c they are protected by the
+ * hardware lock */
+
+drm_buf_t *mga_freelist_get(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_freelist_t *prev;
+ drm_mga_freelist_t *next;
+ static int failed = 0;
+ int ret, s;
+
+ DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__,
+ dev_priv->tail->age, dev_priv->last_prim_age);
+
+ if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) {
+ DRM_DEBUG("I'm waiting on the freelist!!! %d\n",
+ dev_priv->last_prim_age);
+ s = splsofttq();
+ set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
+ for (;;) {
+ mga_dma_schedule(dev, 0);
+ if(!test_bit(MGA_IN_GETBUF,
+ &dev_priv->dispatch_status))
+ break;
+ atomic_inc(&dev->total_sleeps);
+ ret = tsleep(&dev_priv->buf_queue, PZERO|PCATCH,
+ "mgafg", 0);
+ if (ret) {
+ clear_bit(MGA_IN_GETBUF,
+ &dev_priv->dispatch_status);
+ splx(s);
+ goto failed_getbuf;
+ }
+ }
+ splx(s);
+ }
+
+ if(dev_priv->tail->age < dev_priv->last_prim_age) {
+ prev = dev_priv->tail->prev;
+ next = dev_priv->tail;
+ prev->next = NULL;
+ next->prev = next->next = NULL;
+ dev_priv->tail = prev;
+ next->age = MGA_BUF_USED;
+ failed = 0;
+ return next->buf;
+ }
+
+failed_getbuf:
+ failed++;
+ return NULL;
+}
+
+int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf)
+{
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+ drm_mga_freelist_t *prev;
+ drm_mga_freelist_t *head;
+ drm_mga_freelist_t *next;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(buf_priv->my_freelist->age == MGA_BUF_USED) {
+ /* Discarded buffer, put it on the tail */
+ next = buf_priv->my_freelist;
+ next->age = MGA_BUF_FREE;
+ prev = dev_priv->tail;
+ prev->next = next;
+ next->prev = prev;
+ next->next = NULL;
+ dev_priv->tail = next;
+ DRM_DEBUG("Discarded\n");
+ } else {
+ /* Normally aged buffer, put it on the head + 1,
+ * as the real head is a sentinal element
+ */
+ next = buf_priv->my_freelist;
+ head = dev_priv->head;
+ prev = head->next;
+ head->next = next;
+ prev->prev = next;
+ next->prev = head;
+ next->next = prev;
+ }
+
+ return 0;
+}
+
+static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_prim_buf_t *prim_buffer;
+ int i, temp, size_of_buf;
+ int offset = init->reserved_map_agpstart;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) /
+ PAGE_SIZE) * PAGE_SIZE;
+ size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS;
+ dev_priv->warp_ucode_size = init->warp_ucode_size;
+ dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) *
+ (MGA_NUM_PRIM_BUFS + 1),
+ DRM_MEM_DRIVER);
+ if(dev_priv->prim_bufs == NULL) {
+ DRM_ERROR("Unable to allocate memory for prim_buf\n");
+ return ENOMEM;
+ }
+ memset(dev_priv->prim_bufs,
+ 0, sizeof(drm_mga_prim_buf_t *) * (MGA_NUM_PRIM_BUFS + 1));
+
+ temp = init->warp_ucode_size + dev_priv->primary_size;
+ temp = ((temp + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
+
+ dev_priv->ioremap = drm_ioremap(dev->agp->base + offset,
+ temp);
+ if(dev_priv->ioremap == NULL) {
+ DRM_DEBUG("Ioremap failed\n");
+ return ENOMEM;
+ }
+ dev_priv->wait_queue = 0;
+
+ for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) {
+ prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t),
+ DRM_MEM_DRIVER);
+ if(prim_buffer == NULL) return ENOMEM;
+ memset(prim_buffer, 0, sizeof(drm_mga_prim_buf_t));
+ prim_buffer->phys_head = offset + dev->agp->base;
+ prim_buffer->current_dma_ptr =
+ prim_buffer->head =
+ (u_int32_t *) (dev_priv->ioremap +
+ offset -
+ init->reserved_map_agpstart);
+ prim_buffer->num_dwords = 0;
+ prim_buffer->max_dwords = size_of_buf / sizeof(u_int32_t);
+ prim_buffer->max_dwords -= 5; /* Leave room for the softrap */
+ prim_buffer->sec_used = 0;
+ prim_buffer->idx = i;
+ prim_buffer->prim_age = i + 1;
+ offset = offset + size_of_buf;
+ dev_priv->prim_bufs[i] = prim_buffer;
+ }
+ dev_priv->current_prim_idx = 0;
+ dev_priv->next_prim =
+ dev_priv->last_prim =
+ dev_priv->current_prim =
+ dev_priv->prim_bufs[0];
+ dev_priv->next_prim_age = 2;
+ dev_priv->last_prim_age = 1;
+ set_bit(MGA_BUF_IN_USE, &dev_priv->current_prim->buffer_status);
+ return 0;
+}
+
+static void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ int use_agp = PDEA_pagpxfer_enable;
+ unsigned long end;
+ int i;
+ int next_idx;
+ PRIMLOCALS;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ dev_priv->last_prim = prim;
+
+ /* We never check for overflow, b/c there is always room */
+ PRIMPTR(prim);
+ if(num_dwords <= 0) {
+ DRM_DEBUG("num_dwords == 0 when dispatched\n");
+ goto out_prim_wait;
+ }
+ PRIMOUTREG( MGAREG_DMAPAD, 0);
+ PRIMOUTREG( MGAREG_DMAPAD, 0);
+ PRIMOUTREG( MGAREG_DMAPAD, 0);
+ PRIMOUTREG( MGAREG_SOFTRAP, 0);
+ PRIMFINISH(prim);
+
+ end = ticks + (hz*3);
+ if(sarea_priv->dirty & MGA_DMA_FLUSH) {
+ DRM_DEBUG("Dma top flush\n");
+ while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
+ if((signed)(end - ticks) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup in fire primary "
+ "(Dma Top Flush)\n");
+ goto out_prim_wait;
+ }
+
+ for (i = 0 ; i < 4096 ; i++) mga_delay();
+ }
+ sarea_priv->dirty &= ~(MGA_DMA_FLUSH);
+ } else {
+ DRM_DEBUG("Status wait\n");
+ while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) {
+ if((signed)(end - ticks) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup in fire primary "
+ "(Status Wait)\n");
+ goto out_prim_wait;
+ }
+
+ for (i = 0 ; i < 4096 ; i++) mga_delay();
+ }
+ }
+
+ mga_flush_write_combine();
+ atomic_inc(&dev_priv->pending_bufs);
+ MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
+ MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
+ prim->num_dwords = 0;
+ sarea_priv->last_enqueue = prim->prim_age;
+
+ next_idx = prim->idx + 1;
+ if(next_idx >= MGA_NUM_PRIM_BUFS)
+ next_idx = 0;
+
+ dev_priv->next_prim = dev_priv->prim_bufs[next_idx];
+ return;
+
+ out_prim_wait:
+ prim->num_dwords = 0;
+ prim->sec_used = 0;
+ clear_bit(MGA_BUF_IN_USE, &prim->buffer_status);
+ wakeup(&dev_priv->wait_queue);
+ clear_bit(MGA_BUF_SWAP_PENDING, &prim->buffer_status);
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+}
+
+int mga_advance_primary(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_prim_buf_t *prim_buffer;
+ drm_device_dma_t *dma = dev->dma;
+ int next_prim_idx;
+ int ret = 0;
+ int s;
+
+ /* This needs to reset the primary buffer if available,
+ * we should collect stats on how many times it bites
+ * it's tail */
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ next_prim_idx = dev_priv->current_prim_idx + 1;
+ if(next_prim_idx >= MGA_NUM_PRIM_BUFS)
+ next_prim_idx = 0;
+ prim_buffer = dev_priv->prim_bufs[next_prim_idx];
+ set_bit(MGA_IN_WAIT, &dev_priv->dispatch_status);
+
+ /* In use is cleared in interrupt handler */
+
+ s = splsofttq();
+ if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) {
+ for (;;) {
+ mga_dma_schedule(dev, 0);
+ if(!test_and_set_bit(MGA_BUF_IN_USE,
+ &prim_buffer->buffer_status))
+ break;
+ atomic_inc(&dev->total_sleeps);
+ atomic_inc(&dma->total_missed_sched);
+ ret = tsleep(&dev_priv->wait_queue, PZERO|PCATCH,
+ "mgaap", 0);
+ if (ret)
+ break;
+ }
+ if(ret) {
+ splx(s);
+ return ret;
+ }
+ }
+ clear_bit(MGA_IN_WAIT, &dev_priv->dispatch_status);
+ splx(s);
+
+ /* This primary buffer is now free to use */
+ prim_buffer->current_dma_ptr = prim_buffer->head;
+ prim_buffer->num_dwords = 0;
+ prim_buffer->sec_used = 0;
+ prim_buffer->prim_age = dev_priv->next_prim_age++;
+ if(prim_buffer->prim_age == 0 || prim_buffer->prim_age == 0xffffffff) {
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+ mga_reset_freelist(dev);
+ prim_buffer->prim_age = (dev_priv->next_prim_age += 2);
+ }
+
+ /* Reset all buffer status stuff */
+ clear_bit(MGA_BUF_NEEDS_OVERFLOW, &prim_buffer->buffer_status);
+ clear_bit(MGA_BUF_FORCE_FIRE, &prim_buffer->buffer_status);
+ clear_bit(MGA_BUF_SWAP_PENDING, &prim_buffer->buffer_status);
+
+ dev_priv->current_prim = prim_buffer;
+ dev_priv->current_prim_idx = next_prim_idx;
+ return 0;
+}
+
+/* More dynamic performance decisions */
+static __inline int mga_decide_to_fire(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(test_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status)) {
+ atomic_inc(&dma->total_prio);
+ return 1;
+ }
+
+ if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
+ dev_priv->next_prim->num_dwords) {
+ atomic_inc(&dma->total_prio);
+ return 1;
+ }
+
+ if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) &&
+ dev_priv->next_prim->num_dwords) {
+ atomic_inc(&dma->total_prio);
+ return 1;
+ }
+
+ if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) {
+ if(test_bit(MGA_BUF_SWAP_PENDING,
+ &dev_priv->next_prim->buffer_status)) {
+ atomic_inc(&dma->total_dmas);
+ return 1;
+ }
+ }
+
+ if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS / 2) {
+ if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 8) {
+ atomic_inc(&dma->total_hit);
+ return 1;
+ }
+ }
+
+ if(atomic_read(&dev_priv->pending_bufs) >= MGA_NUM_PRIM_BUFS / 2) {
+ if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 4) {
+ atomic_inc(&dma->total_missed_free);
+ return 1;
+ }
+ }
+
+ atomic_inc(&dma->total_tried);
+ return 0;
+}
+
+int mga_dma_schedule(drm_device_t *dev, int locked)
+{
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+
+ if (test_and_set_bit(0, &dev->dma_flag)) {
+ atomic_inc(&dma->total_missed_dma);
+ return EBUSY;
+ }
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ if (!dev_priv) {
+ DRM_DEBUG("dev_priv is not set\n");
+ return (0);
+ }
+
+ if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) ||
+ test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) ||
+ test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
+ locked = 1;
+ }
+
+ if (!locked &&
+ !drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) {
+ atomic_inc(&dma->total_missed_lock);
+ clear_bit(0, &dev->dma_flag);
+ DRM_DEBUG("Not locked\n");
+ return EBUSY;
+ }
+ DRM_DEBUG("I'm locked\n");
+
+ if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) {
+ /* Fire dma buffer */
+ if(mga_decide_to_fire(dev)) {
+ DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx);
+ clear_bit(MGA_BUF_FORCE_FIRE,
+ &dev_priv->next_prim->buffer_status);
+ if(dev_priv->current_prim == dev_priv->next_prim) {
+ /* Schedule overflow for a later time */
+ set_bit(MGA_BUF_NEEDS_OVERFLOW,
+ &dev_priv->next_prim->buffer_status);
+ }
+ mga_fire_primary(dev, dev_priv->next_prim);
+ } else {
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+ }
+ } else {
+ DRM_DEBUG("I can't get the dispatch lock\n");
+ }
+
+ if (!locked) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+
+ if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) &&
+ dev_priv->next_prim->num_dwords == 0 &&
+ atomic_read(&dev_priv->pending_bufs) == 0) {
+ /* Everything has been processed by the hardware */
+ clear_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status);
+ wakeup(&dev_priv->flush_queue);
+ }
+
+ if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
+ dev_priv->tail->age < dev_priv->last_prim_age) {
+ clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
+ DRM_DEBUG("Waking up buf queue\n");
+ wakeup(&dev_priv->buf_queue);
+ } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
+ DRM_DEBUG("Not waking buf_queue on %d %d\n",
+ atomic_read(&dev->total_irq),
+ dev_priv->last_prim_age);
+ }
+
+ clear_bit(0, &dev->dma_flag);
+ return 0;
+}
+
+static void mga_dma_service(void *arg)
+{
+ drm_device_t *dev = (drm_device_t *)arg;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_prim_buf_t *last_prim_buffer;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ atomic_inc(&dev->total_irq);
+ if((MGA_READ(MGAREG_STATUS) & 0x00000001) != 0x00000001) return;
+ MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
+ last_prim_buffer = dev_priv->last_prim;
+ last_prim_buffer->num_dwords = 0;
+ last_prim_buffer->sec_used = 0;
+ dev_priv->sarea_priv->last_dispatch =
+ dev_priv->last_prim_age = last_prim_buffer->prim_age;
+ clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status);
+ wakeup(&dev_priv->wait_queue);
+ clear_bit(MGA_BUF_SWAP_PENDING, &last_prim_buffer->buffer_status);
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+ atomic_dec(&dev_priv->pending_bufs);
+ taskqueue_enqueue(taskqueue_swi, &dev->task);
+}
+
+static void mga_dma_task_queue(void *device, int pending)
+{
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ mga_dma_schedule((drm_device_t *)device, 0);
+}
+
+int mga_dma_cleanup(drm_device_t *dev)
+{
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(dev->dev_private) {
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+
+ if(dev_priv->ioremap) {
+ int temp = (dev_priv->warp_ucode_size +
+ dev_priv->primary_size +
+ PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE;
+
+ drm_ioremapfree((void *) dev_priv->ioremap, temp);
+ }
+ if(dev_priv->real_status_page != 0UL) {
+ mga_free_page(dev, dev_priv->real_status_page);
+ }
+ if(dev_priv->prim_bufs != NULL) {
+ int i;
+ for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) {
+ if(dev_priv->prim_bufs[i] != NULL) {
+ drm_free(dev_priv->prim_bufs[i],
+ sizeof(drm_mga_prim_buf_t),
+ DRM_MEM_DRIVER);
+ }
+ }
+ drm_free(dev_priv->prim_bufs, sizeof(void *) *
+ (MGA_NUM_PRIM_BUFS + 1),
+ DRM_MEM_DRIVER);
+ }
+ if(dev_priv->head != NULL) {
+ mga_freelist_cleanup(dev);
+ }
+
+
+ drm_free(dev->dev_private, sizeof(drm_mga_private_t),
+ DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ }
+
+ return 0;
+}
+
+static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
+ drm_mga_private_t *dev_priv;
+ drm_map_t *sarea_map = NULL;
+ int i;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
+ if(dev_priv == NULL) return ENOMEM;
+ dev->dev_private = (void *) dev_priv;
+
+ memset(dev_priv, 0, sizeof(drm_mga_private_t));
+
+ if((init->reserved_map_idx >= dev->map_count) ||
+ (init->buffer_map_idx >= dev->map_count)) {
+ mga_dma_cleanup(dev);
+ DRM_DEBUG("reserved_map or buffer_map are invalid\n");
+ return EINVAL;
+ }
+
+ dev_priv->reserved_map_idx = init->reserved_map_idx;
+ dev_priv->buffer_map_idx = init->buffer_map_idx;
+ sarea_map = dev->maplist[0];
+ dev_priv->sarea_priv = (drm_mga_sarea_t *)
+ ((u_int8_t *)sarea_map->handle +
+ init->sarea_priv_offset);
+
+ /* Scale primary size to the next page */
+ dev_priv->chipset = init->chipset;
+ dev_priv->frontOffset = init->frontOffset;
+ dev_priv->backOffset = init->backOffset;
+ dev_priv->depthOffset = init->depthOffset;
+ dev_priv->textureOffset = init->textureOffset;
+ dev_priv->textureSize = init->textureSize;
+ dev_priv->cpp = init->cpp;
+ dev_priv->sgram = init->sgram;
+ dev_priv->stride = init->stride;
+
+ dev_priv->mAccess = init->mAccess;
+ dev_priv->flush_queue = 0;
+ dev_priv->buf_queue = 0;
+ dev_priv->WarpPipe = -1;
+
+ DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n",
+ dev_priv->chipset, dev_priv->warp_ucode_size,
+ dev_priv->backOffset, dev_priv->depthOffset);
+ DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n",
+ dev_priv->cpp, dev_priv->sgram, dev_priv->stride,
+ dev_priv->mAccess);
+
+ memcpy(&dev_priv->WarpIndex, &init->WarpIndex,
+ sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES);
+
+ for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++)
+ DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n",
+ i,
+ dev_priv->WarpIndex[i].installed,
+ dev_priv->WarpIndex[i].phys_addr,
+ dev_priv->WarpIndex[i].size);
+
+ if(mga_init_primary_bufs(dev, init) != 0) {
+ DRM_ERROR("Can not initialize primary buffers\n");
+ mga_dma_cleanup(dev);
+ return ENOMEM;
+ }
+ dev_priv->real_status_page = mga_alloc_page(dev);
+ if(dev_priv->real_status_page == 0UL) {
+ mga_dma_cleanup(dev);
+ DRM_ERROR("Can not allocate status page\n");
+ return ENOMEM;
+ }
+
+ dev_priv->status_page = (void*)dev_priv->real_status_page; /* XXX wants nocache */
+#if 0
+ dev_priv->status_page =
+ ioremap_nocache(virt_to_bus((void *)dev_priv->real_status_page),
+ PAGE_SIZE);
+
+ if(dev_priv->status_page == NULL) {
+ mga_dma_cleanup(dev);
+ DRM_ERROR("Can not remap status page\n");
+ return ENOMEM;
+ }
+#endif
+
+ /* Write status page when secend or softrap occurs */
+ MGA_WRITE(MGAREG_PRIMPTR,
+ vtophys((void *)dev_priv->real_status_page) | 0x00000003);
+
+
+ /* Private is now filled in, initialize the hardware */
+ {
+ PRIMLOCALS;
+ PRIMGETPTR( dev_priv );
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x0100);
+ PRIMOUTREG(MGAREG_SOFTRAP, 0);
+ /* Poll for the first buffer to insure that
+ * the status register will be correct
+ */
+
+ mga_flush_write_combine();
+ MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
+
+ MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) |
+ PDEA_pagpxfer_enable));
+
+ while(MGA_READ(MGAREG_DWGSYNC) != 0x0100) ;
+ }
+
+ if(mga_freelist_init(dev) != 0) {
+ DRM_ERROR("Could not initialize freelist\n");
+ mga_dma_cleanup(dev);
+ return ENOMEM;
+ }
+ return 0;
+}
+
+int
+mga_dma_init(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_mga_init_t init;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ init = *(drm_mga_init_t *) data;
+
+ switch(init.func) {
+ case MGA_INIT_DMA:
+ return mga_dma_initialize(dev, &init);
+ case MGA_CLEANUP_DMA:
+ return mga_dma_cleanup(dev);
+ }
+
+ return EINVAL;
+}
+
+int mga_irq_install(drm_device_t *dev, int irq)
+{
+ int rid;
+ int retcode;
+
+ if (!irq) return EINVAL;
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ if (dev->irq) {
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+ return EBUSY;
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ DRM_DEBUG("install irq handler %d\n", irq);
+
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma_flag = 0;
+ dev->dma->next_buffer = NULL;
+ dev->dma->next_queue = NULL;
+ dev->dma->this_buffer = NULL;
+ TASK_INIT(&dev->task, 0, mga_dma_task_queue, dev);
+
+ /* Before installing handler */
+ MGA_WRITE(MGAREG_IEN, 0);
+ /* Install handler */
+ rid = 0;
+ dev->irq = bus_alloc_resource(dev->device, SYS_RES_IRQ, &rid,
+ 0, ~0, 1, RF_SHAREABLE);
+ if (!dev->irq)
+ return ENOENT;
+
+ retcode = bus_setup_intr(dev->device, dev->irq, INTR_TYPE_TTY,
+ mga_dma_service, dev, &dev->irqh);
+ if (retcode) {
+ bus_release_resource(dev->device, SYS_RES_IRQ, 0, dev->irq);
+ dev->irq = 0;
+ return retcode;
+ }
+
+ /* After installing handler */
+ MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
+ MGA_WRITE(MGAREG_IEN, 0x00000001);
+ return 0;
+}
+
+int mga_irq_uninstall(drm_device_t *dev)
+{
+ if (!dev->irq)
+ return EINVAL;
+
+ DRM_DEBUG("remove irq handler %ld\n", rman_get_start(dev->irq));
+ MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
+ MGA_WRITE(MGAREG_IEN, 0);
+
+ bus_teardown_intr(dev->device, dev->irq, dev->irqh);
+ bus_release_resource(dev->device, SYS_RES_IRQ, 0, dev->irq);
+ dev->irq = 0;
+
+ return 0;
+}
+
+int mga_control(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_control_t ctl;
+
+ ctl = *(drm_control_t *) data;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ switch (ctl.func) {
+ case DRM_INST_HANDLER:
+ return mga_irq_install(dev, ctl.irq);
+ case DRM_UNINST_HANDLER:
+ return mga_irq_uninstall(dev);
+ default:
+ return EINVAL;
+ }
+}
+
+static int mga_flush_queue(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ int ret = 0;
+ int s;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(dev_priv == NULL) {
+ return 0;
+ }
+
+ if(dev_priv->next_prim->num_dwords != 0) {
+ s = splsofttq();
+ set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status);
+ for (;;) {
+ mga_dma_schedule(dev, 0);
+ if (!test_bit(MGA_IN_FLUSH,
+ &dev_priv->dispatch_status))
+ break;
+ atomic_inc(&dev->total_sleeps);
+ ret = tsleep(&dev_priv->flush_queue, PZERO|PCATCH,
+ "mgafq", 0);
+ if (ret) {
+ clear_bit(MGA_IN_FLUSH,
+ &dev_priv->dispatch_status);
+ break;
+ }
+ }
+ splx(s);
+ }
+ return ret;
+}
+
+/* Must be called with the lock held */
+void mga_reclaim_buffers(drm_device_t *dev, pid_t pid)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ if (!dma) return;
+ if(dev->dev_private == NULL) return;
+ if(dma->buflist == NULL) return;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ mga_flush_queue(dev);
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+
+ /* Only buffers that need to get reclaimed ever
+ * get set to free
+ */
+ if (buf->pid == pid && buf_priv) {
+ if(buf_priv->my_freelist->age == MGA_BUF_USED)
+ buf_priv->my_freelist->age = MGA_BUF_FREE;
+ }
+ }
+}
+
+int mga_lock(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int ret = 0;
+ drm_lock_t lock;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ lock = *(drm_lock_t *) data;
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ p->p_pid, lock.context);
+ return EINVAL;
+ }
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, p->p_pid, dev->lock.hw_lock->lock,
+ lock.flags);
+
+ if (lock.context < 0) {
+ return EINVAL;
+ }
+
+ /* Only one queue:
+ */
+
+ if (!ret) {
+ atomic_inc(&dev->lock.lock_queue);
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ ret = EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ lock.context)) {
+ dev->lock.pid = p->p_pid;
+ dev->lock.lock_time = ticks;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ ret = tsleep(&dev->lock.lock_queue, PZERO|PCATCH,
+ "mgal2", 0);
+ if (ret)
+ break;
+ }
+ atomic_dec(&dev->lock.lock_queue);
+ }
+
+ if (!ret) {
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ DRM_DEBUG("_DRM_LOCK_QUIESCENT\n");
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+ }
+ }
+
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+ return ret;
+}
+
+int mga_flush_ioctl(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_lock_t lock;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ int s;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ lock = *(drm_lock_t *) data;
+
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_flush_ioctl called without lock held\n");
+ return EINVAL;
+ }
+
+ if(lock.flags & _DRM_LOCK_FLUSH || lock.flags & _DRM_LOCK_FLUSH_ALL) {
+ drm_mga_prim_buf_t *temp_buf =
+ dev_priv->prim_bufs[dev_priv->current_prim_idx];
+
+ if(temp_buf && temp_buf->num_dwords) {
+ s = splsofttq();
+ set_bit(MGA_BUF_FORCE_FIRE, &temp_buf->buffer_status);
+ mga_advance_primary(dev);
+ mga_dma_schedule(dev, 1);
+ splx(s);
+ }
+ }
+ if(lock.flags & _DRM_LOCK_QUIESCENT) {
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+ }
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.c
new file mode 100644
index 000000000..099372012
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.c
@@ -0,0 +1,714 @@
+/* mga_drv.c -- Matrox g200/g400 driver
+ * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ *
+ *
+ */
+
+#include "drmP.h"
+#include "mga_drv.h"
+
+#include <pci/pcivar.h>
+
+MODULE_DEPEND(mga, drm, 1, 1, 1);
+MODULE_DEPEND(mga, agp, 1, 1, 1);
+
+#define MGA_NAME "mga"
+#define MGA_DESC "Matrox g200/g400"
+#define MGA_DATE "19991213"
+#define MGA_MAJOR 1
+#define MGA_MINOR 0
+#define MGA_PATCHLEVEL 0
+
+drm_ctx_t mga_res_ctx;
+
+static int mga_probe(device_t dev)
+{
+ const char *s = 0;
+
+ switch (pci_get_devid(dev)) {
+ case 0x0525102b:
+ s = "Matrox MGA G400 AGP graphics accelerator";
+ break;
+
+ case 0x0521102b:
+ s = "Matrox MGA G200 AGP graphics accelerator";
+ break;
+ }
+
+ if (s) {
+ device_set_desc(dev, s);
+ return 0;
+ }
+
+ return ENXIO;
+}
+
+static int mga_attach(device_t dev)
+{
+ return mga_init(dev);
+}
+
+static int mga_detach(device_t dev)
+{
+ mga_cleanup(dev);
+ return 0;
+}
+
+static device_method_t mga_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, mga_probe),
+ DEVMETHOD(device_attach, mga_attach),
+ DEVMETHOD(device_detach, mga_detach),
+
+ { 0, 0 }
+};
+
+static driver_t mga_driver = {
+ "drm",
+ mga_methods,
+ sizeof(drm_device_t),
+};
+
+static devclass_t mga_devclass;
+#define MGA_SOFTC(unit) \
+ ((drm_device_t *) devclass_get_softc(mga_devclass, unit))
+
+DRIVER_MODULE(if_mga, pci, mga_driver, mga_devclass, 0, 0);
+
+#define CDEV_MAJOR 145
+ /* mga_drv.c */
+static struct cdevsw mga_cdevsw = {
+ /* open */ mga_open,
+ /* close */ mga_close,
+ /* read */ drm_read,
+ /* write */ drm_write,
+ /* ioctl */ mga_ioctl,
+ /* poll */ drm_poll,
+ /* mmap */ drm_mmap,
+ /* strategy */ nostrategy,
+ /* name */ "mga",
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ D_TTY | D_TRACKCLOSE,
+ /* bmaj */ -1
+};
+
+static drm_ioctl_desc_t mga_ioctls[] = {
+ [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { mga_version, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { mga_control, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { mga_addbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { mga_markbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { mga_infobufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { mga_mapbufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { mga_freebufs, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { mga_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { mga_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { mga_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { mga_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { mga_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { mga_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { mga_resctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { mga_dma, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { mga_lock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { mga_unlock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_INIT)] = { mga_dma_init, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)] = { mga_swap_bufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)] = { mga_clear_bufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_iload, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_VERTEX)] = { mga_vertex, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_FLUSH)] = { mga_flush_ioctl, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_INDICES)] = { mga_indices, 1, 0 },
+};
+
+#define MGA_IOCTL_COUNT DRM_ARRAY_SIZE(mga_ioctls)
+
+static int mga_setup(drm_device_t *dev)
+{
+ int i;
+
+ device_busy(dev->device);
+
+ atomic_set(&dev->ioctl_count, 0);
+ atomic_set(&dev->vma_count, 0);
+ dev->buf_use = 0;
+ atomic_set(&dev->buf_alloc, 0);
+
+ drm_dma_setup(dev);
+
+ atomic_set(&dev->total_open, 0);
+ atomic_set(&dev->total_close, 0);
+ atomic_set(&dev->total_ioctl, 0);
+ atomic_set(&dev->total_irq, 0);
+ atomic_set(&dev->total_ctx, 0);
+ atomic_set(&dev->total_locks, 0);
+ atomic_set(&dev->total_unlocks, 0);
+ atomic_set(&dev->total_contends, 0);
+ atomic_set(&dev->total_sleeps, 0);
+
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ dev->magiclist[i].head = NULL;
+ dev->magiclist[i].tail = NULL;
+ }
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ dev->vmalist = NULL;
+ dev->lock.hw_lock = NULL;
+ dev->lock.lock_queue = 0;
+ dev->queue_count = 0;
+ dev->queue_reserved = 0;
+ dev->queue_slots = 0;
+ dev->queuelist = NULL;
+ dev->irq = 0;
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma_flag = 0;
+ dev->last_context = 0;
+ dev->last_switch = 0;
+ dev->last_checked = 0;
+ callout_init(&dev->timer);
+ dev->context_wait = 0;
+
+ timespecclear(&dev->ctx_start);
+ timespecclear(&dev->lck_start);
+
+ dev->buf_rp = dev->buf;
+ dev->buf_wp = dev->buf;
+ dev->buf_end = dev->buf + DRM_BSZ;
+ bzero(&dev->buf_sel, sizeof dev->buf_sel);
+ dev->buf_sigio = NULL;
+ dev->buf_readers = 0;
+ dev->buf_writers = 0;
+ dev->buf_selecting = 0;
+
+ DRM_DEBUG("\n");
+
+ /* The kernel's context could be created here, but is now created
+ in drm_dma_enqueue. This is more resource-efficient for
+ hardware that does not do DMA, but may mean that
+ drm_select_queue fails between the time the interrupt is
+ initialized and the time the queues are initialized. */
+
+ return 0;
+}
+
+
+static int mga_takedown(drm_device_t *dev)
+{
+ int i;
+ drm_magic_entry_t *pt, *next;
+ drm_map_t *map;
+ drm_vma_entry_t *vma, *vma_next;
+
+ DRM_DEBUG("\n");
+
+ if (dev->irq) mga_irq_uninstall(dev);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ callout_stop(&dev->timer);
+
+ if (dev->devname) {
+ drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
+ dev->devname = NULL;
+ }
+
+ if (dev->unique) {
+ drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
+ dev->unique = NULL;
+ dev->unique_len = 0;
+ }
+ /* Clear pid list */
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ for (pt = dev->magiclist[i].head; pt; pt = next) {
+ next = pt->next;
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ }
+ dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
+ }
+ /* Clear AGP information */
+ if (dev->agp) {
+ drm_agp_mem_t *entry;
+ drm_agp_mem_t *nexte;
+
+ /* Remove AGP resources, but leave dev->agp
+ intact until cleanup is called. */
+ for (entry = dev->agp->memory; entry; entry = nexte) {
+ nexte = entry->next;
+ if (entry->bound) drm_unbind_agp(entry->handle);
+ drm_free_agp(entry->handle, entry->pages);
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ }
+ dev->agp->memory = NULL;
+
+ if (dev->agp->acquired)
+ agp_release(dev->agp->agpdev);
+
+ dev->agp->acquired = 0;
+ dev->agp->enabled = 0;
+ }
+ /* Clear vma list (only built for debugging) */
+ if (dev->vmalist) {
+ for (vma = dev->vmalist; vma; vma = vma_next) {
+ vma_next = vma->next;
+ drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
+ }
+ dev->vmalist = NULL;
+ }
+
+ /* Clear map area and mtrr information */
+ if (dev->maplist) {
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ switch (map->type) {
+ case _DRM_REGISTERS:
+ case _DRM_FRAME_BUFFER:
+#ifdef CONFIG_MTRR
+ if (map->mtrr >= 0) {
+ int retcode;
+ retcode = mtrr_del(map->mtrr,
+ map->offset,
+ map->size);
+ DRM_DEBUG("mtrr_del = %d\n", retcode);
+ }
+#endif
+ drm_ioremapfree(map->handle, map->size);
+ break;
+ case _DRM_SHM:
+ drm_free_pages((unsigned long)map->handle,
+ drm_order(map->size)
+ - PAGE_SHIFT,
+ DRM_MEM_SAREA);
+ break;
+ case _DRM_AGP:
+ break;
+ }
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ }
+ drm_free(dev->maplist,
+ dev->map_count * sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ }
+
+ if (dev->queuelist) {
+ for (i = 0; i < dev->queue_count; i++) {
+ drm_waitlist_destroy(&dev->queuelist[i]->waitlist);
+ if (dev->queuelist[i]) {
+ drm_free(dev->queuelist[i],
+ sizeof(*dev->queuelist[0]),
+ DRM_MEM_QUEUES);
+ dev->queuelist[i] = NULL;
+ }
+ }
+ drm_free(dev->queuelist,
+ dev->queue_slots * sizeof(*dev->queuelist),
+ DRM_MEM_QUEUES);
+ dev->queuelist = NULL;
+ }
+
+ drm_dma_takedown(dev);
+
+ dev->queue_count = 0;
+ if (dev->lock.hw_lock) {
+ dev->lock.hw_lock = NULL; /* SHM removed */
+ dev->lock.pid = 0;
+ wakeup(&dev->lock.lock_queue);
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ return 0;
+}
+
+/* mga_init is called via mga_attach at module load time, */
+
+int
+mga_init(device_t nbdev)
+{
+ int retcode;
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ DRM_DEBUG("\n");
+
+ memset((void *)dev, 0, sizeof(*dev));
+ simple_lock_init(&dev->count_lock);
+ lockinit(&dev->dev_lock, PZERO, "drmlk", 0, 0);
+
+#if 0
+ drm_parse_options(mga);
+#endif
+ dev->device = nbdev;
+ dev->devnode = make_dev(&mga_cdevsw,
+ device_get_unit(nbdev),
+ DRM_DEV_UID,
+ DRM_DEV_GID,
+ DRM_DEV_MODE,
+ MGA_NAME);
+ dev->name = MGA_NAME;
+
+ DRM_DEBUG("doing mem init\n");
+ drm_mem_init();
+ DRM_DEBUG("doing proc init\n");
+ drm_sysctl_init(dev);
+ TAILQ_INIT(&dev->files);
+ DRM_DEBUG("doing agp init\n");
+ dev->agp = drm_agp_init();
+ if(dev->agp == NULL) {
+ DRM_INFO("The mga drm module requires the agp module"
+ " to function correctly\nPlease load the agp"
+ " module before you load the mga module\n");
+ drm_sysctl_cleanup(dev);
+ mga_takedown(dev);
+ return ENOMEM;
+ }
+#if 0
+ dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size * 1024 * 1024,
+ MTRR_TYPE_WRCOMB,
+ 1);
+#endif
+ DRM_DEBUG("doing ctxbitmap init\n");
+ if((retcode = drm_ctxbitmap_init(dev))) {
+ DRM_ERROR("Cannot allocate memory for context bitmap.\n");
+ drm_sysctl_cleanup(dev);
+ mga_takedown(dev);
+ return retcode;
+ }
+
+ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+ MGA_NAME,
+ MGA_MAJOR,
+ MGA_MINOR,
+ MGA_PATCHLEVEL,
+ MGA_DATE,
+ device_get_unit(nbdev));
+
+ return 0;
+}
+
+/* mga_cleanup is called via cleanup_module at module unload time. */
+
+void mga_cleanup(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ DRM_DEBUG("\n");
+
+ drm_sysctl_cleanup(dev);
+ destroy_dev(dev->devnode);
+
+ DRM_INFO("Module unloaded\n");
+ drm_ctxbitmap_cleanup(dev);
+ mga_dma_cleanup(dev);
+#if 0
+ if(dev->agp && dev->agp->agp_mtrr) {
+ int retval;
+ retval = mtrr_del(dev->agp->agp_mtrr,
+ dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size * 1024*1024);
+ DRM_DEBUG("mtrr_del = %d\n", retval);
+ }
+#endif
+
+ mga_takedown(dev);
+ if (dev->agp) {
+ drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ dev->agp = NULL;
+ }
+}
+
+int
+mga_version(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_version_t version;
+ int len;
+
+ version = *(drm_version_t *) data;
+
+#define DRM_COPY(name,value) \
+ len = strlen(value); \
+ if (len > name##_len) len = name##_len; \
+ name##_len = strlen(value); \
+ if (len && name) { \
+ int error = copyout(value, name, len); \
+ if (error) return error; \
+ }
+
+ version.version_major = MGA_MAJOR;
+ version.version_minor = MGA_MINOR;
+ version.version_patchlevel = MGA_PATCHLEVEL;
+
+ DRM_COPY(version.name, MGA_NAME);
+ DRM_COPY(version.date, MGA_DATE);
+ DRM_COPY(version.desc, MGA_DESC);
+
+ *(drm_version_t *) data = version;
+ return 0;
+}
+
+int
+mga_open(dev_t kdev, int flags, int fmt, struct proc *p)
+{
+ drm_device_t *dev = MGA_SOFTC(minor(kdev));
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+
+ device_busy(dev->device);
+ if (!(retcode = drm_open_helper(kdev, flags, fmt, p, dev))) {
+ atomic_inc(&dev->total_open);
+ simple_lock(&dev->count_lock);
+ if (!dev->open_count++) {
+ simple_unlock(&dev->count_lock);
+ retcode = mga_setup(dev);
+ }
+ simple_unlock(&dev->count_lock);
+ }
+ device_unbusy(dev->device);
+
+ return retcode;
+}
+
+int
+mga_close(dev_t kdev, int flags, int fmt, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_file_t *priv;
+ int retcode = 0;
+
+ DRM_DEBUG("pid = %d, open_count = %d\n",
+ p->p_pid, dev->open_count);
+
+ priv = drm_find_file_by_proc(dev, p);
+ if (!priv) {
+ DRM_DEBUG("can't find authenticator\n");
+ return EINVAL;
+ }
+
+ if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
+ && dev->lock.pid == p->p_pid) {
+ mga_reclaim_buffers(dev, priv->pid);
+ DRM_ERROR("Process %d dead, freeing lock for context %d\n",
+ p->p_pid,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ drm_lock_free(dev,
+ &dev->lock.hw_lock->lock,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+
+ /* FIXME: may require heavy-handed reset of
+ hardware at this point, possibly
+ processed via a callback to the X
+ server. */
+ } else if (dev->lock.hw_lock) {
+ /* The lock is required to reclaim buffers */
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ retcode = EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ dev->lock.pid = p->p_pid;
+ dev->lock.lock_time = ticks;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ retcode = tsleep(&dev->lock.lock_queue,
+ PZERO|PCATCH,
+ "drmlk2",
+ 0);
+ if (retcode)
+ break;
+ }
+ if(!retcode) {
+ mga_reclaim_buffers(dev, priv->pid);
+ drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT);
+ }
+ }
+ funsetown(dev->buf_sigio);
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, p);
+ priv = drm_find_file_by_proc(dev, p);
+ if (priv) {
+ priv->refs--;
+ if (!priv->refs) {
+ TAILQ_REMOVE(&dev->files, priv, link);
+ drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
+ }
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, p);
+
+ atomic_inc(&dev->total_close);
+ simple_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ simple_unlock(&dev->count_lock);
+ device_unbusy(dev->device);
+ return mga_takedown(dev);
+ }
+ simple_unlock(&dev->count_lock);
+ return retcode;
+}
+
+
+/* mga_ioctl is called whenever a process performs an ioctl on /dev/drm. */
+
+int
+mga_ioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ int nr = DRM_IOCTL_NR(cmd);
+ drm_device_t *dev = kdev->si_drv1;
+ drm_file_t *priv;
+ int retcode = 0;
+ drm_ioctl_desc_t *ioctl;
+ d_ioctl_t *func;
+
+ DRM_DEBUG("dev=%p\n", dev);
+ priv = drm_find_file_by_proc(dev, p);
+ if (!priv) {
+ DRM_DEBUG("can't find authenticator\n");
+ return EINVAL;
+ }
+
+ atomic_inc(&dev->ioctl_count);
+ atomic_inc(&dev->total_ioctl);
+ ++priv->ioctl_count;
+
+ DRM_DEBUG("pid = %d, cmd = 0x%02lx, nr = 0x%02x, auth = %d\n",
+ p->p_pid, cmd, nr, priv->authenticated);
+
+ switch (cmd) {
+ case FIONBIO:
+ atomic_dec(&dev->ioctl_count);
+ return 0;
+
+ case FIOASYNC:
+ atomic_dec(&dev->ioctl_count);
+ dev->flags |= FASYNC;
+ return 0;
+
+ case FIOSETOWN:
+ atomic_dec(&dev->ioctl_count);
+ return fsetown(*(int *)data, &dev->buf_sigio);
+
+ case FIOGETOWN:
+ atomic_dec(&dev->ioctl_count);
+ *(int *) data = fgetown(dev->buf_sigio);
+ return 0;
+ }
+
+ if (nr >= MGA_IOCTL_COUNT) {
+ retcode = EINVAL;
+ } else {
+ ioctl = &mga_ioctls[nr];
+ func = ioctl->func;
+
+ if (!func) {
+ DRM_DEBUG("no function\n");
+ retcode = EINVAL;
+ } else if ((ioctl->root_only && suser(p))
+ || (ioctl->auth_needed && !priv->authenticated)) {
+ retcode = EACCES;
+ } else {
+ retcode = (func)(kdev, cmd, data, flags, p);
+ }
+ }
+
+ atomic_dec(&dev->ioctl_count);
+ return retcode;
+}
+
+int
+mga_unlock(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_lock_t lock;
+ int s;
+
+ lock = *(drm_lock_t *) data;
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ p->p_pid, lock.context);
+ return EINVAL;
+ }
+
+ DRM_DEBUG("%d frees lock (%d holds)\n",
+ lock.context,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ atomic_inc(&dev->total_unlocks);
+ if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
+ atomic_inc(&dev->total_contends);
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
+
+ s = splsofttq();
+ mga_dma_schedule(dev, 1);
+ splx(s);
+
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.h
new file mode 100644
index 000000000..05c4d9d2e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_drv.h
@@ -0,0 +1,420 @@
+/* mga_drv.h -- Private header for the Matrox g200/g400 driver
+ * Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ *
+ */
+
+#ifndef _MGA_DRV_H_
+#define _MGA_DRV_H_
+
+#define MGA_BUF_IN_USE 0
+#define MGA_BUF_SWAP_PENDING 1
+#define MGA_BUF_FORCE_FIRE 2
+#define MGA_BUF_NEEDS_OVERFLOW 3
+
+typedef struct {
+ u_int32_t buffer_status;
+ unsigned int num_dwords;
+ unsigned int max_dwords;
+ u_int32_t *current_dma_ptr;
+ u_int32_t *head;
+ u_int32_t phys_head;
+ unsigned int prim_age;
+ int sec_used;
+ int idx;
+} drm_mga_prim_buf_t;
+
+typedef struct _drm_mga_freelist {
+ unsigned int age;
+ drm_buf_t *buf;
+ struct _drm_mga_freelist *next;
+ struct _drm_mga_freelist *prev;
+} drm_mga_freelist_t;
+
+#define MGA_IN_DISPATCH 0
+#define MGA_IN_FLUSH 1
+#define MGA_IN_WAIT 2
+#define MGA_IN_GETBUF 3
+
+typedef struct _drm_mga_private {
+ u_int32_t dispatch_status;
+ unsigned int next_prim_age;
+ __volatile__ unsigned int last_prim_age;
+ int reserved_map_idx;
+ int buffer_map_idx;
+ drm_mga_sarea_t *sarea_priv;
+ int primary_size;
+ int warp_ucode_size;
+ int chipset;
+ unsigned int frontOffset;
+ unsigned int backOffset;
+ unsigned int depthOffset;
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ int cpp;
+ unsigned int stride;
+ int sgram;
+ int use_agp;
+ drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES];
+ unsigned int WarpPipe;
+ atomic_t pending_bufs;
+ void *status_page;
+ unsigned long real_status_page;
+ u_int8_t *ioremap;
+ drm_mga_prim_buf_t **prim_bufs;
+ drm_mga_prim_buf_t *next_prim;
+ drm_mga_prim_buf_t *last_prim;
+ drm_mga_prim_buf_t *current_prim;
+ int current_prim_idx;
+ drm_mga_freelist_t *head;
+ drm_mga_freelist_t *tail;
+ int flush_queue; /* Processes waiting until flush */
+ int wait_queue; /* Processes waiting until interrupt */
+ int buf_queue; /* Processes waiting for a free buf */
+ /* Some validated register values:
+ */
+ u_int32_t mAccess;
+} drm_mga_private_t;
+
+ /* mga_drv.c */
+extern int mga_init(device_t);
+extern void mga_cleanup(device_t);
+extern d_ioctl_t mga_version;
+extern d_open_t mga_open;
+extern d_close_t mga_close;
+extern d_ioctl_t mga_ioctl;
+extern d_ioctl_t mga_unlock;
+
+ /* mga_dma.c */
+extern int mga_dma_schedule(drm_device_t *dev, int locked);
+extern int mga_irq_install(drm_device_t *dev, int irq);
+extern int mga_irq_uninstall(drm_device_t *dev);
+extern d_ioctl_t mga_dma;
+extern d_ioctl_t mga_control;
+extern d_ioctl_t mga_lock;
+
+/* mga_dma_init does init and release */
+extern int mga_dma_cleanup(drm_device_t *dev);
+extern d_ioctl_t mga_dma_init;
+extern d_ioctl_t mga_flush_ioctl;
+extern void mga_flush_write_combine(void);
+extern unsigned int mga_create_sync_tag(drm_device_t *dev);
+extern drm_buf_t *mga_freelist_get(drm_device_t *dev);
+extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf);
+extern int mga_advance_primary(drm_device_t *dev);
+extern void mga_reclaim_buffers(drm_device_t *dev, pid_t pid);
+
+ /* mga_bufs.c */
+extern d_ioctl_t mga_addbufs;
+extern d_ioctl_t mga_infobufs;
+extern d_ioctl_t mga_markbufs;
+extern d_ioctl_t mga_freebufs;
+extern d_ioctl_t mga_mapbufs;
+extern d_ioctl_t mga_addmap;
+ /* mga_state.c */
+extern d_ioctl_t mga_clear_bufs;
+extern d_ioctl_t mga_swap_bufs;
+extern d_ioctl_t mga_iload;
+extern d_ioctl_t mga_vertex;
+extern d_ioctl_t mga_indices;
+ /* mga_context.c */
+extern d_ioctl_t mga_resctx;
+extern d_ioctl_t mga_addctx;
+extern d_ioctl_t mga_modctx;
+extern d_ioctl_t mga_getctx;
+extern d_ioctl_t mga_switchctx;
+extern d_ioctl_t mga_newctx;
+extern d_ioctl_t mga_rmctx;
+
+extern int mga_context_switch(drm_device_t *dev, int old, int new);
+extern int mga_context_switch_complete(drm_device_t *dev, int new);
+
+
+typedef enum {
+ TT_GENERAL,
+ TT_BLIT,
+ TT_VECTOR,
+ TT_VERTEX
+} transferType_t;
+
+typedef struct {
+ drm_mga_freelist_t *my_freelist;
+ int discard;
+ int dispatched;
+} drm_mga_buf_priv_t;
+
+#define DWGREG0 0x1c00
+#define DWGREG0_END 0x1dff
+#define DWGREG1 0x2c00
+#define DWGREG1_END 0x2dff
+
+#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)
+#define ADRINDEX0(r) (u_int8_t)((r - DWGREG0) >> 2)
+#define ADRINDEX1(r) (u_int8_t)(((r - DWGREG1) >> 2) | 0x80)
+#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r))
+
+#define MGA_VERBOSE 0
+#define MGA_NUM_PRIM_BUFS 8
+
+#define PRIMLOCALS u_int8_t tempIndex[4]; u_int32_t *dma_ptr; u_int32_t phys_head; \
+ int outcount, num_dwords
+
+#define PRIM_OVERFLOW(dev, dev_priv, length) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \
+ &tmp_buf->buffer_status)) { \
+ mga_advance_primary(dev); \
+ mga_dma_schedule(dev, 1); \
+ } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length ||\
+ tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \
+ set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \
+ mga_advance_primary(dev); \
+ mga_dma_schedule(dev, 1); \
+ } \
+} while(0)
+
+#define PRIMGETPTR(dev_priv) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ if(MGA_VERBOSE) \
+ DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \
+ dma_ptr = tmp_buf->current_dma_ptr; \
+ num_dwords = tmp_buf->num_dwords; \
+ phys_head = tmp_buf->phys_head; \
+ outcount = 0; \
+} while(0)
+
+#define PRIMPTR(prim_buf) do { \
+ if(MGA_VERBOSE) \
+ DRM_DEBUG("PRIMPTR in %s\n", __FUNCTION__); \
+ dma_ptr = prim_buf->current_dma_ptr; \
+ num_dwords = prim_buf->num_dwords; \
+ phys_head = prim_buf->phys_head; \
+ outcount = 0; \
+} while(0)
+
+#define PRIMFINISH(prim_buf) do { \
+ if (MGA_VERBOSE) { \
+ DRM_DEBUG( "PRIMFINISH in %s\n", __FUNCTION__); \
+ if (outcount & 3) \
+ DRM_DEBUG(" --- truncation\n"); \
+ } \
+ prim_buf->num_dwords = num_dwords; \
+ prim_buf->current_dma_ptr = dma_ptr; \
+} while(0)
+
+#define PRIMADVANCE(dev_priv) do { \
+drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ if (MGA_VERBOSE) { \
+ DRM_DEBUG("PRIMADVANCE in %s\n", __FUNCTION__); \
+ if (outcount & 3) \
+ DRM_DEBUG(" --- truncation\n"); \
+ } \
+ tmp_buf->num_dwords = num_dwords; \
+ tmp_buf->current_dma_ptr = dma_ptr; \
+} while (0)
+
+#define PRIMUPDATE(dev_priv) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ tmp_buf->sec_used++; \
+} while (0)
+
+#define AGEBUF(dev_priv, buf_priv) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ buf_priv->my_freelist->age = tmp_buf->prim_age; \
+} while (0)
+
+
+#define PRIMOUTREG(reg, val) do { \
+ tempIndex[outcount]=ADRINDEX(reg); \
+ dma_ptr[1+outcount] = val; \
+ if (MGA_VERBOSE) \
+ DRM_DEBUG(" PRIMOUT %d: 0x%x -- 0x%x\n", \
+ num_dwords + 1 + outcount, ADRINDEX(reg), val); \
+ if( ++outcount == 4) { \
+ outcount = 0; \
+ dma_ptr[0] = *(u_int32_t *)tempIndex; \
+ dma_ptr+=5; \
+ num_dwords += 5; \
+ } \
+}while (0)
+
+/* A reduced set of the mga registers.
+ */
+
+#define MGAREG_MGA_EXEC 0x0100
+#define MGAREG_ALPHACTRL 0x2c7c
+#define MGAREG_AR0 0x1c60
+#define MGAREG_AR1 0x1c64
+#define MGAREG_AR2 0x1c68
+#define MGAREG_AR3 0x1c6c
+#define MGAREG_AR4 0x1c70
+#define MGAREG_AR5 0x1c74
+#define MGAREG_AR6 0x1c78
+#define MGAREG_CXBNDRY 0x1c80
+#define MGAREG_CXLEFT 0x1ca0
+#define MGAREG_CXRIGHT 0x1ca4
+#define MGAREG_DMAPAD 0x1c54
+#define MGAREG_DSTORG 0x2cb8
+#define MGAREG_DWGCTL 0x1c00
+#define MGAREG_DWGSYNC 0x2c4c
+#define MGAREG_FCOL 0x1c24
+#define MGAREG_FIFOSTATUS 0x1e10
+#define MGAREG_FOGCOL 0x1cf4
+#define MGAREG_FXBNDRY 0x1c84
+#define MGAREG_FXLEFT 0x1ca8
+#define MGAREG_FXRIGHT 0x1cac
+#define MGAREG_ICLEAR 0x1e18
+#define MGAREG_IEN 0x1e1c
+#define MGAREG_LEN 0x1c5c
+#define MGAREG_MACCESS 0x1c04
+#define MGAREG_PITCH 0x1c8c
+#define MGAREG_PLNWT 0x1c1c
+#define MGAREG_PRIMADDRESS 0x1e58
+#define MGAREG_PRIMEND 0x1e5c
+#define MGAREG_PRIMPTR 0x1e50
+#define MGAREG_SECADDRESS 0x2c40
+#define MGAREG_SECEND 0x2c44
+#define MGAREG_SETUPADDRESS 0x2cd0
+#define MGAREG_SETUPEND 0x2cd4
+#define MGAREG_SOFTRAP 0x2c48
+#define MGAREG_SRCORG 0x2cb4
+#define MGAREG_STATUS 0x1e14
+#define MGAREG_STENCIL 0x2cc8
+#define MGAREG_STENCILCTL 0x2ccc
+#define MGAREG_TDUALSTAGE0 0x2cf8
+#define MGAREG_TDUALSTAGE1 0x2cfc
+#define MGAREG_TEXBORDERCOL 0x2c5c
+#define MGAREG_TEXCTL 0x2c30
+#define MGAREG_TEXCTL2 0x2c3c
+#define MGAREG_TEXFILTER 0x2c58
+#define MGAREG_TEXHEIGHT 0x2c2c
+#define MGAREG_TEXORG 0x2c24
+#define MGAREG_TEXORG1 0x2ca4
+#define MGAREG_TEXORG2 0x2ca8
+#define MGAREG_TEXORG3 0x2cac
+#define MGAREG_TEXORG4 0x2cb0
+#define MGAREG_TEXTRANS 0x2c34
+#define MGAREG_TEXTRANSHIGH 0x2c38
+#define MGAREG_TEXWIDTH 0x2c28
+#define MGAREG_WACCEPTSEQ 0x1dd4
+#define MGAREG_WCODEADDR 0x1e6c
+#define MGAREG_WFLAG 0x1dc4
+#define MGAREG_WFLAG1 0x1de0
+#define MGAREG_WFLAGNB 0x1e64
+#define MGAREG_WFLAGNB1 0x1e08
+#define MGAREG_WGETMSB 0x1dc8
+#define MGAREG_WIADDR 0x1dc0
+#define MGAREG_WIADDR2 0x1dd8
+#define MGAREG_WMISC 0x1e70
+#define MGAREG_WVRTXSZ 0x1dcc
+#define MGAREG_YBOT 0x1c9c
+#define MGAREG_YDST 0x1c90
+#define MGAREG_YDSTLEN 0x1c88
+#define MGAREG_YDSTORG 0x1c94
+#define MGAREG_YTOP 0x1c98
+#define MGAREG_ZORG 0x1c0c
+
+#define PDEA_pagpxfer_enable 0x2
+
+#define WIA_wmode_suspend 0x0
+#define WIA_wmode_start 0x3
+#define WIA_wagp_agp 0x4
+
+#define DC_opcod_line_open 0x0
+#define DC_opcod_autoline_open 0x1
+#define DC_opcod_line_close 0x2
+#define DC_opcod_autoline_close 0x3
+#define DC_opcod_trap 0x4
+#define DC_opcod_texture_trap 0x6
+#define DC_opcod_bitblt 0x8
+#define DC_opcod_iload 0x9
+#define DC_atype_rpl 0x0
+#define DC_atype_rstr 0x10
+#define DC_atype_zi 0x30
+#define DC_atype_blk 0x40
+#define DC_atype_i 0x70
+#define DC_linear_xy 0x0
+#define DC_linear_linear 0x80
+#define DC_zmode_nozcmp 0x0
+#define DC_zmode_ze 0x200
+#define DC_zmode_zne 0x300
+#define DC_zmode_zlt 0x400
+#define DC_zmode_zlte 0x500
+#define DC_zmode_zgt 0x600
+#define DC_zmode_zgte 0x700
+#define DC_solid_disable 0x0
+#define DC_solid_enable 0x800
+#define DC_arzero_disable 0x0
+#define DC_arzero_enable 0x1000
+#define DC_sgnzero_disable 0x0
+#define DC_sgnzero_enable 0x2000
+#define DC_shftzero_disable 0x0
+#define DC_shftzero_enable 0x4000
+#define DC_bop_SHIFT 16
+#define DC_trans_SHIFT 20
+#define DC_bltmod_bmonolef 0x0
+#define DC_bltmod_bmonowf 0x8000000
+#define DC_bltmod_bplan 0x2000000
+#define DC_bltmod_bfcol 0x4000000
+#define DC_bltmod_bu32bgr 0x6000000
+#define DC_bltmod_bu32rgb 0xe000000
+#define DC_bltmod_bu24bgr 0x16000000
+#define DC_bltmod_bu24rgb 0x1e000000
+#define DC_pattern_disable 0x0
+#define DC_pattern_enable 0x20000000
+#define DC_transc_disable 0x0
+#define DC_transc_enable 0x40000000
+#define DC_clipdis_disable 0x0
+#define DC_clipdis_enable 0x80000000
+
+#define SETADD_mode_vertlist 0x0
+
+
+#define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \
+ DC_sgnzero_enable | DC_shftzero_enable | \
+ (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \
+ DC_solid_enable | DC_transc_enable)
+
+
+#define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \
+ DC_solid_disable | DC_arzero_disable | \
+ DC_sgnzero_enable | DC_shftzero_enable | \
+ (0xC << DC_bop_SHIFT) | DC_bltmod_bfcol | \
+ DC_pattern_disable | DC_transc_disable | \
+ DC_clipdis_enable) \
+
+#define MGA_FLUSH_CMD (DC_opcod_texture_trap | (0xF << DC_trans_SHIFT) |\
+ DC_arzero_enable | DC_sgnzero_enable | \
+ DC_atype_i)
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_state.c
new file mode 100644
index 000000000..73029bbe1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga/mga_state.c
@@ -0,0 +1,1074 @@
+/* mga_state.c -- State support for mga g200/g400
+ * Created: Thu Jan 27 02:53:43 2000 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Jeff Hartmann <jhartmann@precisioninsight.com>
+ * Keith Whitwell <keithw@precisioninsight.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "mga_drv.h"
+#include "drm.h"
+
+typedef u_int16_t u16;
+typedef u_int32_t u32;
+
+static void mgaEmitClipRect(drm_mga_private_t * dev_priv,
+ drm_clip_rect_t * box)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ /* This takes 10 dwords */
+ PRIMGETPTR(dev_priv);
+
+ /* Force reset of dwgctl (eliminates clip disable) */
+#if 0
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+#else
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
+#endif
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_CXBNDRY, ((box->x2) << 16) | (box->x1));
+ PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / 2);
+ PRIMOUTREG(MGAREG_YBOT, box->y2 * dev_priv->stride / 2);
+
+ PRIMADVANCE(dev_priv);
+}
+
+static void mgaEmitContext(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ /* This takes a max of 15 dwords */
+ PRIMGETPTR(dev_priv);
+
+ PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]);
+ PRIMOUTREG(MGAREG_MACCESS, regs[MGA_CTXREG_MACCESS]);
+ PRIMOUTREG(MGAREG_PLNWT, regs[MGA_CTXREG_PLNWT]);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+
+ PRIMOUTREG(MGAREG_ALPHACTRL, regs[MGA_CTXREG_ALPHACTRL]);
+ PRIMOUTREG(MGAREG_FOGCOL, regs[MGA_CTXREG_FOGCOLOR]);
+ PRIMOUTREG(MGAREG_WFLAG, regs[MGA_CTXREG_WFLAG]);
+ PRIMOUTREG(MGAREG_ZORG, dev_priv->depthOffset); /* invarient */
+
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
+ PRIMOUTREG(MGAREG_WFLAG1, regs[MGA_CTXREG_WFLAG]);
+ PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]);
+ PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]);
+ PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]);
+ } else {
+ PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ }
+
+ PRIMADVANCE(dev_priv);
+}
+
+static void mgaG200EmitTex(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->TexState[0];
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes 20 dwords */
+
+ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2]);
+ PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
+ PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]);
+ PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]);
+
+ PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]);
+ PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]);
+ PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]);
+ PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]);
+
+ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
+ PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(0x2d00 + 24 * 4, regs[MGA_TEXREG_WIDTH]);
+
+ PRIMOUTREG(0x2d00 + 34 * 4, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
+ PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMADVANCE(dev_priv);
+}
+
+static void mgaG400EmitTex0(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->TexState[0];
+ int multitex = sarea_priv->WarpPipe & MGA_T2;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes a max of 30 dwords */
+
+ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000);
+ PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
+ PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]);
+ PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]);
+
+ PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]);
+ PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]);
+ PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]);
+ PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]);
+
+ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
+ PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(0x2d00 + 49 * 4, 0);
+
+ PRIMOUTREG(0x2d00 + 57 * 4, 0);
+ PRIMOUTREG(0x2d00 + 53 * 4, 0);
+ PRIMOUTREG(0x2d00 + 61 * 4, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ if (!multitex) {
+ PRIMOUTREG(0x2d00 + 52 * 4, 0x40);
+ PRIMOUTREG(0x2d00 + 60 * 4, 0x40);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ }
+
+ PRIMOUTREG(0x2d00 + 54 * 4, regs[MGA_TEXREG_WIDTH] | 0x40);
+ PRIMOUTREG(0x2d00 + 62 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
+ PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
+
+ PRIMADVANCE(dev_priv);
+}
+
+#define TMC_map1_enable 0x80000000
+
+static void mgaG400EmitTex1(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->TexState[1];
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes 25 dwords */
+
+ PRIMOUTREG(MGAREG_TEXCTL2,
+ regs[MGA_TEXREG_CTL2] | TMC_map1_enable | 0x00008000);
+ PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
+ PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]);
+ PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]);
+
+ PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]);
+ PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]);
+ PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]);
+ PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]);
+
+ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
+ PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(0x2d00 + 49 * 4, 0);
+
+ PRIMOUTREG(0x2d00 + 57 * 4, 0);
+ PRIMOUTREG(0x2d00 + 53 * 4, 0);
+ PRIMOUTREG(0x2d00 + 61 * 4, 0);
+ PRIMOUTREG(0x2d00 + 52 * 4, regs[MGA_TEXREG_WIDTH] | 0x40);
+
+ PRIMOUTREG(0x2d00 + 60 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
+ PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
+ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000);
+
+ PRIMADVANCE(dev_priv);
+}
+
+#define EMIT_PIPE 50
+static void mgaG400EmitPipe(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int pipe = sarea_priv->WarpPipe;
+ float fParam = 12800.0f;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes 50 dwords */
+
+ /* Establish vertex size.
+ */
+ PRIMOUTREG(MGAREG_WIADDR2, WIA_wmode_suspend);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ if (pipe & MGA_T2) {
+ PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001e09);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x1e000000);
+ } else {
+ if (dev_priv->WarpPipe & MGA_T2) {
+ /* Flush the WARP pipe */
+ PRIMOUTREG(MGAREG_YDST, 0);
+ PRIMOUTREG(MGAREG_FXLEFT, 0);
+ PRIMOUTREG(MGAREG_FXRIGHT, 1);
+ PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD);
+
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x7000);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0);
+ PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0);
+ }
+
+ PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x18000000);
+ }
+
+ PRIMOUTREG(MGAREG_WFLAG, 0);
+ PRIMOUTREG(MGAREG_WFLAG1, 0);
+ PRIMOUTREG(0x2d00 + 56 * 4, *((u32 *) (&fParam)));
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(0x2d00 + 49 * 4, 0); /* Tex stage 0 */
+ PRIMOUTREG(0x2d00 + 57 * 4, 0); /* Tex stage 0 */
+ PRIMOUTREG(0x2d00 + 53 * 4, 0); /* Tex stage 1 */
+ PRIMOUTREG(0x2d00 + 61 * 4, 0); /* Tex stage 1 */
+
+ PRIMOUTREG(0x2d00 + 54 * 4, 0x40); /* Tex stage 0 : w */
+ PRIMOUTREG(0x2d00 + 62 * 4, 0x40); /* Tex stage 0 : h */
+ PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */
+ PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */
+
+ /* Dma pading required due to hw bug */
+ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
+ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
+ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
+ PRIMOUTREG(MGAREG_WIADDR2,
+ (u32) (dev_priv->WarpIndex[pipe].
+ phys_addr | WIA_wmode_start | WIA_wagp_agp));
+ PRIMADVANCE(dev_priv);
+}
+
+static void mgaG200EmitPipe(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int pipe = sarea_priv->WarpPipe;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes 15 dwords */
+
+ PRIMOUTREG(MGAREG_WIADDR, WIA_wmode_suspend);
+ PRIMOUTREG(MGAREG_WVRTXSZ, 7);
+ PRIMOUTREG(MGAREG_WFLAG, 0);
+ PRIMOUTREG(0x2d00 + 24 * 4, 0); /* tex w/h */
+
+ PRIMOUTREG(0x2d00 + 25 * 4, 0x100);
+ PRIMOUTREG(0x2d00 + 34 * 4, 0); /* tex w/h */
+ PRIMOUTREG(0x2d00 + 42 * 4, 0xFFFF);
+ PRIMOUTREG(0x2d00 + 60 * 4, 0xFFFF);
+
+ /* Dma pading required due to hw bug */
+ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
+ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
+ PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
+ PRIMOUTREG(MGAREG_WIADDR,
+ (u32) (dev_priv->WarpIndex[pipe].
+ phys_addr | WIA_wmode_start | WIA_wagp_agp));
+
+ PRIMADVANCE(dev_priv);
+}
+
+static void mgaEmitState(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int dirty = sarea_priv->dirty;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
+ int multitex = sarea_priv->WarpPipe & MGA_T2;
+
+ if (sarea_priv->WarpPipe != dev_priv->WarpPipe) {
+ mgaG400EmitPipe(dev_priv);
+ dev_priv->WarpPipe = sarea_priv->WarpPipe;
+ }
+
+ if (dirty & MGA_UPLOAD_CTX) {
+ mgaEmitContext(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_CTX;
+ }
+
+ if (dirty & MGA_UPLOAD_TEX0) {
+ mgaG400EmitTex0(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_TEX0;
+ }
+
+ if ((dirty & MGA_UPLOAD_TEX1) && multitex) {
+ mgaG400EmitTex1(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_TEX1;
+ }
+ } else {
+ if (sarea_priv->WarpPipe != dev_priv->WarpPipe) {
+ mgaG200EmitPipe(dev_priv);
+ dev_priv->WarpPipe = sarea_priv->WarpPipe;
+ }
+
+ if (dirty & MGA_UPLOAD_CTX) {
+ mgaEmitContext(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_CTX;
+ }
+
+ if (dirty & MGA_UPLOAD_TEX0) {
+ mgaG200EmitTex(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_TEX0;
+ }
+ }
+}
+
+
+/* Disallow all write destinations except the front and backbuffer.
+ */
+static int mgaVerifyContext(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOffset &&
+ regs[MGA_CTXREG_DSTORG] != dev_priv->backOffset) {
+ DRM_DEBUG("BAD DSTORG: %x (front %x, back %x)\n\n",
+ regs[MGA_CTXREG_DSTORG], dev_priv->frontOffset,
+ dev_priv->backOffset);
+ regs[MGA_CTXREG_DSTORG] = 0;
+ return -1;
+ }
+
+ return 0;
+}
+
+/* Disallow texture reads from PCI space.
+ */
+static int mgaVerifyTex(drm_mga_private_t * dev_priv, int unit)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) {
+ DRM_DEBUG("BAD TEXREG_ORG: %x, unit %d\n",
+ sarea_priv->TexState[unit][MGA_TEXREG_ORG],
+ unit);
+ sarea_priv->TexState[unit][MGA_TEXREG_ORG] = 0;
+ return -1;
+ }
+
+ return 0;
+}
+
+static int mgaVerifyState(drm_mga_private_t * dev_priv)
+{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int dirty = sarea_priv->dirty;
+ int rv = 0;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
+ sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
+
+ if (dirty & MGA_UPLOAD_CTX)
+ rv |= mgaVerifyContext(dev_priv);
+
+ if (dirty & MGA_UPLOAD_TEX0)
+ rv |= mgaVerifyTex(dev_priv, 0);
+
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
+ if (dirty & MGA_UPLOAD_TEX1)
+ rv |= mgaVerifyTex(dev_priv, 1);
+
+ if (dirty & MGA_UPLOAD_PIPE)
+ rv |= (sarea_priv->WarpPipe > MGA_MAX_G400_PIPES);
+ } else {
+ if (dirty & MGA_UPLOAD_PIPE)
+ rv |= (sarea_priv->WarpPipe > MGA_MAX_G200_PIPES);
+ }
+
+ return rv == 0;
+}
+
+static int mgaVerifyIload(drm_mga_private_t * dev_priv,
+ unsigned long bus_address,
+ unsigned int dstOrg, int length)
+{
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (dstOrg < dev_priv->textureOffset ||
+ dstOrg + length >
+ (dev_priv->textureOffset + dev_priv->textureSize)) {
+ return EINVAL;
+ }
+ if (length % 64) {
+ return EINVAL;
+ }
+ return 0;
+}
+
+/* This copies a 64 byte aligned agp region to the frambuffer
+ * with a standard blit, the ioctl needs to do checking */
+
+static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
+ unsigned long bus_address,
+ int length, unsigned int destOrg)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ int use_agp = PDEA_pagpxfer_enable | 0x00000001;
+ u16 y2;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ y2 = length / 64;
+
+ PRIM_OVERFLOW(dev, dev_priv, 30);
+ PRIMGETPTR(dev_priv);
+
+ PRIMOUTREG(MGAREG_DSTORG, destOrg);
+ PRIMOUTREG(MGAREG_MACCESS, 0x00000000);
+ DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp);
+ PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp);
+ PRIMOUTREG(MGAREG_AR5, 64);
+
+ PRIMOUTREG(MGAREG_PITCH, 64);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, MGA_COPY_CMD);
+
+ PRIMOUTREG(MGAREG_AR0, 63);
+ PRIMOUTREG(MGAREG_AR3, 0);
+ PRIMOUTREG(MGAREG_FXBNDRY, (63 << 16));
+ PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, y2);
+
+ PRIMOUTREG(MGAREG_SRCORG, 0);
+ PRIMOUTREG(MGAREG_PITCH, dev_priv->stride / dev_priv->cpp);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMADVANCE(dev_priv);
+}
+
+static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned long address = (unsigned long) buf->bus_address;
+ int length = buf->used;
+ int use_agp = PDEA_pagpxfer_enable;
+ int i = 0;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ DRM_DEBUG("dispatch vertex %d addr 0x%lx, "
+ "length 0x%x nbox %d dirty %x\n",
+ buf->idx, address, length,
+ sarea_priv->nbox, sarea_priv->dirty);
+
+ DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total);
+
+ if (buf->used) {
+ /* WARNING: if you change any of the state functions verify
+ * these numbers (Overestimating this doesn't hurt).
+ */
+ buf_priv->dispatched = 1;
+ primary_needed = (50 + 15 + 15 + 30 + 25 +
+ 10 + 15 * MGA_NR_SAREA_CLIPRECTS);
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ mgaEmitState(dev_priv);
+
+ do {
+ if (i < sarea_priv->nbox) {
+ DRM_DEBUG("idx %d Emit box %d/%d:"
+ "%d,%d - %d,%d\n",
+ buf->idx,
+ i, sarea_priv->nbox,
+ sarea_priv->boxes[i].x1,
+ sarea_priv->boxes[i].y1,
+ sarea_priv->boxes[i].x2,
+ sarea_priv->boxes[i].y2);
+
+ mgaEmitClipRect(dev_priv,
+ &sarea_priv->boxes[i]);
+ }
+
+ PRIMGETPTR(dev_priv);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_SECADDRESS,
+ ((u32) address) | TT_VERTEX);
+ PRIMOUTREG(MGAREG_SECEND,
+ (((u32) (address + length)) | use_agp));
+ PRIMADVANCE(dev_priv);
+ } while (++i < sarea_priv->nbox);
+ }
+
+ if (buf_priv->discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+
+
+}
+
+
+static void mga_dma_dispatch_indices(drm_device_t * dev,
+ drm_buf_t * buf,
+ unsigned int start, unsigned int end)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int address = (unsigned int) buf->bus_address;
+ int use_agp = PDEA_pagpxfer_enable;
+ int i = 0;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ DRM_DEBUG("dispatch indices %d addr 0x%x, "
+ "start 0x%x end 0x%x nbox %d dirty %x\n",
+ buf->idx, address, start, end,
+ sarea_priv->nbox, sarea_priv->dirty);
+
+ if (start != end) {
+ /* WARNING: if you change any of the state functions verify
+ * these numbers (Overestimating this doesn't hurt).
+ */
+ buf_priv->dispatched = 1;
+ primary_needed = (50 + 15 + 15 + 30 + 25 +
+ 10 + 15 * MGA_NR_SAREA_CLIPRECTS);
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ mgaEmitState(dev_priv);
+
+ do {
+ if (i < sarea_priv->nbox) {
+ DRM_DEBUG("idx %d Emit box %d/%d:"
+ "%d,%d - %d,%d\n",
+ buf->idx,
+ i, sarea_priv->nbox,
+ sarea_priv->boxes[i].x1,
+ sarea_priv->boxes[i].y1,
+ sarea_priv->boxes[i].x2,
+ sarea_priv->boxes[i].y2);
+
+ mgaEmitClipRect(dev_priv,
+ &sarea_priv->boxes[i]);
+ }
+
+ PRIMGETPTR(dev_priv);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_SETUPADDRESS,
+ ((address + start) |
+ SETADD_mode_vertlist));
+ PRIMOUTREG(MGAREG_SETUPEND,
+ ((address + end) | use_agp));
+ PRIMADVANCE(dev_priv);
+ } while (++i < sarea_priv->nbox);
+ }
+ if (buf_priv->discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+}
+
+
+static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
+ unsigned int clear_color,
+ unsigned int clear_zval)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+ int nbox = sarea_priv->nbox;
+ drm_clip_rect_t *pbox = sarea_priv->boxes;
+ unsigned int cmd;
+ int i;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (dev_priv->sgram)
+ cmd = MGA_CLEAR_CMD | DC_atype_blk;
+ else
+ cmd = MGA_CLEAR_CMD | DC_atype_rstr;
+
+ primary_needed = nbox * 70;
+ if (primary_needed == 0)
+ primary_needed = 70;
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ PRIMGETPTR(dev_priv);
+
+ for (i = 0; i < nbox; i++) {
+ unsigned int height = pbox[i].y2 - pbox[i].y1;
+
+ DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n",
+ pbox[i].x1, pbox[i].y1, pbox[i].x2,
+ pbox[i].y2, flags);
+
+ if (flags & MGA_FRONT) {
+ DRM_DEBUG("clear front\n");
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_YDSTLEN,
+ (pbox[i].y1 << 16) | height);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ (pbox[i].x2 << 16) | pbox[i].x1);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_FCOL, clear_color);
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset);
+ PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd);
+ }
+
+ if (flags & MGA_BACK) {
+ DRM_DEBUG("clear back\n");
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_YDSTLEN,
+ (pbox[i].y1 << 16) | height);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ (pbox[i].x2 << 16) | pbox[i].x1);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_FCOL, clear_color);
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->backOffset);
+ PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd);
+ }
+
+ if (flags & MGA_DEPTH) {
+ DRM_DEBUG("clear depth\n");
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_YDSTLEN,
+ (pbox[i].y1 << 16) | height);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ (pbox[i].x2 << 16) | pbox[i].x1);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_FCOL, clear_zval);
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->depthOffset);
+ PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd);
+ }
+ }
+
+ /* Force reset of DWGCTL */
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMADVANCE(dev_priv);
+}
+
+static void mga_dma_dispatch_swap(drm_device_t * dev)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+ int nbox = sarea_priv->nbox;
+ drm_clip_rect_t *pbox = sarea_priv->boxes;
+ int i;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ primary_needed = nbox * 5;
+ primary_needed += 60;
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ PRIMGETPTR(dev_priv);
+
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset);
+ PRIMOUTREG(MGAREG_MACCESS, dev_priv->mAccess);
+ PRIMOUTREG(MGAREG_SRCORG, dev_priv->backOffset);
+ PRIMOUTREG(MGAREG_AR5, dev_priv->stride / 2);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, MGA_COPY_CMD);
+
+ for (i = 0; i < nbox; i++) {
+ unsigned int h = pbox[i].y2 - pbox[i].y1;
+ unsigned int start = pbox[i].y1 * dev_priv->stride / 2;
+
+ DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
+ pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2);
+
+ PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1);
+ PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ pbox[i].x1 | ((pbox[i].x2 - 1) << 16));
+ PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC,
+ (pbox[i].y1 << 16) | h);
+ }
+
+ /* Force reset of DWGCTL */
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_SRCORG, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+
+ PRIMADVANCE(dev_priv);
+}
+
+int mga_clear_bufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ drm_mga_clear_t clear;
+ int s;
+
+ clear = *(drm_mga_clear_t *) data;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_clear_bufs called without lock held\n");
+ return EINVAL;
+ }
+
+ if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
+ sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
+
+ /* Make sure we restore the 3D state next time.
+ */
+ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX;
+ mga_dma_dispatch_clear(dev, clear.flags,
+ clear.clear_color, clear.clear_depth);
+ PRIMUPDATE(dev_priv);
+ mga_flush_write_combine();
+ s = splsofttq();
+ mga_dma_schedule(dev, 1);
+ splx(s);
+ return 0;
+}
+
+int mga_swap_bufs(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ int s;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_swap_bufs called without lock held\n");
+ return EINVAL;
+ }
+
+ if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
+ sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
+
+ /* Make sure we restore the 3D state next time.
+ */
+ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX;
+ mga_dma_dispatch_swap(dev);
+ PRIMUPDATE(dev_priv);
+ set_bit(MGA_BUF_SWAP_PENDING,
+ &dev_priv->current_prim->buffer_status);
+ mga_flush_write_combine();
+ s = splsofttq();
+ mga_dma_schedule(dev, 1);
+ splx(s);
+ return 0;
+}
+
+int mga_iload(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_iload_t iload;
+ unsigned long bus_address;
+ int s;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ DRM_DEBUG("Starting Iload\n");
+ iload = *(drm_mga_iload_t *) data;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_iload called without lock held\n");
+ return EINVAL;
+ }
+
+ buf = dma->buflist[iload.idx];
+ buf_priv = buf->dev_private;
+ bus_address = buf->bus_address;
+ DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n",
+ bus_address, iload.length, iload.destOrg);
+
+ if (mgaVerifyIload(dev_priv,
+ bus_address, iload.destOrg, iload.length)) {
+ mga_freelist_put(dev, buf);
+ return EINVAL;
+ }
+
+ sarea_priv->dirty |= MGA_UPLOAD_CTX;
+
+ mga_dma_dispatch_tex_blit(dev, bus_address, iload.length,
+ iload.destOrg);
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->discard = 1;
+ mga_freelist_put(dev, buf);
+ mga_flush_write_combine();
+ s = splsofttq();
+ mga_dma_schedule(dev, 1);
+ splx(s);
+ return 0;
+}
+
+int mga_vertex(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_vertex_t vertex;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ vertex = *(drm_mga_vertex_t *) data;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_vertex called without lock held\n");
+ return EINVAL;
+ }
+
+ DRM_DEBUG("mga_vertex\n");
+
+ buf = dma->buflist[vertex.idx];
+ buf_priv = buf->dev_private;
+
+ buf->used = vertex.used;
+ buf_priv->discard = vertex.discard;
+
+ if (!mgaVerifyState(dev_priv)) {
+ if (vertex.discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+ DRM_DEBUG("bad state\n");
+ return EINVAL;
+ }
+
+ mga_dma_dispatch_vertex(dev, buf);
+
+ PRIMUPDATE(dev_priv);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+
+int mga_indices(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_indices_t indices;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ indices = *(drm_mga_indices_t *) data;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_indices called without lock held\n");
+ return EINVAL;
+ }
+
+ DRM_DEBUG("mga_indices\n");
+
+ buf = dma->buflist[indices.idx];
+ buf_priv = buf->dev_private;
+
+ buf_priv->discard = indices.discard;
+
+ if (!mgaVerifyState(dev_priv)) {
+ if (indices.discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+ return EINVAL;
+ }
+
+ mga_dma_dispatch_indices(dev, buf, indices.start, indices.end);
+
+ PRIMUPDATE(dev_priv);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+
+
+static int
+mga_dma_get_buffers(drm_device_t * dev, drm_dma_t * d, struct proc *p)
+{
+ int i, error;
+ drm_buf_t *buf;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ for (i = d->granted_count; i < d->request_count; i++) {
+ buf = mga_freelist_get(dev);
+ if (!buf)
+ break;
+ buf->pid = p->p_pid;
+ error = copyout(&buf->idx,
+ &d->request_indices[i],
+ sizeof(buf->idx));
+ if (error) return error;
+ error = copyout(&buf->total,
+ &d->request_sizes[i],
+ sizeof(buf->total));
+ if (error) return error;
+ ++d->granted_count;
+ }
+ return 0;
+}
+
+int mga_dma(dev_t kdev, u_long cmd, caddr_t data,
+ int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ drm_dma_t d;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ d = *(drm_dma_t *) data;
+ DRM_DEBUG("%d %d: %d send, %d req\n",
+ p->p_pid, d.context, d.send_count, d.request_count);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_dma called without lock held\n");
+ return EINVAL;
+ }
+
+ /* Please don't send us buffers.
+ */
+ if (d.send_count != 0) {
+ DRM_ERROR
+ ("Process %d trying to send %d buffers via drmDMA\n",
+ p->p_pid, d.send_count);
+ return EINVAL;
+ }
+
+ /* We'll send you buffers.
+ */
+ if (d.request_count < 0 || d.request_count > dma->buf_count) {
+ DRM_ERROR
+ ("Process %d trying to get %d buffers (of %d max)\n",
+ p->p_pid, d.request_count, dma->buf_count);
+ return EINVAL;
+ }
+
+ d.granted_count = 0;
+
+ if (d.request_count) {
+ retcode = mga_dma_get_buffers(dev, &d, p);
+ }
+
+ DRM_DEBUG("%d returning, granted = %d\n",
+ p->p_pid, d.granted_count);
+ *(drm_dma_t *) data = d;
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h
new file mode 100644
index 000000000..eefa28d3f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/mga_drm.h
@@ -0,0 +1,269 @@
+/* mga_drm.h -- Public header for the Matrox g200/g400 driver
+ * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Jeff Hartmann <jhartmann@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ */
+
+#ifndef _MGA_DRM_H_
+#define _MGA_DRM_H_
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmMga.h)
+ */
+#ifndef _MGA_DEFINES_
+#define _MGA_DEFINES_
+
+#define MGA_F 0x1 /* fog */
+#define MGA_A 0x2 /* alpha */
+#define MGA_S 0x4 /* specular */
+#define MGA_T2 0x8 /* multitexture */
+
+#define MGA_WARP_TGZ 0
+#define MGA_WARP_TGZF (MGA_F)
+#define MGA_WARP_TGZA (MGA_A)
+#define MGA_WARP_TGZAF (MGA_F|MGA_A)
+#define MGA_WARP_TGZS (MGA_S)
+#define MGA_WARP_TGZSF (MGA_S|MGA_F)
+#define MGA_WARP_TGZSA (MGA_S|MGA_A)
+#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
+#define MGA_WARP_T2GZ (MGA_T2)
+#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
+#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
+#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
+#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
+#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
+#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
+#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
+
+#define MGA_MAX_G400_PIPES 16
+#define MGA_MAX_G200_PIPES 8 /* no multitex */
+#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
+
+#define MGA_CARD_TYPE_G200 1
+#define MGA_CARD_TYPE_G400 2
+
+#define MGA_FRONT 0x1
+#define MGA_BACK 0x2
+#define MGA_DEPTH 0x4
+
+/* 3d state excluding texture units:
+ */
+#define MGA_CTXREG_DSTORG 0 /* validated */
+#define MGA_CTXREG_MACCESS 1
+#define MGA_CTXREG_PLNWT 2
+#define MGA_CTXREG_DWGCTL 3
+#define MGA_CTXREG_ALPHACTRL 4
+#define MGA_CTXREG_FOGCOLOR 5
+#define MGA_CTXREG_WFLAG 6
+#define MGA_CTXREG_TDUAL0 7
+#define MGA_CTXREG_TDUAL1 8
+#define MGA_CTXREG_FCOL 9
+#define MGA_CTX_SETUP_SIZE 10
+
+/* 2d state
+ */
+#define MGA_2DREG_PITCH 0
+#define MGA_2D_SETUP_SIZE 1
+
+/* Each texture unit has a state:
+ */
+#define MGA_TEXREG_CTL 0
+#define MGA_TEXREG_CTL2 1
+#define MGA_TEXREG_FILTER 2
+#define MGA_TEXREG_BORDERCOL 3
+#define MGA_TEXREG_ORG 4 /* validated */
+#define MGA_TEXREG_ORG1 5
+#define MGA_TEXREG_ORG2 6
+#define MGA_TEXREG_ORG3 7
+#define MGA_TEXREG_ORG4 8
+#define MGA_TEXREG_WIDTH 9
+#define MGA_TEXREG_HEIGHT 10
+#define MGA_TEX_SETUP_SIZE 11
+
+/* What needs to be changed for the current vertex dma buffer?
+ */
+#define MGA_UPLOAD_CTX 0x1
+#define MGA_UPLOAD_TEX0 0x2
+#define MGA_UPLOAD_TEX1 0x4
+#define MGA_UPLOAD_PIPE 0x8
+#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
+#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
+#define MGA_UPLOAD_2D 0x40
+#define MGA_WAIT_AGE 0x80 /* handled client-side */
+#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
+#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
+ quiescent */
+
+/* 32 buffers of 64k each, total 2 meg.
+ */
+#define MGA_DMA_BUF_ORDER 16
+#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER)
+#define MGA_DMA_BUF_NR 31
+
+/* Keep these small for testing.
+ */
+#define MGA_NR_SAREA_CLIPRECTS 8
+
+/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
+ * regions, subject to a minimum region size of (1<<16) == 64k.
+ *
+ * Clients may subdivide regions internally, but when sharing between
+ * clients, the region size is the minimum granularity.
+ */
+
+#define MGA_CARD_HEAP 0
+#define MGA_AGP_HEAP 1
+#define MGA_NR_TEX_HEAPS 2
+#define MGA_NR_TEX_REGIONS 16
+#define MGA_LOG_MIN_TEX_REGION_SIZE 16
+#endif
+
+typedef struct _drm_mga_warp_index {
+ int installed;
+ unsigned long phys_addr;
+ int size;
+} drm_mga_warp_index_t;
+
+typedef struct drm_mga_init {
+ enum {
+ MGA_INIT_DMA = 0x01,
+ MGA_CLEANUP_DMA = 0x02
+ } func;
+ int reserved_map_agpstart;
+ int reserved_map_idx;
+ int buffer_map_idx;
+ int sarea_priv_offset;
+ int primary_size;
+ int warp_ucode_size;
+ unsigned int frontOffset;
+ unsigned int backOffset;
+ unsigned int depthOffset;
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ unsigned int agpTextureOffset;
+ unsigned int agpTextureSize;
+ unsigned int cpp;
+ unsigned int stride;
+ int sgram;
+ int chipset;
+ drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES];
+ unsigned int mAccess;
+} drm_mga_init_t;
+
+/* Warning: if you change the sarea structure, you must change the Xserver
+ * structures as well */
+
+typedef struct _drm_mga_tex_region {
+ unsigned char next, prev;
+ unsigned char in_use;
+ unsigned int age;
+} drm_mga_tex_region_t;
+
+typedef struct _drm_mga_sarea {
+ /* The channel for communication of state information to the kernel
+ * on firing a vertex dma buffer.
+ */
+ unsigned int ContextState[MGA_CTX_SETUP_SIZE];
+ unsigned int ServerState[MGA_2D_SETUP_SIZE];
+ unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
+ unsigned int WarpPipe;
+ unsigned int dirty;
+
+ unsigned int nbox;
+ drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
+
+
+ /* Information about the most recently used 3d drawable. The
+ * client fills in the req_* fields, the server fills in the
+ * exported_ fields and puts the cliprects into boxes, above.
+ *
+ * The client clears the exported_drawable field before
+ * clobbering the boxes data.
+ */
+ unsigned int req_drawable; /* the X drawable id */
+ unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
+
+ unsigned int exported_drawable;
+ unsigned int exported_index;
+ unsigned int exported_stamp;
+ unsigned int exported_buffers;
+ unsigned int exported_nfront;
+ unsigned int exported_nback;
+ int exported_back_x, exported_front_x, exported_w;
+ int exported_back_y, exported_front_y, exported_h;
+ drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
+
+ /* Counters for aging textures and for client-side throttling.
+ */
+ unsigned int last_enqueue; /* last time a buffer was enqueued */
+ unsigned int last_dispatch; /* age of the most recently dispatched buffer */
+ unsigned int last_quiescent; /* */
+
+
+ /* LRU lists for texture memory in agp space and on the card
+ */
+ drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
+ unsigned int texAge[MGA_NR_TEX_HEAPS];
+
+ /* Mechanism to validate card state.
+ */
+ int ctxOwner;
+} drm_mga_sarea_t;
+
+/* Device specific ioctls:
+ */
+typedef struct _drm_mga_clear {
+ unsigned int clear_color;
+ unsigned int clear_depth;
+ unsigned int flags;
+} drm_mga_clear_t;
+
+typedef struct _drm_mga_swap {
+ int dummy;
+} drm_mga_swap_t;
+
+typedef struct _drm_mga_iload {
+ int idx;
+ int length;
+ unsigned int destOrg;
+} drm_mga_iload_t;
+
+typedef struct _drm_mga_vertex {
+ int idx; /* buffer to queue */
+ int used; /* bytes in use */
+ int discard; /* client finished with buffer? */
+} drm_mga_vertex_t;
+
+typedef struct _drm_mga_indices {
+ int idx; /* buffer to queue */
+ unsigned int start;
+ unsigned int end;
+ int discard; /* client finished with buffer? */
+} drm_mga_indices_t;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h
new file mode 100644
index 000000000..bff103c23
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h
@@ -0,0 +1,111 @@
+/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
+ * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 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: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/r128_drm.h,v 1.1 2000/06/17 00:03:29 martin Exp $
+ */
+
+#ifndef _R128_DRM_H_
+#define _R128_DRM_H_
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmR128.h)
+ */
+typedef struct drm_r128_init {
+ enum {
+ R128_INIT_CCE = 0x01,
+ R128_CLEANUP_CCE = 0x02
+ } func;
+ int sarea_priv_offset;
+ int is_pci;
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_secure;
+ int ring_size;
+ int usec_timeout;
+
+ int fb_offset;
+ int agp_ring_offset;
+ int agp_read_ptr_offset;
+ int agp_vertbufs_offset;
+ int agp_indbufs_offset;
+ int agp_textures_offset;
+ int mmio_offset;
+} drm_r128_init_t;
+
+typedef struct drm_r128_packet {
+ unsigned long *buffer;
+ int count;
+ int flags;
+} drm_r128_packet_t;
+
+typedef enum drm_r128_prim {
+ _DRM_R128_PRIM_NONE = 0x0001,
+ _DRM_R128_PRIM_POINT = 0x0002,
+ _DRM_R128_PRIM_LINE = 0x0004,
+ _DRM_R128_PRIM_POLY_LINE = 0x0008,
+ _DRM_R128_PRIM_TRI_LIST = 0x0010,
+ _DRM_R128_PRIM_TRI_FAN = 0x0020,
+ _DRM_R128_PRIM_TRI_STRIP = 0x0040,
+ _DRM_R128_PRIM_TRI_TYPE2 = 0x0080
+} drm_r128_prim_t;
+
+typedef struct drm_r128_vertex {
+ /* Indices here refer to the offset into
+ buflist in drm_buf_get_t. */
+ int send_count; /* Number of buffers to send */
+ int *send_indices; /* List of handles to buffers */
+ int *send_sizes; /* Lengths of data to send */
+ drm_r128_prim_t prim; /* Primitive type */
+ int request_count; /* Number of buffers requested */
+ int *request_indices; /* Buffer information */
+ int *request_sizes;
+ int granted_count; /* Number of buffers granted */
+} drm_r128_vertex_t;
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (r128_sarea.h)
+ */
+#define R128_LOCAL_TEX_HEAP 0
+#define R128_AGP_TEX_HEAP 1
+#define R128_NR_TEX_HEAPS 2
+#define R128_NR_TEX_REGIONS 64
+#define R128_LOG_TEX_GRANULARITY 16
+
+typedef struct drm_tex_region {
+ unsigned char next, prev;
+ unsigned char in_use;
+ int age;
+} drm_tex_region_t;
+
+typedef struct drm_r128_sarea {
+ drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
+ int tex_age[R128_NR_TEX_HEAPS];
+ int ctx_owner;
+ int ring_write;
+} drm_r128_sarea_t;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/Makefile b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/Makefile
new file mode 100644
index 000000000..471a5fbfd
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/Makefile
@@ -0,0 +1,15 @@
+# $FreeBSD$
+
+KMOD = tdfx
+SRCS = tdfx_drv.c tdfx_context.c
+SRCS += device_if.h bus_if.h pci_if.h
+CFLAGS += ${DEBUG_FLAGS} -I..
+KMODDEPS = drm
+
+@:
+ ln -sf /sys @
+
+machine:
+ ln -sf /sys/i386/include machine
+
+.include <bsd.kmod.mk>
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_context.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_context.c
new file mode 100644
index 000000000..5a334058b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_context.c
@@ -0,0 +1,204 @@
+/* tdfx_context.c -- IOCTLs for tdfx contexts -*- c -*-
+ * Created: Thu Oct 7 10:50:22 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
+ *
+ */
+
+#include "drmP.h"
+#include "tdfx_drv.h"
+
+extern drm_ctx_t tdfx_res_ctx;
+
+static int tdfx_alloc_queue(drm_device_t *dev)
+{
+ return drm_ctxbitmap_next(dev);
+}
+
+int tdfx_context_switch(drm_device_t *dev, int old, int new)
+{
+ char buf[64];
+
+ atomic_inc(&dev->total_ctx);
+
+ if (test_and_set_bit(0, &dev->context_flag)) {
+ DRM_ERROR("Reentering -- FIXME\n");
+ return -EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ getnanotime(&dev->ctx_start);
+#endif
+
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
+
+ if (new == dev->last_context) {
+ clear_bit(0, &dev->context_flag);
+ return 0;
+ }
+
+ if (drm_flags & DRM_FLAG_NOCTX) {
+ tdfx_context_switch_complete(dev, new);
+ } else {
+ sprintf(buf, "C %d %d\n", old, new);
+ drm_write_string(dev, buf);
+ }
+
+ return 0;
+}
+
+int tdfx_context_switch_complete(drm_device_t *dev, int new)
+{
+ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
+ dev->last_switch = ticks;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Lock isn't held after context switch\n");
+ }
+
+ /* If a context switch is ever initiated
+ when the kernel holds the lock, release
+ that lock here. */
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &dev->lck_start);
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(&ts)]);
+ }
+#endif
+ clear_bit(0, &dev->context_flag);
+ wakeup(&dev->context_wait);
+
+ return 0;
+}
+
+
+int
+tdfx_resctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t ctx;
+ int i, error;
+
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
+ res = *(drm_ctx_res_t *) data;
+ if (res.count >= DRM_RESERVED_CONTEXTS) {
+ memset(&ctx, 0, sizeof(ctx));
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ ctx.handle = i;
+ error = copyout(&i, &res.contexts[i], sizeof(i));
+ if (error) return error;
+ }
+ }
+ res.count = DRM_RESERVED_CONTEXTS;
+ *(drm_ctx_res_t *) data = res;
+ return 0;
+}
+
+
+int
+tdfx_addctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ if ((ctx.handle = tdfx_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
+ /* Skip kernel's context and get a new one. */
+ ctx.handle = tdfx_alloc_queue(dev);
+ }
+ DRM_DEBUG("%d\n", ctx.handle);
+ if (ctx.handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
+ /* Should this return -EBUSY instead? */
+ return ENOMEM;
+ }
+
+ *(drm_ctx_t *) data = ctx;
+ return 0;
+}
+
+int
+tdfx_modctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ if (ctx.flags==_DRM_CONTEXT_PRESERVED)
+ tdfx_res_ctx.handle=ctx.handle;
+ return 0;
+}
+
+int
+tdfx_getctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ /* This is 0, because we don't hanlde any context flags */
+ ctx.flags = 0;
+ *(drm_ctx_t *) data = ctx;
+ return 0;
+}
+
+int
+tdfx_switchctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ return tdfx_context_switch(dev, dev->last_context, ctx.handle);
+}
+
+int
+tdfx_newctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ DRM_DEBUG("%d\n", ctx.handle);
+ tdfx_context_switch_complete(dev, ctx.handle);
+
+ return 0;
+}
+
+int
+tdfx_rmctx(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_ctx_t ctx;
+
+ ctx = *(drm_ctx_t *) data;
+ drm_ctxbitmap_free(dev, ctx.handle);
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.c
new file mode 100644
index 000000000..91e7d5603
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.c
@@ -0,0 +1,738 @@
+/* tdfx.c -- tdfx driver -*- c -*-
+ * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
+ *
+ */
+
+#include "drmP.h"
+#include "tdfx_drv.h"
+
+#include <pci/pcivar.h>
+
+MODULE_DEPEND(tdfx, drm, 1, 1, 1);
+#ifdef DRM_AGP
+MODULE_DEPEND(tdfx, agp, 1, 1, 1);
+#endif
+
+#define TDFX_NAME "tdfx"
+#define TDFX_DESC "tdfx"
+#define TDFX_DATE "19991009"
+#define TDFX_MAJOR 1
+#define TDFX_MINOR 0
+#define TDFX_PATCHLEVEL 0
+
+static int tdfx_init(device_t nbdev);
+static void tdfx_cleanup(device_t nbdev);
+
+drm_ctx_t tdfx_res_ctx;
+
+static int tdfx_probe(device_t dev)
+{
+ const char *s = 0;
+
+ switch (pci_get_devid(dev)) {
+ case 0x0003121a:
+ s = "3Dfx Voodoo Banshee graphics accelerator";
+ break;
+
+ case 0x0005121a:
+ s = "3Dfx Voodoo 3 graphics accelerator";
+ break;
+ }
+
+ if (s) {
+ device_set_desc(dev, s);
+ return 0;
+ }
+
+ return ENXIO;
+}
+
+static int tdfx_attach(device_t dev)
+{
+ tdfx_init(dev);
+ return 0;
+}
+
+static int tdfx_detach(device_t dev)
+{
+ tdfx_cleanup(dev);
+ return 0;
+}
+
+static device_method_t tdfx_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, tdfx_probe),
+ DEVMETHOD(device_attach, tdfx_attach),
+ DEVMETHOD(device_detach, tdfx_detach),
+
+ { 0, 0 }
+};
+
+static driver_t tdfx_driver = {
+ "drm",
+ tdfx_methods,
+ sizeof(drm_device_t),
+};
+
+static devclass_t tdfx_devclass;
+#define TDFX_SOFTC(unit) \
+ ((drm_device_t *) devclass_get_softc(tdfx_devclass, unit))
+
+DRIVER_MODULE(if_tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
+
+#define CDEV_MAJOR 145
+ /* tdfx_drv.c */
+static d_open_t tdfx_open;
+static d_close_t tdfx_close;
+static d_ioctl_t tdfx_version;
+static d_ioctl_t tdfx_ioctl;
+static d_ioctl_t tdfx_lock;
+static d_ioctl_t tdfx_unlock;
+
+static struct cdevsw tdfx_cdevsw = {
+ /* open */ tdfx_open,
+ /* close */ tdfx_close,
+ /* read */ drm_read,
+ /* write */ drm_write,
+ /* ioctl */ tdfx_ioctl,
+ /* poll */ drm_poll,
+ /* mmap */ drm_mmap,
+ /* strategy */ nostrategy,
+ /* name */ "tdfx",
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ D_TTY | D_TRACKCLOSE,
+ /* bmaj */ -1
+};
+
+static drm_ioctl_desc_t tdfx_ioctls[] = {
+ [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { tdfx_version, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { tdfx_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { tdfx_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { tdfx_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { tdfx_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { tdfx_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { tdfx_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { tdfx_resctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { tdfx_lock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { tdfx_unlock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
+#ifdef DRM_AGP
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_unbind, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_bind, 1, 1},
+#endif
+};
+#define TDFX_IOCTL_COUNT DRM_ARRAY_SIZE(tdfx_ioctls)
+
+static int
+tdfx_setup(drm_device_t *dev)
+{
+ int i;
+
+ device_busy(dev->device);
+
+ atomic_set(&dev->ioctl_count, 0);
+ atomic_set(&dev->vma_count, 0);
+ dev->buf_use = 0;
+ atomic_set(&dev->buf_alloc, 0);
+
+ atomic_set(&dev->total_open, 0);
+ atomic_set(&dev->total_close, 0);
+ atomic_set(&dev->total_ioctl, 0);
+ atomic_set(&dev->total_irq, 0);
+ atomic_set(&dev->total_ctx, 0);
+ atomic_set(&dev->total_locks, 0);
+ atomic_set(&dev->total_unlocks, 0);
+ atomic_set(&dev->total_contends, 0);
+ atomic_set(&dev->total_sleeps, 0);
+
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ dev->magiclist[i].head = NULL;
+ dev->magiclist[i].tail = NULL;
+ }
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ dev->vmalist = NULL;
+ dev->lock.hw_lock = NULL;
+ dev->lock.lock_queue = 0;
+ dev->queue_count = 0;
+ dev->queue_reserved = 0;
+ dev->queue_slots = 0;
+ dev->queuelist = NULL;
+ dev->irq = 0;
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma = 0;
+ dev->dma_flag = 0;
+ dev->last_context = 0;
+ dev->last_switch = 0;
+ dev->last_checked = 0;
+ callout_init(&dev->timer);
+ dev->context_wait = 0;
+
+ timespecclear(&dev->ctx_start);
+ timespecclear(&dev->lck_start);
+
+ dev->buf_rp = dev->buf;
+ dev->buf_wp = dev->buf;
+ dev->buf_end = dev->buf + DRM_BSZ;
+ bzero(&dev->buf_sel, sizeof dev->buf_sel);
+ dev->buf_sigio = NULL;
+ dev->buf_readers = 0;
+ dev->buf_writers = 0;
+ dev->buf_selecting = 0;
+
+ tdfx_res_ctx.handle=-1;
+
+ DRM_DEBUG("\n");
+
+ /* The kernel's context could be created here, but is now created
+ in drm_dma_enqueue. This is more resource-efficient for
+ hardware that does not do DMA, but may mean that
+ drm_select_queue fails between the time the interrupt is
+ initialized and the time the queues are initialized. */
+
+ return 0;
+}
+
+
+static int
+tdfx_takedown(drm_device_t *dev)
+{
+ int i;
+ drm_magic_entry_t *pt, *next;
+ drm_map_t *map;
+ drm_vma_entry_t *vma, *vma_next;
+
+ DRM_DEBUG("\n");
+
+ lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, curproc);
+ callout_stop(&dev->timer);
+
+ if (dev->devname) {
+ drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
+ dev->devname = NULL;
+ }
+
+ if (dev->unique) {
+ drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
+ dev->unique = NULL;
+ dev->unique_len = 0;
+ }
+ /* Clear pid list */
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ for (pt = dev->magiclist[i].head; pt; pt = next) {
+ next = pt->next;
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ }
+ dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
+ }
+#ifdef DRM_AGP
+ /* Clear AGP information */
+ if (dev->agp) {
+ drm_agp_mem_t *temp;
+ drm_agp_mem_t *temp_next;
+
+ temp = dev->agp->memory;
+ while(temp != NULL) {
+ temp_next = temp->next;
+ drm_free_agp(temp->handle, temp->pages);
+ drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
+ temp = temp_next;
+ }
+
+ if (dev->agp->acquired)
+ agp_release(dev->agp->agpdev);
+ drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ dev->agp = NULL;
+ }
+#endif
+
+ /* Clear vma list (only built for debugging) */
+ if (dev->vmalist) {
+ for (vma = dev->vmalist; vma; vma = vma_next) {
+ vma_next = vma->next;
+ drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
+ }
+ dev->vmalist = NULL;
+ }
+
+ /* Clear map area and mtrr information */
+ if (dev->maplist) {
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ switch (map->type) {
+ case _DRM_REGISTERS:
+ case _DRM_FRAME_BUFFER:
+#ifdef CONFIG_MTRR
+ if (map->mtrr >= 0) {
+ int retcode;
+ retcode = mtrr_del(map->mtrr,
+ map->offset,
+ map->size);
+ DRM_DEBUG("mtrr_del = %d\n", retcode);
+ }
+#endif
+ drm_ioremapfree(map->handle, map->size);
+ break;
+ case _DRM_SHM:
+ drm_free_pages((unsigned long)map->handle,
+ drm_order(map->size)
+ - PAGE_SHIFT,
+ DRM_MEM_SAREA);
+ break;
+ case _DRM_AGP:
+ break; /* XXX */
+ }
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ }
+ drm_free(dev->maplist,
+ dev->map_count * sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ }
+
+ if (dev->lock.hw_lock) {
+ dev->lock.hw_lock = NULL; /* SHM removed */
+ dev->lock.pid = 0;
+ wakeup(&dev->lock.lock_queue);
+ }
+ lockmgr(&dev->dev_lock, LK_RELEASE, 0, curproc);
+
+ return 0;
+}
+
+/* tdfx_init is called via tdfx_attach at module load time, */
+
+static int
+tdfx_init(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+ int retcode;
+
+ DRM_DEBUG("\n");
+
+ memset((void *)dev, 0, sizeof(*dev));
+ simple_lock_init(&dev->count_lock);
+ lockinit(&dev->dev_lock, PZERO, "drmlk", 0, 0);
+
+#if 0
+ drm_parse_options(tdfx);
+#endif
+
+ dev->device = nbdev;
+ dev->devnode = make_dev(&tdfx_cdevsw,
+ device_get_unit(nbdev),
+ DRM_DEV_UID,
+ DRM_DEV_GID,
+ DRM_DEV_MODE,
+ TDFX_NAME);
+ dev->name = TDFX_NAME;
+
+ drm_mem_init();
+ drm_sysctl_init(dev);
+ TAILQ_INIT(&dev->files);
+
+#ifdef DRM_AGP
+ dev->agp = drm_agp_init();
+#endif
+ if((retcode = drm_ctxbitmap_init(dev))) {
+ DRM_ERROR("Cannot allocate memory for context bitmap.\n");
+ drm_sysctl_cleanup(dev);
+ tdfx_takedown(dev);
+ return retcode;
+ }
+
+ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+ TDFX_NAME,
+ TDFX_MAJOR,
+ TDFX_MINOR,
+ TDFX_PATCHLEVEL,
+ TDFX_DATE,
+ device_get_unit(nbdev));
+
+ return 0;
+}
+
+/* tdfx_cleanup is called via tdfx_detach at module unload time. */
+
+static void
+tdfx_cleanup(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ DRM_DEBUG("\n");
+
+ drm_sysctl_cleanup(dev);
+ destroy_dev(dev->devnode);
+
+ DRM_INFO("Module unloaded\n");
+
+ drm_ctxbitmap_cleanup(dev);
+ tdfx_takedown(dev);
+}
+
+static int
+tdfx_version(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_version_t version;
+ int len;
+
+ version = *(drm_version_t *) data;
+
+#define DRM_COPY(name,value) \
+ len = strlen(value); \
+ if (len > name##_len) len = name##_len; \
+ name##_len = strlen(value); \
+ if (len && name) { \
+ int error = copyout(value, name, len); \
+ if (error) return error; \
+ }
+
+ version.version_major = TDFX_MAJOR;
+ version.version_minor = TDFX_MINOR;
+ version.version_patchlevel = TDFX_PATCHLEVEL;
+
+ DRM_COPY(version.name, TDFX_NAME);
+ DRM_COPY(version.date, TDFX_DATE);
+ DRM_COPY(version.desc, TDFX_DESC);
+
+ *(drm_version_t *) data = version;
+ return 0;
+}
+
+static int
+tdfx_open(dev_t kdev, int flags, int fmt, struct proc *p)
+{
+ drm_device_t *dev = TDFX_SOFTC(minor(kdev));
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+
+ device_busy(dev->device);
+ if (!(retcode = drm_open_helper(kdev, flags, fmt, p, dev))) {
+ atomic_inc(&dev->total_open);
+ simple_lock(&dev->count_lock);
+ if (!dev->open_count++) {
+ simple_unlock(&dev->count_lock);
+ retcode = tdfx_setup(dev);
+ }
+ simple_unlock(&dev->count_lock);
+ }
+ device_unbusy(dev->device);
+
+ return retcode;
+}
+
+static int
+tdfx_close(dev_t kdev, int flags, int fmt, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+ if (!(retcode = drm_close(kdev, flags, fmt, p))) {
+ atomic_inc(&dev->total_close);
+ simple_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ simple_unlock(&dev->count_lock);
+ return EBUSY;
+ }
+ simple_unlock(&dev->count_lock);
+ device_unbusy(dev->device);
+ return tdfx_takedown(dev);
+ }
+ simple_unlock(&dev->count_lock);
+ }
+
+ return retcode;
+}
+
+/* tdfx_ioctl is called whenever a process performs an ioctl on /dev/drm. */
+
+static int
+tdfx_ioctl(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ int nr = DRM_IOCTL_NR(cmd);
+ drm_device_t *dev = kdev->si_drv1;
+ drm_file_t *priv;
+ int retcode = 0;
+ drm_ioctl_desc_t *ioctl;
+ d_ioctl_t *func;
+
+ DRM_DEBUG("dev=%p\n", dev);
+ priv = drm_find_file_by_proc(dev, p);
+ if (!priv) {
+ DRM_DEBUG("can't find authenticator\n");
+ return EINVAL;
+ }
+
+ atomic_inc(&dev->ioctl_count);
+ atomic_inc(&dev->total_ioctl);
+ ++priv->ioctl_count;
+
+ DRM_DEBUG("pid = %d, cmd = 0x%02lx, nr = 0x%02x, auth = %d\n",
+ p->p_pid, cmd, nr, priv->authenticated);
+
+ switch (cmd) {
+ case FIONBIO:
+ atomic_dec(&dev->ioctl_count);
+ return 0;
+
+ case FIOASYNC:
+ atomic_dec(&dev->ioctl_count);
+ dev->flags |= FASYNC;
+ return 0;
+
+ case FIOSETOWN:
+ atomic_dec(&dev->ioctl_count);
+ return fsetown(*(int *)data, &dev->buf_sigio);
+
+ case FIOGETOWN:
+ atomic_dec(&dev->ioctl_count);
+ *(int *) data = fgetown(dev->buf_sigio);
+ return 0;
+ }
+
+ if (nr >= TDFX_IOCTL_COUNT) {
+ retcode = EINVAL;
+ } else {
+ ioctl = &tdfx_ioctls[nr];
+ func = ioctl->func;
+
+ if (!func) {
+ DRM_DEBUG("no function\n");
+ retcode = EINVAL;
+ } else if ((ioctl->root_only && suser(p))
+ || (ioctl->auth_needed && !priv->authenticated)) {
+ retcode = EACCES;
+ } else {
+ retcode = (func)(kdev, cmd, data, flags, p);
+ }
+ }
+
+ atomic_dec(&dev->ioctl_count);
+ return retcode;
+}
+
+static int
+tdfx_lock(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ int ret = 0;
+ drm_lock_t lock;
+#if DRM_DMA_HISTOGRAM
+
+ getnanotime(&dev->lck_start);
+#endif
+
+ lock = *(drm_lock_t *) data;
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ p->p_pid, lock.context);
+ return EINVAL;
+ }
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, p->p_pid, dev->lock.hw_lock->lock,
+ lock.flags);
+
+#if 0
+ /* dev->queue_count == 0 right now for
+ tdfx. FIXME? */
+ if (lock.context < 0 || lock.context >= dev->queue_count)
+ return EINVAL;
+#endif
+
+ if (!ret) {
+#if 0
+ if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
+ != lock.context) {
+ long j = ticks - dev->lock.lock_time;
+
+ if (lock.context == tdfx_res_ctx.handle &&
+ j >= 0 && j < DRM_LOCK_SLICE) {
+ /* Can't take lock if we just had it and
+ there is contention. */
+ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d ticks=%d\n",
+ lock.context, p->p_pid, j,
+ dev->lock.lock_time, ticks);
+ ret = tsleep(&never, PZERO|PCATCH, "drmlk1",
+ DRM_LOCK_SLICE - j);
+ if (ret)
+ return ret;
+ DRM_DEBUG("ticks=%d\n", ticks);
+ }
+ }
+#endif
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ ret = EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ lock.context)) {
+ dev->lock.pid = p->p_pid;
+ dev->lock.lock_time = ticks;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ ret = tsleep(&dev->lock.lock_queue,
+ PZERO|PCATCH,
+ "drmlk2",
+ 0);
+ if (ret)
+ break;
+ }
+ }
+
+#if 0
+ if (!ret && dev->last_context != lock.context &&
+ lock.context != tdfx_res_ctx.handle &&
+ dev->last_context != tdfx_res_ctx.handle) {
+ add_wait_queue(&dev->context_wait, &entry);
+ current->state = TASK_INTERRUPTIBLE;
+ /* PRE: dev->last_context != lock.context */
+ tdfx_context_switch(dev, dev->last_context, lock.context);
+ /* POST: we will wait for the context
+ switch and will dispatch on a later call
+ when dev->last_context == lock.context
+ NOTE WE HOLD THE LOCK THROUGHOUT THIS
+ TIME! */
+ current->policy |= SCHED_YIELD;
+ schedule();
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->context_wait, &entry);
+ if (signal_pending(current)) {
+ ret = EINTR;
+ } else if (dev->last_context != lock.context) {
+ DRM_ERROR("Context mismatch: %d %d\n",
+ dev->last_context, lock.context);
+ }
+ }
+#endif
+
+ if (!ret) {
+ if (lock.flags & _DRM_LOCK_READY) {
+ /* Wait for space in DMA/FIFO */
+ }
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ /* Make hardware quiescent */
+#if 0
+ tdfx_quiescent(dev);
+#endif
+ }
+ }
+
+#if 0
+ DRM_ERROR("pid = %5d, old counter = %5ld\n",
+ p->p_pid, current->counter);
+#endif
+#if 0
+ while (current->counter > 25)
+ current->counter >>= 1; /* decrease time slice */
+ DRM_ERROR("pid = %5d, new counter = %5ld\n",
+ p->p_pid, current->counter);
+#endif
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+
+#if DRM_DMA_HISTOGRAM
+ {
+ struct timespec ts;
+ getnanotime(&ts);
+ timespecsub(&ts, &dev->lck_start);
+ atomic_inc(&dev->histo.lhld[drm_histogram_slot(&ts)]);
+ }
+#endif
+
+ return ret;
+}
+
+
+static int
+tdfx_unlock(dev_t kdev, u_long cmd, caddr_t data, int flags, struct proc *p)
+{
+ drm_device_t *dev = kdev->si_drv1;
+ drm_lock_t lock;
+
+ lock = *(drm_lock_t *) data;
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ p->p_pid, lock.context);
+ return EINVAL;
+ }
+
+ DRM_DEBUG("%d frees lock (%d holds)\n",
+ lock.context,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ atomic_inc(&dev->total_unlocks);
+ if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
+ atomic_inc(&dev->total_contends);
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
+ /* FIXME: Try to send data to card here */
+ if (!dev->context_flag) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.h
new file mode 100644
index 000000000..5b27e0521
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/tdfx/tdfx_drv.h
@@ -0,0 +1,45 @@
+/* tdfx_drv.h -- Private header for tdfx driver -*- c -*-
+ * Created: Thu Oct 7 10:40:04 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ *
+ */
+
+#ifndef _TDFX_DRV_H_
+#define _TDFX_DRV_H_
+
+ /* tdfx_context.c */
+
+extern d_ioctl_t tdfx_resctx;
+extern d_ioctl_t tdfx_addctx;
+extern d_ioctl_t tdfx_modctx;
+extern d_ioctl_t tdfx_getctx;
+extern d_ioctl_t tdfx_switchctx;
+extern d_ioctl_t tdfx_newctx;
+extern d_ioctl_t tdfx_rmctx;
+
+extern int tdfx_context_switch(drm_device_t *dev, int old, int new);
+extern int tdfx_context_switch_complete(drm_device_t *dev, int new);
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drm.c
new file mode 100644
index 000000000..8241d51b4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drm.c
@@ -0,0 +1,1108 @@
+/* xf86drm.c -- User-level interface to DRM device
+ * Created: Tue Jan 5 08:16:21 1999 by faith@precisioninsight.com
+ * Revised: Wed Aug 4 07:54:23 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.43 1999/08/04 18:14:43 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drm.c,v 1.1 2000/06/17 00:03:27 martin Exp $
+ *
+ */
+
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# include <sys/types.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void*), void*);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+int sysctlbyname(const char *, void *, size_t *, void *, size_t);
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include "xf86drm.h"
+#include "drm.h"
+
+#define makedev(x,y) ((dev_t)(((x) << 8) | (y))) /* create dev_t */
+
+static int drmOpenByBusid(const char *busid);
+static int drmOpenDevice(const char *path, long dev,
+ mode_t mode, uid_t user, gid_t group);
+
+static void *drmHashTable = NULL; /* Context switch callbacks */
+
+typedef struct drmHashEntry {
+ int fd;
+ void (*f)(int, void *, void *);
+ void *tagTable;
+} drmHashEntry;
+
+void *drmMalloc(int size)
+{
+ void *pt;
+ if ((pt = _DRM_MALLOC(size))) memset(pt, 0, size);
+ return pt;
+}
+
+void drmFree(void *pt)
+{
+ if (pt) _DRM_FREE(pt);
+}
+
+static char *drmStrdup(const char *s)
+{
+ return s ? strdup(s) : NULL;
+}
+
+
+static unsigned long drmGetKeyFromFd(int fd)
+{
+#ifdef XFree86LOADER
+ struct xf86stat st;
+#else
+ struct stat st;
+#endif
+
+ st.st_rdev = 0;
+ fstat(fd, &st);
+ return st.st_rdev;
+}
+
+static drmHashEntry *drmGetEntry(int fd)
+{
+ unsigned long key = drmGetKeyFromFd(fd);
+ void *value;
+ drmHashEntry *entry;
+
+ if (!drmHashTable) drmHashTable = drmHashCreate();
+
+ if (drmHashLookup(drmHashTable, key, &value)) {
+ entry = drmMalloc(sizeof(*entry));
+ entry->fd = fd;
+ entry->f = NULL;
+ entry->tagTable = drmHashCreate();
+ drmHashInsert(drmHashTable, key, entry);
+ } else {
+ entry = value;
+ }
+ return entry;
+}
+
+/* drm_open is used to open the /dev/drm device */
+
+static int drm_open(const char *file)
+{
+ int fd = open(file, O_RDWR, 0);
+
+ if (fd >= 0) return fd;
+ return -errno;
+}
+
+/* drmAvailable looks for a usable device node in /dev/dri. */
+
+int drmAvailable(void)
+{
+ int i, fd;
+ char dev_name[64];
+ mode_t mode = DRM_DEV_MODE;
+ mode_t dirmode;
+ gid_t group = DRM_DEV_GID;
+ uid_t user = DRM_DEV_UID;
+ long dev = 0;
+
+ if (!geteuid()) {
+ dirmode = mode;
+ if (dirmode & S_IRUSR) dirmode |= S_IXUSR;
+ if (dirmode & S_IRGRP) dirmode |= S_IXGRP;
+ if (dirmode & S_IROTH) dirmode |= S_IXOTH;
+ dirmode &= ~(S_IWGRP | S_IWOTH);
+ mkdir("/dev/dri", 0);
+ chown("/dev/dri", user, group);
+ chmod("/dev/dri", dirmode);
+ }
+
+ for (i = 0; i < 8; i++) {
+ sprintf(dev_name, "/dev/dri/card%d", i);
+ dev = makedev(145, i);
+ fd = drmOpenDevice(dev_name, dev, mode, user, group);
+ if (fd < 0) {
+ remove(dev_name);
+ continue;
+ }
+ close(fd);
+ return 1;
+ }
+ return 0;
+}
+
+static int drmOpenDevice(const char *path, long dev,
+ mode_t mode, uid_t user, gid_t group)
+{
+#ifdef XFree86LOADER
+ struct xf86stat st;
+#else
+ struct stat st;
+#endif
+
+ if (!stat(path, &st) && st.st_rdev == dev) return drm_open(path);
+
+ if (geteuid()) return DRM_ERR_NOT_ROOT;
+ remove(path);
+ if (mknod(path, S_IFCHR, dev)) {
+ remove(path);
+ return DRM_ERR_NOT_ROOT;
+ }
+ chown(path, user, group);
+ chmod(path, mode);
+ return drm_open(path);
+}
+
+static int drmOpenByName(const char *name)
+{
+ int i;
+ char dev_name[64];
+ mode_t mode = DRM_DEV_MODE;
+ mode_t dirmode;
+ gid_t group = DRM_DEV_GID;
+ uid_t user = DRM_DEV_UID;
+ long dev = 0;
+ drmVersionPtr version;
+ int fd;
+
+#if defined(XFree86Server)
+ mode = xf86ConfigDRI.mode ? xf86ConfigDRI.mode : DRM_DEV_MODE;
+ group = xf86ConfigDRI.group ? xf86ConfigDRI.group : DRM_DEV_GID;
+#endif
+
+#if defined(XFree86Server)
+ if (!drmAvailable()) {
+ /* try to load the kernel module now */
+ if (!xf86LoadKernelModule(name)) {
+ ErrorF("[drm] failed to load kernel module \"%s\"\n",
+ name);
+ return -1;
+ }
+ }
+#else
+ if (!drmAvailable())
+ return -1;
+#endif
+
+ if (!geteuid()) {
+ dirmode = mode;
+ if (dirmode & S_IRUSR) dirmode |= S_IXUSR;
+ if (dirmode & S_IRGRP) dirmode |= S_IXGRP;
+ if (dirmode & S_IROTH) dirmode |= S_IXOTH;
+ dirmode &= ~(S_IWGRP | S_IWOTH);
+ mkdir("/dev/dri", 0);
+ chown("/dev/dri", user, group);
+ chmod("/dev/dri", dirmode);
+ }
+
+ for (i = 0; i < 8; i++) {
+ sprintf(dev_name, "/dev/dri/card%d", i);
+ dev = makedev(145, i);
+ fd = drmOpenDevice(dev_name, dev, mode, user, group);
+ if (fd < 0) {
+ remove(dev_name);
+ continue;
+ }
+ version = drmGetVersion(fd);
+ if (!version) {
+ continue;
+ }
+ if (!strcmp(version->name, name)) {
+ drmFreeVersion(version);
+ return fd;
+ }
+ drmFreeVersion(version);
+ }
+
+#if 0
+ for (i = 0; i < 8; i++) {
+ sprintf(sysctl_name, "hw.dri.%d.name", i);
+ sprintf(dev_name, "/dev/dri/card%d", i);
+ len = sizeof(buf);
+ if (sysctlbyname(sysctl_name, buf, &len, 0, 0) == 0) {
+ buf[len-1] = '\0';
+ for (driver = pt = buf; *pt && *pt != ' '; ++pt)
+ ;
+ if (*pt) { /* Device is next */
+ *pt = '\0';
+ if (!strcmp(driver, name)) { /* Match */
+ for (devstring = ++pt; *pt && *pt != ' '; ++pt)
+ ;
+ if (*pt) { /* Found busid */
+ return drmOpenByBusid(++pt);
+ } else { /* No busid */
+ dev = strtol(devstring, NULL, 0);
+ return drmOpenDevice(dev_name, dev,
+ mode, user, group);
+ }
+ }
+ }
+ } else remove(dev_name);
+ }
+#endif
+
+ return -1;
+}
+
+static int drmOpenByBusid(const char *busid)
+{
+ int i;
+ char dev_name[64];
+ char *buf;
+ int fd;
+
+ for (i = 0; i < 8; i++) {
+ sprintf(dev_name, "/dev/dri/card%d", i);
+ if ((fd = drm_open(dev_name)) >= 0) {
+ buf = drmGetBusid(fd);
+ if (buf && !strcmp(buf, busid)) {
+ drmFreeBusid(buf);
+ return fd;
+ }
+ if (buf) drmFreeBusid(buf);
+ close(fd);
+ }
+ }
+ return -1;
+}
+
+
+/* drmOpen looks up the specified name and busid, and opens the device
+ found. The entry in /dev/dri is created if necessary (and if root).
+ A file descriptor is returned. On error, the return value is
+ negative. */
+
+int drmOpen(const char *name, const char *busid)
+{
+ if (busid) return drmOpenByBusid(busid);
+ return drmOpenByName(name);
+}
+
+void drmFreeVersion(drmVersionPtr v)
+{
+ if (!v) return;
+ if (v->name) drmFree(v->name);
+ if (v->date) drmFree(v->date);
+ if (v->desc) drmFree(v->desc);
+ drmFree(v);
+}
+
+static void drmFreeKernelVersion(drm_version_t *v)
+{
+ if (!v) return;
+ if (v->name) drmFree(v->name);
+ if (v->date) drmFree(v->date);
+ if (v->desc) drmFree(v->desc);
+ drmFree(v);
+}
+
+static void drmCopyVersion(drmVersionPtr d, drm_version_t *s)
+{
+ d->version_major = s->version_major;
+ d->version_minor = s->version_minor;
+ d->version_patchlevel = s->version_patchlevel;
+ d->name_len = s->name_len;
+ d->name = drmStrdup(s->name);
+ d->date_len = s->date_len;
+ d->date = drmStrdup(s->date);
+ d->desc_len = s->desc_len;
+ d->desc = drmStrdup(s->desc);
+}
+
+/* drmVersion obtains the version information via an ioctl. Similar
+ * information is available via /proc/drm. */
+
+drmVersionPtr drmGetVersion(int fd)
+{
+ drmVersionPtr retval;
+ drm_version_t *version = drmMalloc(sizeof(*version));
+
+ /* First, get the lengths */
+ version->name_len = 0;
+ version->name = NULL;
+ version->date_len = 0;
+ version->date = NULL;
+ version->desc_len = 0;
+ version->desc = NULL;
+
+ if (ioctl(fd, DRM_IOCTL_VERSION, version)) {
+ drmFreeKernelVersion(version);
+ return NULL;
+ }
+
+ /* Now, allocate space and get the data */
+ if (version->name_len)
+ version->name = drmMalloc(version->name_len + 1);
+ if (version->date_len)
+ version->date = drmMalloc(version->date_len + 1);
+ if (version->desc_len)
+ version->desc = drmMalloc(version->desc_len + 1);
+
+ if (ioctl(fd, DRM_IOCTL_VERSION, version)) {
+ drmFreeKernelVersion(version);
+ return NULL;
+ }
+
+ /* The results might not be null-terminated
+ strings, so terminate them. */
+
+ if (version->name_len) version->name[version->name_len] = '\0';
+ if (version->date_len) version->date[version->date_len] = '\0';
+ if (version->desc_len) version->desc[version->desc_len] = '\0';
+
+ /* Now, copy it all back into the
+ client-visible data structure... */
+ retval = drmMalloc(sizeof(*retval));
+ drmCopyVersion(retval, version);
+ drmFreeKernelVersion(version);
+ return retval;
+}
+
+void drmFreeBusid(const char *busid)
+{
+ drmFree((void *)busid);
+}
+
+char *drmGetBusid(int fd)
+{
+ drm_unique_t u;
+
+ u.unique_len = 0;
+ u.unique = NULL;
+
+ if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL;
+ u.unique = drmMalloc(u.unique_len + 1);
+ if (ioctl(fd, DRM_IOCTL_GET_UNIQUE, &u)) return NULL;
+ u.unique[u.unique_len] = '\0';
+ return u.unique;
+}
+
+int drmSetBusid(int fd, const char *busid)
+{
+ drm_unique_t u;
+
+ u.unique = (char *)busid;
+ u.unique_len = strlen(busid);
+
+ if (ioctl(fd, DRM_IOCTL_SET_UNIQUE, &u)) return -errno;
+ return 0;
+}
+
+int drmGetMagic(int fd, drmMagicPtr magic)
+{
+ drm_auth_t auth;
+
+ *magic = 0;
+ if (ioctl(fd, DRM_IOCTL_GET_MAGIC, &auth)) return -errno;
+ *magic = auth.magic;
+ return 0;
+}
+
+int drmAuthMagic(int fd, drmMagic magic)
+{
+ drm_auth_t auth;
+
+ auth.magic = magic;
+ if (ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &auth)) return -errno;
+ return 0;
+}
+
+int drmAddMap(int fd,
+ drmHandle offset,
+ drmSize size,
+ drmMapType type,
+ drmMapFlags flags,
+ drmHandlePtr handle)
+{
+ drm_map_t map;
+
+ map.offset = offset;
+ map.size = size;
+ map.handle = 0;
+ map.type = type;
+ map.flags = flags;
+ if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) return -errno;
+ if (handle) *handle = (drmHandle)map.handle;
+ return 0;
+}
+
+int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags,
+ int agp_offset)
+{
+ drm_buf_desc_t request;
+
+ request.count = count;
+ request.size = size;
+ request.low_mark = 0;
+ request.high_mark = 0;
+ request.flags = flags;
+ request.agp_start = agp_offset;
+
+ if (ioctl(fd, DRM_IOCTL_ADD_BUFS, &request)) return -errno;
+ return request.count;
+}
+
+int drmMarkBufs(int fd, double low, double high)
+{
+ drm_buf_info_t info;
+ int i;
+
+ info.count = 0;
+ info.list = NULL;
+
+ if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) return -EINVAL;
+
+ if (!info.count) return -EINVAL;
+
+ if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
+ return -ENOMEM;
+
+ if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
+ int retval = -errno;
+ drmFree(info.list);
+ return retval;
+ }
+
+ for (i = 0; i < info.count; i++) {
+ info.list[i].low_mark = low * info.list[i].count;
+ info.list[i].high_mark = high * info.list[i].count;
+ if (ioctl(fd, DRM_IOCTL_MARK_BUFS, &info.list[i])) {
+ int retval = -errno;
+ drmFree(info.list);
+ return retval;
+ }
+ }
+ drmFree(info.list);
+
+ return 0;
+}
+
+int drmFreeBufs(int fd, int count, int *list)
+{
+ drm_buf_free_t request;
+
+ request.count = count;
+ request.list = list;
+ if (ioctl(fd, DRM_IOCTL_FREE_BUFS, &request)) return -errno;
+ return 0;
+}
+
+int drmClose(int fd)
+{
+ unsigned long key = drmGetKeyFromFd(fd);
+ drmHashEntry *entry = drmGetEntry(fd);
+
+ drmHashDestroy(entry->tagTable);
+ entry->fd = 0;
+ entry->f = NULL;
+ entry->tagTable = NULL;
+
+ drmHashDelete(drmHashTable, key);
+ drmFree(entry);
+
+ return close(fd);
+}
+
+int drmMap(int fd,
+ drmHandle handle,
+ drmSize size,
+ drmAddressPtr address)
+{
+ if (fd < 0) return -EINVAL;
+ *address = mmap(0, size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, handle);
+ if (*address == MAP_FAILED) return -errno;
+ return 0;
+}
+
+int drmUnmap(drmAddress address, drmSize size)
+{
+ return munmap(address, size);
+}
+
+drmBufInfoPtr drmGetBufInfo(int fd)
+{
+ drm_buf_info_t info;
+ drmBufInfoPtr retval;
+ int i;
+
+ info.count = 0;
+ info.list = NULL;
+
+ if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) return NULL;
+
+ if (info.count) {
+ if (!(info.list = drmMalloc(info.count * sizeof(*info.list))))
+ return NULL;
+
+ if (ioctl(fd, DRM_IOCTL_INFO_BUFS, &info)) {
+ drmFree(info.list);
+ return NULL;
+ }
+ /* Now, copy it all back into the
+ client-visible data structure... */
+ retval = drmMalloc(sizeof(*retval));
+ retval->count = info.count;
+ retval->list = drmMalloc(info.count * sizeof(*retval->list));
+ for (i = 0; i < info.count; i++) {
+ retval->list[i].count = info.list[i].count;
+ retval->list[i].size = info.list[i].size;
+ retval->list[i].low_mark = info.list[i].low_mark;
+ retval->list[i].high_mark = info.list[i].high_mark;
+ }
+ drmFree(info.list);
+ return retval;
+ }
+ return NULL;
+}
+
+drmBufMapPtr drmMapBufs(int fd)
+{
+ drm_buf_map_t bufs;
+ drmBufMapPtr retval;
+ int i;
+
+ bufs.count = 0;
+ bufs.list = NULL;
+ if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) return NULL;
+
+ if (bufs.count) {
+ if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list))))
+ return NULL;
+
+ if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) {
+ drmFree(bufs.list);
+ return NULL;
+ }
+ /* Now, copy it all back into the
+ client-visible data structure... */
+ retval = drmMalloc(sizeof(*retval));
+ retval->count = bufs.count;
+ retval->list = drmMalloc(bufs.count * sizeof(*retval->list));
+ for (i = 0; i < bufs.count; i++) {
+ retval->list[i].idx = bufs.list[i].idx;
+ retval->list[i].total = bufs.list[i].total;
+ retval->list[i].used = 0;
+ retval->list[i].address = bufs.list[i].address;
+ }
+ return retval;
+ }
+ return NULL;
+}
+
+int drmUnmapBufs(drmBufMapPtr bufs)
+{
+ int i;
+
+ for (i = 0; i < bufs->count; i++) {
+ munmap(bufs->list[i].address, bufs->list[i].total);
+ }
+ return 0;
+}
+
+int drmDMA(int fd, drmDMAReqPtr request)
+{
+ drm_dma_t dma;
+
+ /* Copy to hidden structure */
+ dma.context = request->context;
+ dma.send_count = request->send_count;
+ dma.send_indices = request->send_list;
+ dma.send_sizes = request->send_sizes;
+ dma.flags = request->flags;
+ dma.request_count = request->request_count;
+ dma.request_size = request->request_size;
+ dma.request_indices = request->request_list;
+ dma.request_sizes = request->request_sizes;
+ if (ioctl(fd, DRM_IOCTL_DMA, &dma)) return -errno;
+ request->granted_count = dma.granted_count;
+
+ return 0;
+}
+
+int drmGetLock(int fd, drmContext context, drmLockFlags flags)
+{
+ drm_lock_t lock;
+
+ lock.context = context;
+ lock.flags = 0;
+ if (flags & DRM_LOCK_READY) lock.flags |= _DRM_LOCK_READY;
+ if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT;
+ if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
+ if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL;
+ if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES;
+ if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES;
+
+ while (ioctl(fd, DRM_IOCTL_LOCK, &lock))
+ ;
+ return 0;
+}
+
+int drmUnlock(int fd, drmContext context)
+{
+ drm_lock_t lock;
+
+ lock.context = context;
+ lock.flags = 0;
+ return ioctl(fd, DRM_IOCTL_UNLOCK, &lock);
+}
+
+drmContextPtr drmGetReservedContextList(int fd, int *count)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t *list;
+ drmContextPtr retval;
+ int i;
+
+ res.count = 0;
+ res.contexts = NULL;
+ if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) return NULL;
+
+ if (!res.count) return NULL;
+
+ if (!(list = drmMalloc(res.count * sizeof(*list)))) return NULL;
+ if (!(retval = drmMalloc(res.count * sizeof(*retval)))) {
+ drmFree(list);
+ return NULL;
+ }
+
+ res.contexts = list;
+ if (ioctl(fd, DRM_IOCTL_RES_CTX, &res)) return NULL;
+
+ for (i = 0; i < res.count; i++) retval[i] = list[i].handle;
+ drmFree(list);
+
+ *count = res.count;
+ return retval;
+}
+
+void drmFreeReservedContextList(drmContextPtr pt)
+{
+ drmFree(pt);
+}
+
+int drmCreateContext(int fd, drmContextPtr handle)
+{
+ drm_ctx_t ctx;
+
+ ctx.flags = 0; /* Modified with functions below */
+ if (ioctl(fd, DRM_IOCTL_ADD_CTX, &ctx)) return -errno;
+ *handle = ctx.handle;
+ return 0;
+}
+
+int drmSwitchToContext(int fd, drmContext context)
+{
+ drm_ctx_t ctx;
+
+ ctx.handle = context;
+ if (ioctl(fd, DRM_IOCTL_SWITCH_CTX, &ctx)) return -errno;
+ return 0;
+}
+
+int drmSetContextFlags(int fd, drmContext context, drmContextFlags flags)
+{
+ drm_ctx_t ctx;
+
+ /* Context preserving means that no context
+ switched are done between DMA buffers
+ from one context and the next. This is
+ suitable for use in the X server (which
+ promises to maintain hardware context,
+ or in the client-side library when
+ buffers are swapped on behalf of two
+ threads. */
+ ctx.handle = context;
+ ctx.flags = 0;
+ if (flags & DRM_CONTEXT_PRESERVED) ctx.flags |= _DRM_CONTEXT_PRESERVED;
+ if (flags & DRM_CONTEXT_2DONLY) ctx.flags |= _DRM_CONTEXT_2DONLY;
+ if (ioctl(fd, DRM_IOCTL_MOD_CTX, &ctx)) return -errno;
+ return 0;
+}
+
+int drmGetContextFlags(int fd, drmContext context, drmContextFlagsPtr flags)
+{
+ drm_ctx_t ctx;
+
+ ctx.handle = context;
+ if (ioctl(fd, DRM_IOCTL_GET_CTX, &ctx)) return -errno;
+ *flags = 0;
+ if (ctx.flags & _DRM_CONTEXT_PRESERVED) *flags |= DRM_CONTEXT_PRESERVED;
+ if (ctx.flags & _DRM_CONTEXT_2DONLY) *flags |= DRM_CONTEXT_2DONLY;
+ return 0;
+}
+
+int drmDestroyContext(int fd, drmContext handle)
+{
+ drm_ctx_t ctx;
+ ctx.handle = handle;
+ if (ioctl(fd, DRM_IOCTL_RM_CTX, &ctx)) return -errno;
+ return 0;
+}
+
+int drmCreateDrawable(int fd, drmDrawablePtr handle)
+{
+ drm_draw_t draw;
+ if (ioctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) return -errno;
+ *handle = draw.handle;
+ return 0;
+}
+
+int drmDestroyDrawable(int fd, drmDrawable handle)
+{
+ drm_draw_t draw;
+ draw.handle = handle;
+ if (ioctl(fd, DRM_IOCTL_RM_DRAW, &draw)) return -errno;
+ return 0;
+}
+
+int drmAgpAcquire(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) return -errno;
+ return 0;
+}
+
+int drmAgpRelease(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) return -errno;
+ return 0;
+}
+
+int drmAgpEnable(int fd, unsigned long mode)
+{
+ drm_agp_mode_t m;
+
+ m.mode = mode;
+ if (ioctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) return -errno;
+ return 0;
+}
+
+int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
+ unsigned long *address, unsigned long *handle)
+{
+ drm_agp_buffer_t b;
+ *handle = 0;
+ b.size = size;
+ b.handle = 0;
+ b.type = type;
+ if (ioctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) return -errno;
+ if (address != 0UL) *address = b.physical;
+ *handle = b.handle;
+ return 0;
+}
+
+int drmAgpFree(int fd, unsigned long handle)
+{
+ drm_agp_buffer_t b;
+
+ b.size = 0;
+ b.handle = handle;
+ if (ioctl(fd, DRM_IOCTL_AGP_FREE, &b)) return -errno;
+ return 0;
+}
+
+int drmAgpBind(int fd, unsigned long handle, unsigned long offset)
+{
+ drm_agp_binding_t b;
+
+ b.handle = handle;
+ b.offset = offset;
+ if (ioctl(fd, DRM_IOCTL_AGP_BIND, &b)) return -errno;
+ return 0;
+}
+
+int drmAgpUnbind(int fd, unsigned long handle)
+{
+ drm_agp_binding_t b;
+
+ b.handle = handle;
+ b.offset = 0;
+ if (ioctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) return -errno;
+ return 0;
+}
+
+int drmAgpVersionMajor(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno;
+ return i.agp_version_major;
+}
+
+int drmAgpVersionMinor(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno;
+ return i.agp_version_minor;
+}
+
+unsigned long drmAgpGetMode(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.mode;
+}
+
+unsigned long drmAgpBase(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.aperture_base;
+}
+
+unsigned long drmAgpSize(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.aperture_size;
+}
+
+unsigned long drmAgpMemoryUsed(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.memory_used;
+}
+
+unsigned long drmAgpMemoryAvail(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.memory_allowed;
+}
+
+unsigned int drmAgpVendorId(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.id_vendor;
+}
+
+unsigned int drmAgpDeviceId(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.id_device;
+}
+
+int drmError(int err, const char *label)
+{
+ switch (err) {
+ case DRM_ERR_NO_DEVICE: fprintf(stderr, "%s: no device\n", label); break;
+ case DRM_ERR_NO_ACCESS: fprintf(stderr, "%s: no access\n", label); break;
+ case DRM_ERR_NOT_ROOT: fprintf(stderr, "%s: not root\n", label); break;
+ case DRM_ERR_INVALID: fprintf(stderr, "%s: invalid args\n", label);break;
+ default:
+ if (err < 0) err = -err;
+ fprintf( stderr, "%s: error %d (%s)\n", label, err, strerror(err) );
+ break;
+ }
+
+ return 1;
+}
+
+int drmCtlInstHandler(int fd, int irq)
+{
+ drm_control_t ctl;
+
+ ctl.func = DRM_INST_HANDLER;
+ ctl.irq = irq;
+ if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) return -errno;
+ return 0;
+}
+
+int drmCtlUninstHandler(int fd)
+{
+ drm_control_t ctl;
+
+ ctl.func = DRM_UNINST_HANDLER;
+ ctl.irq = 0;
+ if (ioctl(fd, DRM_IOCTL_CONTROL, &ctl)) return -errno;
+ return 0;
+}
+
+int drmFinish(int fd, int context, drmLockFlags flags)
+{
+ drm_lock_t lock;
+
+ lock.context = context;
+ lock.flags = 0;
+ if (flags & DRM_LOCK_READY) lock.flags |= _DRM_LOCK_READY;
+ if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT;
+ if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
+ if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL;
+ if (flags & DRM_HALT_ALL_QUEUES) lock.flags |= _DRM_HALT_ALL_QUEUES;
+ if (flags & DRM_HALT_CUR_QUEUES) lock.flags |= _DRM_HALT_CUR_QUEUES;
+ if (ioctl(fd, DRM_IOCTL_FINISH, &lock)) return -errno;
+ return 0;
+}
+
+int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum)
+{
+ drm_irq_busid_t p;
+
+ p.busnum = busnum;
+ p.devnum = devnum;
+ p.funcnum = funcnum;
+ if (ioctl(fd, DRM_IOCTL_IRQ_BUSID, &p)) return -errno;
+ return p.irq;
+}
+
+int drmAddContextTag(int fd, drmContext context, void *tag)
+{
+ drmHashEntry *entry = drmGetEntry(fd);
+
+ if (drmHashInsert(entry->tagTable, context, tag)) {
+ drmHashDelete(entry->tagTable, context);
+ drmHashInsert(entry->tagTable, context, tag);
+ }
+ return 0;
+}
+
+int drmDelContextTag(int fd, drmContext context)
+{
+ drmHashEntry *entry = drmGetEntry(fd);
+
+ return drmHashDelete(entry->tagTable, context);
+}
+
+void *drmGetContextTag(int fd, drmContext context)
+{
+ drmHashEntry *entry = drmGetEntry(fd);
+ void *value;
+
+ if (drmHashLookup(entry->tagTable, context, &value)) return NULL;
+
+ return value;
+}
+
+#if defined(XFree86Server) || defined(DRM_USE_MALLOC)
+static void drmSIGIOHandler(int interrupt, void *arg)
+{
+ unsigned long key;
+ void *value;
+ ssize_t count;
+ drm_ctx_t ctx;
+ typedef void (*_drmCallback)(int, void *, void *);
+ char buf[256];
+ drmContext old;
+ drmContext new;
+ void *oldctx;
+ void *newctx;
+ char *pt;
+ drmHashEntry *entry;
+
+ if (!drmHashTable) return;
+ if (drmHashFirst(drmHashTable, &key, &value)) {
+ entry = value;
+ do {
+#if 1
+ fprintf(stderr, "Trying %d\n", entry->fd);
+#endif
+ if ((count = read(entry->fd, buf, sizeof(buf)))) {
+ buf[count] = '\0';
+#if 1
+ 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 1
+ fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
+#endif
+ ((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
+ ctx.handle = new;
+ ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
+ }
+ } while (drmHashNext(drmHashTable, &key, &value));
+ }
+}
+
+int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
+{
+ drmHashEntry *entry;
+
+ entry = drmGetEntry(fd);
+ entry->f = f;
+
+ return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
+}
+
+int drmRemoveSIGIOHandler(int fd)
+{
+ drmHashEntry *entry = drmGetEntry(fd);
+
+ entry->f = NULL;
+
+ return xf86RemoveSIGIOHandler(fd);
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c
new file mode 100644
index 000000000..67cd444be
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c
@@ -0,0 +1,435 @@
+/* xf86drmHash.c -- Small hash table support for integer -> integer mapping
+ * Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com
+ * Revised: Thu Jun 3 16:11:06 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 1999/06/07 13:01:42 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmHash.c,v 1.1 2000/06/17 00:03:27 martin Exp $
+ *
+ * DESCRIPTION
+ *
+ * This file contains a straightforward implementation of a fixed-sized
+ * hash table using self-organizing linked lists [Knuth73, pp. 398-399] for
+ * collision resolution. There are two potentially interesting things
+ * about this implementation:
+ *
+ * 1) The table is power-of-two sized. Prime sized tables are more
+ * traditional, but do not have a significant advantage over power-of-two
+ * sized table, especially when double hashing is not used for collision
+ * resolution.
+ *
+ * 2) The hash computation uses a table of random integers [Hanson97,
+ * pp. 39-41].
+ *
+ * FUTURE ENHANCEMENTS
+ *
+ * With a table size of 512, the current implementation is sufficient for a
+ * few hundred keys. Since this is well above the expected size of the
+ * tables for which this implementation was designed, the implementation of
+ * dynamic hash tables was postponed until the need arises. A common (and
+ * naive) approach to dynamic hash table implementation simply creates a
+ * new hash table when necessary, rehashes all the data into the new table,
+ * and destroys the old table. The approach in [Larson88] is superior in
+ * two ways: 1) only a portion of the table is expanded when needed,
+ * distributing the expansion cost over several insertions, and 2) portions
+ * of the table can be locked, enabling a scalable thread-safe
+ * implementation.
+ *
+ * REFERENCES
+ *
+ * [Hanson97] David R. Hanson. C Interfaces and Implementations:
+ * Techniques for Creating Reusable Software. Reading, Massachusetts:
+ * Addison-Wesley, 1997.
+ *
+ * [Knuth73] Donald E. Knuth. The Art of Computer Programming. Volume 3:
+ * Sorting and Searching. Reading, Massachusetts: Addison-Wesley, 1973.
+ *
+ * [Larson88] Per-Ake Larson. "Dynamic Hash Tables". CACM 31(4), April
+ * 1988, pp. 446-457.
+ *
+ */
+
+#define HASH_MAIN 0
+
+#if HASH_MAIN
+# include <stdio.h>
+# include <stdlib.h>
+#else
+# include "xf86drm.h"
+# ifdef XFree86LOADER
+# include "xf86.h"
+# include "xf86_ansic.h"
+# else
+# include <stdio.h>
+# include <stdlib.h>
+# endif
+#endif
+
+#define N(x) drm##x
+
+#define HASH_MAGIC 0xdeadbeef
+#define HASH_DEBUG 0
+#define HASH_SIZE 512 /* Good for about 100 entries */
+ /* If you change this value, you probably
+ have to change the HashHash hashing
+ function! */
+
+#if HASH_MAIN
+#define HASH_ALLOC malloc
+#define HASH_FREE free
+#define HASH_RANDOM_DECL
+#define HASH_RANDOM_INIT(seed) srandom(seed)
+#define HASH_RANDOM random()
+#else
+#define HASH_ALLOC drmMalloc
+#define HASH_FREE drmFree
+#define HASH_RANDOM_DECL void *state
+#define HASH_RANDOM_INIT(seed) state = drmRandomCreate(seed)
+#define HASH_RANDOM drmRandom(state)
+
+#endif
+
+typedef struct HashBucket {
+ unsigned long key;
+ void *value;
+ struct HashBucket *next;
+} HashBucket, *HashBucketPtr;
+
+typedef struct HashTable {
+ unsigned long magic;
+ unsigned long entries;
+ unsigned long hits; /* At top of linked list */
+ unsigned long partials; /* Not at top of linked list */
+ unsigned long misses; /* Not in table */
+ HashBucketPtr buckets[HASH_SIZE];
+ int p0;
+ HashBucketPtr p1;
+} HashTable, *HashTablePtr;
+
+#if HASH_MAIN
+extern void *N(HashCreate)(void);
+extern int N(HashDestroy)(void *t);
+extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value);
+extern int N(HashInsert)(void *t, unsigned long key, unsigned long value);
+extern int N(HashDelete)(void *t, unsigned long key);
+#endif
+
+static unsigned long HashHash(unsigned long key)
+{
+ unsigned long hash = 0;
+ unsigned long tmp = key;
+ static int init = 0;
+ static unsigned long scatter[256];
+ int i;
+
+ if (!init) {
+ HASH_RANDOM_DECL;
+ HASH_RANDOM_INIT(37);
+ for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
+ ++init;
+ }
+
+ while (tmp) {
+ hash = (hash << 1) + scatter[tmp & 0xff];
+ tmp >>= 8;
+ }
+
+ hash %= HASH_SIZE;
+#if HASH_DEBUG
+ printf( "Hash(%d) = %d\n", key, hash);
+#endif
+ return hash;
+}
+
+void *N(HashCreate)(void)
+{
+ HashTablePtr table;
+ int i;
+
+ table = HASH_ALLOC(sizeof(*table));
+ if (!table) return NULL;
+ table->magic = HASH_MAGIC;
+ table->entries = 0;
+ table->hits = 0;
+ table->partials = 0;
+ table->misses = 0;
+
+ for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
+ return table;
+}
+
+int N(HashDestroy)(void *t)
+{
+ HashTablePtr table = (HashTablePtr)t;
+ HashBucketPtr bucket;
+ HashBucketPtr next;
+ int i;
+
+ if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+ for (i = 0; i < HASH_SIZE; i++) {
+ for (bucket = table->buckets[i]; bucket;) {
+ next = bucket->next;
+ HASH_FREE(bucket);
+ bucket = next;
+ }
+ }
+ HASH_FREE(table);
+ return 0;
+}
+
+/* Find the bucket and organize the list so that this bucket is at the
+ top. */
+
+static HashBucketPtr HashFind(HashTablePtr table,
+ unsigned long key, unsigned long *h)
+{
+ unsigned long hash = HashHash(key);
+ HashBucketPtr prev = NULL;
+ HashBucketPtr bucket;
+
+ if (h) *h = hash;
+
+ for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
+ if (bucket->key == key) {
+ if (prev) {
+ /* Organize */
+ prev->next = bucket->next;
+ bucket->next = table->buckets[hash];
+ table->buckets[hash] = bucket;
+ ++table->partials;
+ } else {
+ ++table->hits;
+ }
+ return bucket;
+ }
+ prev = bucket;
+ }
+ ++table->misses;
+ return NULL;
+}
+
+int N(HashLookup)(void *t, unsigned long key, void **value)
+{
+ HashTablePtr table = (HashTablePtr)t;
+ HashBucketPtr bucket;
+
+ if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+ bucket = HashFind(table, key, NULL);
+ if (!bucket) return 1; /* Not found */
+ *value = bucket->value;
+ return 0; /* Found */
+}
+
+int N(HashInsert)(void *t, unsigned long key, void *value)
+{
+ HashTablePtr table = (HashTablePtr)t;
+ HashBucketPtr bucket;
+ unsigned long hash;
+
+ if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+ if (HashFind(table, key, &hash)) return 1; /* Already in table */
+
+ bucket = HASH_ALLOC(sizeof(*bucket));
+ if (!bucket) return -1; /* Error */
+ bucket->key = key;
+ bucket->value = value;
+ bucket->next = table->buckets[hash];
+ table->buckets[hash] = bucket;
+#if HASH_DEBUG
+ printf("Inserted %d at %d/%p\n", key, hash, bucket);
+#endif
+ return 0; /* Added to table */
+}
+
+int N(HashDelete)(void *t, unsigned long key)
+{
+ HashTablePtr table = (HashTablePtr)t;
+ unsigned long hash;
+ HashBucketPtr bucket;
+
+ if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+ bucket = HashFind(table, key, &hash);
+
+ if (!bucket) return 1; /* Not found */
+
+ table->buckets[hash] = bucket->next;
+ HASH_FREE(bucket);
+ return 0;
+}
+
+int N(HashNext)(void *t, unsigned long *key, void **value)
+{
+ HashTablePtr table = (HashTablePtr)t;
+
+ for (; table->p0 < HASH_SIZE;
+ ++table->p0, table->p1 = table->buckets[table->p0]) {
+ if (table->p1) {
+ *key = table->p1->key;
+ *value = table->p1->value;
+ table->p1 = table->p1->next;
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int N(HashFirst)(void *t, unsigned long *key, void **value)
+{
+ HashTablePtr table = (HashTablePtr)t;
+
+ if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+
+ table->p0 = 0;
+ table->p1 = table->buckets[0];
+ return N(HashNext)(table, key, value);
+}
+
+#if HASH_MAIN
+#define DIST_LIMIT 10
+static int dist[DIST_LIMIT];
+
+static void clear_dist(void) {
+ int i;
+
+ for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
+}
+
+static int count_entries(HashBucketPtr bucket)
+{
+ int count = 0;
+
+ for (; bucket; bucket = bucket->next) ++count;
+ return count;
+}
+
+static void update_dist(int count)
+{
+ if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
+ else ++dist[count];
+}
+
+static void compute_dist(HashTablePtr table)
+{
+ int i;
+ HashBucketPtr bucket;
+
+ printf("Entries = %ld, hits = %ld, partials = %ld, misses = %ld\n",
+ table->entries, table->hits, table->partials, table->misses);
+ clear_dist();
+ for (i = 0; i < HASH_SIZE; i++) {
+ bucket = table->buckets[i];
+ update_dist(count_entries(bucket));
+ }
+ for (i = 0; i < DIST_LIMIT; i++) {
+ if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
+ else printf("other %10d\n", dist[i]);
+ }
+}
+
+static void check_table(HashTablePtr table,
+ unsigned long key, unsigned long value)
+{
+ unsigned long retval = 0;
+ int retcode = N(HashLookup)(table, key, &retval);
+
+ switch (retcode) {
+ case -1:
+ printf("Bad magic = 0x%08lx:"
+ " key = %lu, expected = %lu, returned = %lu\n",
+ table->magic, key, value, retval);
+ break;
+ case 1:
+ printf("Not found: key = %lu, expected = %lu returned = %lu\n",
+ key, value, retval);
+ break;
+ case 0:
+ if (value != retval)
+ printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
+ key, value, retval);
+ break;
+ default:
+ printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
+ retcode, key, value, retval);
+ break;
+ }
+}
+
+int main(void)
+{
+ HashTablePtr table;
+ int i;
+
+ printf("\n***** 256 consecutive integers ****\n");
+ table = N(HashCreate)();
+ for (i = 0; i < 256; i++) N(HashInsert)(table, i, i);
+ for (i = 0; i < 256; i++) check_table(table, i, i);
+ for (i = 256; i >= 0; i--) check_table(table, i, i);
+ compute_dist(table);
+ N(HashDestroy)(table);
+
+ printf("\n***** 1024 consecutive integers ****\n");
+ table = N(HashCreate)();
+ for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i);
+ for (i = 0; i < 1024; i++) check_table(table, i, i);
+ for (i = 1024; i >= 0; i--) check_table(table, i, i);
+ compute_dist(table);
+ N(HashDestroy)(table);
+
+ printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
+ table = N(HashCreate)();
+ for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i);
+ for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
+ for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
+ compute_dist(table);
+ N(HashDestroy)(table);
+
+ printf("\n***** 1024 random integers ****\n");
+ table = N(HashCreate)();
+ srandom(0xbeefbeef);
+ for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 1024; i++) check_table(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 1024; i++) check_table(table, random(), i);
+ compute_dist(table);
+ N(HashDestroy)(table);
+
+ printf("\n***** 5000 random integers ****\n");
+ table = N(HashCreate)();
+ srandom(0xbeefbeef);
+ for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 5000; i++) check_table(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 5000; i++) check_table(table, random(), i);
+ compute_dist(table);
+ N(HashDestroy)(table);
+
+ return 0;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c
new file mode 100644
index 000000000..067c6376e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmI810.c
@@ -0,0 +1,86 @@
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include "xf86drm.h"
+#include "xf86drmI810.h"
+#include "drm.h"
+
+Bool drmI810CleanupDma(int driSubFD)
+{
+ drm_i810_init_t init;
+
+ memset(&init, 0, sizeof(drm_i810_init_t));
+ init.func = I810_CLEANUP_DMA;
+
+ if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool drmI810InitDma(int driSubFD, drmI810Init *info)
+{
+ drm_i810_init_t init;
+
+ memset(&init, 0, sizeof(drm_i810_init_t));
+
+ init.func = I810_INIT_DMA;
+ init.ring_map_idx = info->ring_map_idx;
+ init.buffer_map_idx = info->buffer_map_idx;
+ init.ring_start = info->start;
+ init.ring_end = info->end;
+ init.ring_size = info->size;
+ init.sarea_priv_offset = info->sarea_off;
+ init.front_offset = info->front_offset;
+ init.back_offset = info->back_offset;
+ init.depth_offset = info->depth_offset;
+ init.w = info->w;
+ init.h = info->h;
+ init.pitch = info->pitch;
+ init.pitch_bits = info->pitch_bits;
+
+ if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c
new file mode 100644
index 000000000..aa3a6c745
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmMga.c
@@ -0,0 +1,116 @@
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include "xf86drm.h"
+#include "xf86drmMga.h"
+#include "drm.h"
+
+Bool drmMgaCleanupDma(int driSubFD)
+{
+ drm_mga_init_t init;
+ memset(&init, 0, sizeof(drm_mga_init_t));
+ init.func = MGA_CLEANUP_DMA;
+ if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool drmMgaLockUpdate(int driSubFD, drmLockFlags flags)
+{
+ drm_lock_t lock;
+
+ memset(&lock, 0, sizeof(drm_lock_t));
+
+ if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT;
+ if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
+ if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL;
+
+ if(ioctl(driSubFD, DRM_IOCTL_MGA_FLUSH, &lock)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool drmMgaInitDma(int driSubFD, drmMgaInit *info)
+{
+ drm_mga_init_t init;
+ int i;
+
+ memset(&init, 0, sizeof(drm_mga_init_t));
+ init.func = MGA_INIT_DMA;
+ init.reserved_map_agpstart = info->reserved_map_agpstart;
+ init.reserved_map_idx = info->reserved_map_idx;
+ init.buffer_map_idx = info->buffer_map_idx;
+ init.sarea_priv_offset = info->sarea_priv_offset;
+ init.primary_size = info->primary_size;
+ init.warp_ucode_size = info->warp_ucode_size;
+ init.frontOffset = info->frontOffset;
+ init.backOffset = info->backOffset;
+ init.depthOffset = info->depthOffset;
+ init.textureOffset = info->textureOffset;
+ init.textureSize = info->textureSize;
+ init.agpTextureSize = info->agpTextureSize;
+ init.agpTextureOffset = info->agpTextureOffset;
+ init.cpp = info->cpp;
+ init.stride = info->stride;
+ init.sgram = info->sgram;
+ init.chipset = info->chipset;
+
+ for(i = 0; i < MGA_MAX_WARP_PIPES; i++) {
+ init.WarpIndex[i].installed = info->WarpIndex[i].installed;
+ init.WarpIndex[i].phys_addr = info->WarpIndex[i].phys_addr;
+ init.WarpIndex[i].size = info->WarpIndex[i].size;
+ }
+
+ init.mAccess = info->mAccess;
+
+
+
+ if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c
new file mode 100644
index 000000000..07904c754
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c
@@ -0,0 +1,198 @@
+/* xf86drmR128.c -- User-level interface to Rage 128 DRM device
+ * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 1999, 2000 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.
+ *
+ * Author: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmR128.c,v 1.1 2000/06/17 00:03:27 martin Exp $
+ *
+ */
+
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+#include "drm.h"
+
+int drmR128InitCCE(int fd, drmR128Init *info)
+{
+ drm_r128_init_t init;
+
+ memset(&init, 0, sizeof(drm_r128_init_t));
+
+ init.func = R128_INIT_CCE;
+ init.sarea_priv_offset = info->sarea_priv_offset;
+ init.is_pci = info->is_pci;
+ init.cce_mode = info->cce_mode;
+ init.cce_fifo_size = info->cce_fifo_size;
+ init.cce_secure = info->cce_secure;
+ init.ring_size = info->ring_size;
+ init.usec_timeout = info->usec_timeout;
+
+ init.fb_offset = info->fb_offset;
+ init.agp_ring_offset = info->agp_ring_offset;
+ init.agp_read_ptr_offset = info->agp_read_ptr_offset;
+ init.agp_vertbufs_offset = info->agp_vertbufs_offset;
+ init.agp_indbufs_offset = info->agp_indbufs_offset;
+ init.agp_textures_offset = info->agp_textures_offset;
+ init.mmio_offset = info->mmio_offset;
+
+ if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
+
+ return 0;
+}
+
+int drmR128CleanupCCE(int fd)
+{
+ drm_r128_init_t init;
+
+ memset(&init, 0, sizeof(drm_r128_init_t));
+
+ init.func = R128_CLEANUP_CCE;
+
+ if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
+
+ return 0;
+}
+
+int drmR128EngineReset(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128EngineFlush(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128CCEWaitForIdle(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_CCEIDL, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags)
+{
+ drm_r128_packet_t packet;
+ int ret;
+
+ memset(&packet, 0, sizeof(drm_r128_packet_t));
+
+ packet.count = *count;
+ packet.flags = flags;
+
+ while (packet.count > 0) {
+ packet.buffer = buffer + (*count - packet.count);
+ ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet);
+ if (ret < 0 && ret != -EAGAIN) {
+ *count = packet.count;
+ return -errno;
+ }
+ }
+
+ *count = 0;
+ return 0;
+}
+
+int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes)
+{
+ drm_r128_vertex_t v;
+
+ v.send_count = 0;
+ v.send_indices = NULL;
+ v.send_sizes = NULL;
+ v.prim = DRM_R128_PRIM_NONE;
+ v.request_count = count;
+ v.request_indices = indices;
+ v.request_sizes = sizes;
+ v.granted_count = 0;
+
+ if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno;
+
+ return v.granted_count;
+}
+
+int drmR128FlushVertexBuffers(int fd, int count, int *indices,
+ int *sizes, drmR128PrimType prim)
+{
+ drm_r128_vertex_t v;
+
+ v.send_count = count;
+ v.send_indices = indices;
+ v.send_sizes = sizes;
+ v.prim = prim;
+ v.request_count = 0;
+ v.request_indices = NULL;
+ v.request_sizes = NULL;
+ v.granted_count = 0;
+
+ if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno;
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c
new file mode 100644
index 000000000..d0f49906b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c
@@ -0,0 +1,219 @@
+/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation
+ * Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com
+ * Revised: Thu Jun 24 14:53:45 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 1999/06/24 18:54:55 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmRandom.c,v 1.1 2000/06/17 00:03:28 martin Exp $
+ *
+ * DESCRIPTION
+ *
+ * This file contains a simple, straightforward implementation of the Park
+ * & Miller "Minimal Standard" PRNG [PM88, PMS93], which is a Lehmer
+ * multiplicative linear congruential generator (MLCG) with a period of
+ * 2^31-1.
+ *
+ * This implementation is intended to provide a reliable, portable PRNG
+ * that is suitable for testing a hash table implementation and for
+ * implementing skip lists.
+ *
+ * FUTURE ENHANCEMENTS
+ *
+ * If initial seeds are not selected randomly, two instances of the PRNG
+ * can be correlated. [Knuth81, pp. 32-33] describes a shuffling technique
+ * that can eliminate this problem.
+ *
+ * If PRNGs are used for simulation, the period of the current
+ * implementation may be too short. [LE88] discusses methods of combining
+ * MLCGs to produce much longer periods, and suggests some alternative
+ * values for A and M. [LE90 and Sch92] also provide information on
+ * long-period PRNGs.
+ *
+ * REFERENCES
+ *
+ * [Knuth81] Donald E. Knuth. The Art of Computer Programming. Volume 2:
+ * Seminumerical Algorithms. Reading, Massachusetts: Addison-Wesley, 1981.
+ *
+ * [LE88] Pierre L'Ecuyer. "Efficient and Portable Combined Random Number
+ * Generators". CACM 31(6), June 1988, pp. 742-774.
+ *
+ * [LE90] Pierre L'Ecuyer. "Random Numbers for Simulation". CACM 33(10,
+ * October 1990, pp. 85-97.
+ *
+ * [PM88] Stephen K. Park and Keith W. Miller. "Random Number Generators:
+ * Good Ones are Hard to Find". CACM 31(10), October 1988, pp. 1192-1201.
+ *
+ * [Sch92] Bruce Schneier. "Pseudo-Ransom Sequence Generator for 32-Bit
+ * CPUs". Dr. Dobb's Journal 17(2), February 1992, pp. 34, 37-38, 40.
+ *
+ * [PMS93] Stephen K. Park, Keith W. Miller, and Paul K. Stockmeyer. In
+ * "Technical Correspondence: Remarks on Choosing and Implementing Random
+ * Number Generators". CACM 36(7), July 1993, pp. 105-110.
+ *
+ */
+
+#define RANDOM_MAIN 0
+
+#if RANDOM_MAIN
+# include <stdio.h>
+# include <stdlib.h>
+#else
+# include "xf86drm.h"
+# ifdef XFree86LOADER
+# include "xf86.h"
+# include "xf86_ansic.h"
+# else
+# include <stdio.h>
+# include <stdlib.h>
+# endif
+#endif
+
+#define N(x) drm##x
+
+#define RANDOM_MAGIC 0xfeedbeef
+#define RANDOM_DEBUG 0
+
+#if RANDOM_MAIN
+#define RANDOM_ALLOC malloc
+#define RANDOM_FREE free
+#else
+#define RANDOM_ALLOC drmMalloc
+#define RANDOM_FREE drmFree
+#endif
+
+typedef struct RandomState {
+ unsigned long magic;
+ unsigned long a;
+ unsigned long m;
+ unsigned long q; /* m div a */
+ unsigned long r; /* m mod a */
+ unsigned long check;
+ long seed;
+} RandomState;
+
+#if RANDOM_MAIN
+extern void *N(RandomCreate)(unsigned long seed);
+extern int N(RandomDestroy)(void *state);
+extern unsigned long N(Random)(void *state);
+extern double N(RandomDouble)(void *state);
+#endif
+
+void *N(RandomCreate)(unsigned long seed)
+{
+ RandomState *state;
+
+ state = RANDOM_ALLOC(sizeof(*state));
+ if (!state) return NULL;
+ state->magic = RANDOM_MAGIC;
+#if 0
+ /* Park & Miller, October 1988 */
+ state->a = 16807;
+ state->m = 2147483647;
+ state->check = 1043618065; /* After 10000 iterations */
+#else
+ /* Park, Miller, and Stockmeyer, July 1993 */
+ state->a = 48271;
+ state->m = 2147483647;
+ state->check = 399268537; /* After 10000 iterations */
+#endif
+ state->q = state->m / state->a;
+ state->r = state->m % state->a;
+
+ state->seed = seed;
+ /* Check for illegal boundary conditions,
+ and choose closest legal value. */
+ if (state->seed <= 0) state->seed = 1;
+ if (state->seed >= state->m) state->seed = state->m - 1;
+
+ return state;
+}
+
+int N(RandomDestroy)(void *state)
+{
+ RANDOM_FREE(state);
+ return 0;
+}
+
+unsigned long N(Random)(void *state)
+{
+ RandomState *s = (RandomState *)state;
+ long hi;
+ long lo;
+
+ hi = s->seed / s->q;
+ lo = s->seed % s->q;
+ s->seed = s->a * lo - s->r * hi;
+ if (s->seed <= 0) s->seed += s->m;
+
+ return s->seed;
+}
+
+double N(RandomDouble)(void *state)
+{
+ RandomState *s = (RandomState *)state;
+
+ return (double)N(Random)(state)/(double)s->m;
+}
+
+#if RANDOM_MAIN
+static void check_period(long seed)
+{
+ unsigned long count = 0;
+ unsigned long initial;
+ void *state;
+
+ state = N(RandomCreate)(seed);
+ initial = N(Random)(state);
+ ++count;
+ while (initial != N(Random)(state)) {
+ if (!++count) break;
+ }
+ printf("With seed of %10ld, period = %10lu (0x%08lx)\n",
+ seed, count, count);
+ N(RandomDestroy)(state);
+}
+
+int main(void)
+{
+ RandomState *state;
+ int i;
+ unsigned long rand;
+
+ state = N(RandomCreate)(1);
+ for (i = 0; i < 10000; i++) {
+ rand = N(Random)(state);
+ }
+ printf("After 10000 iterations: %lu (%lu expected): %s\n",
+ rand, state->check,
+ rand - state->check ? "*INCORRECT*" : "CORRECT");
+ N(RandomDestroy)(state);
+
+ printf("Checking periods...\n");
+ check_period(1);
+ check_period(2);
+ check_period(31415926);
+
+ return 0;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c
new file mode 100644
index 000000000..51a54f934
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c
@@ -0,0 +1,490 @@
+/* xf86drmSL.c -- Skip list support
+ * Created: Mon May 10 09:28:13 1999 by faith@precisioninsight.com
+ * Revised: Thu Jun 3 16:13:01 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.
+ *
+ * $PI: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.2 1999/06/07 13:01:42 faith Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/xf86drmSL.c,v 1.1 2000/06/17 00:03:28 martin Exp $
+ *
+ * DESCRIPTION
+ *
+ * This file contains a straightforward skip list implementation.n
+ *
+ * FUTURE ENHANCEMENTS
+ *
+ * REFERENCES
+ *
+ * [Pugh90] William Pugh. Skip Lists: A Probabilistic Alternative to
+ * Balanced Trees. CACM 33(6), June 1990, pp. 668-676.
+ *
+ */
+
+#define SL_MAIN 0
+
+#if SL_MAIN
+# include <stdio.h>
+# include <stdlib.h>
+# include <sys/time.h>
+#else
+# include "xf86drm.h"
+# ifdef XFree86LOADER
+# include "xf86.h"
+# include "xf86_ansic.h"
+# else
+# include <stdio.h>
+# include <stdlib.h>
+# endif
+#endif
+
+#define N(x) drm##x
+
+#define SL_LIST_MAGIC 0xfacade00LU
+#define SL_ENTRY_MAGIC 0x00fab1edLU
+#define SL_FREED_MAGIC 0xdecea5edLU
+#define SL_MAX_LEVEL 16
+#define SL_DEBUG 0
+#define SL_RANDOM_SEED 0xc01055a1LU
+
+#if SL_MAIN
+#define SL_ALLOC malloc
+#define SL_FREE free
+#define SL_RANDOM_DECL static int state = 0;
+#define SL_RANDOM_INIT(seed) if (!state) { srandom(seed); ++state; }
+#define SL_RANDOM random()
+#else
+#define SL_ALLOC drmMalloc
+#define SL_FREE drmFree
+#define SL_RANDOM_DECL static void *state = NULL
+#define SL_RANDOM_INIT(seed) if (!state) state = drmRandomCreate(seed)
+#define SL_RANDOM drmRandom(state)
+
+#endif
+
+typedef struct SLEntry {
+ unsigned long magic; /* SL_ENTRY_MAGIC */
+ unsigned long key;
+ void *value;
+ int levels;
+ struct SLEntry *forward[1]; /* variable sized array */
+} SLEntry, *SLEntryPtr;
+
+typedef struct SkipList {
+ unsigned long magic; /* SL_LIST_MAGIC */
+ int level;
+ int count;
+ SLEntryPtr head;
+ SLEntryPtr p0; /* Position for iteration */
+} SkipList, *SkipListPtr;
+
+#if SL_MAIN
+extern void *N(SLCreate)(void);
+extern int N(SLDestroy)(void *l);
+extern int N(SLLookup)(void *l, unsigned long key, void **value);
+extern int N(SLInsert)(void *l, unsigned long key, void *value);
+extern int N(SLDelete)(void *l, unsigned long key);
+extern int N(SLNext)(void *l, unsigned long *key, void **value);
+extern int N(SLFirst)(void *l, unsigned long *key, void **value);
+extern void N(SLDump)(void *l);
+extern int N(SLLookupNeighbors)(void *l, unsigned long key,
+ unsigned long *prev_key, void **prev_value,
+ unsigned long *next_key, void **next_value);
+#endif
+
+static SLEntryPtr SLCreateEntry(int max_level, unsigned long key, void *value)
+{
+ SLEntryPtr entry;
+
+ if (max_level < 0 || max_level > SL_MAX_LEVEL) max_level = SL_MAX_LEVEL;
+
+ entry = SL_ALLOC(sizeof(*entry)
+ + (max_level + 1) * sizeof(entry->forward[0]));
+ if (!entry) return NULL;
+ entry->magic = SL_ENTRY_MAGIC;
+ entry->key = key;
+ entry->value = value;
+ entry->levels = max_level + 1;
+
+ return entry;
+}
+
+static int SLRandomLevel(void)
+{
+ int level = 1;
+ SL_RANDOM_DECL;
+
+ SL_RANDOM_INIT(SL_RANDOM_SEED);
+
+ while ((SL_RANDOM & 0x01) && level < SL_MAX_LEVEL) ++level;
+ return level;
+}
+
+void *N(SLCreate)(void)
+{
+ SkipListPtr list;
+ int i;
+
+ list = SL_ALLOC(sizeof(*list));
+ if (!list) return NULL;
+ list->magic = SL_LIST_MAGIC;
+ list->level = 0;
+ list->head = SLCreateEntry(SL_MAX_LEVEL, 0, NULL);
+ list->count = 0;
+
+ for (i = 0; i <= SL_MAX_LEVEL; i++) list->head->forward[i] = NULL;
+
+ return list;
+}
+
+int N(SLDestroy)(void *l)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr entry;
+ SLEntryPtr next;
+
+ if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
+
+ for (entry = list->head; entry; entry = next) {
+ if (entry->magic != SL_ENTRY_MAGIC) return -1; /* Bad magic */
+ next = entry->forward[0];
+ entry->magic = SL_FREED_MAGIC;
+ SL_FREE(entry);
+ }
+
+ list->magic = SL_FREED_MAGIC;
+ SL_FREE(list);
+ return 0;
+}
+
+static SLEntryPtr SLLocate(void *l, unsigned long key, SLEntryPtr *update)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr entry;
+ int i;
+
+ if (list->magic != SL_LIST_MAGIC) return NULL;
+
+ for (i = list->level, entry = list->head; i >= 0; i--) {
+ while (entry->forward[i] && entry->forward[i]->key < key)
+ entry = entry->forward[i];
+ update[i] = entry;
+ }
+
+ return entry->forward[0];
+}
+
+int N(SLInsert)(void *l, unsigned long key, void *value)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr entry;
+ SLEntryPtr update[SL_MAX_LEVEL + 1];
+ int level;
+ int i;
+
+ if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
+
+ entry = SLLocate(list, key, update);
+
+ if (entry && entry->key == key) return 1; /* Already in list */
+
+
+ level = SLRandomLevel();
+ if (level > list->level) {
+ level = ++list->level;
+ update[level] = list->head;
+ }
+
+ entry = SLCreateEntry(level, key, value);
+
+ /* Fix up forward pointers */
+ for (i = 0; i <= level; i++) {
+ entry->forward[i] = update[i]->forward[i];
+ update[i]->forward[i] = entry;
+ }
+
+ ++list->count;
+ return 0; /* Added to table */
+}
+
+int N(SLDelete)(void *l, unsigned long key)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr update[SL_MAX_LEVEL + 1];
+ SLEntryPtr entry;
+ int i;
+
+ if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
+
+ entry = SLLocate(list, key, update);
+
+ if (!entry || entry->key != key) return 1; /* Not found */
+
+ /* Fix up forward pointers */
+ for (i = 0; i <= list->level; i++) {
+ if (update[i]->forward[i] == entry)
+ update[i]->forward[i] = entry->forward[i];
+ }
+
+ entry->magic = SL_FREED_MAGIC;
+ SL_FREE(entry);
+
+ while (list->level && !list->head->forward[list->level]) --list->level;
+ --list->count;
+ return 0;
+}
+
+int N(SLLookup)(void *l, unsigned long key, void **value)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr update[SL_MAX_LEVEL + 1];
+ SLEntryPtr entry;
+
+ entry = SLLocate(list, key, update);
+
+ if (entry && entry->key == key) {
+ *value = entry;
+ return 0;
+ }
+ *value = NULL;
+ return -1;
+}
+
+int N(SLLookupNeighbors)(void *l, unsigned long key,
+ unsigned long *prev_key, void **prev_value,
+ unsigned long *next_key, void **next_value)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr update[SL_MAX_LEVEL + 1];
+ SLEntryPtr entry;
+ int retcode = 0;
+
+ entry = SLLocate(list, key, update);
+
+ *prev_key = *next_key = key;
+ *prev_value = *next_value = NULL;
+
+ if (update[0]) {
+ *prev_key = update[0]->key;
+ *prev_value = update[0]->value;
+ ++retcode;
+ if (update[0]->forward[0]) {
+ *next_key = update[0]->forward[0]->key;
+ *next_value = update[0]->forward[0]->value;
+ ++retcode;
+ }
+ }
+ return retcode;
+}
+
+int N(SLNext)(void *l, unsigned long *key, void **value)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr entry;
+
+ if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
+
+ entry = list->p0;
+
+ if (entry) {
+ list->p0 = entry->forward[0];
+ *key = entry->key;
+ *value = entry->value;
+ return 1;
+ }
+ list->p0 = NULL;
+ return 0;
+}
+
+int N(SLFirst)(void *l, unsigned long *key, void **value)
+{
+ SkipListPtr list = (SkipListPtr)l;
+
+ if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
+
+ list->p0 = list->head->forward[0];
+ return N(SLNext)(list, key, value);
+}
+
+/* Dump internal data structures for debugging. */
+void N(SLDump)(void *l)
+{
+ SkipListPtr list = (SkipListPtr)l;
+ SLEntryPtr entry;
+ int i;
+
+ if (list->magic != SL_LIST_MAGIC) {
+ printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
+ list->magic, SL_LIST_MAGIC);
+ return;
+ }
+
+ printf("Level = %d, count = %d\n", list->level, list->count);
+ for (entry = list->head; entry; entry = entry->forward[0]) {
+ if (entry->magic != SL_ENTRY_MAGIC) {
+ printf("Bad magic: 0x%08lx (expected 0x%08lx)\n",
+ list->magic, SL_ENTRY_MAGIC);
+ }
+ printf("\nEntry %p <0x%08lx, %p> has %2d levels\n",
+ entry, entry->key, entry->value, entry->levels);
+ for (i = 0; i < entry->levels; i++) {
+ if (entry->forward[i]) {
+ printf(" %2d: %p <0x%08lx, %p>\n",
+ i,
+ entry->forward[i],
+ entry->forward[i]->key,
+ entry->forward[i]->value);
+ } else {
+ printf(" %2d: %p\n", i, entry->forward[i]);
+ }
+ }
+ }
+}
+
+#if SL_MAIN
+static void print(SkipListPtr list)
+{
+ unsigned long key;
+ void *value;
+
+ if (N(SLFirst)(list, &key, &value)) {
+ do {
+ printf("key = %5lu, value = %p\n", key, value);
+ } while (N(SLNext)(list, &key, &value));
+ }
+}
+
+static double do_time(int size, int iter)
+{
+ SkipListPtr list;
+ int i, j;
+ unsigned long keys[1000000];
+ unsigned long previous;
+ unsigned long key;
+ void *value;
+ struct timeval start, stop;
+ double usec;
+ SL_RANDOM_DECL;
+
+ SL_RANDOM_INIT(12345);
+
+ list = N(SLCreate)();
+
+ for (i = 0; i < size; i++) {
+ keys[i] = SL_RANDOM;
+ N(SLInsert)(list, keys[i], NULL);
+ }
+
+ previous = 0;
+ if (N(SLFirst)(list, &key, &value)) {
+ do {
+ if (key <= previous) {
+ printf( "%lu !< %lu\n", previous, key);
+ }
+ previous = key;
+ } while (N(SLNext)(list, &key, &value));
+ }
+
+ gettimeofday(&start, NULL);
+ for (j = 0; j < iter; j++) {
+ for (i = 0; i < size; i++) {
+ if (N(SLLookup)(list, keys[i], &value))
+ printf("Error %lu %d\n", keys[i], i);
+ }
+ }
+ gettimeofday(&stop, NULL);
+
+ usec = (double)(stop.tv_sec * 1000000 + stop.tv_usec
+ - start.tv_sec * 1000000 - start.tv_usec) / (size * iter);
+
+ printf("%0.2f microseconds for list length %d\n", usec, size);
+
+ N(SLDestroy)(list);
+
+ return usec;
+}
+
+static void print_neighbors(void *list, unsigned long key)
+{
+ unsigned long prev_key = 0;
+ unsigned long next_key = 0;
+ void *prev_value;
+ void *next_value;
+ int retval;
+
+ retval = drmSLLookupNeighbors(list, key,
+ &prev_key, &prev_value,
+ &next_key, &next_value);
+ printf("Neighbors of %5lu: %d %5lu %5lu\n",
+ key, retval, prev_key, next_key);
+}
+
+int main(void)
+{
+ SkipListPtr list;
+ double usec, usec2, usec3, usec4;
+
+ list = N(SLCreate)();
+ printf( "list at %p\n", list);
+
+ print(list);
+ printf("\n==============================\n\n");
+
+ N(SLInsert)(list, 123, NULL);
+ N(SLInsert)(list, 213, NULL);
+ N(SLInsert)(list, 50, NULL);
+ print(list);
+ printf("\n==============================\n\n");
+
+ print_neighbors(list, 0);
+ print_neighbors(list, 50);
+ print_neighbors(list, 51);
+ print_neighbors(list, 123);
+ print_neighbors(list, 200);
+ print_neighbors(list, 213);
+ print_neighbors(list, 256);
+ printf("\n==============================\n\n");
+
+ N(SLDelete)(list, 50);
+ print(list);
+ printf("\n==============================\n\n");
+
+ N(SLDump)(list);
+ N(SLDestroy)(list);
+ printf("\n==============================\n\n");
+
+ usec = do_time(100, 10000);
+ usec2 = do_time(1000, 500);
+ printf("Table size increased by %0.2f, search time increased by %0.2f\n",
+ 1000.0/100.0, usec2 / usec);
+
+ usec3 = do_time(10000, 50);
+ printf("Table size increased by %0.2f, search time increased by %0.2f\n",
+ 10000.0/100.0, usec3 / usec);
+
+ usec4 = do_time(100000, 4);
+ printf("Table size increased by %0.2f, search time increased by %0.2f\n",
+ 100000.0/100.0, usec4 / usec);
+
+ return 0;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile
index 6d1d879e4..dff53fa05 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile,v 3.10 2000/02/13 03:36:06 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bsdi/Imakefile,v 3.12 2000/06/27 14:27:29 tsi Exp $
@@ -11,12 +11,14 @@ MOUSESRC = bsdi_mouse.c
MOUSEOBJ = bsdi_mouse.o
SRCS = bsdi_init.c bsdi_video.c bsdi_io.c bios_devmem.c \
- mapVT_noop.c VTsw_noop.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
- libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c
+ VTsw_noop.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
+ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
+ kmod_noop.c
OBJS = bsdi_init.o bsdi_video.o bsdi_io.o bios_devmem.o \
- mapVT_noop.o VTsw_noop.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
- libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o
+ VTsw_noop.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC)
@@ -29,7 +31,6 @@ SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
LinkSourceFile(bios_devmem.c,../shared)
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(VTsw_noop.c,../shared)
LinkSourceFile(std_kbdEv.c,../shared)
LinkSourceFile(posix_tty.c,../shared)
@@ -38,6 +39,7 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile
index 6267531f7..764440fdc 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile
@@ -3,7 +3,7 @@ XCOMM $XConsortium: Imakefile /main/16 1996/10/27 18:07:43 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.10 2000/03/07 13:59:06 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Imakefile,v 1.13 2000/06/13 02:28:36 dawes Exp $
#include <Server.tmpl>
@@ -20,8 +20,10 @@ XCOMM Sparc (Linux) PCI driver
PCIDRVRSRC = sparcPci.c
PCIDRVROBJ = sparcPci.o
+SBUSDRVSRC = linuxSbus.c
+SBUSDRVOBJ = linuxSbus.o
-#elif defined(LinuxArchitecture) && defined(PpcArchitecture)
+#elif defined(LinuxArchitecture) && (defined(PpcArchitecture) || defined(MipsArchitecture))
XCOMM generic linux PCI driver (using /proc/bus/pci, requires kernel 2.2)
@@ -35,8 +37,16 @@ XCOMM PowerPC PCI drivers
PCIDRVRSRC = ppcPci.c
PCIDRVROBJ = ppcPci.o
+#elif defined(LinuxArchitecture) && ( defined(i386Architecture) || defined(ia64Architecture))
+
+XCOMM ix86 PCI driver with OS fallback for Linux
+
+PCIDRVRSRC = ix86Pci.c linuxPci.c
+PCIDRVROBJ = ix86Pci.o linuxPci.o
+
#elif defined(FreeBSDArchitecture) && defined(AlphaArchitecture)
+
XCOMM generic FreeBSD PCI driver (using /dev/pci)
PCIDRVRSRC = freebsdPci.c
@@ -55,8 +65,8 @@ XCOMM PCIDRVROBJ = linuxPci.o
XCOMM no PCI driver -- shouldn't get here
#endif
-SRCS = Pci.c $(PCIDRVRSRC)
-OBJS = Pci.o $(PCIDRVROBJ)
+SRCS = Pci.c $(PCIDRVRSRC) $(SBUSDRVSRC)
+OBJS = Pci.o $(PCIDRVROBJ) $(SBUSDRVOBJ)
INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(SERVERSRC)/include -I$(XINCLUDESRC)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c
index fd2a0472f..a797fcb43 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.24 2000/02/08 13:13:28 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.c,v 1.32 2000/06/20 19:40:31 eich Exp $ */
/*
* Pci.c - New server PCI access functions
*
@@ -206,8 +206,9 @@ pciBusFuncs_t pciNOOPFuncs = {
pciAddrNOOP
};
-pciBusInfo_t *pciBusInfo[MAX_PCI_BUSES];
+pciBusInfo_t *pciBusInfo[MAX_PCI_BUSES] = { NULL, };
int pciNumBuses = 0; /* Actual number of PCI buses */
+static Bool inProbe = FALSE;
static pciConfigPtr pci_devp[MAX_PCI_DEVICES + 1] = {NULL, };
#ifdef INCLUDE_LOCKPCI
@@ -240,7 +241,13 @@ pciInit()
xf86Verbose = DEBUGPCI;
#endif
- ARCH_PCI_INIT();
+ ARCH_PCI_INIT();
+ if (!pciNumBuses)
+#if defined(ARCH_PCI_OS_INIT)
+ ARCH_PCI_OS_INIT();
+#else
+ xf86Msg(X_ERROR,"No OS PCI support available\n");
+#endif
}
@@ -282,7 +289,7 @@ ErrorF("pciReadLong(0x%lx, %d)\n", tag, offset);
if (!pciInitialized)
pciInit();
- if (bus < pciNumBuses && pciBusInfo[bus] &&
+ if ((bus < pciNumBuses || inProbe) && pciBusInfo[bus] &&
pciBusInfo[bus]->funcs.pciReadLong) {
CARD32 rv = (*pciBusInfo[bus]->funcs.pciReadLong)(tag, offset);
@@ -618,6 +625,7 @@ pciGenFindNext(void)
{
unsigned long devid, tmp;
unsigned char base_class, sub_class, sec_bus, pri_bus;
+ Bool speculativeProbe = FALSE;
#ifdef DEBUGPCI
ErrorF("pciGenFindNext\n");
@@ -679,7 +687,13 @@ ErrorF("pciGenFindNext: next bus\n");
/*
* No more devices for this bus. Next bus please
*/
- if (++pciBusNum >= pciNumBuses) {
+ if (speculativeProbe) {
+ xfree(pciBusInfo[pciBusNum]);
+ pciBusInfo[pciBusNum] = NULL;
+ }
+
+
+ if (++pciBusNum >= MAX_PCI_BUSES) {
#ifdef DEBUGPCI
ErrorF("pciGenFindNext: out of buses\n");
#endif
@@ -694,8 +708,12 @@ ErrorF("pciGenFindNext: out of buses\n");
#ifdef DEBUGPCI
ErrorF("pciGenFindNext: pciBusInfo[%d] = 0x%lx\n", pciBusNum, pciBusInfo[pciBusNum]);
#endif
- if (!pciBusInfo[pciBusNum])
- continue; /* Bus not defined, next please */
+ if (!pciBusInfo[pciBusNum]) {
+ pciBusInfo[pciBusNum] = xnfalloc(sizeof(pciBusInfo_t));
+ *pciBusInfo[pciBusNum] = *pciBusInfo[0];
+
+ speculativeProbe = TRUE;
+ }
/*
* At this point, pciBusNum, pciDevNum, and pciFuncNum have been
@@ -706,13 +724,20 @@ ErrorF("pciGenFindNext: pciBusInfo[%d] = 0x%lx\n", pciBusNum, pciBusInfo[pciBusN
ErrorF("pciGenFindNext: [%d, %d, %d]\n", pciBusNum, pciDevNum, pciFuncNum);
#endif
pciDeviceTag = PCI_MAKE_TAG(pciBusNum, pciDevNum, pciFuncNum);
+ inProbe = TRUE;
devid = pciReadLong(pciDeviceTag, 0);
+ inProbe = FALSE;
#ifdef DEBUGPCI
ErrorF("pciGenFindNext: pciDeviceTag = 0x%lx, devid = 0x%lx\n", pciDeviceTag, devid);
#endif
if (devid == 0xffffffff)
continue; /* Nobody home. Next device please */
+ if (speculativeProbe && (pciNumBuses <= pciBusNum))
+ pciNumBuses = pciBusNum + 1;
+
+ speculativeProbe = FALSE;
+
/*
* Before checking for a specific devid, look for enabled
* PCI to PCI bridge devices. If one is found, create and
@@ -722,7 +747,8 @@ ErrorF("pciGenFindNext: pciDeviceTag = 0x%lx, devid = 0x%lx\n", pciDeviceTag, de
tmp = pciReadLong(pciDeviceTag, PCI_CLASS_REG);
base_class = PCI_CLASS_EXTRACT(tmp);
sub_class = PCI_SUBCLASS_EXTRACT(tmp);
- if (base_class == PCI_CLASS_BRIDGE && sub_class == PCI_SUBCLASS_BRIDGE_PCI) {
+ if (base_class == PCI_CLASS_BRIDGE)
+ if (sub_class == PCI_SUBCLASS_BRIDGE_PCI) {
tmp = pciReadLong(pciDeviceTag, PCI_PCI_BRIDGE_BUS_REG);
sec_bus = PCI_SECONDARY_BUS_EXTRACT(tmp);
pri_bus = PCI_PRIMARY_BUS_EXTRACT(tmp);
@@ -1113,7 +1139,7 @@ xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg,
#elif defined(__sparc__)
pointer
-xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, pointer Base,
+xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag, unsigned long Base,
unsigned long Size)
{
FatalError("xf86MapPciMem: Unsupported on SPARC\n");
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h
index d97d599e7..d9be4570c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.9 2000/02/12 20:45:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/Pci.h,v 1.12 2000/06/20 21:19:11 mvojkovi Exp $ */
/*
* Copyright 1998 by Concurrent Computer Corporation
*
@@ -136,7 +136,7 @@
/*
* Select architecture specific PCI init function
*/
-#if defined(__powerpc__) && defined(linux)
+#if (defined(__powerpc__) || defined(__mips__)) && defined(linux)
# define ARCH_PCI_INIT linuxPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
#elif defined(__powerpc__)
@@ -149,6 +149,14 @@
#elif defined(__alpha__) && defined(linux)
# define ARCH_PCI_INIT axpPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
+#elif defined(__i386__) && defined(linux)
+# define ARCH_PCI_INIT ix86PciInit
+# define ARCH_PCI_OS_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
+#elif defined(__ia64__) && defined(linux)
+# define ARCH_PCI_INIT ix86PciInit
+# define ARCH_PCI_OS_INIT linuxPciInit
+# define INCLUDE_XF86_MAP_PCI_MEM
#elif defined(__alpha__) && defined(__FreeBSD__)
# define ARCH_PCI_INIT freebsdPciInit
# define INCLUDE_XF86_MAP_PCI_MEM
@@ -157,6 +165,9 @@
# define INCLUDE_XF86_MAP_PCI_MEM
#endif
extern void ARCH_PCI_INIT(void);
+#if defined(ARCH_PCI_OS_INIT)
+extern void ARCH_PCI_OS_INIT(void);
+#endif
/*
* Table of functions used to access a specific PCI bus domain
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c
index 5bfc959b4..68a4c2488 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c,v 1.7 1999/07/04 06:39:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/ix86Pci.c,v 1.8 2000/06/09 07:53:25 eich Exp $ */
/*
* ix86Pci.c - x86 PCI driver
*
@@ -430,6 +430,8 @@ void ix86PciSelectCfgmech(void)
ix86Pci0.funcs.pciSetBitsLong = ix86PciSetBitsLongCFG2;
return;
+ case PCIOsConfig:
+ return;
}
/* No PCI found */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c
new file mode 100644
index 000000000..0852eba20
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c
@@ -0,0 +1,581 @@
+/*
+ * Linux platform specific 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/linuxSbus.c,v 1.3 2000/06/30 17:15:18 dawes Exp $ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <asm/openpromio.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+#include "xf86sbusBus.h"
+#include "xf86Sbus.h"
+
+static int promFd = -1;
+static int promRootNode, promCurrentNode;
+static int promOpenCount = 0;
+static int promP1275 = -1;
+#define MAX_PROP 128
+#define MAX_VAL (4096-128-4)
+static struct openpromio *promOpio;
+
+static 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;
+}
+
+static 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;
+}
+
+static 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;
+}
+
+static 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;
+ }
+}
+
+enum {
+ PROM_NODE_PCI = 16,
+ PROM_NODE_EBUS = 8,
+ PROM_NODE_SBUS = 4,
+ PROM_NODE_PREF = 2,
+ PROM_NODE_SIBLING = 1
+};
+
+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)
+{
+ 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);
+}
+
+void
+sparcPromClose(void)
+{
+ if (promOpenCount > 1) {
+ promOpenCount--;
+ return;
+ }
+ if (promFd != -1) {
+ close(promFd);
+ promFd = -1;
+ }
+ if (promOpio) {
+ xfree(promOpio);
+ promOpio = NULL;
+ }
+ promOpenCount = 0;
+}
+
+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;
+}
+
+char *
+sparcPromGetProperty(sbusPromNodePtr pnode, const char *prop, int *lenp)
+{
+ if (promSetNode(pnode))
+ return NULL;
+ return promGetProperty(prop, lenp);
+}
+
+int
+sparcPromGetBool(sbusPromNodePtr pnode, const char *prop)
+{
+ if (promSetNode(pnode))
+ return 0;
+ return promGetBool(prop);
+}
+
+static sbusDevicePtr *devicePtrs;
+
+static void promWalk(int node, int oldnode, int flags)
+{
+ int nextnode;
+ int len, sbus = (flags & PROM_NODE_SBUS);
+ char *prop = promGetProperty("device_type", &len);
+ int devId, i, j;
+ sbusPromNode pNode, pNode2;
+
+ while (prop) {
+ if (len <= 0 || strcmp(prop, "display"))
+ break;
+ prop = promGetProperty("name", &len);
+ if (!prop || len <= 0)
+ break;
+ while ((*prop >= 'A' && *prop <= 'Z') || *prop == ',') prop++;
+ if (!sbus && strcmp(prop, "ffb") && strcmp(prop, "afb") &&
+ strcmp(prop, "cgfourteen"))
+ break;
+ /* All /SUNW,ffb outside of SBUS tree come before all
+ * /SUNW,afb outside of SBUS tree in Linux. */
+ if (!sbus && !strcmp(prop, "afb"))
+ flags |= PROM_NODE_PREF;
+ for (i = 0; sbusDeviceTable[i].devId; i++)
+ if (!strcmp(prop, sbusDeviceTable[i].promName))
+ break;
+ devId = sbusDeviceTable[i].devId;
+ if (! devId)
+ 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;
+ }
+ prop = promGetProperty("name", &len);
+ if (prop && len > 0) {
+ if (!strcmp(prop, "sbus") || !strcmp(prop, "sbi"))
+ sbus = PROM_NODE_SBUS;
+ }
+ nextnode = promGetChild(node);
+ if (nextnode)
+ promWalk(nextnode, node, sbus);
+ nextnode = promGetSibling(node);
+ if (nextnode)
+ promWalk(nextnode, node, PROM_NODE_SIBLING|sbus);
+}
+
+void
+sparcPromAssignNodes(void)
+{
+ sbusDevicePtr psdp, *psdpp;
+ int n, holes = 0, i, j;
+ FILE *f;
+
+ devicePtrs = xnfcalloc(sizeof(sbusDevicePtr), 32);
+ for (psdpp = xf86SbusInfo, psdp = *psdpp, n = 0; psdp; psdp = *++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);
+ promWalk(promRootNode, 0, 2);
+ 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--;
+ }
+ xfree(devicePtrs);
+}
+
+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
+promWalk2(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 && promWalk2(strchr (path, 0), node, nextnode, searchNode, ntype))
+ return 1;
+ nextnode = promGetSibling(node);
+ if (nextnode && promWalk2(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 (promWalk2(ret, promRootNode, promGetChild(promRootNode), pnode->node, 0))
+ return ret;
+ xfree(ret);
+ return NULL;
+}
+
+static int
+promWalk3(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 = promWalk3(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 = promWalk3(name + 1, regstr, promRootNode, 0);
+ xfree(name);
+ return i;
+}
+
+pointer
+xf86MapSbusMem(sbusDevicePtr psdp, unsigned long offset, unsigned long size)
+{
+ pointer ret;
+
+ 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, size, PROT_READ | PROT_WRITE, MAP_PRIVATE,
+ psdp->fd, offset);
+ if (ret == (pointer) -1) {
+ ret = (pointer) mmap (NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED,
+ psdp->fd, offset);
+ }
+ if (ret == (pointer) -1)
+ return NULL;
+
+ return ret;
+}
+
+void
+xf86UnmapSbusMem(sbusDevicePtr psdp, pointer addr, unsigned long size)
+{
+ munmap (addr, size);
+}
+
+/* Tell OS that we are driving the HW cursor ourselves. */
+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 = zeros;
+ fbcursor.mask = zeros;
+ fbcursor.size.x = 32;
+ fbcursor.size.y = 1;
+ fbcursor.set = FB_CUR_SETALL;
+ ioctl(psdp->fd, FBIOSCURSOR, &fbcursor);
+}
+
+/* Set HW cursor colormap. */
+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/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c b/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c
index 49d01331b..e3a0b7e5c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.1 1999/03/28 15:32:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/sparcPci.c,v 1.2 2000/04/04 19:25:19 dawes Exp $ */
/*
* Copyright 1998 by Concurrent Computer Corporation
*
@@ -101,7 +101,7 @@ sparcPciInit()
CARD32
sparcPciCfgRead(PCITAG tag, int off)
{
- int bus, dfn, len;
+ int bus, dfn;
CARD32 val = 0xffffffff;
bus = PCI_BUS_FROM_TAG(tag);
@@ -114,7 +114,7 @@ sparcPciCfgRead(PCITAG tag, int off)
void
sparcPciCfgWrite(PCITAG tag, int off, CARD32 val)
{
- int bus, dfn, len;
+ int bus, dfn;
bus = PCI_BUS_FROM_TAG(tag);
dfn = PCI_DFN_FROM_TAG(tag);
@@ -125,7 +125,7 @@ sparcPciCfgWrite(PCITAG tag, int off, CARD32 val)
void
sparcPciCfgSetBits(PCITAG tag, int off, CARD32 mask, CARD32 bits)
{
- int bus, dfn, len;
+ int bus, dfn;
CARD32 val = 0xffffffff;
bus = PCI_BUS_FROM_TAG(tag);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h b/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h
index b068394c0..80f306c42 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.23 2000/02/08 13:13:29 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.24 2000/03/27 05:10:03 tsi Exp $ */
/*
* Copyright 1998 by Concurrent Computer Corporation
*
@@ -333,6 +333,7 @@
#define PCI_PPB_MEMLIMIT_EXTRACT(x) (((x) << 0) & 0xFFFF0000)
#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E
+#define PCI_PCI_BRIDGE_ISA_EN 0x04
#define PCI_PCI_BRIDGE_VGA_EN 0x08
/* Subsystem identification register */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h b/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h
new file mode 100644
index 000000000..050b01431
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h
@@ -0,0 +1,40 @@
+/*
+ * 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.
+ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Sbus.h,v 1.2 2000/06/30 17:15:18 dawes Exp $ */
+
+#ifndef _XF86_SBUS_H
+#define _XF86_SBUS_H
+
+#ifdef linux
+#include <asm/types.h>
+#include <asm/fbio.h>
+#include <asm/openpromio.h>
+#elif defined(SVR4)
+#include <sys/fbio.h>
+#elif define(CSRG_BASED)
+#include <machine/fbio.h>
+#else
+#include <sun/fbio.h>
+#endif
+
+#endif /* _XF86_SBUS_H */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile
index 677c2992d..8d77cdc61 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile
@@ -1,15 +1,15 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile,v 1.5 2000/02/13 03:36:07 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/Imakefile,v 1.6 2000/06/17 00:03:33 martin Exp $
#include <Server.tmpl>
BIOS_MOD = bios_DGmmap
SRCS = dgux_init.c dgux_video.c IO_utils.c dgux_io.c $(BIOS_MOD).c VTsw_noop.c \
dgux_kbd.c dgux_kbdEv.c dgux_tty.c std_mouse.c std_mseEv.c \
- stdResource.c stdPci.c sigiostubs.c pm_noop.c
+ stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c
OBJS = dgux_init.o dgux_video.o IO_utils.o dgux_io.o $(BIOS_MOD).o VTsw_noop.o \
dgux_kbd.o dgux_kbdEv.o dgux_tty.o std_mouse.o std_mseEv.o \
- stdResource.o stdPci.o sigiostubs.o pm_noop.o
+ stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC)
@@ -29,5 +29,6 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c b/xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c
index 600a51481..91b839708 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c,v 1.4 1999/04/29 12:24:52 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/dgux/dgux_video.c,v 1.5 2000/06/27 14:27:29 tsi Exp $ */
/*
* INTEL DG/UX RELEASE 4.20 MU03
* Copyright 1997 Takis Psarogiannakopoulos Cambridge,UK
@@ -201,29 +201,6 @@ unsigned long Size;
munmap(Base, Size);
}
-
-
-
-
-/* NULL for DG/ux */
-void xf86MapDisplay(ScreenNum, Region)
-int ScreenNum;
-int Region;
-{
- return;
-}
-
-
-
-
-/* NULL for DG/ux */
-void xf86UnMapDisplay(ScreenNum, Region)
-int ScreenNum;
-int Region;
-{
- return;
-}
-
/***************************************************************************/
/* I/O Permissions section */
/***************************************************************************/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile
index fed41ff72..8542e901f 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile,v 1.9 2000/02/13 03:36:08 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/hurd/Imakefile,v 1.11 2000/06/27 14:27:30 tsi Exp $
#include <Server.tmpl>
@@ -8,12 +8,12 @@ MOUSESRC = hurd_mouse.c
MOUSEOBJ = hurd_mouse.o
SRCS = hurd_init.c hurd_video.c hurd_io.c libc_wrapper.c $(BIOS_MOD).c \
- mapVT_noop.c VTsw_noop.c posix_tty.c std_kbdEv.c $(MOUSESRC) \
- stdResource.c stdPci.c sigiostubs.c pm_noop.c
+ VTsw_noop.c posix_tty.c std_kbdEv.c $(MOUSESRC) \
+ stdResource.c stdPci.c sigiostubs.c pm_noop.c kmod_noop.c
OBJS = hurd_init.o hurd_video.o hurd_io.o libc_wrapper.o $(BIOS_MOD).o \
- mapVT_noop.o VTsw_noop.o posix_tty.o std_kbdEv.o $(MOUSEOBJ) \
- stdResource.o stdPci.o sigiostubs.o pm_noop.o
+ VTsw_noop.o posix_tty.o std_kbdEv.o $(MOUSEOBJ) \
+ stdResource.o stdPci.o sigiostubs.o pm_noop.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi
@@ -27,7 +27,6 @@ NormalLibraryObjectRule()
LinkSourceFile(VTsw_noop.c,../shared)
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(posix_tty.c,../shared)
LinkSourceFile(std_kbdEv.c,../shared)
LinkSourceFile(libc_wrapper.c,../shared)
@@ -35,6 +34,7 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile
index 8a9458ef2..122a9e374 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile
@@ -1,5 +1,5 @@
XCOMM $XConsortium: Imakefile /main/10 1996/10/19 18:06:19 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile,v 3.38 2000/02/23 04:47:22 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/Imakefile,v 3.41 2000/06/27 14:27:30 tsi Exp $
#include <Server.tmpl>
@@ -40,14 +40,14 @@ AXP_OBJ=lnx_ev56.o
#endif
SRCS = lnx_init.c lnx_video.c lnx_io.c libc_wrapper.c bios_mmap.c \
- mapVT_noop.c VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
+ VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
lnx_pci.c vidmem.c lnx_apm.c $(JOYSTICK_SRC) $(DRI_SRC) $(RES_SRCS) \
- $(AXP_SRC)
+ $(AXP_SRC) lnx_kmod.c
OBJS = lnx_init.o lnx_video.o lnx_io.o libc_wrapper.o bios_mmap.o \
- mapVT_noop.o VTsw_usl.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
+ VTsw_usl.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
lnx_pci.o vidmem.o lnx_apm.o $(JOYSTICK_OBJ) $(DRI_OBJ) $(RES_OBJS) \
- $(AXP_OBJ)
+ $(AXP_OBJ) lnx_kmod.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC)
@@ -94,12 +94,12 @@ InstallDynamicModule(lnx_jstk.o,$(MODULEDIR),input)
#endif
LinkSourceFile(bios_mmap.c,../shared)
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(std_kbdEv.c,../shared)
LinkSourceFile(posix_tty.c,../shared)
LinkSourceFile(libc_wrapper.c,../shared)
LinkSourceFile(vidmem.c,../shared)
LinkSourceFile(VTsw_usl.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
LinkSourceFile($(DRI_SRC),../shared)
@@ -109,6 +109,7 @@ LinkSourceFile(stdResource.c,../shared)
DependTarget()
+InstallDriverSDKNonExecFile(agpgart.h,$(DRIVERSDKINCLUDEDIR)/linux)
#if 0
InstallDriverSDKDynamicModule(lnx_jstk.o,$(DRIVERSDKMODULEDIR))
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h
index 7457cd114..a3d03d03e 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h
@@ -23,6 +23,7 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/agpgart.h,v 1.3 2000/06/17 00:03:33 martin Exp $ */
#ifndef _AGP_H
#define _AGP_H 1
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
index 96388450b..5620604a0 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.5 2000/02/23 04:47:22 martin Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/Imakefile,v 1.6 2000/06/17 00:03:34 martin Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -13,15 +13,16 @@ MOBJ = drmmodule.o
MTRR_DEFINES = -DHAS_MTRR_SUPPORT
#endif
-SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c $(MSRC)
-OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o $(MOBJ)
-
+SRCS = xf86drm.c xf86drmHash.c xf86drmRandom.c xf86drmSL.c xf86drmI810.c xf86drmMga.c xf86drmR128.c $(MSRC)
+OBJS = xf86drm.o xf86drmHash.o xf86drmRandom.o xf86drmSL.o xf86drmI810.o xf86drmMga.o xf86drmR128.o $(MOBJ)
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC) -I../.. -Ikernel
DEFINES = $(MTRR_DEFINES) $(GLX_DEFINES)
+#if DoLoadableServer
+
ModuleObjectRule()
LibraryModuleTarget(drm,$(OBJS))
NormalLintTarget($(SRCS))
@@ -30,6 +31,14 @@ NormalLintTarget($(SRCS))
InstallLibraryModule(drm,$(MODULEDIR),linux)
#endif
+#else
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+#endif
+
+
#define IHaveSubdirs
SUBDIRS = kernel
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c
index cf4249f38..8be822445 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c
@@ -1,6 +1,5 @@
/* drmmodule.c -- Module initialization
* Created: Fri Jun 4 09:05:48 1999 by faith@precisioninsight.com
- * Revised: Fri Jun 4 09:09:22 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
@@ -24,7 +23,9 @@
* 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/linux/drm/drmmodule.c,v 1.2 2000/02/23 04:47:22 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/drmmodule.c,v 1.3 2000/06/17 00:03:34 martin Exp $
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel
index 44d75c487..e262213ad 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel
@@ -9,12 +9,13 @@
# Note 2! The CFLAGS definitions are now inherited from the
# parent makes..
#
-# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel,v 1.5 2000/02/14 06:27:25 martin Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.kernel,v 1.6 2000/06/17 00:03:34 martin Exp $
L_TARGET := libdrm.a
L_OBJS := init.o memory.o proc.o auth.o context.o drawable.o bufs.o \
- lists.o lock.o ioctl.o fops.o vm.o dma.o
+ lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o \
+ agpsupport.o
M_OBJS :=
@@ -26,6 +27,14 @@ ifdef CONFIG_DRM_TDFX
M_OBJS += tdfx.o
endif
+ifdef CONFIG_DRM_MGA
+M_OBJS += mga.o
+endif
+
+ifdef CONFIG_DRM_R128
+M_OBJS += r128.o
+endif
+
include $(TOPDIR)/Rules.make
gamma.o: gamma_drv.o gamma_dma.o $(L_TARGET)
@@ -33,3 +42,12 @@ gamma.o: gamma_drv.o gamma_dma.o $(L_TARGET)
tdfx.o: tdfx_drv.o tdfx_context.o $(L_TARGET)
$(LD) $(LD_RFLAG) -r -o $@ tdfx_drv.o tdfx_context.o -L. -ldrm
+
+i810.o: i810_drv.o i810_context.o $(L_TARGET)
+ $(LD) $(LD_RFLAG) -r -o $@ i810_drv.o i810_bufs.o i810_dma.o i810_context.o -L. -ldrm
+
+mga.o: mga_drv.o mga_context.o mga_dma.o mga_bufs.o $(L_TARGET)
+ $(LD) $(LD_RFLAG) -r -o $@ mga_drv.o mga_bufs.o mga_dma.o mga_context.o mga_state.o -L. -ldrm
+
+r128.o: r128_drv.o r128_context.o $(L_TARGET)
+ $(LD) $(LD_RFLAG) -r -o $@ r128_drv.o r128_context.o -L. -ldrm
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
index 8a41f880b..ecc196bdd 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/Makefile.linux
@@ -1,8 +1,8 @@
# Makefile -- For the Direct Rendering Manager module (drm)
# Created: Mon Jan 4 09:26:53 1999 by faith@precisioninsight.com
-# Revised: Sun Feb 13 23:15:59 2000 by kevin@precisioninsight.com
#
# Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+# Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
# All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,19 +24,35 @@
# 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/linux/drm/kernel/Makefile.linux,v 1.6 2000/02/23 04:47:25 martin Exp $
-#
+#
+# ***** NOTE NOTE NOTE NOTE NOTE *****
+# To override the automatic Linux source tree determination, pass the
+# pathname for the kernel that you want to compile on the command line,
+# like this:
+# make TREE=/usr/my-kernel-tree/include
+#
+#
+# ***** NOTE NOTE NOTE NOTE NOTE *****
+# Because some distributions patch 2.2.x kernels to make kill_fasync have
+# three parameters, this script tries to determine, via the examination of
+# header files, if your kernel has been patched. If this detection is
+# incorrect, you can override the value on the command line, like this:
+# make PARAMS=2
+# or
+# make PARAMS=3
.SUFFIXES:
# *** Setup
-MODS= gamma.o tdfx.o
+# **** End of SMP/MODVERSIONS detection
+
+MODS= gamma.o tdfx.o r128.o
LIBS= libdrm.a
PROGS= drmstat
DRMOBJS= init.o memory.o proc.o auth.o context.o drawable.o bufs.o \
- lists.o lock.o ioctl.o fops.o vm.o dma.o
+ lists.o lock.o ioctl.o fops.o vm.o dma.o ctxbitmap.o
DRMHEADERS= drm.h drmP.h
GAMMAOBJS= gamma_drv.o gamma_dma.o
@@ -45,9 +61,14 @@ GAMMAHEADERS= gamma_drv.h $(DRMHEADERS)
TDFXOBJS= tdfx_drv.o tdfx_context.o
TDFXHEADERS= tdfx_drv.h $(DRMHEADERS)
+R128OBJS= r128_drv.o r128_dma.o r128_bufs.o r128_context.o
+R128HEADERS= r128_drv.h r128_drm.h $(DRMHEADERS)
+
PROGOBJS= drmstat.po xf86drm.po xf86drmHash.po xf86drmRandom.po sigio.po
PROGHEADERS= xf86drm.h $(DRMHEADERS)
+INC= /usr/include
+
CFLAGS= -O2 $(WARNINGS)
WARNINGS= -Wall -Wwrite-strings -Wpointer-arith -Wcast-align \
-Wstrict-prototypes -Wshadow -Wnested-externs \
@@ -90,11 +111,6 @@ endif
endif
endif
-# To override this determination, pass the path on the make command line:
-# make TREE=/usr/my-kernel-tree/include
-# or hardcode a value for TREE here:
-# TREE:=/usr/include
-
ifeq ($(TREE),0)
all:; @echo Error: Could not locate kernel tree in $A $B $C
else
@@ -102,7 +118,30 @@ SMP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
| grep -s 'SMP = ' | cut -d' ' -f3)
MODVERSIONS := $(shell gcc -E -I $(TREE) picker.c 2>/dev/null \
| grep -s 'MODVERSIONS = ' | cut -d' ' -f3)
-all::;@echo KERNEL HEADERS IN $(TREE): SMP=${SMP} MODVERSIONS=${MODVERSIONS}
+AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
+ | grep -s 'AGP = ' | cut -d' ' -f3)
+PARAMS := $(shell if fgrep kill_fasync $(TREE)/linux/fs.h \
+ | fgrep -q band; then echo 3; else echo 2; fi)
+ifeq ($(AGP),0)
+AGP := $(shell gcc -E -nostdinc -I$(TREE) picker.c 2>/dev/null \
+ | grep -s 'AGP_MODULE = ' | cut -d' ' -f3)
+endif
+
+ifeq ($(AGP),1)
+MODCFLAGS += -DDRM_AGP
+DRMOBJS += agpsupport.o
+MODS += mga.o i810.o
+
+MGAOBJS= mga_drv.o mga_dma.o mga_bufs.o mga_state.o mga_context.o
+MGAHEADERS= mga_drv.h $(DRMHEADERS)
+
+I810OBJS= i810_drv.o i810_dma.o i810_bufs.o i810_context.o
+I810HEADERS= i810_drv.h $(DRMHEADERS)
+endif
+
+all::;@echo === KERNEL HEADERS IN $(TREE)
+all::;@echo === SMP=${SMP} MODVERSIONS=${MODVERSIONS} AGP=${AGP}
+all::;@echo === kill_fasync has $(PARAMS) parameters
all:: $(LIBS) $(MODS) $(PROGS)
endif
@@ -115,6 +154,9 @@ endif
ifeq ($(MODVERSIONS),1)
MODCFLAGS += -DMODVERSIONS -include $(TREE)/linux/modversions.h
endif
+ifeq ($(PARAMS),3)
+MODCFLAGS += -DKILLFASYNCHASTHREEPARAMETERS
+endif
# **** End of configuration
@@ -128,6 +170,17 @@ gamma.o: $(GAMMAOBJS) $(LIBS)
tdfx.o: $(TDFXOBJS) $(LIBS)
$(LD) -r $^ -o $@
+r128.o: $(R128OBJS) $(LIBS)
+ $(LD) -r $^ -o $@
+
+ifeq ($(AGP),1)
+mga.o: $(MGAOBJS) $(LIBS)
+ $(LD) -r $^ -o $@
+
+i810.o: $(I810OBJS) $(LIBS)
+ $(LD) -r $^ -o $@
+endif
+
drmstat: $(PROGOBJS)
$(CC) $(PRGCFLAGS) $^ $(PRGLIBS) -o $@
@@ -140,7 +193,7 @@ ChangeLog:
# .o files are used for modules
%.o: %.c
- $(CC) $(MODCFLAGS) -c $< -o $@
+ $(CC) $(MODCFLAGS) -I$(TREE) -c $< -o $@
%.po: %.c
$(CC) $(PRGCFLAGS) -DDRM_USE_MALLOC -c $< -o $@
@@ -149,8 +202,12 @@ ChangeLog:
$(DRMOBJS): $(DRMHEADERS)
$(GAMMAOBJS): $(GAMMAHEADERS)
$(TDFXOBJS): $(TDFXHEADERS)
+$(R128OBJS): $(R128HEADERS)
+ifeq ($(AGP),1)
+$(MGAOBJS): $(MGAHEADERS)
+$(I810OBJS): $(I810HEADERS)
+endif
$(PROGOBJS): $(PROGHEADERS)
clean:
- rm -f *.o *.po *~ core $(PROGS)
-
+ rm -f *.o *.a *.po *~ core $(PROGS)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c
index fb58154d6..c89c3e258 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 09:56:45 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,9 +24,7 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/agpsupport.c,v 1.1 2000/02/11 17:26:02 dawes Exp $
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -159,6 +158,8 @@ int drm_agp_alloc(struct inode *inode, struct file *filp, unsigned int cmd,
-EFAULT);
if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
return -ENOMEM;
+
+ memset(entry, 0, sizeof(*entry));
pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
type = (u32) request.type;
@@ -237,6 +238,8 @@ int drm_agp_bind(struct inode *inode, struct file *filp, unsigned int cmd,
page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE;
if ((retcode = drm_bind_agp(entry->memory, page))) return retcode;
entry->bound = dev->agp->base + (page << PAGE_SHIFT);
+ DRM_DEBUG("base = 0x%lx entry->bound = 0x%lx\n",
+ dev->agp->base, entry->bound);
return 0;
}
@@ -254,8 +257,10 @@ int drm_agp_free(struct inode *inode, struct file *filp, unsigned int cmd,
if (!(entry = drm_agp_lookup_entry(dev, request.handle)))
return -EINVAL;
if (entry->bound) drm_unbind_agp(entry->memory);
- entry->prev->next = entry->next;
- entry->next->prev = entry->prev;
+
+ if (entry->prev) entry->prev->next = entry->next;
+ else dev->agp->memory = entry->next;
+ if (entry->next) entry->next->prev = entry->prev;
drm_free_agp(entry->memory, entry->pages);
drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return 0;
@@ -269,15 +274,12 @@ drm_agp_head_t *drm_agp_init(void)
for (fill = &drm_agp_fill[0]; fill->name; fill++) {
char *n = (char *)fill->name;
-#if 0
- *fill->f = (drm_agp_func_u)get_module_symbol(NULL, n);
-#endif
*fill->f = (drm_agp_func_u)get_module_symbol(NULL, n);
- printk("%s resolves to 0x%08lx\n", n, (*fill->f).address);
+ DRM_DEBUG("%s resolves to 0x%08lx\n", n, (*fill->f).address);
if (!(*fill->f).address) agp_available = 0;
}
- printk("agp_available = %d\n", agp_available);
+ DRM_DEBUG("agp_available = %d\n", agp_available);
if (agp_available) {
if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c
index 0e3b1c565..9f81c5391 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/auth.c
@@ -1,8 +1,8 @@
/* auth.c -- IOCTLs for authentication -*- linux-c -*-
* Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
- * Revised: Fri Aug 20 11:31:48 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,8 +23,9 @@
* OTHER LIABILITY, WHETHER IN AN ACTION 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/linux/drm/kernel/auth.c,v 1.2 2000/02/23 04:47:25 martin Exp $
+ *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -44,7 +45,6 @@ static drm_file_t *drm_find_file(drm_device_t *dev, drm_magic_t magic)
down(&dev->struct_sem);
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
- if (pt->priv->authenticated) continue;
if (pt->magic == magic) {
retval = pt->priv;
break;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c
index 85244c7dc..011e42410 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/bufs.c
@@ -1,8 +1,8 @@
/* bufs.c -- IOCTLs to manage buffers -*- linux-c -*-
* Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:14:11 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,11 +24,13 @@
* 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/linux/drm/kernel/bufs.c,v 1.5 2000/02/23 04:47:25 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
#define __NO_VERSION__
+#include <linux/config.h>
#include "drmP.h"
#include "linux/un.h"
@@ -102,6 +104,11 @@ int drm_addmap(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lock.hw_lock = map->handle; /* Pointer to lock */
}
break;
+#ifdef DRM_AGP
+ case _DRM_AGP:
+ map->offset = map->offset + dev->agp->base;
+ break;
+#endif
default:
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return -EINVAL;
@@ -172,7 +179,7 @@ int drm_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
if (dev->queue_count) return -EBUSY; /* Not while in use */
- alignment = (request.flags & DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size;
page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
total = PAGE_SIZE << page_order;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c
index fdf8fd9f1..ca491094e 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/context.c
@@ -1,8 +1,8 @@
/* context.c -- IOCTLs for contexts and DMA queues -*- linux-c -*-
* Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
- * Revised: Fri Aug 20 11:32:09 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/context.c,v 1.2 2000/02/23 04:47:26 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c
index f67209d44..615505979 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c
@@ -1,7 +1,8 @@
/* ctxbitmap.c -- Context bitmap management -*- linux-c -*-
* Created: Thu Jan 6 03:56:42 2000 by jhartmann@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,9 +24,7 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * Author: Jeff Hartmann <jhartmann@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ctxbitmap.c,v 1.1 2000/02/11 17:26:02 dawes Exp $
+ * Author: Jeff Hartmann <jhartmann@valinux.com>
*
*/
@@ -53,7 +52,7 @@ int drm_ctxbitmap_next(drm_device_t *dev)
bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
if (bit < DRM_MAX_CTXBITMAP) {
set_bit(bit, dev->ctx_bitmap);
- printk("drm_ctxbitmap_next bit : %d\n", bit);
+ DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit);
return bit;
}
return -1;
@@ -64,15 +63,15 @@ int drm_ctxbitmap_init(drm_device_t *dev)
int i;
int temp;
- dev->ctx_bitmap = (unsigned long *) drm_alloc(PAGE_SIZE * 4,
+ dev->ctx_bitmap = (unsigned long *) drm_alloc(PAGE_SIZE,
DRM_MEM_CTXBITMAP);
if(dev->ctx_bitmap == NULL) {
return -ENOMEM;
}
- memset((void *) dev->ctx_bitmap, 0, PAGE_SIZE * 4);
+ memset((void *) dev->ctx_bitmap, 0, PAGE_SIZE);
for(i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
temp = drm_ctxbitmap_next(dev);
- printk("drm_ctxbitmap_init : %d\n", temp);
+ DRM_DEBUG("drm_ctxbitmap_init : %d\n", temp);
}
return 0;
@@ -80,7 +79,7 @@ int drm_ctxbitmap_init(drm_device_t *dev)
void drm_ctxbitmap_cleanup(drm_device_t *dev)
{
- drm_free((void *)dev->ctx_bitmap, PAGE_SIZE * 4,
+ drm_free((void *)dev->ctx_bitmap, PAGE_SIZE,
DRM_MEM_CTXBITMAP);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c
index 8291e52e4..ac2d1bc5a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/dma.c
@@ -1,8 +1,8 @@
/* dma.c -- DMA IOCTL and function support -*- linux-c -*-
* Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:19:45 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/dma.c,v 1.5 2000/02/23 04:47:26 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinuxa.com>
*
*/
@@ -63,15 +64,24 @@ void drm_dma_takedown(drm_device_t *dev)
dma->bufs[i].page_order,
DRM_MEM_DMA);
}
- drm_free(dma->bufs[i].buflist,
- dma->buf_count
- * sizeof(*dma->bufs[0].buflist),
- DRM_MEM_BUFS);
drm_free(dma->bufs[i].seglist,
- dma->buf_count
+ dma->bufs[i].seg_count
* sizeof(*dma->bufs[0].seglist),
DRM_MEM_SEGS);
- drm_freelist_destroy(&dma->bufs[i].freelist);
+ }
+ if(dma->bufs[i].buf_count) {
+ for(j = 0; j < dma->bufs[i].buf_count; j++) {
+ if(dma->bufs[i].buflist[j].dev_private) {
+ drm_free(dma->bufs[i].buflist[j].dev_private,
+ dma->bufs[i].buflist[j].dev_priv_size,
+ DRM_MEM_BUFS);
+ }
+ }
+ drm_free(dma->bufs[i].buflist,
+ dma->bufs[i].buf_count *
+ sizeof(*dma->bufs[0].buflist),
+ DRM_MEM_BUFS);
+ drm_freelist_destroy(&dma->bufs[i].freelist);
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c
index c7acecb97..03839f5be 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drawable.c
@@ -1,8 +1,8 @@
/* drawable.c -- IOCTLs for drawables -*- linux-c -*-
* Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
- * Revised: Fri Aug 20 09:27:03 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/drawable.c,v 1.2 2000/02/23 04:47:26 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
index 7b8e88265..4affcc415 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
@@ -1,8 +1,8 @@
/* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:15:23 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/drm.h,v 1.5 2000/02/23 04:47:26 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
* Acknowledgements:
* Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
@@ -61,6 +62,20 @@ typedef unsigned int drm_context_t;
typedef unsigned int drm_drawable_t;
typedef unsigned int drm_magic_t;
+/* Warning: If you change this structure, make sure you change
+ * XF86DRIClipRectRec in the server as well */
+
+typedef struct drm_clip_rect {
+ unsigned short x1;
+ unsigned short y1;
+ unsigned short x2;
+ unsigned short y2;
+} drm_clip_rect_t;
+
+/* Seperate include files for the i810/mga/r128 specific structures */
+#include "mga_drm.h"
+#include "i810_drm.h"
+#include "r128_drm.h"
typedef struct drm_version {
int version_major; /* Major version */
@@ -101,7 +116,8 @@ typedef struct drm_control {
typedef enum drm_map_type {
_DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */
_DRM_REGISTERS = 1, /* no caching, no core dump */
- _DRM_SHM = 2 /* shared, cached */
+ _DRM_SHM = 2, /* shared, cached */
+ _DRM_AGP = 3 /* AGP/GART */
} drm_map_type_t;
typedef enum drm_map_flags {
@@ -165,8 +181,11 @@ typedef struct drm_buf_desc {
int low_mark; /* Low water mark */
int high_mark; /* High water mark */
enum {
- DRM_PAGE_ALIGN = 0x01 /* Align on page boundaries for DMA */
+ _DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */
+ _DRM_AGP_BUFFER = 0x02 /* Buffer is in agp space */
} flags;
+ unsigned long agp_start; /* Start address of where the agp buffers
+ * are in the agp aperture */
} drm_buf_desc_t;
typedef struct drm_buf_info {
@@ -237,6 +256,38 @@ typedef struct drm_irq_busid {
int funcnum;
} drm_irq_busid_t;
+typedef struct drm_agp_mode {
+ unsigned long mode;
+} drm_agp_mode_t;
+
+ /* For drm_agp_alloc -- allocated a buffer */
+typedef struct drm_agp_buffer {
+ unsigned long size; /* In bytes -- will round to page boundary */
+ unsigned long handle; /* Used for BIND/UNBIND ioctls */
+ unsigned long type; /* Type of memory to allocate */
+ unsigned long physical; /* Physical used by i810 */
+} drm_agp_buffer_t;
+
+ /* For drm_agp_bind */
+typedef struct drm_agp_binding {
+ unsigned long handle; /* From drm_agp_buffer */
+ unsigned long offset; /* In bytes -- will round to page boundary */
+} drm_agp_binding_t;
+
+typedef struct drm_agp_info {
+ int agp_version_major;
+ int agp_version_minor;
+ unsigned long mode;
+ unsigned long aperture_base; /* physical address */
+ unsigned long aperture_size; /* bytes */
+ unsigned long memory_allowed; /* bytes */
+ unsigned long memory_used;
+
+ /* PCI information */
+ unsigned short id_vendor;
+ unsigned short id_device;
+} drm_agp_info_t;
+
#define DRM_IOCTL_BASE 'd'
#define DRM_IOCTL_NR(n) _IOC_NR(n)
#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
@@ -247,7 +298,7 @@ typedef struct drm_irq_busid {
#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
-#define DRM_IOCTL_GET_MAGIC DRM_IOW( 0x02, drm_auth_t)
+#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t)
#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
@@ -276,4 +327,39 @@ typedef struct drm_irq_busid {
#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)
+#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
+#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
+#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t)
+#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t)
+#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t)
+#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t)
+#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t)
+#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t)
+
+/* Mga specific ioctls */
+#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
+#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t)
+#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t)
+#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x43, drm_mga_iload_t)
+#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x44, drm_mga_vertex_t)
+#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x45, drm_lock_t )
+#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t)
+
+/* I810 specific ioctls */
+#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t)
+#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t)
+#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t)
+#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43)
+#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44)
+#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t)
+#define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46)
+
+/* Rage 128 specific ioctls */
+#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
+#define DRM_IOCTL_R128_RESET DRM_IO( 0x41)
+#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42)
+#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43)
+#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t)
+#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t)
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
index 312fba36f..9ad83bde7 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h
@@ -1,8 +1,8 @@
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:34:30 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/drmP.h,v 1.6 2000/02/23 04:47:27 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -32,6 +33,7 @@
#define _DRM_P_H_
#ifdef __KERNEL__
+#include <linux/config.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
@@ -48,8 +50,12 @@
#ifdef CONFIG_MTRR
#include <asm/mtrr.h>
#endif
+#ifdef DRM_AGP
+#include <linux/types.h>
+#include <linux/agp_backend.h>
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,1,0)
-#include <asm/spinlock.h>
+#include <linux/tqueue.h>
#include <linux/poll.h>
#endif
#include "drm.h"
@@ -69,21 +75,27 @@
#define DRM_FLAG_DEBUG 0x01
#define DRM_FLAG_NOCTX 0x02
-#define DRM_MEM_DMA 0
-#define DRM_MEM_SAREA 1
-#define DRM_MEM_DRIVER 2
-#define DRM_MEM_MAGIC 3
-#define DRM_MEM_IOCTLS 4
-#define DRM_MEM_MAPS 5
-#define DRM_MEM_VMAS 6
-#define DRM_MEM_BUFS 7
-#define DRM_MEM_SEGS 8
-#define DRM_MEM_PAGES 9
-#define DRM_MEM_FILES 10
-#define DRM_MEM_QUEUES 11
-#define DRM_MEM_CMDS 12
-#define DRM_MEM_MAPPINGS 13
-#define DRM_MEM_BUFLISTS 14
+#define DRM_MEM_DMA 0
+#define DRM_MEM_SAREA 1
+#define DRM_MEM_DRIVER 2
+#define DRM_MEM_MAGIC 3
+#define DRM_MEM_IOCTLS 4
+#define DRM_MEM_MAPS 5
+#define DRM_MEM_VMAS 6
+#define DRM_MEM_BUFS 7
+#define DRM_MEM_SEGS 8
+#define DRM_MEM_PAGES 9
+#define DRM_MEM_FILES 10
+#define DRM_MEM_QUEUES 11
+#define DRM_MEM_CMDS 12
+#define DRM_MEM_MAPPINGS 13
+#define DRM_MEM_BUFLISTS 14
+#define DRM_MEM_AGPLISTS 15
+#define DRM_MEM_TOTALAGP 16
+#define DRM_MEM_BOUNDAGP 17
+#define DRM_MEM_CTXBITMAP 18
+
+#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
/* Backward compatibility section */
/* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
@@ -118,7 +130,6 @@ typedef struct wait_queue *wait_queue_head_t;
#endif
/* Generic cmpxchg added in 2.3.x */
-#if CPU != 386
#ifndef __HAVE_ARCH_CMPXCHG
/* Include this here so that driver can be
used with older kernels. */
@@ -153,10 +164,6 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
(unsigned long)(n),sizeof(*(ptr))))
#endif
-#else
- /* Compiling for a 386 proper... */
-#error DRI not supported on Intel 80386
-#endif
/* Macros to make printk easier */
#define DRM_ERROR(fmt, arg...) \
@@ -218,8 +225,8 @@ typedef struct drm_magic_entry {
} drm_magic_entry_t;
typedef struct drm_magic_head {
- struct drm_magic_entry *head;
- struct drm_magic_entry *tail;
+ struct drm_magic_entry *head;
+ struct drm_magic_entry *tail;
} drm_magic_head_t;
typedef struct drm_vma_entry {
@@ -235,6 +242,7 @@ typedef struct drm_buf {
int used; /* Amount of buffer in use (for DMA) */
unsigned long offset; /* Byte offset (used internally) */
void *address; /* Address of buffer */
+ unsigned long bus_address; /* Bus address of buffer */
struct drm_buf *next; /* Kernel-only: used for free list */
__volatile__ int waiting; /* On kernel DMA queue */
__volatile__ int pending; /* On hardware DMA queue */
@@ -250,12 +258,16 @@ typedef struct drm_buf {
DRM_LIST_PRIO = 4,
DRM_LIST_RECLAIM = 5
} list; /* Which list we're on */
+
#if DRM_DMA_HISTOGRAM
cycles_t time_queued; /* Queued to kernel DMA queue */
cycles_t time_dispatched; /* Dispatched to hardware */
cycles_t time_completed; /* Completed by hardware */
cycles_t time_freed; /* Back on freelist */
#endif
+
+ int dev_priv_size; /* Size of buffer private stoarge */
+ void *dev_private; /* Per-buffer private storage */
} drm_buf_t;
#if DRM_DMA_HISTOGRAM
@@ -376,6 +388,9 @@ typedef struct drm_device_dma {
int page_count;
unsigned long *pagelist;
unsigned long byte_count;
+ enum {
+ _DRM_DMA_USE_AGP = 0x01
+ } flags;
/* DMA support */
drm_buf_t *this_buffer; /* Buffer being sent */
@@ -384,6 +399,41 @@ typedef struct drm_device_dma {
wait_queue_head_t waiting; /* Processes waiting on free bufs */
} drm_device_dma_t;
+#ifdef DRM_AGP
+typedef struct drm_agp_mem {
+ unsigned long handle;
+ agp_memory *memory;
+ unsigned long bound; /* address */
+ int pages;
+ struct drm_agp_mem *prev;
+ struct drm_agp_mem *next;
+} drm_agp_mem_t;
+
+typedef struct drm_agp_head {
+ agp_kern_info agp_info;
+ const char *chipset;
+ drm_agp_mem_t *memory;
+ unsigned long mode;
+ int enabled;
+ int acquired;
+ unsigned long base;
+ int agp_mtrr;
+} drm_agp_head_t;
+
+typedef struct {
+ void (*free_memory)(agp_memory *);
+ agp_memory *(*allocate_memory)(size_t, u32);
+ int (*bind_memory)(agp_memory *, off_t);
+ int (*unbind_memory)(agp_memory *);
+ void (*enable)(u32);
+ int (*acquire)(void);
+ void (*release)(void);
+ void (*copy_info)(agp_kern_info *);
+} drm_agp_func_t;
+
+extern drm_agp_func_t drm_agp;
+#endif
+
typedef struct drm_device {
const char *name; /* Simple driver name */
char *unique; /* Unique identifier: e.g., busid */
@@ -462,6 +512,12 @@ typedef struct drm_device {
struct fasync_struct *buf_async;/* Processes waiting for SIGIO */
wait_queue_head_t buf_readers; /* Processes waiting to read */
wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
+
+#ifdef DRM_AGP
+ drm_agp_head_t *agp;
+#endif
+ unsigned long *ctx_bitmap;
+ void *dev_private;
} drm_device_t;
@@ -470,6 +526,7 @@ typedef struct drm_device {
/* Misc. support (init.c) */
extern int drm_flags;
extern void drm_parse_options(char *s);
+extern int drm_cpu_valid(void);
/* Device support (fops.c) */
@@ -533,6 +590,14 @@ extern void drm_free_pages(unsigned long address, int order,
extern void *drm_ioremap(unsigned long offset, unsigned long size);
extern void drm_ioremapfree(void *pt, unsigned long size);
+#ifdef DRM_AGP
+extern agp_memory *drm_alloc_agp(int pages, u32 type);
+extern int drm_free_agp(agp_memory *handle, int pages);
+extern int drm_bind_agp(agp_memory *handle, unsigned int start);
+extern int drm_unbind_agp(agp_memory *handle);
+#endif
+
+
/* Buffer management support (bufs.c) */
extern int drm_order(unsigned long size);
extern int drm_addmap(struct inode *inode, struct file *filp,
@@ -642,5 +707,32 @@ extern int drm_flush_unblock(drm_device_t *dev, int context,
drm_lock_flags_t flags);
extern int drm_flush_block_and_flush(drm_device_t *dev, int context,
drm_lock_flags_t flags);
+
+ /* Context Bitmap support (ctxbitmap.c) */
+extern int drm_ctxbitmap_init(drm_device_t *dev);
+extern void drm_ctxbitmap_cleanup(drm_device_t *dev);
+extern int drm_ctxbitmap_next(drm_device_t *dev);
+extern void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
+
+#ifdef DRM_AGP
+ /* AGP/GART support (agpsupport.c) */
+extern drm_agp_head_t *drm_agp_init(void);
+extern int drm_agp_acquire(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_release(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_enable(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_info(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_alloc(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_free(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_unbind(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int drm_agp_bind(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+#endif
#endif
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c
index 8fe6f7072..8c691c49b 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmstat.c
@@ -1,8 +1,8 @@
/* drmstat.c -- DRM device status and testing program
* Created: Tue Jan 5 08:19:24 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:35:00 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,7 @@
* 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/linux/drm/kernel/drmstat.c,v 1.6 2000/02/23 04:47:27 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -187,7 +187,7 @@ int main(int argc, char **argv)
case 'b':
count = strtoul(optarg, &pt, 0);
size = strtoul(pt+1, NULL, 0);
- if ((r = drmAddBufs(fd, count, size, 0)) < 0) {
+ if ((r = drmAddBufs(fd, count, size, 0, 65536)) < 0) {
drmError(r, argv[0]);
return 1;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c
index 2a064e5df..4ade7aa18 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/fops.c
@@ -1,8 +1,8 @@
/* fops.c -- File operations for DRM -*- linux-c -*-
* Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
- * Revised: Fri Dec 3 10:26:26 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,9 @@
* 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/linux/drm/kernel/fops.c,v 1.6 2000/02/23 04:47:27 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
*
*/
@@ -40,6 +42,7 @@ int drm_open_helper(struct inode *inode, struct file *filp, drm_device_t *dev)
drm_file_t *priv;
if (filp->f_flags & O_EXCL) return -EBUSY; /* No exclusive opens */
+ if (!drm_cpu_valid()) return -EINVAL;
DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);
@@ -211,10 +214,15 @@ int drm_write_string(drm_device_t *dev, const char *s)
send -= count;
}
-#if LINUX_VERSION_CODE < 0x020315
+#if LINUX_VERSION_CODE < 0x020315 && !defined(KILLFASYNCHASTHREEPARAMETERS)
+ /* The extra parameter to kill_fasync was added in 2.3.21, and is
+ _not_ present in _stock_ 2.2.14 and 2.2.15. However, some
+ distributions patch 2.2.x kernels to add this parameter. The
+ Makefile.linux attempts to detect this addition and defines
+ KILLFASYNCHASTHREEPARAMETERS if three parameters are found. */
if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO);
#else
- /* Parameter added in 2.3.21 */
+ /* Parameter added in 2.3.21 */
if (dev->buf_async) kill_fasync(dev->buf_async, SIGIO, POLL_IN);
#endif
DRM_DEBUG("waking\n");
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
index eec0f8592..a99f24cae 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_dma.c
@@ -1,8 +1,8 @@
/* gamma_dma.c -- DMA support for GMX 2000 -*- linux-c -*-
* Created: Fri Mar 19 14:30:16 1999 by faith@precisioninsight.com
- * Revised: Thu Sep 16 12:55:37 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/gamma_dma.c,v 1.2 2000/02/23 04:47:28 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -87,13 +88,31 @@ static inline void gamma_dma_dispatch(drm_device_t *dev, unsigned long address,
GAMMA_WRITE(GAMMA_DMACOUNT, length / 4);
}
-static inline void gamma_dma_quiescent(drm_device_t *dev)
+static inline void gamma_dma_quiescent_single(drm_device_t *dev)
{
while (GAMMA_READ(GAMMA_DMACOUNT))
;
while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
;
+
+ GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
+ GAMMA_WRITE(GAMMA_SYNC, 0);
+
+ do {
+ while (!GAMMA_READ(GAMMA_OUTFIFOWORDS))
+ ;
+ } while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
+}
+
+static inline void gamma_dma_quiescent_dual(drm_device_t *dev)
+{
+ while (GAMMA_READ(GAMMA_DMACOUNT))
+ ;
+ while (GAMMA_READ(GAMMA_INFIFOSPACE) < 3)
+ ;
+
GAMMA_WRITE(GAMMA_BROADCASTMASK, 3);
+
GAMMA_WRITE(GAMMA_FILTERMODE, 1 << 10);
GAMMA_WRITE(GAMMA_SYNC, 0);
@@ -103,7 +122,6 @@ static inline void gamma_dma_quiescent(drm_device_t *dev)
;
} while (GAMMA_READ(GAMMA_OUTPUTFIFO) != GAMMA_SYNC_TAG);
-
/* Read from second MX */
do {
while (!GAMMA_READ(GAMMA_OUTFIFOWORDS + 0x10000))
@@ -788,8 +806,13 @@ int gamma_lock(struct inode *inode, struct file *filp, unsigned int cmd,
if (!ret) {
if (lock.flags & _DRM_LOCK_READY)
gamma_dma_ready(dev);
- if (lock.flags & _DRM_LOCK_QUIESCENT)
- gamma_dma_quiescent(dev);
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ if (gamma_found() == 1) {
+ gamma_dma_quiescent_single(dev);
+ } else {
+ gamma_dma_quiescent_dual(dev);
+ }
+ }
}
DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c
index ce970835a..987c903d2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.c
@@ -1,8 +1,8 @@
/* gamma.c -- 3dlabs GMX 2000 driver -*- linux-c -*-
* Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
- * Revised: Tue Oct 12 08:51:36 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,22 +24,32 @@
* 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/linux/drm/kernel/gamma_drv.c,v 1.4 2000/02/23 04:47:28 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
+#include <linux/config.h>
#define EXPORT_SYMTAB
#include "drmP.h"
#include "gamma_drv.h"
+#include <linux/pci.h>
EXPORT_SYMBOL(gamma_init);
EXPORT_SYMBOL(gamma_cleanup);
+#ifndef PCI_DEVICE_ID_3DLABS_GAMMA
+#define PCI_DEVICE_ID_3DLABS_GAMMA 0x0008
+#endif
+#ifndef PCI_DEVICE_ID_3DLABS_MX
+#define PCI_DEVICE_ID_3DLABS_MX 0x0006
+#endif
+
#define GAMMA_NAME "gamma"
#define GAMMA_DESC "3dlabs GMX 2000"
-#define GAMMA_DATE "19990830"
-#define GAMMA_MAJOR 0
+#define GAMMA_DATE "20000606"
+#define GAMMA_MAJOR 1
#define GAMMA_MINOR 0
-#define GAMMA_PATCHLEVEL 5
+#define GAMMA_PATCHLEVEL 0
static drm_device_t gamma_device;
@@ -98,10 +108,13 @@ static drm_ioctl_desc_t gamma_ioctls[] = {
int init_module(void);
void cleanup_module(void);
static char *gamma = NULL;
+static int devices = 0;
MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas.");
MODULE_DESCRIPTION("3dlabs GMX 2000");
MODULE_PARM(gamma, "s");
+MODULE_PARM(devices, "i");
+MODULE_PARM_DESC(devices, "devices=x, where x is the number of MX chips on your card\n");
/* init_module is called when insmod is used to load the module */
@@ -121,7 +134,7 @@ void cleanup_module(void)
#ifndef MODULE
/* gamma_setup is called by the kernel to parse command-line options passed
* via the boot-loader (e.g., LILO). It calls the insmod option routine,
- * drm_parse_drm.
+ * drm_parse_options.
*
* This is not currently supported, since it requires changes to
* linux/init/main.c. */
@@ -271,6 +284,12 @@ static int gamma_takedown(drm_device_t *dev)
- PAGE_SHIFT,
DRM_MEM_SAREA);
break;
+#ifdef DRM_AGP
+ case _DRM_AGP:
+ /* Do nothing here, because this is all
+ handled in the AGP/GART driver. */
+ break;
+#endif
}
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
@@ -310,6 +329,34 @@ static int gamma_takedown(drm_device_t *dev)
return 0;
}
+int gamma_found(void)
+{
+ return devices;
+}
+
+int gamma_find_devices(void)
+{
+ struct pci_dev *d = NULL, *one = NULL, *two = NULL;
+
+ d = pci_find_device(PCI_VENDOR_ID_3DLABS,PCI_DEVICE_ID_3DLABS_GAMMA,d);
+ if (!d) return 0;
+
+ one = pci_find_device(PCI_VENDOR_ID_3DLABS,PCI_DEVICE_ID_3DLABS_MX,d);
+ if (!one) return 0;
+
+ /* Make sure it's on the same card, if not - no MX's found */
+ if (PCI_SLOT(d->devfn) != PCI_SLOT(one->devfn)) return 0;
+
+ two = pci_find_device(PCI_VENDOR_ID_3DLABS,PCI_DEVICE_ID_3DLABS_MX,one);
+ if (!two) return 1;
+
+ /* Make sure it's on the same card, if not - only 1 MX found */
+ if (PCI_SLOT(d->devfn) != PCI_SLOT(two->devfn)) return 1;
+
+ /* Two MX's found - we don't currently support more than 2 */
+ return 2;
+}
+
/* gamma_init is called via init_module at module load time, or via
* linux/init/main.c (this is not currently supported). */
@@ -327,6 +374,8 @@ int gamma_init(void)
#ifdef MODULE
drm_parse_options(gamma);
#endif
+ devices = gamma_find_devices();
+ if (devices == 0) return -1;
if ((retcode = misc_register(&gamma_misc))) {
DRM_ERROR("Cannot register \"%s\"\n", GAMMA_NAME);
@@ -338,13 +387,14 @@ int gamma_init(void)
drm_mem_init();
drm_proc_init(dev);
- DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d with %d MX devices\n",
GAMMA_NAME,
GAMMA_MAJOR,
GAMMA_MINOR,
GAMMA_PATCHLEVEL,
GAMMA_DATE,
- gamma_misc.minor);
+ gamma_misc.minor,
+ devices);
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h
index d78a13eb7..d7e70f7fc 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/gamma_drv.h
@@ -1,8 +1,8 @@
/* gamma_drv.h -- Private header for 3dlabs GMX 2000 driver -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Fri Aug 20 09:24:27 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/gamma_drv.h,v 1.2 2000/02/23 04:47:28 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@precisioninsight.com>
*
*/
@@ -53,5 +54,7 @@ extern int gamma_irq_install(drm_device_t *dev, int irq);
extern int gamma_irq_uninstall(drm_device_t *dev);
extern int gamma_control(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+extern int gamma_find_devices(void);
+extern int gamma_found(void);
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c
index 49455b434..fa1f84dcd 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c
@@ -2,6 +2,7 @@
* Created: Thu Jan 6 01:47:26 2000 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,161 +24,35 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_bufs.c,v 1.1 2000/02/11 17:26:04 dawes Exp $
- *
*/
#define __NO_VERSION__
#include "drmP.h"
+#include "i810_drv.h"
#include "linux/un.h"
int i810_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_device_dma_t *dma = dev->dma;
- drm_buf_desc_t request;
- drm_buf_entry_t *entry;
- drm_buf_t *buf;
- unsigned long offset;
- unsigned long agp_offset;
- int count;
- int order;
- int size;
- int alignment;
- int page_order;
- int total;
- int byte_count;
- int i;
-
- if (!dma) return -EINVAL;
-
- copy_from_user_ret(&request,
- (drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
-
- count = request.count;
- order = drm_order(request.size);
- size = 1 << order;
- agp_offset = request.agp_start;
- alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
- byte_count = 0;
-
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
- if (dev->queue_count) return -EBUSY; /* Not while in use */
- spin_lock(&dev->count_lock);
- if (dev->buf_use) {
- spin_unlock(&dev->count_lock);
- return -EBUSY;
- }
- atomic_inc(&dev->buf_alloc);
- spin_unlock(&dev->count_lock);
-
- down(&dev->struct_sem);
- entry = &dma->bufs[order];
- if (entry->buf_count) {
- up(&dev->struct_sem);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM; /* May only call once for each order */
- }
-
- entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- if (!entry->buflist) {
- up(&dev->struct_sem);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- memset(entry->buflist, 0, count * sizeof(*entry->buflist));
-
- entry->buf_size = size;
- entry->page_order = page_order;
-
- while(entry->buf_count < count) {
- for(offset = 0; offset + size <= total && entry->buf_count < count;
- offset += alignment, ++entry->buf_count) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
- buf->offset = agp_offset - dev->agp->base + offset;/* ?? */
- buf->bus_address = agp_offset + offset;
- buf->address = agp_offset + offset + dev->agp->base;
- buf->next = NULL;
- buf->waiting = 0;
- buf->pending = 0;
- init_waitqueue_head(&buf->dma_wait);
- buf->pid = 0;
-#if DRM_DMA_HISTOGRAM
- buf->time_queued = 0;
- buf->time_dispatched = 0;
- buf->time_completed = 0;
- buf->time_freed = 0;
-#endif
- DRM_DEBUG("buffer %d @ %p\n",
- entry->buf_count, buf->address);
- }
- byte_count += PAGE_SIZE << page_order;
- }
-
- dma->buflist = drm_realloc(dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
- for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
- dma->buflist[i] = &entry->buflist[i - dma->buf_count];
-
- dma->buf_count += entry->buf_count;
- dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
-
- drm_freelist_create(&entry->freelist, entry->buf_count);
- for (i = 0; i < entry->buf_count; i++) {
- drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
- }
-
- up(&dev->struct_sem);
-
- request.count = entry->buf_count;
- request.size = size;
-
- copy_to_user_ret((drm_buf_desc_t *)arg,
- &request,
- sizeof(request),
- -EFAULT);
-
- atomic_dec(&dev->buf_alloc);
- return 0;
-}
-
-int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
-{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_device_dma_t *dma = dev->dma;
- drm_buf_desc_t request;
- int count;
- int order;
- int size;
- int total;
- int page_order;
- drm_buf_entry_t *entry;
- unsigned long page;
- drm_buf_t *buf;
- int alignment;
- unsigned long offset;
- int i;
- int byte_count;
- int page_count;
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ drm_buf_entry_t *entry;
+ drm_buf_t *buf;
+ unsigned long offset;
+ unsigned long agp_offset;
+ int count;
+ int order;
+ int size;
+ int alignment;
+ int page_order;
+ int total;
+ int byte_count;
+ int i;
if (!dma) return -EINVAL;
@@ -186,20 +61,17 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
sizeof(request),
-EFAULT);
- count = request.count;
- order = drm_order(request.size);
- size = 1 << order;
-
- DRM_DEBUG("count = %d, size = %d (%d), order = %d, queue_count = %d\n",
- request.count, request.size, size, order, dev->queue_count);
-
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
- if (dev->queue_count) return -EBUSY; /* Not while in use */
-
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+ agp_offset = request.agp_start;
alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
+ total = PAGE_SIZE << page_order;
+ byte_count = 0;
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
+ if (dev->queue_count) return -EBUSY; /* Not while in use */
spin_lock(&dev->count_lock);
if (dev->buf_use) {
spin_unlock(&dev->count_lock);
@@ -207,15 +79,15 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
}
atomic_inc(&dev->buf_alloc);
spin_unlock(&dev->count_lock);
-
+
down(&dev->struct_sem);
entry = &dma->bufs[order];
if (entry->buf_count) {
up(&dev->struct_sem);
atomic_dec(&dev->buf_alloc);
- return -ENOMEM; /* May only call once for each order */
+ return -ENOMEM; /* May only call once for each order */
}
-
+
entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
if (!entry->buflist) {
@@ -224,69 +96,45 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
return -ENOMEM;
}
memset(entry->buflist, 0, count * sizeof(*entry->buflist));
-
- entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- if (!entry->seglist) {
- drm_free(entry->buflist,
- count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- up(&dev->struct_sem);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- memset(entry->seglist, 0, count * sizeof(*entry->seglist));
-
- dma->pagelist = drm_realloc(dma->pagelist,
- dma->page_count * sizeof(*dma->pagelist),
- (dma->page_count + (count << page_order))
- * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- DRM_DEBUG("pagelist: %d entries\n",
- dma->page_count + (count << page_order));
-
-
- entry->buf_size = size;
+
+ entry->buf_size = size;
entry->page_order = page_order;
- byte_count = 0;
- page_count = 0;
- while (entry->buf_count < count) {
- if (!(page = drm_alloc_pages(page_order, DRM_MEM_DMA))) break;
- entry->seglist[entry->seg_count++] = page;
- for (i = 0; i < (1 << page_order); i++) {
- DRM_DEBUG("page %d @ 0x%08lx\n",
- dma->page_count + page_count,
- page + PAGE_SIZE * i);
- dma->pagelist[dma->page_count + page_count++]
- = page + PAGE_SIZE * i;
- }
- for (offset = 0;
- offset + size <= total && entry->buf_count < count;
- offset += alignment, ++entry->buf_count) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
- buf->offset = (dma->byte_count + byte_count + offset);
- buf->address = (void *)(page + offset);
- buf->next = NULL;
- buf->waiting = 0;
- buf->pending = 0;
- init_waitqueue_head(&buf->dma_wait);
- buf->pid = 0;
+ offset = 0;
+
+ while(entry->buf_count < count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+ buf->offset = offset;
+ buf->bus_address = dev->agp->base + agp_offset + offset;
+ buf->address = (void *)(agp_offset + offset + dev->agp->base);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ init_waitqueue_head(&buf->dma_wait);
+ buf->pid = 0;
+
+ buf->dev_private = drm_alloc(sizeof(drm_i810_buf_priv_t),
+ DRM_MEM_BUFS);
+ buf->dev_priv_size = sizeof(drm_i810_buf_priv_t);
+ memset(buf->dev_private, 0, sizeof(drm_i810_buf_priv_t));
+
#if DRM_DMA_HISTOGRAM
- buf->time_queued = 0;
- buf->time_dispatched = 0;
- buf->time_completed = 0;
- buf->time_freed = 0;
+ buf->time_queued = 0;
+ buf->time_dispatched = 0;
+ buf->time_completed = 0;
+ buf->time_freed = 0;
#endif
- DRM_DEBUG("buffer %d @ %p\n",
- entry->buf_count, buf->address);
- }
+ offset = offset + alignment;
+ entry->buf_count++;
byte_count += PAGE_SIZE << page_order;
+
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
}
-
+
dma->buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count)
@@ -294,45 +142,43 @@ int i810_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
DRM_MEM_BUFS);
for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
dma->buflist[i] = &entry->buflist[i - dma->buf_count];
-
- dma->buf_count += entry->buf_count;
- dma->seg_count += entry->seg_count;
- dma->page_count += entry->seg_count << page_order;
- dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
-
+
+ dma->buf_count += entry->buf_count;
+ dma->byte_count += byte_count;
drm_freelist_create(&entry->freelist, entry->buf_count);
for (i = 0; i < entry->buf_count; i++) {
drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
}
-
+
up(&dev->struct_sem);
-
+
request.count = entry->buf_count;
request.size = size;
-
+
copy_to_user_ret((drm_buf_desc_t *)arg,
&request,
sizeof(request),
-EFAULT);
-
+
atomic_dec(&dev->buf_alloc);
+ dma->flags = _DRM_DMA_USE_AGP;
return 0;
}
int i810_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
- drm_buf_desc_t request;
+ drm_buf_desc_t request;
- copy_from_user_ret(&request,
- (drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
- if(request.flags & _DRM_AGP_BUFFER)
- return i810_addbufs_agp(inode, filp, cmd, arg);
- else
- return i810_addbufs_pci(inode, filp, cmd, arg);
+ if(request.flags & _DRM_AGP_BUFFER)
+ return i810_addbufs_agp(inode, filp, cmd, arg);
+ else
+ return -EINVAL;
}
int i810_infobufs(struct inode *inode, struct file *filp, unsigned int cmd,
@@ -486,99 +332,3 @@ int i810_freebufs(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
-int i810_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
-{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_device_dma_t *dma = dev->dma;
- int retcode = 0;
- const int zero = 0;
- unsigned long virtual;
- unsigned long address;
- drm_buf_map_t request;
- int i;
-
- if (!dma) return -EINVAL;
-
- DRM_DEBUG("\n");
-
- spin_lock(&dev->count_lock);
- if (atomic_read(&dev->buf_alloc)) {
- spin_unlock(&dev->count_lock);
- return -EBUSY;
- }
- ++dev->buf_use; /* Can't allocate more after this call */
- spin_unlock(&dev->count_lock);
-
- copy_from_user_ret(&request,
- (drm_buf_map_t *)arg,
- sizeof(request),
- -EFAULT);
-
- if (request.count >= dma->buf_count) {
- if(dma->flags & _DRM_DMA_USE_AGP) {
- /* This is an ugly vicious hack */
- drm_map_t *map = NULL;
- for(i = 0; i < dev->map_count; i++) {
- map = dev->maplist[i];
- if(map->type == _DRM_AGP) break;
- }
- if (i >= dev->map_count || !map) {
- retcode = -EINVAL;
- goto done;
- }
-
- virtual = do_mmap(filp, 0, map->size, PROT_READ|PROT_WRITE,
- MAP_SHARED, (unsigned long)map->handle);
- }
- else {
- virtual = do_mmap(filp, 0, dma->byte_count,
- PROT_READ|PROT_WRITE, MAP_SHARED, 0);
- }
- if (virtual > -1024UL) {
- /* Real error */
- retcode = (signed long)virtual;
- goto done;
- }
- request.virtual = (void *)virtual;
-
- for (i = 0; i < dma->buf_count; i++) {
- if (copy_to_user(&request.list[i].idx,
- &dma->buflist[i]->idx,
- sizeof(request.list[0].idx))) {
- retcode = -EFAULT;
- goto done;
- }
- if (copy_to_user(&request.list[i].total,
- &dma->buflist[i]->total,
- sizeof(request.list[0].total))) {
- retcode = -EFAULT;
- goto done;
- }
- if (copy_to_user(&request.list[i].used,
- &zero,
- sizeof(zero))) {
- retcode = -EFAULT;
- goto done;
- }
- address = virtual + dma->buflist[i]->offset;
- if (copy_to_user(&request.list[i].address,
- &address,
- sizeof(address))) {
- retcode = -EFAULT;
- goto done;
- }
- }
- }
-done:
- request.count = dma->buf_count;
- DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
-
- copy_to_user_ret((drm_buf_map_t *)arg,
- &request,
- sizeof(request),
- -EFAULT);
-
- return retcode;
-}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c
new file mode 100644
index 000000000..689814db5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_context.c
@@ -0,0 +1,205 @@
+/* i810_context.c -- IOCTLs for i810 contexts -*- linux-c -*-
+ * Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ *
+ */
+
+#include <linux/sched.h>
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "i810_drv.h"
+
+static int i810_alloc_queue(drm_device_t *dev)
+{
+ int temp = drm_ctxbitmap_next(dev);
+ DRM_DEBUG("i810_alloc_queue: %d\n", temp);
+ return temp;
+}
+
+int i810_context_switch(drm_device_t *dev, int old, int new)
+{
+ char buf[64];
+
+ atomic_inc(&dev->total_ctx);
+
+ if (test_and_set_bit(0, &dev->context_flag)) {
+ DRM_ERROR("Reentering -- FIXME\n");
+ return -EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ dev->ctx_start = get_cycles();
+#endif
+
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
+
+ if (new == dev->last_context) {
+ clear_bit(0, &dev->context_flag);
+ return 0;
+ }
+
+ if (drm_flags & DRM_FLAG_NOCTX) {
+ i810_context_switch_complete(dev, new);
+ } else {
+ sprintf(buf, "C %d %d\n", old, new);
+ drm_write_string(dev, buf);
+ }
+
+ return 0;
+}
+
+int i810_context_switch_complete(drm_device_t *dev, int new)
+{
+ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
+ dev->last_switch = jiffies;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Lock isn't held after context switch\n");
+ }
+
+ /* If a context switch is ever initiated
+ when the kernel holds the lock, release
+ that lock here. */
+#if DRM_DMA_HISTOGRAM
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(get_cycles()
+ - dev->ctx_start)]);
+
+#endif
+ clear_bit(0, &dev->context_flag);
+ wake_up(&dev->context_wait);
+
+ return 0;
+}
+
+int i810_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t ctx;
+ int i;
+
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
+ copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT);
+ if (res.count >= DRM_RESERVED_CONTEXTS) {
+ memset(&ctx, 0, sizeof(ctx));
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ ctx.handle = i;
+ copy_to_user_ret(&res.contexts[i],
+ &i,
+ sizeof(i),
+ -EFAULT);
+ }
+ }
+ res.count = DRM_RESERVED_CONTEXTS;
+ copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT);
+ return 0;
+}
+
+int i810_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if ((ctx.handle = i810_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
+ /* Skip kernel's context and get a new one. */
+ ctx.handle = i810_alloc_queue(dev);
+ }
+ if (ctx.handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
+ /* Should this return -EBUSY instead? */
+ return -ENOMEM;
+ }
+ DRM_DEBUG("%d\n", ctx.handle);
+ copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT);
+ return 0;
+}
+
+int i810_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ /* This does nothing for the i810 */
+ return 0;
+}
+
+int i810_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT);
+ /* This is 0, because we don't hanlde any context flags */
+ ctx.flags = 0;
+ copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT);
+ return 0;
+}
+
+int i810_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ return i810_context_switch(dev, dev->last_context, ctx.handle);
+}
+
+int i810_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ i810_context_switch_complete(dev, ctx.handle);
+
+ return 0;
+}
+
+int i810_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ if(ctx.handle != DRM_KERNEL_CONTEXT) {
+ drm_ctxbitmap_free(dev, ctx.handle);
+ }
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
index 09959b657..96b7a44fe 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,10 +24,9 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_dma.c,v 1.1 2000/02/11 17:26:04 dawes Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
@@ -36,6 +36,18 @@
#include <linux/interrupt.h> /* For task queue support */
+/* in case we don't have a 2.3.99-pre6 kernel or later: */
+#ifndef VM_DONTCOPY
+#define VM_DONTCOPY 0
+#endif
+
+#define I810_BUF_FREE 2
+#define I810_BUF_CLIENT 1
+#define I810_BUF_HARDWARE 0
+
+#define I810_BUF_UNMAPPED 0
+#define I810_BUF_MAPPED 1
+
#define I810_REG(reg) 2
#define I810_BASE(reg) ((unsigned long) \
dev->maplist[I810_REG(reg)]->handle)
@@ -43,544 +55,835 @@
#define I810_DEREF(reg) *(__volatile__ int *)I810_ADDR(reg)
#define I810_READ(reg) I810_DEREF(reg)
#define I810_WRITE(reg,val) do { I810_DEREF(reg) = val; } while (0)
-
-void i810_dma_init(drm_device_t *dev)
+#define I810_DEREF16(reg) *(__volatile__ u16 *)I810_ADDR(reg)
+#define I810_READ16(reg) I810_DEREF16(reg)
+#define I810_WRITE16(reg,val) do { I810_DEREF16(reg) = val; } while (0)
+
+#define RING_LOCALS unsigned int outring, ringmask; volatile char *virt;
+
+#define BEGIN_LP_RING(n) do { \
+ if (I810_VERBOSE) \
+ DRM_DEBUG("BEGIN_LP_RING(%d) in %s\n", \
+ n, __FUNCTION__); \
+ if (dev_priv->ring.space < n*4) \
+ i810_wait_ring(dev, n*4); \
+ dev_priv->ring.space -= n*4; \
+ outring = dev_priv->ring.tail; \
+ ringmask = dev_priv->ring.tail_mask; \
+ virt = dev_priv->ring.virtual_start; \
+} while (0)
+
+#define ADVANCE_LP_RING() do { \
+ if (I810_VERBOSE) DRM_DEBUG("ADVANCE_LP_RING\n"); \
+ dev_priv->ring.tail = outring; \
+ I810_WRITE(LP_RING + RING_TAIL, outring); \
+} while(0)
+
+#define OUT_RING(n) do { \
+ if (I810_VERBOSE) DRM_DEBUG(" OUT_RING %x\n", (int)(n)); \
+ *(volatile unsigned int *)(virt + outring) = n; \
+ outring += 4; \
+ outring &= ringmask; \
+} while (0);
+
+static inline void i810_print_status_page(drm_device_t *dev)
{
- printk(KERN_INFO "i810_dma_init\n");
+ drm_device_dma_t *dma = dev->dma;
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ u32 *temp = (u32 *)dev_priv->hw_status_page;
+ int i;
+
+ DRM_DEBUG( "hw_status: Interrupt Status : %x\n", temp[0]);
+ DRM_DEBUG( "hw_status: LpRing Head ptr : %x\n", temp[1]);
+ DRM_DEBUG( "hw_status: IRing Head ptr : %x\n", temp[2]);
+ DRM_DEBUG( "hw_status: Reserved : %x\n", temp[3]);
+ DRM_DEBUG( "hw_status: Driver Counter : %d\n", temp[5]);
+ for(i = 6; i < dma->buf_count + 6; i++) {
+ DRM_DEBUG( "buffer status idx : %d used: %d\n", i - 6, temp[i]);
+ }
}
-void i810_dma_cleanup(drm_device_t *dev)
+static drm_buf_t *i810_freelist_get(drm_device_t *dev)
{
- printk(KERN_INFO "i810_dma_cleanup\n");
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+ int used;
+
+ /* Linear search might not be the best solution */
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ /* In use is already a pointer */
+ used = cmpxchg(buf_priv->in_use, I810_BUF_FREE,
+ I810_BUF_CLIENT);
+ if(used == I810_BUF_FREE) {
+ return buf;
+ }
+ }
+ return NULL;
}
-static inline void i810_dma_dispatch(drm_device_t *dev, unsigned long address,
- unsigned long length)
+/* This should only be called if the buffer is not sent to the hardware
+ * yet, the hardware updates in use for us once its on the ring buffer.
+ */
+
+static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf)
{
- printk(KERN_INFO "i810_dma_dispatch\n");
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ int used;
+
+ /* In use is already a pointer */
+ used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_FREE);
+ if(used != I810_BUF_CLIENT) {
+ DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx);
+ return -EINVAL;
+ }
+
+ return 0;
}
-static inline void i810_dma_quiescent(drm_device_t *dev)
+static struct file_operations i810_buffer_fops = {
+ open: i810_open,
+ flush: drm_flush,
+ release: i810_release,
+ ioctl: i810_ioctl,
+ mmap: i810_mmap_buffers,
+ read: drm_read,
+ fasync: drm_fasync,
+ poll: drm_poll,
+};
+
+int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma)
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_buf_t *buf = dev_priv->mmap_buffer;
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+
+ vma->vm_flags |= (VM_IO | VM_DONTCOPY);
+ vma->vm_file = filp;
+
+ buf_priv->currently_mapped = I810_BUF_MAPPED;
+
+ if (remap_page_range(vma->vm_start,
+ VM_OFFSET(vma),
+ vma->vm_end - vma->vm_start,
+ vma->vm_page_prot)) return -EAGAIN;
+ return 0;
}
-static inline void i810_dma_ready(drm_device_t *dev)
+static int i810_map_buffer(drm_buf_t *buf, struct file *filp)
{
- i810_dma_quiescent(dev);
- printk(KERN_INFO "i810_dma_ready\n");
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ struct file_operations *old_fops;
+ int retcode = 0;
+
+ if(buf_priv->currently_mapped == I810_BUF_MAPPED) return -EINVAL;
+ down(&current->mm->mmap_sem);
+ old_fops = filp->f_op;
+ filp->f_op = &i810_buffer_fops;
+ dev_priv->mmap_buffer = buf;
+ buf_priv->virtual = (void *)do_mmap(filp, 0, buf->total,
+ PROT_READ|PROT_WRITE,
+ MAP_SHARED,
+ buf->bus_address);
+ dev_priv->mmap_buffer = NULL;
+ filp->f_op = old_fops;
+ if ((unsigned long)buf_priv->virtual > -1024UL) {
+ /* Real error */
+ DRM_DEBUG("mmap error\n");
+ retcode = (signed int)buf_priv->virtual;
+ buf_priv->virtual = 0;
+ }
+ up(&current->mm->mmap_sem);
+ return retcode;
}
-static inline int i810_dma_is_ready(drm_device_t *dev)
+static int i810_unmap_buffer(drm_buf_t *buf)
{
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ int retcode = 0;
- i810_dma_quiescent(dev);
+ if(buf_priv->currently_mapped != I810_BUF_MAPPED) return -EINVAL;
+ down(&current->mm->mmap_sem);
+ retcode = do_munmap(current->mm, (unsigned long)buf_priv->virtual,
+ (size_t) buf->total);
+ buf_priv->currently_mapped = I810_BUF_UNMAPPED;
+ buf_priv->virtual = 0;
+ up(&current->mm->mmap_sem);
- printk(KERN_INFO "i810_dma_is_ready\n");
- return 1;
+ return retcode;
}
-
-static void i810_dma_service(int irq, void *device, struct pt_regs *regs)
+static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d,
+ struct file *filp)
{
- drm_device_t *dev = (drm_device_t *)device;
- drm_device_dma_t *dma = dev->dma;
-
- atomic_inc(&dev->total_irq);
- if (i810_dma_is_ready(dev)) {
- /* Free previous buffer */
- if (test_and_set_bit(0, &dev->dma_flag)) {
- atomic_inc(&dma->total_missed_free);
- return;
- }
- if (dma->this_buffer) {
- drm_free_buffer(dev, dma->this_buffer);
- dma->this_buffer = NULL;
- }
- clear_bit(0, &dev->dma_flag);
-
- /* Dispatch new buffer */
- queue_task(&dev->tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ drm_file_t *priv = filp->private_data;
+ drm_buf_t *buf;
+ drm_i810_buf_priv_t *buf_priv;
+ int retcode = 0;
+
+ buf = i810_freelist_get(dev);
+ if (!buf) {
+ retcode = -ENOMEM;
+ DRM_DEBUG("%s retcode %d\n", __FUNCTION__, retcode);
+ goto out_get_buf;
+ }
+
+ retcode = i810_map_buffer(buf, filp);
+ if(retcode) {
+ i810_freelist_put(dev, buf);
+ DRM_DEBUG("mapbuf failed in %s retcode %d\n",
+ __FUNCTION__, retcode);
+ goto out_get_buf;
}
+ buf->pid = priv->pid;
+ buf_priv = buf->dev_private;
+ d->granted = 1;
+ d->request_idx = buf->idx;
+ d->request_size = buf->total;
+ d->virtual = buf_priv->virtual;
+
+out_get_buf:
+ return retcode;
}
-/* Only called by i810_dma_schedule. */
-static int i810_do_dma(drm_device_t *dev, int locked)
+static unsigned long i810_alloc_page(drm_device_t *dev)
{
- unsigned long address;
- unsigned long length;
- drm_buf_t *buf;
- int retcode = 0;
- drm_device_dma_t *dma = dev->dma;
-#if DRM_DMA_HISTOGRAM
- cycles_t dma_start, dma_stop;
-#endif
-
- if (test_and_set_bit(0, &dev->dma_flag)) {
- atomic_inc(&dma->total_missed_dma);
- return -EBUSY;
- }
+ unsigned long address;
+
+ address = __get_free_page(GFP_KERNEL);
+ if(address == 0UL)
+ return 0;
-#if DRM_DMA_HISTOGRAM
- dma_start = get_cycles();
-#endif
-
- if (!dma->next_buffer) {
- DRM_ERROR("No next_buffer\n");
- clear_bit(0, &dev->dma_flag);
- return -EINVAL;
- }
+ atomic_inc(&mem_map[MAP_NR((void *) address)].count);
+ set_bit(PG_locked, &mem_map[MAP_NR((void *) address)].flags);
+
+ return address;
+}
- buf = dma->next_buffer;
- address = (unsigned long)buf->bus_address;
- length = buf->used;
+static void i810_free_page(drm_device_t *dev, unsigned long page)
+{
+ if(page == 0UL)
+ return;
+ atomic_dec(&mem_map[MAP_NR((void *) page)].count);
+ clear_bit(PG_locked, &mem_map[MAP_NR((void *) page)].flags);
+ wake_up(&mem_map[MAP_NR((void *) page)].wait);
+ free_page(page);
+ return;
+}
- DRM_DEBUG("context %d, buffer %d (%ld bytes)\n",
- buf->context, buf->idx, length);
-
- if (buf->list == DRM_LIST_RECLAIM) {
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
- clear_bit(0, &dev->dma_flag);
- return -EINVAL;
- }
-
- if (!length) {
- DRM_ERROR("0 length buffer\n");
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
- clear_bit(0, &dev->dma_flag);
- return 0;
- }
-
- if (!i810_dma_is_ready(dev)) {
- clear_bit(0, &dev->dma_flag);
- return -EBUSY;
- }
+static int i810_dma_cleanup(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
- if (buf->while_locked) {
- if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
- DRM_ERROR("Dispatching buffer %d from pid %d"
- " \"while locked\", but no lock held\n",
- buf->idx, buf->pid);
+ if(dev->dev_private) {
+ int i;
+ drm_i810_private_t *dev_priv =
+ (drm_i810_private_t *) dev->dev_private;
+
+ if(dev_priv->ring.virtual_start) {
+ drm_ioremapfree((void *) dev_priv->ring.virtual_start,
+ dev_priv->ring.Size);
+ }
+ if(dev_priv->hw_status_page != 0UL) {
+ i810_free_page(dev, dev_priv->hw_status_page);
+ /* Need to rewrite hardware status page */
+ I810_WRITE(0x02080, 0x1ffff000);
}
- } else {
- if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- atomic_inc(&dma->total_missed_lock);
- clear_bit(0, &dev->dma_flag);
- return -EBUSY;
+ drm_free(dev->dev_private, sizeof(drm_i810_private_t),
+ DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ drm_ioremapfree(buf_priv->kernel_virtual, buf->total);
}
}
+ return 0;
+}
- if (dev->last_context != buf->context
- && !(dev->queuelist[buf->context]->flags
- & _DRM_CONTEXT_PRESERVED)) {
- /* PRE: dev->last_context != buf->context */
- if (drm_context_switch(dev, dev->last_context, buf->context)) {
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
+static int i810_wait_ring(drm_device_t *dev, int n)
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_i810_ring_buffer_t *ring = &(dev_priv->ring);
+ int iters = 0;
+ unsigned long end;
+ unsigned int last_head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
+
+ end = jiffies + (HZ*3);
+ while (ring->space < n) {
+ int i;
+
+ ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
+ ring->space = ring->head - (ring->tail+8);
+ if (ring->space < 0) ring->space += ring->Size;
+
+ if (ring->head != last_head)
+ end = jiffies + (HZ*3);
+
+ iters++;
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("space: %d wanted %d\n", ring->space, n);
+ DRM_ERROR("lockup\n");
+ goto out_wait_ring;
}
- retcode = -EBUSY;
- goto cleanup;
-
- /* POST: we will wait for the context
- switch and will dispatch on a later call
- when dev->last_context == buf->context.
- NOTE WE HOLD THE LOCK THROUGHOUT THIS
- TIME! */
- }
-
- drm_clear_next_buffer(dev);
- buf->pending = 1;
- buf->waiting = 0;
- buf->list = DRM_LIST_PEND;
-#if DRM_DMA_HISTOGRAM
- buf->time_dispatched = get_cycles();
-#endif
-
- i810_dma_dispatch(dev, address, length);
- drm_free_buffer(dev, dma->this_buffer);
- dma->this_buffer = buf;
- atomic_add(length, &dma->total_bytes);
- atomic_inc(&dma->total_dmas);
-
- if (!buf->while_locked && !dev->context_flag && !locked) {
- if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- DRM_ERROR("\n");
- }
+ for (i = 0 ; i < 2000 ; i++) ;
}
-cleanup:
- clear_bit(0, &dev->dma_flag);
-
-#if DRM_DMA_HISTOGRAM
- dma_stop = get_cycles();
- atomic_inc(&dev->histo.dma[drm_histogram_slot(dma_stop - dma_start)]);
-#endif
-
- return retcode;
+out_wait_ring:
+ return iters;
}
-static void i810_dma_schedule_timer_wrapper(unsigned long dev)
+static void i810_kernel_lost_context(drm_device_t *dev)
{
- i810_dma_schedule((drm_device_t *)dev, 0);
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_i810_ring_buffer_t *ring = &(dev_priv->ring);
+
+ ring->head = I810_READ(LP_RING + RING_HEAD) & HEAD_ADDR;
+ ring->tail = I810_READ(LP_RING + RING_TAIL);
+ ring->space = ring->head - (ring->tail+8);
+ if (ring->space < 0) ring->space += ring->Size;
}
-static void i810_dma_schedule_tq_wrapper(void *dev)
+static int i810_freelist_init(drm_device_t *dev)
{
- i810_dma_schedule(dev, 0);
+ drm_device_dma_t *dma = dev->dma;
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+ int my_idx = 24;
+ u32 *hw_status = (u32 *)(dev_priv->hw_status_page + my_idx);
+ int i;
+
+ if(dma->buf_count > 1019) {
+ /* Not enough space in the status page for the freelist */
+ return -EINVAL;
+ }
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+
+ buf_priv->in_use = hw_status++;
+ buf_priv->my_use_idx = my_idx;
+ my_idx += 4;
+
+ *buf_priv->in_use = I810_BUF_FREE;
+
+ buf_priv->kernel_virtual = drm_ioremap(buf->bus_address,
+ buf->total);
+ }
+ return 0;
}
-int i810_dma_schedule(drm_device_t *dev, int locked)
+static int i810_dma_initialize(drm_device_t *dev,
+ drm_i810_private_t *dev_priv,
+ drm_i810_init_t *init)
{
- int next;
- drm_queue_t *q;
- drm_buf_t *buf;
- int retcode = 0;
- int processed = 0;
- int missed;
- int expire = 20;
- drm_device_dma_t *dma = dev->dma;
-#if DRM_DMA_HISTOGRAM
- cycles_t schedule_start;
-#endif
+ drm_map_t *sarea_map;
- if (test_and_set_bit(0, &dev->interrupt_flag)) {
- /* Not reentrant */
- atomic_inc(&dma->total_missed_sched);
- return -EBUSY;
+ dev->dev_private = (void *) dev_priv;
+ memset(dev_priv, 0, sizeof(drm_i810_private_t));
+
+ if (init->ring_map_idx >= dev->map_count ||
+ init->buffer_map_idx >= dev->map_count) {
+ i810_dma_cleanup(dev);
+ DRM_ERROR("ring_map or buffer_map are invalid\n");
+ return -EINVAL;
+ }
+
+ dev_priv->ring_map_idx = init->ring_map_idx;
+ dev_priv->buffer_map_idx = init->buffer_map_idx;
+ sarea_map = dev->maplist[0];
+ dev_priv->sarea_priv = (drm_i810_sarea_t *)
+ ((u8 *)sarea_map->handle +
+ init->sarea_priv_offset);
+
+ atomic_set(&dev_priv->flush_done, 0);
+ init_waitqueue_head(&dev_priv->flush_queue);
+
+ dev_priv->ring.Start = init->ring_start;
+ dev_priv->ring.End = init->ring_end;
+ dev_priv->ring.Size = init->ring_size;
+
+ dev_priv->ring.virtual_start = drm_ioremap(dev->agp->base +
+ init->ring_start,
+ init->ring_size);
+
+ dev_priv->ring.tail_mask = dev_priv->ring.Size - 1;
+
+ if (dev_priv->ring.virtual_start == NULL) {
+ i810_dma_cleanup(dev);
+ DRM_ERROR("can not ioremap virtual address for"
+ " ring buffer\n");
+ return -ENOMEM;
}
- missed = atomic_read(&dma->total_missed_sched);
-#if DRM_DMA_HISTOGRAM
- schedule_start = get_cycles();
-#endif
+ dev_priv->w = init->w;
+ dev_priv->h = init->h;
+ dev_priv->pitch = init->pitch;
+ dev_priv->back_offset = init->back_offset;
+ dev_priv->depth_offset = init->depth_offset;
-again:
- if (dev->context_flag) {
- clear_bit(0, &dev->interrupt_flag);
- return -EBUSY;
+ dev_priv->front_di1 = init->front_offset | init->pitch_bits;
+ dev_priv->back_di1 = init->back_offset | init->pitch_bits;
+ dev_priv->zi1 = init->depth_offset | init->pitch_bits;
+
+
+ /* Program Hardware Status Page */
+ dev_priv->hw_status_page = i810_alloc_page(dev);
+ memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE);
+ if(dev_priv->hw_status_page == 0UL) {
+ i810_dma_cleanup(dev);
+ DRM_ERROR("Can not allocate hardware status page\n");
+ return -ENOMEM;
}
- if (dma->next_buffer) {
- /* Unsent buffer that was previously
- selected, but that couldn't be sent
- because the lock could not be obtained
- or the DMA engine wasn't ready. Try
- again. */
- atomic_inc(&dma->total_tried);
- if (!(retcode = i810_do_dma(dev, locked))) {
- atomic_inc(&dma->total_hit);
- ++processed;
- }
- } else {
- do {
- next = drm_select_queue(dev,
- i810_dma_schedule_timer_wrapper);
- if (next >= 0) {
- q = dev->queuelist[next];
- buf = drm_waitlist_get(&q->waitlist);
- dma->next_buffer = buf;
- dma->next_queue = q;
- if (buf && buf->list == DRM_LIST_RECLAIM) {
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
- }
- }
- } while (next >= 0 && !dma->next_buffer);
- if (dma->next_buffer) {
- if (!(retcode = i810_do_dma(dev, locked))) {
- ++processed;
- }
- }
+ DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page);
+
+ I810_WRITE(0x02080, virt_to_bus((void *)dev_priv->hw_status_page));
+ DRM_DEBUG("Enabled hardware status page\n");
+
+ /* Now we need to init our freelist */
+ if(i810_freelist_init(dev) != 0) {
+ i810_dma_cleanup(dev);
+ DRM_ERROR("Not enough space in the status page for"
+ " the freelist\n");
+ return -ENOMEM;
}
+ return 0;
+}
- if (--expire) {
- if (missed != atomic_read(&dma->total_missed_sched)) {
- atomic_inc(&dma->total_lost);
- if (i810_dma_is_ready(dev)) goto again;
- }
- if (processed && i810_dma_is_ready(dev)) {
- atomic_inc(&dma->total_lost);
- processed = 0;
- goto again;
- }
- }
+int i810_dma_init(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_i810_private_t *dev_priv;
+ drm_i810_init_t init;
+ int retcode = 0;
- clear_bit(0, &dev->interrupt_flag);
+ copy_from_user_ret(&init, (drm_i810_init_t *)arg,
+ sizeof(init), -EFAULT);
-#if DRM_DMA_HISTOGRAM
- atomic_inc(&dev->histo.schedule[drm_histogram_slot(get_cycles()
- - schedule_start)]);
-#endif
- return retcode;
+ switch(init.func) {
+ case I810_INIT_DMA:
+ dev_priv = drm_alloc(sizeof(drm_i810_private_t),
+ DRM_MEM_DRIVER);
+ if(dev_priv == NULL) return -ENOMEM;
+ retcode = i810_dma_initialize(dev, dev_priv, &init);
+ break;
+ case I810_CLEANUP_DMA:
+ retcode = i810_dma_cleanup(dev);
+ break;
+ default:
+ retcode = -EINVAL;
+ break;
+ }
+
+ return retcode;
}
-static int i810_dma_priority(drm_device_t *dev, drm_dma_t *d)
-{
- unsigned long address;
- unsigned long length;
- int must_free = 0;
- int retcode = 0;
- int i;
- int idx;
- drm_buf_t *buf;
- drm_buf_t *last_buf = NULL;
- drm_device_dma_t *dma = dev->dma;
- DECLARE_WAITQUEUE(entry, current);
- /* Turn off interrupt handling */
- while (test_and_set_bit(0, &dev->interrupt_flag)) {
- schedule();
- if (signal_pending(current)) return -EINTR;
- }
- if (!(d->flags & _DRM_DMA_WHILE_LOCKED)) {
- while (!drm_lock_take(&dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- schedule();
- if (signal_pending(current)) {
- clear_bit(0, &dev->interrupt_flag);
- return -EINTR;
- }
- }
- ++must_free;
+
+/* Most efficient way to verify state for the i810 is as it is
+ * emitted. Non-conformant state is silently dropped.
+ *
+ * Use 'volatile' & local var tmp to force the emitted values to be
+ * identical to the verified ones.
+ */
+static void i810EmitContextVerified( drm_device_t *dev,
+ volatile unsigned int *code )
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ int i, j = 0;
+ unsigned int tmp;
+ RING_LOCALS;
+
+ BEGIN_LP_RING( I810_CTX_SETUP_SIZE );
+
+ OUT_RING( GFX_OP_COLOR_FACTOR );
+ OUT_RING( code[I810_CTXREG_CF1] );
+
+ OUT_RING( GFX_OP_STIPPLE );
+ OUT_RING( code[I810_CTXREG_ST1] );
+
+ for ( i = 4 ; i < I810_CTX_SETUP_SIZE ; i++ ) {
+ tmp = code[i];
+
+ if ((tmp & (7<<29)) == (3<<29) &&
+ (tmp & (0x1f<<24)) < (0x1d<<24))
+ {
+ OUT_RING( tmp );
+ j++;
+ }
}
- atomic_inc(&dma->total_prio);
- for (i = 0; i < d->send_count; i++) {
- idx = d->send_indices[i];
- if (idx < 0 || idx >= dma->buf_count) {
- DRM_ERROR("Index %d (of %d max)\n",
- d->send_indices[i], dma->buf_count - 1);
- continue;
- }
- buf = dma->buflist[ idx ];
- if (buf->pid != current->pid) {
- DRM_ERROR("Process %d using buffer owned by %d\n",
- current->pid, buf->pid);
- retcode = -EINVAL;
- goto cleanup;
- }
- if (buf->list != DRM_LIST_NONE) {
- DRM_ERROR("Process %d using %d's buffer on list %d\n",
- current->pid, buf->pid, buf->list);
- retcode = -EINVAL;
- goto cleanup;
- }
- /* This isn't a race condition on
- buf->list, since our concern is the
- buffer reclaim during the time the
- process closes the /dev/drm? handle, so
- it can't also be doing DMA. */
- buf->list = DRM_LIST_PRIO;
- buf->used = d->send_sizes[i];
- buf->context = d->context;
- buf->while_locked = d->flags & _DRM_DMA_WHILE_LOCKED;
- address = (unsigned long)buf->address;
- length = buf->used;
- if (!length) {
- DRM_ERROR("0 length buffer\n");
- }
- if (buf->pending) {
- DRM_ERROR("Sending pending buffer:"
- " buffer %d, offset %d\n",
- d->send_indices[i], i);
- retcode = -EINVAL;
- goto cleanup;
- }
- if (buf->waiting) {
- DRM_ERROR("Sending waiting buffer:"
- " buffer %d, offset %d\n",
- d->send_indices[i], i);
- retcode = -EINVAL;
- goto cleanup;
+ if (j & 1)
+ OUT_RING( 0 );
+
+ ADVANCE_LP_RING();
+}
+
+static void i810EmitTexVerified( drm_device_t *dev,
+ volatile unsigned int *code )
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ int i, j = 0;
+ unsigned int tmp;
+ RING_LOCALS;
+
+ BEGIN_LP_RING( I810_TEX_SETUP_SIZE );
+
+ OUT_RING( GFX_OP_MAP_INFO );
+ OUT_RING( code[I810_TEXREG_MI1] );
+ OUT_RING( code[I810_TEXREG_MI2] );
+ OUT_RING( code[I810_TEXREG_MI3] );
+
+ for ( i = 4 ; i < I810_TEX_SETUP_SIZE ; i++ ) {
+ tmp = code[i];
+
+ if ((tmp & (7<<29)) == (3<<29) &&
+ (tmp & (0x1f<<24)) < (0x1d<<24))
+ {
+ OUT_RING( tmp );
+ j++;
}
- buf->pending = 1;
+ }
- if (dev->last_context != buf->context
- && !(dev->queuelist[buf->context]->flags
- & _DRM_CONTEXT_PRESERVED)) {
- add_wait_queue(&dev->context_wait, &entry);
- current->state = TASK_INTERRUPTIBLE;
- /* PRE: dev->last_context != buf->context */
- drm_context_switch(dev, dev->last_context,
- buf->context);
- /* POST: we will wait for the context
- switch and will dispatch on a later call
- when dev->last_context == buf->context.
- NOTE WE HOLD THE LOCK THROUGHOUT THIS
- TIME! */
- schedule();
- current->state = TASK_RUNNING;
- remove_wait_queue(&dev->context_wait, &entry);
- if (signal_pending(current)) {
- retcode = -EINTR;
- goto cleanup;
- }
- if (dev->last_context != buf->context) {
- DRM_ERROR("Context mismatch: %d %d\n",
- dev->last_context,
- buf->context);
- }
- }
+ if (j & 1)
+ OUT_RING( 0 );
-#if DRM_DMA_HISTOGRAM
- buf->time_queued = get_cycles();
- buf->time_dispatched = buf->time_queued;
-#endif
- i810_dma_dispatch(dev, address, length);
- if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- DRM_ERROR("\n");
- }
+ ADVANCE_LP_RING();
+}
- atomic_add(length, &dma->total_bytes);
- atomic_inc(&dma->total_dmas);
-
- if (last_buf) {
- drm_free_buffer(dev, last_buf);
- }
- last_buf = buf;
+
+/* Need to do some additional checking when setting the dest buffer.
+ */
+static void i810EmitDestVerified( drm_device_t *dev,
+ volatile unsigned int *code )
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ unsigned int tmp;
+ RING_LOCALS;
+
+ BEGIN_LP_RING( I810_DEST_SETUP_SIZE + 2 );
+
+ tmp = code[I810_DESTREG_DI1];
+ if (tmp == dev_priv->front_di1 || tmp == dev_priv->back_di1) {
+ OUT_RING( CMD_OP_DESTBUFFER_INFO );
+ OUT_RING( tmp );
+ } else
+ DRM_DEBUG("bad di1 %x (allow %x or %x)\n",
+ tmp, dev_priv->front_di1, dev_priv->back_di1);
+
+ /* invarient:
+ */
+ OUT_RING( CMD_OP_Z_BUFFER_INFO );
+ OUT_RING( dev_priv->zi1 );
+
+ OUT_RING( GFX_OP_DESTBUFFER_VARS );
+ OUT_RING( code[I810_DESTREG_DV1] );
+
+ OUT_RING( GFX_OP_DRAWRECT_INFO );
+ OUT_RING( code[I810_DESTREG_DR1] );
+ OUT_RING( code[I810_DESTREG_DR2] );
+ OUT_RING( code[I810_DESTREG_DR3] );
+ OUT_RING( code[I810_DESTREG_DR4] );
+ OUT_RING( 0 );
+
+ ADVANCE_LP_RING();
+}
+
+
+
+static void i810EmitState( drm_device_t *dev )
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int dirty = sarea_priv->dirty;
+
+ if (dirty & I810_UPLOAD_BUFFERS) {
+ i810EmitDestVerified( dev, sarea_priv->BufferState );
+ sarea_priv->dirty &= ~I810_UPLOAD_BUFFERS;
}
+ if (dirty & I810_UPLOAD_CTX) {
+ i810EmitContextVerified( dev, sarea_priv->ContextState );
+ sarea_priv->dirty &= ~I810_UPLOAD_CTX;
+ }
-cleanup:
- if (last_buf) {
- i810_dma_ready(dev);
- drm_free_buffer(dev, last_buf);
+ if (dirty & I810_UPLOAD_TEX0) {
+ i810EmitTexVerified( dev, sarea_priv->TexState[0] );
+ sarea_priv->dirty &= ~I810_UPLOAD_TEX0;
}
-
- if (must_free && !dev->context_flag) {
- if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- DRM_ERROR("\n");
- }
+
+ if (dirty & I810_UPLOAD_TEX1) {
+ i810EmitTexVerified( dev, sarea_priv->TexState[1] );
+ sarea_priv->dirty &= ~I810_UPLOAD_TEX1;
}
- clear_bit(0, &dev->interrupt_flag);
- return retcode;
}
-static int i810_dma_send_buffers(drm_device_t *dev, drm_dma_t *d)
+
+
+/* need to verify
+ */
+static void i810_dma_dispatch_clear( drm_device_t *dev, int flags,
+ unsigned int clear_color,
+ unsigned int clear_zval )
{
- DECLARE_WAITQUEUE(entry, current);
- drm_buf_t *last_buf = NULL;
- int retcode = 0;
- drm_device_dma_t *dma = dev->dma;
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ int nbox = sarea_priv->nbox;
+ drm_clip_rect_t *pbox = sarea_priv->boxes;
+ int pitch = dev_priv->pitch;
+ int cpp = 2;
+ int i;
+ RING_LOCALS;
+
+ i810_kernel_lost_context(dev);
+
+ if (nbox > I810_NR_SAREA_CLIPRECTS)
+ nbox = I810_NR_SAREA_CLIPRECTS;
+
+ for (i = 0 ; i < nbox ; i++, pbox++) {
+ unsigned int x = pbox->x1;
+ unsigned int y = pbox->y1;
+ unsigned int width = (pbox->x2 - x) * cpp;
+ unsigned int height = pbox->y2 - y;
+ unsigned int start = y * pitch + x * cpp;
+
+ if (pbox->x1 > pbox->x2 ||
+ pbox->y1 > pbox->y2 ||
+ pbox->x2 > dev_priv->w ||
+ pbox->y2 > dev_priv->h)
+ continue;
- if (d->flags & _DRM_DMA_BLOCK) {
- last_buf = dma->buflist[d->send_indices[d->send_count-1]];
- add_wait_queue(&last_buf->dma_wait, &entry);
- }
-
- if ((retcode = drm_dma_enqueue(dev, d))) {
- if (d->flags & _DRM_DMA_BLOCK)
- remove_wait_queue(&last_buf->dma_wait, &entry);
- return retcode;
- }
-
- i810_dma_schedule(dev, 0);
-
- if (d->flags & _DRM_DMA_BLOCK) {
- DRM_DEBUG("%d waiting\n", current->pid);
- current->state = TASK_INTERRUPTIBLE;
- for (;;) {
- if (!last_buf->waiting
- && !last_buf->pending)
- break; /* finished */
- schedule();
- if (signal_pending(current)) {
- retcode = -EINTR; /* Can't restart */
- break;
- }
+ if ( flags & I810_FRONT ) {
+ DRM_DEBUG("clear front\n");
+ BEGIN_LP_RING( 6 );
+ OUT_RING( BR00_BITBLT_CLIENT |
+ BR00_OP_COLOR_BLT | 0x3 );
+ OUT_RING( BR13_SOLID_PATTERN | (0xF0 << 16) | pitch );
+ OUT_RING( (height << 16) | width );
+ OUT_RING( start );
+ OUT_RING( clear_color );
+ OUT_RING( 0 );
+ ADVANCE_LP_RING();
}
- current->state = TASK_RUNNING;
- DRM_DEBUG("%d running\n", current->pid);
- remove_wait_queue(&last_buf->dma_wait, &entry);
- if (!retcode
- || (last_buf->list==DRM_LIST_PEND && !last_buf->pending)) {
- if (!waitqueue_active(&last_buf->dma_wait)) {
- drm_free_buffer(dev, last_buf);
- }
+
+ if ( flags & I810_BACK ) {
+ DRM_DEBUG("clear back\n");
+ BEGIN_LP_RING( 6 );
+ OUT_RING( BR00_BITBLT_CLIENT |
+ BR00_OP_COLOR_BLT | 0x3 );
+ OUT_RING( BR13_SOLID_PATTERN | (0xF0 << 16) | pitch );
+ OUT_RING( (height << 16) | width );
+ OUT_RING( dev_priv->back_offset + start );
+ OUT_RING( clear_color );
+ OUT_RING( 0 );
+ ADVANCE_LP_RING();
}
- if (retcode) {
- DRM_ERROR("ctx%d w%d p%d c%d i%d l%d %d/%d\n",
- d->context,
- last_buf->waiting,
- last_buf->pending,
- DRM_WAITCOUNT(dev, d->context),
- last_buf->idx,
- last_buf->list,
- last_buf->pid,
- current->pid);
+
+ if ( flags & I810_DEPTH ) {
+ DRM_DEBUG("clear depth\n");
+ BEGIN_LP_RING( 6 );
+ OUT_RING( BR00_BITBLT_CLIENT |
+ BR00_OP_COLOR_BLT | 0x3 );
+ OUT_RING( BR13_SOLID_PATTERN | (0xF0 << 16) | pitch );
+ OUT_RING( (height << 16) | width );
+ OUT_RING( dev_priv->depth_offset + start );
+ OUT_RING( clear_zval );
+ OUT_RING( 0 );
+ ADVANCE_LP_RING();
}
}
- return retcode;
}
-int i810_dma(struct inode *inode, struct file *filp, unsigned int cmd,
- unsigned long arg)
+static void i810_dma_dispatch_swap( drm_device_t *dev )
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_device_dma_t *dma = dev->dma;
- int retcode = 0;
- drm_dma_t d;
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ int nbox = sarea_priv->nbox;
+ drm_clip_rect_t *pbox = sarea_priv->boxes;
+ int pitch = dev_priv->pitch;
+ int cpp = 2;
+ int ofs = dev_priv->back_offset;
+ int i;
+ RING_LOCALS;
+
+ DRM_DEBUG("swapbuffers\n");
+
+ i810_kernel_lost_context(dev);
+
+ if (nbox > I810_NR_SAREA_CLIPRECTS)
+ nbox = I810_NR_SAREA_CLIPRECTS;
+
+ for (i = 0 ; i < nbox; i++, pbox++)
+ {
+ unsigned int w = pbox->x2 - pbox->x1;
+ unsigned int h = pbox->y2 - pbox->y1;
+ unsigned int dst = pbox->x1*cpp + pbox->y1*pitch;
+ unsigned int start = ofs + dst;
+
+ if (pbox->x1 > pbox->x2 ||
+ pbox->y1 > pbox->y2 ||
+ pbox->x2 > dev_priv->w ||
+ pbox->y2 > dev_priv->h)
+ continue;
+
+ DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
+ pbox[i].x1, pbox[i].y1,
+ pbox[i].x2, pbox[i].y2);
+
+ BEGIN_LP_RING( 6 );
+ OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_SRC_COPY_BLT | 0x4 );
+ OUT_RING( pitch | (0xCC << 16));
+ OUT_RING( (h << 16) | (w * cpp));
+ OUT_RING( dst );
+ OUT_RING( pitch );
+ OUT_RING( start );
+ ADVANCE_LP_RING();
+ }
+}
- printk("i810_dma start\n");
- copy_from_user_ret(&d, (drm_dma_t *)arg, sizeof(d), -EFAULT);
- DRM_DEBUG("%d %d: %d send, %d req\n",
- current->pid, d.context, d.send_count, d.request_count);
- if (d.context == DRM_KERNEL_CONTEXT || d.context >= dev->queue_slots) {
- DRM_ERROR("Process %d using context %d\n",
- current->pid, d.context);
- return -EINVAL;
+static void i810_dma_dispatch_vertex(drm_device_t *dev,
+ drm_buf_t *buf,
+ int discard,
+ int used)
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+ drm_i810_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ drm_clip_rect_t *box = sarea_priv->boxes;
+ int nbox = sarea_priv->nbox;
+ unsigned long address = (unsigned long)buf->bus_address;
+ unsigned long start = address - dev->agp->base;
+ int i = 0, u;
+ RING_LOCALS;
+
+ i810_kernel_lost_context(dev);
+
+ if (nbox > I810_NR_SAREA_CLIPRECTS)
+ nbox = I810_NR_SAREA_CLIPRECTS;
+
+ if (discard) {
+ u = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
+ I810_BUF_HARDWARE);
+ if(u != I810_BUF_CLIENT) {
+ DRM_DEBUG("xxxx 2\n");
+ }
}
- if (d.send_count < 0 || d.send_count > dma->buf_count) {
- DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n",
- current->pid, d.send_count, dma->buf_count);
- return -EINVAL;
+ if (used > 4*1024)
+ used = 0;
+
+ if (sarea_priv->dirty)
+ i810EmitState( dev );
+
+ DRM_DEBUG("dispatch vertex addr 0x%lx, used 0x%x nbox %d\n",
+ address, used, nbox);
+
+ dev_priv->counter++;
+ DRM_DEBUG( "dispatch counter : %ld\n", dev_priv->counter);
+ DRM_DEBUG( "i810_dma_dispatch\n");
+ DRM_DEBUG( "start : %lx\n", start);
+ DRM_DEBUG( "used : %d\n", used);
+ DRM_DEBUG( "start + used - 4 : %ld\n", start + used - 4);
+
+ if (buf_priv->currently_mapped == I810_BUF_MAPPED) {
+ *(u32 *)buf_priv->virtual = (GFX_OP_PRIMITIVE |
+ sarea_priv->vertex_prim |
+ ((used/4)-2));
+
+ if (used & 4) {
+ *(u32 *)((u32)buf_priv->virtual + used) = 0;
+ used += 4;
+ }
+
+ i810_unmap_buffer(buf);
}
- if (d.request_count < 0 || d.request_count > dma->buf_count) {
- DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
- current->pid, d.request_count, dma->buf_count);
- return -EINVAL;
+
+ if (used) {
+ do {
+ if (i < nbox) {
+ BEGIN_LP_RING(4);
+ OUT_RING( GFX_OP_SCISSOR | SC_UPDATE_SCISSOR |
+ SC_ENABLE );
+ OUT_RING( GFX_OP_SCISSOR_INFO );
+ OUT_RING( box[i].x1 | (box[i].y1<<16) );
+ OUT_RING( (box[i].x2-1) | ((box[i].y2-1)<<16) );
+ ADVANCE_LP_RING();
+ }
+
+ BEGIN_LP_RING(4);
+ OUT_RING( CMD_OP_BATCH_BUFFER );
+ OUT_RING( start | BB1_PROTECTED );
+ OUT_RING( start + used - 4 );
+ OUT_RING( 0 );
+ ADVANCE_LP_RING();
+
+ } while (++i < nbox);
}
- if (d.send_count) {
-#if 0
- if (d.flags & _DRM_DMA_PRIORITY)
- retcode = i810_dma_priority(dev, &d);
- else
- retcode = i810_dma_send_buffers(dev, &d);
-#endif
- printk("i810_dma priority\n");
-
- retcode = i810_dma_priority(dev, &d);
+ BEGIN_LP_RING(10);
+ OUT_RING( CMD_STORE_DWORD_IDX );
+ OUT_RING( 20 );
+ OUT_RING( dev_priv->counter );
+ OUT_RING( 0 );
+
+ if (discard) {
+ OUT_RING( CMD_STORE_DWORD_IDX );
+ OUT_RING( buf_priv->my_use_idx );
+ OUT_RING( I810_BUF_FREE );
+ OUT_RING( 0 );
}
- d.granted_count = 0;
+ OUT_RING( CMD_REPORT_HEAD );
+ OUT_RING( 0 );
+ ADVANCE_LP_RING();
+}
- if (!retcode && d.request_count) {
- retcode = drm_dma_get_buffers(dev, &d);
- }
- DRM_DEBUG("%d returning, granted = %d\n",
- current->pid, d.granted_count);
- copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT);
+/* Interrupts are only for flushing */
+static void i810_dma_service(int irq, void *device, struct pt_regs *regs)
+{
+ drm_device_t *dev = (drm_device_t *)device;
+ u16 temp;
+
+ atomic_inc(&dev->total_irq);
+ temp = I810_READ16(I810REG_INT_IDENTITY_R);
+ temp = temp & ~(0x6000);
+ if(temp != 0) I810_WRITE16(I810REG_INT_IDENTITY_R,
+ temp); /* Clear all interrupts */
+ else
+ return;
+
+ queue_task(&dev->tq, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
+}
- printk("i810_dma end (granted)\n");
- return retcode;
+static void i810_dma_task_queue(void *device)
+{
+ drm_device_t *dev = (drm_device_t *) device;
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+
+ atomic_set(&dev_priv->flush_done, 1);
+ wake_up_interruptible(&dev_priv->flush_queue);
}
int i810_irq_install(drm_device_t *dev, int irq)
{
int retcode;
-
+ u16 temp;
+
if (!irq) return -EINVAL;
down(&dev->struct_sem);
@@ -591,6 +894,7 @@ int i810_irq_install(drm_device_t *dev, int irq)
dev->irq = irq;
up(&dev->struct_sem);
+ DRM_DEBUG( "Interrupt Install : %d\n", irq);
DRM_DEBUG("%d\n", irq);
dev->context_flag = 0;
@@ -603,16 +907,25 @@ int i810_irq_install(drm_device_t *dev, int irq)
dev->tq.next = NULL;
dev->tq.sync = 0;
- dev->tq.routine = i810_dma_schedule_tq_wrapper;
+ dev->tq.routine = i810_dma_task_queue;
dev->tq.data = dev;
-
/* Before installing handler */
- /* TODO */
+ temp = I810_READ16(I810REG_HWSTAM);
+ temp = temp & 0x6000;
+ I810_WRITE16(I810REG_HWSTAM, temp);
+
+ temp = I810_READ16(I810REG_INT_MASK_R);
+ temp = temp & 0x6000;
+ I810_WRITE16(I810REG_INT_MASK_R, temp); /* Unmask interrupts */
+ temp = I810_READ16(I810REG_INT_ENABLE_R);
+ temp = temp & 0x6000;
+ I810_WRITE16(I810REG_INT_ENABLE_R, temp); /* Disable all interrupts */
+
/* Install handler */
if ((retcode = request_irq(dev->irq,
i810_dma_service,
- 0,
+ SA_SHIRQ,
dev->devname,
dev))) {
down(&dev->struct_sem);
@@ -620,15 +933,21 @@ int i810_irq_install(drm_device_t *dev, int irq)
up(&dev->struct_sem);
return retcode;
}
-
- /* After installing handler */
- /* TODO */
+ temp = I810_READ16(I810REG_INT_ENABLE_R);
+ temp = temp & 0x6000;
+ temp = temp | 0x0003;
+ I810_WRITE16(I810REG_INT_ENABLE_R,
+ temp); /* Enable bp & user interrupts */
return 0;
}
int i810_irq_uninstall(drm_device_t *dev)
{
int irq;
+ u16 temp;
+
+
+/* return 0; */
down(&dev->struct_sem);
irq = dev->irq;
@@ -636,16 +955,25 @@ int i810_irq_uninstall(drm_device_t *dev)
up(&dev->struct_sem);
if (!irq) return -EINVAL;
-
+
+ DRM_DEBUG( "Interrupt UnInstall: %d\n", irq);
DRM_DEBUG("%d\n", irq);
-
- /* TODO : Disable interrupts */
+
+ temp = I810_READ16(I810REG_INT_IDENTITY_R);
+ temp = temp & ~(0x6000);
+ if(temp != 0) I810_WRITE16(I810REG_INT_IDENTITY_R,
+ temp); /* Clear all interrupts */
+
+ temp = I810_READ16(I810REG_INT_ENABLE_R);
+ temp = temp & 0x6000;
+ I810_WRITE16(I810REG_INT_ENABLE_R,
+ temp); /* Disable all interrupts */
+
free_irq(irq, dev);
return 0;
}
-
int i810_control(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@@ -654,8 +982,7 @@ int i810_control(struct inode *inode, struct file *filp, unsigned int cmd,
drm_control_t ctl;
int retcode;
- printk(KERN_INFO "i810_control\n");
- i810_dma_init(dev);
+ DRM_DEBUG( "i810_control\n");
copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT);
@@ -674,20 +1001,161 @@ int i810_control(struct inode *inode, struct file *filp, unsigned int cmd,
return 0;
}
+static inline void i810_dma_emit_flush(drm_device_t *dev)
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ RING_LOCALS;
+
+ i810_kernel_lost_context(dev);
+
+ BEGIN_LP_RING(2);
+ OUT_RING( CMD_REPORT_HEAD );
+ OUT_RING( GFX_OP_USER_INTERRUPT );
+ ADVANCE_LP_RING();
+
+/* i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */
+/* atomic_set(&dev_priv->flush_done, 1); */
+/* wake_up_interruptible(&dev_priv->flush_queue); */
+}
+
+static inline void i810_dma_quiescent_emit(drm_device_t *dev)
+{
+ drm_i810_private_t *dev_priv = dev->dev_private;
+ RING_LOCALS;
+
+ i810_kernel_lost_context(dev);
+
+ BEGIN_LP_RING(4);
+ OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
+ OUT_RING( CMD_REPORT_HEAD );
+ OUT_RING( 0 );
+ OUT_RING( GFX_OP_USER_INTERRUPT );
+ ADVANCE_LP_RING();
+
+/* i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */
+/* atomic_set(&dev_priv->flush_done, 1); */
+/* wake_up_interruptible(&dev_priv->flush_queue); */
+}
+
+static void i810_dma_quiescent(drm_device_t *dev)
+{
+ DECLARE_WAITQUEUE(entry, current);
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+ unsigned long end;
+
+ if(dev_priv == NULL) {
+ return;
+ }
+ atomic_set(&dev_priv->flush_done, 0);
+ current->state = TASK_INTERRUPTIBLE;
+ add_wait_queue(&dev_priv->flush_queue, &entry);
+ end = jiffies + (HZ*3);
+
+ for (;;) {
+ i810_dma_quiescent_emit(dev);
+ if (atomic_read(&dev_priv->flush_done) == 1) break;
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("lockup\n");
+ break;
+ }
+ schedule_timeout(HZ*3);
+ if (signal_pending(current)) {
+ break;
+ }
+ }
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev_priv->flush_queue, &entry);
+
+ return;
+}
+
+static int i810_flush_queue(drm_device_t *dev)
+{
+ DECLARE_WAITQUEUE(entry, current);
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ unsigned long end;
+ int i, ret = 0;
+
+ if(dev_priv == NULL) {
+ return 0;
+ }
+ atomic_set(&dev_priv->flush_done, 0);
+ current->state = TASK_INTERRUPTIBLE;
+ add_wait_queue(&dev_priv->flush_queue, &entry);
+ end = jiffies + (HZ*3);
+ for (;;) {
+ i810_dma_emit_flush(dev);
+ if (atomic_read(&dev_priv->flush_done) == 1) break;
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("lockup\n");
+ break;
+ }
+ schedule_timeout(HZ*3);
+ if (signal_pending(current)) {
+ ret = -EINTR; /* Can't restart */
+ break;
+ }
+ }
+
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev_priv->flush_queue, &entry);
+
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+
+ int used = cmpxchg(buf_priv->in_use, I810_BUF_HARDWARE,
+ I810_BUF_FREE);
+
+ if (used == I810_BUF_HARDWARE)
+ DRM_DEBUG("reclaimed from HARDWARE\n");
+ if (used == I810_BUF_CLIENT)
+ DRM_DEBUG("still on client HARDWARE\n");
+ }
+
+ return ret;
+}
+
+/* Must be called with the lock held */
+void i810_reclaim_buffers(drm_device_t *dev, pid_t pid)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ if (!dma) return;
+ if (!dev->dev_private) return;
+ if (!dma->buflist) return;
+
+ i810_flush_queue(dev);
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_i810_buf_priv_t *buf_priv = buf->dev_private;
+
+ if (buf->pid == pid && buf_priv) {
+ int used = cmpxchg(buf_priv->in_use, I810_BUF_CLIENT,
+ I810_BUF_FREE);
+
+ if (used == I810_BUF_CLIENT)
+ DRM_DEBUG("reclaimed from client\n");
+ if(buf_priv->currently_mapped == I810_BUF_MAPPED)
+ buf_priv->currently_mapped = I810_BUF_UNMAPPED;
+ }
+ }
+}
+
int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
+
DECLARE_WAITQUEUE(entry, current);
int ret = 0;
drm_lock_t lock;
- drm_queue_t *q;
-#if DRM_DMA_HISTOGRAM
- cycles_t start;
-
- dev->lck_start = start = get_cycles();
-#endif
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
@@ -696,26 +1164,18 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
current->pid, lock.context);
return -EINVAL;
}
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, current->pid, dev->lock.hw_lock->lock,
+ lock.flags);
- if (lock.context < 0 || lock.context >= dev->queue_count) {
+ if (lock.context < 0) {
return -EINVAL;
}
- q = dev->queuelist[lock.context];
-
- ret = drm_flush_block_and_flush(dev, lock.context, lock.flags);
+ /* Only one queue:
+ */
if (!ret) {
- if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
- != lock.context) {
- long j = jiffies - dev->lock.lock_time;
-
- if (j > 0 && j <= DRM_LOCK_SLICE) {
- /* Can't take lock if we just had it and
- there is contention. */
- current->state = TASK_INTERRUPTIBLE;
- schedule_timeout(j);
- }
- }
add_wait_queue(&dev->lock.lock_queue, &entry);
for (;;) {
if (!dev->lock.hw_lock) {
@@ -728,13 +1188,13 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
dev->lock.pid = current->pid;
dev->lock.lock_time = jiffies;
atomic_inc(&dev->total_locks);
- atomic_inc(&q->total_locks);
break; /* Got lock */
}
/* Contention */
atomic_inc(&dev->total_sleeps);
current->state = TASK_INTERRUPTIBLE;
+ DRM_DEBUG("Calling lock schedule\n");
schedule();
if (signal_pending(current)) {
ret = -ERESTARTSYS;
@@ -744,19 +1204,153 @@ int i810_lock(struct inode *inode, struct file *filp, unsigned int cmd,
current->state = TASK_RUNNING;
remove_wait_queue(&dev->lock.lock_queue, &entry);
}
-
- drm_flush_unblock(dev, lock.context, lock.flags); /* cleanup phase */
if (!ret) {
- if (lock.flags & _DRM_LOCK_READY)
- i810_dma_ready(dev);
- if (lock.flags & _DRM_LOCK_QUIESCENT)
- i810_dma_quiescent(dev);
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ DRM_DEBUG("_DRM_LOCK_QUIESCENT\n");
+ DRM_DEBUG("fred\n");
+ i810_dma_quiescent(dev);
+ }
}
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+ return ret;
+}
-#if DRM_DMA_HISTOGRAM
- atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]);
-#endif
+int i810_flush_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ DRM_DEBUG("i810_flush_ioctl\n");
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("i810_flush_ioctl called without lock held\n");
+ return -EINVAL;
+ }
+
+ i810_flush_queue(dev);
+ return 0;
+}
+
+
+int i810_dma_vertex(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+ u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+ drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
+ dev_priv->sarea_priv;
+ drm_i810_vertex_t vertex;
+
+ copy_from_user_ret(&vertex, (drm_i810_vertex_t *)arg, sizeof(vertex),
+ -EFAULT);
+
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("i810_dma_vertex called without lock held\n");
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n",
+ vertex.idx, vertex.used, vertex.discard);
+
+ i810_dma_dispatch_vertex( dev,
+ dma->buflist[ vertex.idx ],
+ vertex.discard, vertex.used );
+
+ atomic_add(vertex.used, &dma->total_bytes);
+ atomic_inc(&dma->total_dmas);
+ sarea_priv->last_enqueue = dev_priv->counter-1;
+ sarea_priv->last_dispatch = (int) hw_status[5];
+
+ return 0;
+}
+
+
+
+int i810_clear_bufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_i810_clear_t clear;
+
+ copy_from_user_ret(&clear, (drm_i810_clear_t *)arg, sizeof(clear),
+ -EFAULT);
+
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("i810_clear_bufs called without lock held\n");
+ return -EINVAL;
+ }
+
+ i810_dma_dispatch_clear( dev, clear.flags,
+ clear.clear_color,
+ clear.clear_depth );
+ return 0;
+}
+
+int i810_swap_bufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ DRM_DEBUG("i810_swap_bufs\n");
+
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("i810_swap_buf called without lock held\n");
+ return -EINVAL;
+ }
+
+ i810_dma_dispatch_swap( dev );
+ return 0;
+}
+
+int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+ u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+ drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
+ dev_priv->sarea_priv;
+
+ sarea_priv->last_dispatch = (int) hw_status[5];
+ return 0;
+}
+
+int i810_getbuf(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ int retcode = 0;
+ drm_i810_dma_t d;
+ drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private;
+ u32 *hw_status = (u32 *)dev_priv->hw_status_page;
+ drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *)
+ dev_priv->sarea_priv;
+
+ DRM_DEBUG("getbuf\n");
+ copy_from_user_ret(&d, (drm_i810_dma_t *)arg, sizeof(d), -EFAULT);
+
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("i810_dma called without lock held\n");
+ return -EINVAL;
+ }
- return ret;
+ d.granted = 0;
+
+ retcode = i810_dma_get_buffer(dev, &d, filp);
+
+ DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
+ current->pid, retcode, d.granted);
+
+ copy_to_user_ret((drm_dma_t *)arg, &d, sizeof(d), -EFAULT);
+ sarea_priv->last_dispatch = (int) hw_status[5];
+
+ return retcode;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h
new file mode 100644
index 000000000..4c8e09f6a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drm.h
@@ -0,0 +1,188 @@
+#ifndef _I810_DRM_H_
+#define _I810_DRM_H_
+
+/* WARNING: These defines must be the same as what the Xserver uses.
+ * if you change them, you must change the defines in the Xserver.
+ */
+
+#ifndef _I810_DEFINES_
+#define _I810_DEFINES_
+
+#define I810_DMA_BUF_ORDER 12
+#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
+#define I810_DMA_BUF_NR 256
+#define I810_NR_SAREA_CLIPRECTS 8
+
+/* Each region is a minimum of 64k, and there are at most 64 of them.
+ */
+#define I810_NR_TEX_REGIONS 64
+#define I810_LOG_MIN_TEX_REGION_SIZE 16
+#endif
+
+#define I810_UPLOAD_TEX0IMAGE 0x1 /* handled clientside */
+#define I810_UPLOAD_TEX1IMAGE 0x2 /* handled clientside */
+#define I810_UPLOAD_CTX 0x4
+#define I810_UPLOAD_BUFFERS 0x8
+#define I810_UPLOAD_TEX0 0x10
+#define I810_UPLOAD_TEX1 0x20
+#define I810_UPLOAD_CLIPRECTS 0x40
+
+
+/* Indices into buf.Setup where various bits of state are mirrored per
+ * context and per buffer. These can be fired at the card as a unit,
+ * or in a piecewise fashion as required.
+ */
+
+/* Destbuffer state
+ * - backbuffer linear offset and pitch -- invarient in the current dri
+ * - zbuffer linear offset and pitch -- also invarient
+ * - drawing origin in back and depth buffers.
+ *
+ * Keep the depth/back buffer state here to acommodate private buffers
+ * in the future.
+ */
+#define I810_DESTREG_DI0 0 /* CMD_OP_DESTBUFFER_INFO (2 dwords) */
+#define I810_DESTREG_DI1 1
+#define I810_DESTREG_DV0 2 /* GFX_OP_DESTBUFFER_VARS (2 dwords) */
+#define I810_DESTREG_DV1 3
+#define I810_DESTREG_DR0 4 /* GFX_OP_DRAWRECT_INFO (4 dwords) */
+#define I810_DESTREG_DR1 5
+#define I810_DESTREG_DR2 6
+#define I810_DESTREG_DR3 7
+#define I810_DESTREG_DR4 8
+#define I810_DEST_SETUP_SIZE 10
+
+/* Context state
+ */
+#define I810_CTXREG_CF0 0 /* GFX_OP_COLOR_FACTOR */
+#define I810_CTXREG_CF1 1
+#define I810_CTXREG_ST0 2 /* GFX_OP_STIPPLE */
+#define I810_CTXREG_ST1 3
+#define I810_CTXREG_VF 4 /* GFX_OP_VERTEX_FMT */
+#define I810_CTXREG_MT 5 /* GFX_OP_MAP_TEXELS */
+#define I810_CTXREG_MC0 6 /* GFX_OP_MAP_COLOR_STAGES - stage 0 */
+#define I810_CTXREG_MC1 7 /* GFX_OP_MAP_COLOR_STAGES - stage 1 */
+#define I810_CTXREG_MC2 8 /* GFX_OP_MAP_COLOR_STAGES - stage 2 */
+#define I810_CTXREG_MA0 9 /* GFX_OP_MAP_ALPHA_STAGES - stage 0 */
+#define I810_CTXREG_MA1 10 /* GFX_OP_MAP_ALPHA_STAGES - stage 1 */
+#define I810_CTXREG_MA2 11 /* GFX_OP_MAP_ALPHA_STAGES - stage 2 */
+#define I810_CTXREG_SDM 12 /* GFX_OP_SRC_DEST_MONO */
+#define I810_CTXREG_FOG 13 /* GFX_OP_FOG_COLOR */
+#define I810_CTXREG_B1 14 /* GFX_OP_BOOL_1 */
+#define I810_CTXREG_B2 15 /* GFX_OP_BOOL_2 */
+#define I810_CTXREG_LCS 16 /* GFX_OP_LINEWIDTH_CULL_SHADE_MODE */
+#define I810_CTXREG_PV 17 /* GFX_OP_PV_RULE -- Invarient! */
+#define I810_CTXREG_ZA 18 /* GFX_OP_ZBIAS_ALPHAFUNC */
+#define I810_CTXREG_AA 19 /* GFX_OP_ANTIALIAS */
+#define I810_CTX_SETUP_SIZE 20
+
+/* Texture state (per tex unit)
+ */
+#define I810_TEXREG_MI0 0 /* GFX_OP_MAP_INFO (4 dwords) */
+#define I810_TEXREG_MI1 1
+#define I810_TEXREG_MI2 2
+#define I810_TEXREG_MI3 3
+#define I810_TEXREG_MF 4 /* GFX_OP_MAP_FILTER */
+#define I810_TEXREG_MLC 5 /* GFX_OP_MAP_LOD_CTL */
+#define I810_TEXREG_MLL 6 /* GFX_OP_MAP_LOD_LIMITS */
+#define I810_TEXREG_MCS 7 /* GFX_OP_MAP_COORD_SETS ??? */
+#define I810_TEX_SETUP_SIZE 8
+
+#define I810_FRONT 0x1
+#define I810_BACK 0x2
+#define I810_DEPTH 0x4
+
+
+typedef struct _drm_i810_init {
+ enum {
+ I810_INIT_DMA = 0x01,
+ I810_CLEANUP_DMA = 0x02
+ } func;
+ int ring_map_idx;
+ int buffer_map_idx;
+ int sarea_priv_offset;
+ unsigned int ring_start;
+ unsigned int ring_end;
+ unsigned int ring_size;
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+ unsigned int w;
+ unsigned int h;
+ unsigned int pitch;
+ unsigned int pitch_bits;
+} drm_i810_init_t;
+
+/* Warning: If you change the SAREA structure you must change the Xserver
+ * structure as well */
+
+typedef struct _drm_i810_tex_region {
+ unsigned char next, prev; /* indices to form a circular LRU */
+ unsigned char in_use; /* owned by a client, or free? */
+ int age; /* tracked by clients to update local LRU's */
+} drm_i810_tex_region_t;
+
+typedef struct _drm_i810_sarea {
+ unsigned int ContextState[I810_CTX_SETUP_SIZE];
+ unsigned int BufferState[I810_DEST_SETUP_SIZE];
+ unsigned int TexState[2][I810_TEX_SETUP_SIZE];
+ unsigned int dirty;
+
+ unsigned int nbox;
+ drm_clip_rect_t boxes[I810_NR_SAREA_CLIPRECTS];
+
+ /* Maintain an LRU of contiguous regions of texture space. If
+ * you think you own a region of texture memory, and it has an
+ * age different to the one you set, then you are mistaken and
+ * it has been stolen by another client. If global texAge
+ * hasn't changed, there is no need to walk the list.
+ *
+ * These regions can be used as a proxy for the fine-grained
+ * texture information of other clients - by maintaining them
+ * in the same lru which is used to age their own textures,
+ * clients have an approximate lru for the whole of global
+ * texture space, and can make informed decisions as to which
+ * areas to kick out. There is no need to choose whether to
+ * kick out your own texture or someone else's - simply eject
+ * them all in LRU order.
+ */
+
+ drm_i810_tex_region_t texList[I810_NR_TEX_REGIONS+1];
+ /* Last elt is sentinal */
+ int texAge; /* last time texture was uploaded */
+ int last_enqueue; /* last time a buffer was enqueued */
+ int last_dispatch; /* age of the most recently dispatched buffer */
+ int last_quiescent; /* */
+ int ctxOwner; /* last context to upload state */
+
+ int vertex_prim;
+
+} drm_i810_sarea_t;
+
+typedef struct _drm_i810_clear {
+ int clear_color;
+ int clear_depth;
+ int flags;
+} drm_i810_clear_t;
+
+
+
+/* These may be placeholders if we have more cliprects than
+ * I810_NR_SAREA_CLIPRECTS. In that case, the client sets discard to
+ * false, indicating that the buffer will be dispatched again with a
+ * new set of cliprects.
+ */
+typedef struct _drm_i810_vertex {
+ int idx; /* buffer index */
+ int used; /* nr bytes in use */
+ int discard; /* client is finished with the buffer? */
+} drm_i810_vertex_t;
+
+typedef struct drm_i810_dma {
+ void *virtual;
+ int request_idx;
+ int request_size;
+ int granted;
+} drm_i810_dma_t;
+
+#endif /* _I810_DRM_H_ */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c
index f33153a36..6f78fbc99 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,25 +24,26 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.c,v 1.1 2000/02/11 17:26:05 dawes Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
*/
+#include <linux/config.h>
#define EXPORT_SYMTAB
#include "drmP.h"
#include "i810_drv.h"
+
+
EXPORT_SYMBOL(i810_init);
EXPORT_SYMBOL(i810_cleanup);
#define I810_NAME "i810"
-#define I810_DESC "Matrox g200/g400"
+#define I810_DESC "Intel I810"
#define I810_DATE "19991213"
-#define I810_MAJOR 0
+#define I810_MAJOR 1
#define I810_MINOR 0
-#define I810_PATCHLEVEL 1
+#define I810_PATCHLEVEL 0
static drm_device_t i810_device;
drm_ctx_t i810_res_ctx;
@@ -54,6 +56,7 @@ static struct file_operations i810_fops = {
mmap: drm_mmap,
read: drm_read,
fasync: drm_fasync,
+ poll: drm_poll,
};
static struct miscdevice i810_misc = {
@@ -77,21 +80,18 @@ static drm_ioctl_desc_t i810_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { i810_addbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { i810_markbufs, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { i810_infobufs, 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { i810_mapbufs, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { i810_freebufs, 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { drm_addctx, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { drm_rmctx, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { drm_modctx, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { drm_getctx, 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { drm_switchctx, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { drm_newctx, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { drm_resctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { i810_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { i810_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { i810_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { i810_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { i810_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { i810_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { i810_resctx, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { i810_dma, 1, 0 },
-
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { i810_lock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { i810_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
@@ -104,6 +104,14 @@ static drm_ioctl_desc_t i810_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_INIT)] = { i810_dma_init, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_VERTEX)] = { i810_dma_vertex, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_CLEAR)] = { i810_clear_bufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_FLUSH)] = { i810_flush_ioctl,1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_GETAGE)] = { i810_getage, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_GETBUF)] = { i810_getbuf, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_I810_SWAP)] = { i810_swap_bufs, 1, 0 },
};
#define I810_IOCTL_COUNT DRM_ARRAY_SIZE(i810_ioctls)
@@ -121,7 +129,7 @@ MODULE_PARM(i810, "s");
int init_module(void)
{
- printk("doing i810_init()\n");
+ DRM_DEBUG("doing i810_init()\n");
return i810_init();
}
@@ -364,7 +372,7 @@ int i810_init(void)
#ifdef MODULE
drm_parse_options(i810);
#endif
- printk("doing misc_register\n");
+ DRM_DEBUG("doing misc_register\n");
if ((retcode = misc_register(&i810_misc))) {
DRM_ERROR("Cannot register \"%s\"\n", I810_NAME);
return retcode;
@@ -372,13 +380,22 @@ int i810_init(void)
dev->device = MKDEV(MISC_MAJOR, i810_misc.minor);
dev->name = I810_NAME;
- printk("doing mem init\n");
+ DRM_DEBUG("doing mem init\n");
drm_mem_init();
- printk("doing proc init\n");
+ DRM_DEBUG("doing proc init\n");
drm_proc_init(dev);
- printk("doing agp init\n");
+ DRM_DEBUG("doing agp init\n");
dev->agp = drm_agp_init();
- printk("doing ctxbitmap init\n");
+ if(dev->agp == NULL) {
+ DRM_INFO("The i810 drm module requires the agpgart module"
+ " to function correctly\nPlease load the agpgart"
+ " module before you load the i810 module\n");
+ drm_proc_cleanup();
+ misc_deregister(&i810_misc);
+ i810_takedown(dev);
+ return -ENOMEM;
+ }
+ DRM_DEBUG("doing ctxbitmap init\n");
if((retcode = drm_ctxbitmap_init(dev))) {
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
drm_proc_cleanup();
@@ -386,10 +403,6 @@ int i810_init(void)
i810_takedown(dev);
return retcode;
}
-#if 0
- printk("doing i810_dma_init\n");
- i810_dma_init(dev);
-#endif
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
I810_NAME,
@@ -417,7 +430,6 @@ void i810_cleanup(void)
DRM_INFO("Module unloaded\n");
}
drm_ctxbitmap_cleanup(dev);
- i810_dma_cleanup(dev);
i810_takedown(dev);
if (dev->agp) {
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
@@ -484,24 +496,82 @@ int i810_release(struct inode *inode, struct file *filp)
drm_device_t *dev = priv->dev;
int retcode = 0;
- DRM_DEBUG("open_count = %d\n", dev->open_count);
- if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
- atomic_inc(&dev->total_close);
- spin_lock(&dev->count_lock);
- if (!--dev->open_count) {
- if (atomic_read(&dev->ioctl_count) || dev->blocked) {
- DRM_ERROR("Device busy: %d %d\n",
- atomic_read(&dev->ioctl_count),
- dev->blocked);
- spin_unlock(&dev->count_lock);
- return -EBUSY;
+ DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
+ current->pid, dev->device, dev->open_count);
+
+ if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
+ && dev->lock.pid == current->pid) {
+ i810_reclaim_buffers(dev, priv->pid);
+ DRM_ERROR("Process %d dead, freeing lock for context %d\n",
+ current->pid,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ drm_lock_free(dev,
+ &dev->lock.hw_lock->lock,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+
+ /* FIXME: may require heavy-handed reset of
+ hardware at this point, possibly
+ processed via a callback to the X
+ server. */
+ } else if (dev->lock.hw_lock) {
+ /* The lock is required to reclaim buffers */
+ DECLARE_WAITQUEUE(entry, current);
+ add_wait_queue(&dev->lock.lock_queue, &entry);
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ retcode = -EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ dev->lock.pid = priv->pid;
+ dev->lock.lock_time = jiffies;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ current->state = TASK_INTERRUPTIBLE;
+ schedule();
+ if (signal_pending(current)) {
+ retcode = -ERESTARTSYS;
+ break;
}
- spin_unlock(&dev->count_lock);
- return i810_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->lock.lock_queue, &entry);
+ if(!retcode) {
+ i810_reclaim_buffers(dev, priv->pid);
+ drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT);
+ }
+ }
+ drm_fasync(-1, filp, 0);
+
+ down(&dev->struct_sem);
+ if (priv->prev) priv->prev->next = priv->next;
+ else dev->file_first = priv->next;
+ if (priv->next) priv->next->prev = priv->prev;
+ else dev->file_last = priv->prev;
+ up(&dev->struct_sem);
+
+ drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
+ MOD_DEC_USE_COUNT;
+ atomic_inc(&dev->total_close);
+ spin_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ spin_unlock(&dev->count_lock);
+ return i810_takedown(dev);
}
+ spin_unlock(&dev->count_lock);
return retcode;
}
@@ -566,8 +636,7 @@ int i810_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
atomic_inc(&dev->total_unlocks);
if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
atomic_inc(&dev->total_contends);
- drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
- i810_dma_schedule(dev, 1);
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
if (!dev->context_flag) {
if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT)) {
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h
index 0f5f42bb6..c387bf727 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,15 +24,58 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/i810_drv.h,v 1.1 2000/02/11 17:26:05 dawes Exp $
*/
#ifndef _I810_DRV_H_
#define _I810_DRV_H_
+typedef struct drm_i810_buf_priv {
+ u32 *in_use;
+ int my_use_idx;
+ int currently_mapped;
+ void *virtual;
+ void *kernel_virtual;
+ int map_count;
+ struct vm_area_struct *vma;
+} drm_i810_buf_priv_t;
+
+typedef struct _drm_i810_ring_buffer{
+ int tail_mask;
+ unsigned long Start;
+ unsigned long End;
+ unsigned long Size;
+ u8 *virtual_start;
+ int head;
+ int tail;
+ int space;
+} drm_i810_ring_buffer_t;
+
+typedef struct drm_i810_private {
+ int ring_map_idx;
+ int buffer_map_idx;
+
+ drm_i810_ring_buffer_t ring;
+ drm_i810_sarea_t *sarea_priv;
+
+ unsigned long hw_status_page;
+ unsigned long counter;
+
+ atomic_t flush_done;
+ wait_queue_head_t flush_queue; /* Processes waiting until flush */
+ drm_buf_t *mmap_buffer;
+
+
+ u32 front_di1, back_di1, zi1;
+
+ int back_offset;
+ int depth_offset;
+ int w, h;
+ int pitch;
+} drm_i810_private_t;
+
/* i810_drv.c */
extern int i810_init(void);
extern void i810_cleanup(void);
@@ -46,16 +90,22 @@ extern int i810_unlock(struct inode *inode, struct file *filp,
/* i810_dma.c */
extern int i810_dma_schedule(drm_device_t *dev, int locked);
-extern int i810_dma(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg);
+extern int i810_getbuf(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
extern int i810_irq_install(drm_device_t *dev, int irq);
extern int i810_irq_uninstall(drm_device_t *dev);
extern int i810_control(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_lock(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-extern void i810_dma_init(drm_device_t *dev);
-extern void i810_dma_cleanup(drm_device_t *dev);
+extern int i810_dma_init(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_flush_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern void i810_reclaim_buffers(drm_device_t *dev, pid_t pid);
+extern int i810_getage(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg);
+extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma);
/* i810_bufs.c */
@@ -67,10 +117,108 @@ extern int i810_markbufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int i810_freebufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-extern int i810_mapbufs(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg);
extern int i810_addmap(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+ /* i810_context.c */
+extern int i810_resctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_addctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_modctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_getctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_switchctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_newctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int i810_rmctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+extern int i810_context_switch(drm_device_t *dev, int old, int new);
+extern int i810_context_switch_complete(drm_device_t *dev, int new);
+
+#define I810_VERBOSE 0
+
+
+int i810_dma_vertex(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+int i810_swap_bufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+int i810_clear_bufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
+#define GFX_OP_BREAKPOINT_INTERRUPT ((0<<29)|(1<<23))
+#define CMD_REPORT_HEAD (7<<23)
+#define CMD_STORE_DWORD_IDX ((0x21<<23) | 0x1)
+#define CMD_OP_BATCH_BUFFER ((0x0<<29)|(0x30<<23)|0x1)
+
+#define INST_PARSER_CLIENT 0x00000000
+#define INST_OP_FLUSH 0x02000000
+#define INST_FLUSH_MAP_CACHE 0x00000001
+
+
+#define BB1_START_ADDR_MASK (~0x7)
+#define BB1_PROTECTED (1<<0)
+#define BB1_UNPROTECTED (0<<0)
+#define BB2_END_ADDR_MASK (~0x7)
+
+#define I810REG_HWSTAM 0x02098
+#define I810REG_INT_IDENTITY_R 0x020a4
+#define I810REG_INT_MASK_R 0x020a8
+#define I810REG_INT_ENABLE_R 0x020a0
+
+#define LP_RING 0x2030
+#define HP_RING 0x2040
+#define RING_TAIL 0x00
+#define TAIL_ADDR 0x000FFFF8
+#define RING_HEAD 0x04
+#define HEAD_WRAP_COUNT 0xFFE00000
+#define HEAD_WRAP_ONE 0x00200000
+#define HEAD_ADDR 0x001FFFFC
+#define RING_START 0x08
+#define START_ADDR 0x00FFFFF8
+#define RING_LEN 0x0C
+#define RING_NR_PAGES 0x000FF000
+#define RING_REPORT_MASK 0x00000006
+#define RING_REPORT_64K 0x00000002
+#define RING_REPORT_128K 0x00000004
+#define RING_NO_REPORT 0x00000000
+#define RING_VALID_MASK 0x00000001
+#define RING_VALID 0x00000001
+#define RING_INVALID 0x00000000
+
+#define GFX_OP_SCISSOR ((0x3<<29)|(0x1c<<24)|(0x10<<19))
+#define SC_UPDATE_SCISSOR (0x1<<1)
+#define SC_ENABLE_MASK (0x1<<0)
+#define SC_ENABLE (0x1<<0)
+
+#define GFX_OP_SCISSOR_INFO ((0x3<<29)|(0x1d<<24)|(0x81<<16)|(0x1))
+#define SCI_YMIN_MASK (0xffff<<16)
+#define SCI_XMIN_MASK (0xffff<<0)
+#define SCI_YMAX_MASK (0xffff<<16)
+#define SCI_XMAX_MASK (0xffff<<0)
+
+#define GFX_OP_COLOR_FACTOR ((0x3<<29)|(0x1d<<24)|(0x1<<16)|0x0)
+#define GFX_OP_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
+#define GFX_OP_MAP_INFO ((0x3<<29)|(0x1d<<24)|0x2)
+#define GFX_OP_DESTBUFFER_VARS ((0x3<<29)|(0x1d<<24)|(0x85<<16)|0x0)
+#define GFX_OP_DRAWRECT_INFO ((0x3<<29)|(0x1d<<24)|(0x80<<16)|(0x3))
+#define GFX_OP_PRIMITIVE ((0x3<<29)|(0x1f<<24))
+
+#define CMD_OP_Z_BUFFER_INFO ((0x0<<29)|(0x16<<23))
+#define CMD_OP_DESTBUFFER_INFO ((0x0<<29)|(0x15<<23))
+
+#define BR00_BITBLT_CLIENT 0x40000000
+#define BR00_OP_COLOR_BLT 0x10000000
+#define BR00_OP_SRC_COPY_BLT 0x10C00000
+#define BR13_SOLID_PATTERN 0x80000000
+
+
#endif
+
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c
index 25c0aed22..aefc884eb 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/init.c
@@ -1,8 +1,8 @@
/* init.c -- Setup/Cleanup for DRM -*- linux-c -*-
* Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
- * Revised: Fri Aug 20 09:27:02 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/init.c,v 1.2 2000/02/23 04:47:29 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -34,7 +35,7 @@
int drm_flags = 0;
/* drm_parse_option parses a single option. See description for
- drm_parse_drm for details. */
+ drm_parse_options for details. */
static void drm_parse_option(char *s)
{
@@ -96,3 +97,10 @@ void drm_parse_options(char *s)
}
}
+int drm_cpu_valid(void)
+{
+#if defined(__i386__)
+ if (boot_cpu_data.x86 == 3) return 0; /* No cmpxchg on a 386 */
+#endif
+ return 1;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c
index 8edfb4374..b246f76e5 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/ioctl.c
@@ -1,8 +1,8 @@
/* ioctl.c -- IOCTL processing for DRM -*- linux-c -*-
* Created: Fri Jan 8 09:01:26 1999 by faith@precisioninsight.com
- * Revised: Fri Aug 20 09:27:02 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/ioctl.c,v 1.2 2000/02/23 04:47:29 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c
index af8f6150a..f62495aa2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lists.c
@@ -1,8 +1,8 @@
/* lists.c -- Buffer list handling routines -*- linux-c -*-
* Created: Mon Apr 19 20:54:22 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:37:52 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/lists.c,v 1.6 2000/02/23 04:56:42 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c
index adf27ab5d..550827278 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/lock.c
@@ -1,8 +1,8 @@
/* lock.c -- IOCTLs for locking -*- linux-c -*-
* Created: Tue Feb 2 08:37:54 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:38:25 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/lock.c,v 1.5 2000/02/23 04:47:29 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c
index a8a81abd8..0e92401bb 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/memory.c
@@ -1,8 +1,8 @@
/* memory.c -- Memory management wrappers for DRM -*- linux-c -*-
* Created: Thu Feb 4 14:00:34 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:39:37 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/memory.c,v 1.5 2000/02/23 04:47:30 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -44,21 +45,25 @@ static spinlock_t drm_mem_lock = SPIN_LOCK_UNLOCKED;
static unsigned long drm_ram_available = 0; /* In pages */
static unsigned long drm_ram_used = 0;
static drm_mem_stats_t drm_mem_stats[] = {
- [DRM_MEM_DMA] = { "dmabufs" },
- [DRM_MEM_SAREA] = { "sareas" },
- [DRM_MEM_DRIVER] = { "driver" },
- [DRM_MEM_MAGIC] = { "magic" },
- [DRM_MEM_IOCTLS] = { "ioctltab" },
- [DRM_MEM_MAPS] = { "maplist" },
- [DRM_MEM_VMAS] = { "vmalist" },
- [DRM_MEM_BUFS] = { "buflist" },
- [DRM_MEM_SEGS] = { "seglist" },
- [DRM_MEM_PAGES] = { "pagelist" },
- [DRM_MEM_FILES] = { "files" },
- [DRM_MEM_QUEUES] = { "queues" },
- [DRM_MEM_CMDS] = { "commands" },
- [DRM_MEM_MAPPINGS] = { "mappings" },
- [DRM_MEM_BUFLISTS] = { "buflists" },
+ [DRM_MEM_DMA] = { "dmabufs" },
+ [DRM_MEM_SAREA] = { "sareas" },
+ [DRM_MEM_DRIVER] = { "driver" },
+ [DRM_MEM_MAGIC] = { "magic" },
+ [DRM_MEM_IOCTLS] = { "ioctltab" },
+ [DRM_MEM_MAPS] = { "maplist" },
+ [DRM_MEM_VMAS] = { "vmalist" },
+ [DRM_MEM_BUFS] = { "buflist" },
+ [DRM_MEM_SEGS] = { "seglist" },
+ [DRM_MEM_PAGES] = { "pagelist" },
+ [DRM_MEM_FILES] = { "files" },
+ [DRM_MEM_QUEUES] = { "queues" },
+ [DRM_MEM_CMDS] = { "commands" },
+ [DRM_MEM_MAPPINGS] = { "mappings" },
+ [DRM_MEM_BUFLISTS] = { "buflists" },
+ [DRM_MEM_AGPLISTS] = { "agplist" },
+ [DRM_MEM_TOTALAGP] = { "totalagp" },
+ [DRM_MEM_BOUNDAGP] = { "boundagp" },
+ [DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
{ NULL, 0, } /* Last entry must be null */
};
@@ -324,3 +329,120 @@ void drm_ioremapfree(void *pt, unsigned long size)
free_count, alloc_count);
}
}
+
+#ifdef DRM_AGP
+agp_memory *drm_alloc_agp(int pages, u32 type)
+{
+ agp_memory *handle;
+
+ if (!pages) {
+ DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
+ return NULL;
+ }
+
+ if (drm_agp.allocate_memory) {
+ if ((handle = (*drm_agp.allocate_memory)(pages,
+ type))) {
+ spin_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_TOTALAGP].bytes_allocated
+ += pages << PAGE_SHIFT;
+ spin_unlock(&drm_mem_lock);
+ return handle;
+ }
+ }
+ spin_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_TOTALAGP].fail_count;
+ spin_unlock(&drm_mem_lock);
+ return NULL;
+}
+
+int drm_free_agp(agp_memory *handle, int pages)
+{
+ int alloc_count;
+ int free_count;
+ int retval = -EINVAL;
+
+ if (!handle) {
+ DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+ "Attempt to free NULL AGP handle\n");
+ return retval;;
+ }
+
+ if (drm_agp.free_memory) {
+ (*drm_agp.free_memory)(handle);
+ spin_lock(&drm_mem_lock);
+ free_count = ++drm_mem_stats[DRM_MEM_TOTALAGP].free_count;
+ alloc_count = drm_mem_stats[DRM_MEM_TOTALAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_TOTALAGP].bytes_freed
+ += pages << PAGE_SHIFT;
+ spin_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
+ "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+ return 0;
+ }
+ return retval;
+}
+
+int drm_bind_agp(agp_memory *handle, unsigned int start)
+{
+ int retcode = -EINVAL;
+
+ DRM_DEBUG("drm_bind_agp called\n");
+ if (!handle) {
+ DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+ "Attempt to bind NULL AGP handle\n");
+ return retcode;
+ }
+
+ DRM_DEBUG("drm_agp.bind_memory : %p\n", drm_agp.bind_memory);
+ if (drm_agp.bind_memory) {
+ if (!(retcode = (*drm_agp.bind_memory)(handle, start))) {
+ spin_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_allocated
+ += handle->page_count << PAGE_SHIFT;
+ spin_unlock(&drm_mem_lock);
+ DRM_DEBUG("drm_agp.bind_memory: retcode %d\n", retcode);
+ return retcode;
+ }
+ }
+ spin_lock(&drm_mem_lock);
+ ++drm_mem_stats[DRM_MEM_BOUNDAGP].fail_count;
+ spin_unlock(&drm_mem_lock);
+ return retcode;
+}
+
+int drm_unbind_agp(agp_memory *handle)
+{
+ int alloc_count;
+ int free_count;
+ int retcode = -EINVAL;
+
+ if (!handle) {
+ DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+ "Attempt to unbind NULL AGP handle\n");
+ return retcode;
+ }
+
+ if (drm_agp.unbind_memory) {
+ int c = handle->page_count;
+ if ((retcode = (*drm_agp.unbind_memory)(handle)))
+ return retcode;
+ spin_lock(&drm_mem_lock);
+ free_count = ++drm_mem_stats[DRM_MEM_BOUNDAGP].free_count;
+ alloc_count = drm_mem_stats[DRM_MEM_BOUNDAGP].succeed_count;
+ drm_mem_stats[DRM_MEM_BOUNDAGP].bytes_freed += c << PAGE_SHIFT;
+ spin_unlock(&drm_mem_lock);
+ if (free_count > alloc_count) {
+ DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
+ "Excess frees: %d frees, %d allocs\n",
+ free_count, alloc_count);
+ }
+ }
+ return retcode;
+}
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c
index 34f1112a6..b97eb4959 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c
@@ -2,6 +2,7 @@
* Created: Thu Jan 6 01:47:26 2000 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,179 +24,176 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_bufs.c,v 1.1 2000/02/11 17:26:06 dawes Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
*/
#define __NO_VERSION__
#include "drmP.h"
#include "mga_drv.h"
-#include "mga_dma.h"
#include "linux/un.h"
int mga_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_device_dma_t *dma = dev->dma;
- drm_buf_desc_t request;
- drm_buf_entry_t *entry;
- drm_buf_t *buf;
- unsigned long offset;
- unsigned long agp_offset;
- int count;
- int order;
- int size;
- int alignment;
- int page_order;
- int total;
- int byte_count;
- int i;
-
- if (!dma) return -EINVAL;
-
- copy_from_user_ret(&request,
- (drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
-
- count = request.count;
- order = drm_order(request.size);
- size = 1 << order;
- agp_offset = request.agp_start;
- alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
- byte_count = 0;
-
- DRM_DEBUG("count: %d\n", count);
- DRM_DEBUG("order: %d\n", order);
- DRM_DEBUG("size: %d\n", size);
- DRM_DEBUG("agp_offset: %d\n", agp_offset);
- DRM_DEBUG("alignment: %d\n", alignment);
- DRM_DEBUG("page_order: %d\n", page_order);
- DRM_DEBUG("total: %d\n", total);
- DRM_DEBUG("byte_count: %d\n", byte_count);
-
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
- if (dev->queue_count) return -EBUSY; /* Not while in use */
- spin_lock(&dev->count_lock);
- if (dev->buf_use) {
- spin_unlock(&dev->count_lock);
- return -EBUSY;
- }
- atomic_inc(&dev->buf_alloc);
- spin_unlock(&dev->count_lock);
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ drm_buf_entry_t *entry;
+ drm_buf_t *buf;
+ unsigned long offset;
+ unsigned long agp_offset;
+ int count;
+ int order;
+ int size;
+ int alignment;
+ int page_order;
+ int total;
+ int byte_count;
+ int i;
+
+ if (!dma) return -EINVAL;
+
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+ agp_offset = request.agp_start;
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size) :size;
+ page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
+ total = PAGE_SIZE << page_order;
+ byte_count = 0;
+
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
+ DRM_DEBUG("byte_count: %d\n", byte_count);
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
+ if (dev->queue_count) return -EBUSY; /* Not while in use */
+ spin_lock(&dev->count_lock);
+ if (dev->buf_use) {
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ atomic_inc(&dev->buf_alloc);
+ spin_unlock(&dev->count_lock);
- down(&dev->struct_sem);
- entry = &dma->bufs[order];
- if (entry->buf_count) {
- up(&dev->struct_sem);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM; /* May only call once for each order */
- }
+ down(&dev->struct_sem);
+ entry = &dma->bufs[order];
+ if (entry->buf_count) {
+ up(&dev->struct_sem);
+ atomic_dec(&dev->buf_alloc);
+ return -ENOMEM; /* May only call once for each order */
+ }
- entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- if (!entry->buflist) {
- up(&dev->struct_sem);
- atomic_dec(&dev->buf_alloc);
- return -ENOMEM;
- }
- memset(entry->buflist, 0, count * sizeof(*entry->buflist));
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ if (!entry->buflist) {
+ up(&dev->struct_sem);
+ atomic_dec(&dev->buf_alloc);
+ return -ENOMEM;
+ }
+ memset(entry->buflist, 0, count * sizeof(*entry->buflist));
- entry->buf_size = size;
- entry->page_order = page_order;
- offset = 0;
+ entry->buf_size = size;
+ entry->page_order = page_order;
+ offset = 0;
- while(entry->buf_count < count) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
-
- DRM_DEBUG("offset : %d\n", offset);
-
- buf->offset = offset; /* Hrm */
- buf->bus_address = dev->agp->base + agp_offset + offset;
- buf->address = (void *)(agp_offset + offset + dev->agp->base);
- buf->next = NULL;
- buf->waiting = 0;
- buf->pending = 0;
- init_waitqueue_head(&buf->dma_wait);
- buf->pid = 0;
-
- buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS);
- buf->dev_priv_size = sizeof(drm_mga_buf_priv_t);
+ while(entry->buf_count < count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+
+ DRM_DEBUG("offset : %ld\n", offset);
+
+ buf->offset = offset; /* Hrm */
+ buf->bus_address = dev->agp->base + agp_offset + offset;
+ buf->address = (void *)(agp_offset + offset + dev->agp->base);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ init_waitqueue_head(&buf->dma_wait);
+ buf->pid = 0;
+
+ buf->dev_private = drm_alloc(sizeof(drm_mga_buf_priv_t), DRM_MEM_BUFS);
+ buf->dev_priv_size = sizeof(drm_mga_buf_priv_t);
#if DRM_DMA_HISTOGRAM
- buf->time_queued = 0;
- buf->time_dispatched = 0;
- buf->time_completed = 0;
- buf->time_freed = 0;
+ buf->time_queued = 0;
+ buf->time_dispatched = 0;
+ buf->time_completed = 0;
+ buf->time_freed = 0;
#endif
- offset = offset + alignment;
- entry->buf_count++;
- byte_count += PAGE_SIZE << page_order;
+ offset = offset + alignment;
+ entry->buf_count++;
+ byte_count += PAGE_SIZE << page_order;
- DRM_DEBUG("buffer %d @ %p\n",
- entry->buf_count, buf->address);
- }
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
+ }
- dma->buflist = drm_realloc(dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
- for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
- dma->buflist[i] = &entry->buflist[i - dma->buf_count];
+ dma->buflist = drm_realloc(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ (dma->buf_count + entry->buf_count)
+ * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
+ dma->buflist[i] = &entry->buflist[i - dma->buf_count];
- dma->buf_count += entry->buf_count;
+ dma->buf_count += entry->buf_count;
- DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
+ DRM_DEBUG("dma->buf_count : %d\n", dma->buf_count);
- dma->byte_count += byte_count;
+ dma->byte_count += byte_count;
- DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
+ DRM_DEBUG("entry->buf_count : %d\n", entry->buf_count);
- drm_freelist_create(&entry->freelist, entry->buf_count);
- for (i = 0; i < entry->buf_count; i++) {
- drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
- }
+ drm_freelist_create(&entry->freelist, entry->buf_count);
+ for (i = 0; i < entry->buf_count; i++) {
+ drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
+ }
- up(&dev->struct_sem);
+ up(&dev->struct_sem);
- request.count = entry->buf_count;
- request.size = size;
+ request.count = entry->buf_count;
+ request.size = size;
- copy_to_user_ret((drm_buf_desc_t *)arg,
- &request,
- sizeof(request),
- -EFAULT);
+ copy_to_user_ret((drm_buf_desc_t *)arg,
+ &request,
+ sizeof(request),
+ -EFAULT);
- atomic_dec(&dev->buf_alloc);
+ atomic_dec(&dev->buf_alloc);
- DRM_DEBUG("count: %d\n", count);
- DRM_DEBUG("order: %d\n", order);
- DRM_DEBUG("size: %d\n", size);
- DRM_DEBUG("agp_offset: %d\n", agp_offset);
- DRM_DEBUG("alignment: %d\n", alignment);
- DRM_DEBUG("page_order: %d\n", page_order);
- DRM_DEBUG("total: %d\n", total);
- DRM_DEBUG("byte_count: %d\n", byte_count);
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
+ DRM_DEBUG("byte_count: %d\n", byte_count);
- dma->flags = _DRM_DMA_USE_AGP;
+ dma->flags = _DRM_DMA_USE_AGP;
- DRM_DEBUG("dma->flags : %lx\n", dma->flags);
+ DRM_DEBUG("dma->flags : %x\n", dma->flags);
- return 0;
+ return 0;
}
int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
@@ -362,17 +360,17 @@ int mga_addbufs_pci(struct inode *inode, struct file *filp, unsigned int cmd,
int mga_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
- drm_buf_desc_t request;
+ drm_buf_desc_t request;
- copy_from_user_ret(&request,
- (drm_buf_desc_t *)arg,
- sizeof(request),
- -EFAULT);
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
- if(request.flags & _DRM_AGP_BUFFER)
- return mga_addbufs_agp(inode, filp, cmd, arg);
- else
- return mga_addbufs_pci(inode, filp, cmd, arg);
+ if(request.flags & _DRM_AGP_BUFFER)
+ return mga_addbufs_agp(inode, filp, cmd, arg);
+ else
+ return mga_addbufs_pci(inode, filp, cmd, arg);
}
int mga_infobufs(struct inode *inode, struct file *filp, unsigned int cmd,
@@ -546,7 +544,7 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
spin_lock(&dev->count_lock);
if (atomic_read(&dev->buf_alloc)) {
spin_unlock(&dev->count_lock);
- DRM_DEBUG("Buzy\n");
+ DRM_DEBUG("Busy\n");
return -EBUSY;
}
++dev->buf_use; /* Can't allocate more after this call */
@@ -558,79 +556,84 @@ int mga_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
-EFAULT);
DRM_DEBUG("mga_mapbufs\n");
- DRM_DEBUG("dma->flags : %lx\n", dma->flags);
+ DRM_DEBUG("dma->flags : %x\n", dma->flags);
- if (request.count >= dma->buf_count) {
- if(dma->flags & _DRM_DMA_USE_AGP) {
- drm_mga_private_t *dev_priv = dev->dev_private;
- drm_map_t *map = NULL;
+ if (request.count >= dma->buf_count) {
+ if(dma->flags & _DRM_DMA_USE_AGP) {
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_map_t *map = NULL;
- map = dev->maplist[dev_priv->buffer_map_idx];
- if (!map) {
- DRM_DEBUG("map is null\n");
- retcode = -EINVAL;
- goto done;
- }
-
- DRM_DEBUG("map->offset : %lx\n", map->offset);
- DRM_DEBUG("map->size : %lx\n", map->size);
- DRM_DEBUG("map->type : %d\n", map->type);
- DRM_DEBUG("map->flags : %x\n", map->flags);
- DRM_DEBUG("map->handle : %lx\n", map->handle);
- DRM_DEBUG("map->mtrr : %d\n", map->mtrr);
-
- virtual = do_mmap(filp, 0, map->size, PROT_READ|PROT_WRITE,
- MAP_SHARED, (unsigned long)map->offset);
- } else {
- virtual = do_mmap(filp, 0, dma->byte_count,
- PROT_READ|PROT_WRITE, MAP_SHARED, 0);
- }
- if (virtual > -1024UL) {
- /* Real error */
- DRM_DEBUG("mmap error\n");
- retcode = (signed long)virtual;
- goto done;
- }
- request.virtual = (void *)virtual;
+ map = dev->maplist[dev_priv->buffer_map_idx];
+ if (!map) {
+ DRM_DEBUG("map is null\n");
+ retcode = -EINVAL;
+ goto done;
+ }
+
+ DRM_DEBUG("map->offset : %lx\n", map->offset);
+ DRM_DEBUG("map->size : %lx\n", map->size);
+ DRM_DEBUG("map->type : %d\n", map->type);
+ DRM_DEBUG("map->flags : %x\n", map->flags);
+ DRM_DEBUG("map->handle : %p\n", map->handle);
+ DRM_DEBUG("map->mtrr : %d\n", map->mtrr);
+ down(&current->mm->mmap_sem);
+ virtual = do_mmap(filp, 0, map->size,
+ PROT_READ|PROT_WRITE,
+ MAP_SHARED,
+ (unsigned long)map->offset);
+ up(&current->mm->mmap_sem);
+ } else {
+ down(&current->mm->mmap_sem);
+ virtual = do_mmap(filp, 0, dma->byte_count,
+ PROT_READ|PROT_WRITE, MAP_SHARED, 0);
+ up(&current->mm->mmap_sem);
+ }
+ if (virtual > -1024UL) {
+ /* Real error */
+ DRM_DEBUG("mmap error\n");
+ retcode = (signed long)virtual;
+ goto done;
+ }
+ request.virtual = (void *)virtual;
- for (i = 0; i < dma->buf_count; i++) {
- if (copy_to_user(&request.list[i].idx,
- &dma->buflist[i]->idx,
- sizeof(request.list[0].idx))) {
- retcode = -EFAULT;
- goto done;
- }
- if (copy_to_user(&request.list[i].total,
- &dma->buflist[i]->total,
- sizeof(request.list[0].total))) {
- retcode = -EFAULT;
- goto done;
- }
- if (copy_to_user(&request.list[i].used,
- &zero,
- sizeof(zero))) {
- retcode = -EFAULT;
- goto done;
- }
- address = virtual + dma->buflist[i]->offset;
- if (copy_to_user(&request.list[i].address,
- &address,
- sizeof(address))) {
- retcode = -EFAULT;
- goto done;
- }
- }
- }
- done:
- request.count = dma->buf_count;
- DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
+ for (i = 0; i < dma->buf_count; i++) {
+ if (copy_to_user(&request.list[i].idx,
+ &dma->buflist[i]->idx,
+ sizeof(request.list[0].idx))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ if (copy_to_user(&request.list[i].total,
+ &dma->buflist[i]->total,
+ sizeof(request.list[0].total))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ if (copy_to_user(&request.list[i].used,
+ &zero,
+ sizeof(zero))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ address = virtual + dma->buflist[i]->offset;
+ if (copy_to_user(&request.list[i].address,
+ &address,
+ sizeof(address))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ }
+ }
+ done:
+ request.count = dma->buf_count;
+ DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
- copy_to_user_ret((drm_buf_map_t *)arg,
- &request,
- sizeof(request),
- -EFAULT);
+ copy_to_user_ret((drm_buf_map_t *)arg,
+ &request,
+ sizeof(request),
+ -EFAULT);
- DRM_DEBUG("retcode : %d\n", retcode);
+ DRM_DEBUG("retcode : %d\n", retcode);
- return retcode;
+ return retcode;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c
index fb0d336fa..d02592740 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,9 +24,8 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * Author: Rickard E. (Rik) Faith <faith@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_context.c,v 1.1 2000/02/11 17:26:06 dawes Exp $
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
*/
@@ -38,7 +38,7 @@
static int mga_alloc_queue(drm_device_t *dev)
{
int temp = drm_ctxbitmap_next(dev);
- printk("mga_alloc_queue: %d\n", temp);
+ DRM_DEBUG("mga_alloc_queue: %d\n", temp);
return temp;
}
@@ -57,7 +57,7 @@ int mga_context_switch(drm_device_t *dev, int old, int new)
dev->ctx_start = get_cycles();
#endif
- printk("Context switch from %d to %d\n", old, new);
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
if (new == dev->last_context) {
clear_bit(0, &dev->context_flag);
@@ -104,7 +104,7 @@ int mga_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_ctx_t ctx;
int i;
- printk("%d\n", DRM_RESERVED_CONTEXTS);
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT);
if (res.count >= DRM_RESERVED_CONTEXTS) {
memset(&ctx, 0, sizeof(ctx));
@@ -134,11 +134,11 @@ int mga_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
ctx.handle = mga_alloc_queue(dev);
}
if (ctx.handle == -1) {
- printk("Not enough free contexts.\n");
+ DRM_DEBUG("Not enough free contexts.\n");
/* Should this return -EBUSY instead? */
return -ENOMEM;
}
- printk("%d\n", ctx.handle);
+ DRM_DEBUG("%d\n", ctx.handle);
copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT);
return 0;
}
@@ -170,7 +170,7 @@ int mga_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
- printk("%d\n", ctx.handle);
+ DRM_DEBUG("%d\n", ctx.handle);
return mga_context_switch(dev, dev->last_context, ctx.handle);
}
@@ -182,7 +182,7 @@ int mga_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
- printk("%d\n", ctx.handle);
+ DRM_DEBUG("%d\n", ctx.handle);
mga_context_switch_complete(dev, ctx.handle);
return 0;
@@ -194,51 +194,11 @@ int mga_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
drm_file_t *priv = filp->private_data;
drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
- drm_queue_t *q;
- drm_buf_t *buf;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
- printk("%d\n", ctx.handle);
- if(ctx.handle == DRM_KERNEL_CONTEXT) {
- q = dev->queuelist[ctx.handle];
- atomic_inc(&q->use_count);
- if (atomic_read(&q->use_count) == 1) {
- /* No longer in use */
- atomic_dec(&q->use_count);
- return -EINVAL;
- }
- atomic_inc(&q->finalization); /* Mark queue in finalization state */
- atomic_sub(2, &q->use_count);
- /* Mark queue as unused (pending finalization) */
-
- while (test_and_set_bit(0, &dev->interrupt_flag)) {
- printk("Calling schedule from rmctx\n");
- schedule();
- if (signal_pending(current)) {
- clear_bit(0, &dev->interrupt_flag);
- return -EINTR;
- }
- }
-
- /* Remove queued buffers */
- while ((buf = drm_waitlist_get(&q->waitlist))) {
- drm_free_buffer(dev, buf);
- }
- clear_bit(0, &dev->interrupt_flag);
-
- /* Wakeup blocked processes */
- wake_up_interruptible(&q->read_queue);
- wake_up_interruptible(&q->write_queue);
- wake_up_interruptible(&q->flush_queue);
-
- /* Finalization over. Queue is made
- available when both use_count and
- finalization become 0, which won't
- happen until all the waiting processes
- stop waiting. */
- atomic_dec(&q->finalization);
- } else {
- drm_ctxbitmap_free(dev, ctx.handle);
+ DRM_DEBUG("%d\n", ctx.handle);
+ if(ctx.handle != DRM_KERNEL_CONTEXT) {
+ drm_ctxbitmap_free(dev, ctx.handle);
}
return 0;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c
index 2e24e5b48..28e8811c8 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,19 +24,15 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_dma.c,v 1.1 2000/02/11 17:26:07 dawes Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
#define __NO_VERSION__
#include "drmP.h"
#include "mga_drv.h"
-#include "mgareg_flags.h"
-#include "mga_dma.h"
-#include "mga_state.h"
#include <linux/interrupt.h> /* For task queue support */
@@ -48,643 +45,578 @@
#define MGA_WRITE(reg,val) do { MGA_DEREF(reg) = val; } while (0)
#define PDEA_pagpxfer_enable 0x2
-#define MGA_SYNC_TAG 0x423f4200
-
-typedef enum {
- TT_GENERAL,
- TT_BLIT,
- TT_VECTOR,
- TT_VERTEX
-} transferType_t;
+static int mga_flush_queue(drm_device_t *dev);
-static void mga_delay(void)
+static unsigned long mga_alloc_page(drm_device_t *dev)
{
- return;
+ unsigned long address;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ address = __get_free_page(GFP_KERNEL);
+ if(address == 0UL) {
+ return 0;
+ }
+ atomic_inc(&mem_map[MAP_NR((void *) address)].count);
+ set_bit(PG_locked, &mem_map[MAP_NR((void *) address)].flags);
+
+ return address;
}
-int mga_dma_cleanup(drm_device_t *dev)
+static void mga_free_page(drm_device_t *dev, unsigned long page)
{
- if(dev->dev_private) {
- drm_mga_private_t *dev_priv =
- (drm_mga_private_t *) dev->dev_private;
-
- if(dev_priv->ioremap) {
- int temp = (dev_priv->warp_ucode_size +
- dev_priv->primary_size +
- PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE;
+ DRM_DEBUG("%s\n", __FUNCTION__);
- drm_ioremapfree((void *) dev_priv->ioremap, temp);
- }
-
- drm_free(dev->dev_private, sizeof(drm_mga_private_t),
- DRM_MEM_DRIVER);
- dev->dev_private = NULL;
+ if(page == 0UL) {
+ return;
}
-
- return 0;
+ atomic_dec(&mem_map[MAP_NR((void *) page)].count);
+ clear_bit(PG_locked, &mem_map[MAP_NR((void *) page)].flags);
+ wake_up(&mem_map[MAP_NR((void *) page)].wait);
+ free_page(page);
+ return;
}
-static int mga_alloc_kernel_queue(drm_device_t *dev)
+static void mga_delay(void)
{
- drm_queue_t *queue = NULL;
- /* Allocate a new queue */
- down(&dev->struct_sem);
-
- if(dev->queue_count != 0) {
- /* Reseting the kernel context here is not
- * a race, since it can only happen when that
- * queue is empty.
- */
- queue = dev->queuelist[DRM_KERNEL_CONTEXT];
- printk("Kernel queue already allocated\n");
- } else {
- queue = drm_alloc(sizeof(*queue), DRM_MEM_QUEUES);
- if(!queue) {
- up(&dev->struct_sem);
- printk("out of memory\n");
- return -ENOMEM;
- }
- ++dev->queue_count;
- dev->queuelist = drm_alloc(sizeof(*dev->queuelist),
- DRM_MEM_QUEUES);
- if(!dev->queuelist) {
- up(&dev->struct_sem);
- drm_free(queue, sizeof(*queue), DRM_MEM_QUEUES);
- printk("out of memory\n");
- return -ENOMEM;
- }
- }
-
- memset(queue, 0, sizeof(*queue));
- atomic_set(&queue->use_count, 1);
- atomic_set(&queue->finalization, 0);
- atomic_set(&queue->block_count, 0);
- atomic_set(&queue->block_read, 0);
- atomic_set(&queue->block_write, 0);
- atomic_set(&queue->total_queued, 0);
- atomic_set(&queue->total_flushed, 0);
- atomic_set(&queue->total_locks, 0);
-
- init_waitqueue_head(&queue->write_queue);
- init_waitqueue_head(&queue->read_queue);
- init_waitqueue_head(&queue->flush_queue);
-
- queue->flags = 0;
-
- drm_waitlist_create(&queue->waitlist, dev->dma->buf_count);
-
- dev->queue_slots = 1;
- dev->queuelist[DRM_KERNEL_CONTEXT] = queue;
- dev->queue_count--;
-
- up(&dev->struct_sem);
- printk("%d (new)\n", dev->queue_count - 1);
- return DRM_KERNEL_CONTEXT;
+ return;
}
-static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
- drm_mga_private_t *dev_priv;
- drm_map_t *prim_map = NULL;
- drm_map_t *sarea_map = NULL;
- int temp;
+void mga_flush_write_combine(void)
+{
+ int xchangeDummy;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ __asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy));
+ __asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;"
+ " movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;"
+ " pop %%eax" : /* no outputs */ : /* no inputs */ );
+}
- dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
- if(dev_priv == NULL) return -ENOMEM;
- dev->dev_private = (void *) dev_priv;
+/* These are two age tags that will never be sent to
+ * the hardware */
+#define MGA_BUF_USED 0xffffffff
+#define MGA_BUF_FREE 0
- printk("dev_private\n");
+static int mga_freelist_init(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_freelist_t *item;
+ int i;
- memset(dev_priv, 0, sizeof(drm_mga_private_t));
- atomic_set(&dev_priv->pending_bufs, 0);
+ DRM_DEBUG("%s\n", __FUNCTION__);
- if((init->reserved_map_idx >= dev->map_count) ||
- (init->buffer_map_idx >= dev->map_count)) {
- mga_dma_cleanup(dev);
- printk("reserved_map or buffer_map are invalid\n");
- return -EINVAL;
- }
+ dev_priv->head = drm_alloc(sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+ if(dev_priv->head == NULL) return -ENOMEM;
+ memset(dev_priv->head, 0, sizeof(drm_mga_freelist_t));
+ dev_priv->head->age = MGA_BUF_USED;
- if(mga_alloc_kernel_queue(dev) != DRM_KERNEL_CONTEXT) {
- mga_dma_cleanup(dev);
- DRM_ERROR("Kernel context queue not present\n");
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[ i ];
+ buf_priv = buf->dev_private;
+ item = drm_alloc(sizeof(drm_mga_freelist_t),
+ DRM_MEM_DRIVER);
+ if(item == NULL) return -ENOMEM;
+ memset(item, 0, sizeof(drm_mga_freelist_t));
+ item->age = MGA_BUF_FREE;
+ item->prev = dev_priv->head;
+ item->next = dev_priv->head->next;
+ if(dev_priv->head->next != NULL)
+ dev_priv->head->next->prev = item;
+ if(item->next == NULL) dev_priv->tail = item;
+ item->buf = buf;
+ buf_priv->my_freelist = item;
+ buf_priv->discard = 0;
+ buf_priv->dispatched = 0;
+ dev_priv->head->next = item;
}
-
- dev_priv->reserved_map_idx = init->reserved_map_idx;
- dev_priv->buffer_map_idx = init->buffer_map_idx;
- sarea_map = dev->maplist[0];
- dev_priv->sarea_priv = (drm_mga_sarea_t *)
- ((u8 *)sarea_map->handle +
- init->sarea_priv_offset);
- printk("sarea_priv\n");
-
- /* Scale primary size to the next page */
- dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) /
- PAGE_SIZE) * PAGE_SIZE;
- dev_priv->warp_ucode_size = init->warp_ucode_size;
- dev_priv->chipset = init->chipset;
- dev_priv->fbOffset = init->fbOffset;
- dev_priv->backOffset = init->backOffset;
- dev_priv->depthOffset = init->depthOffset;
- dev_priv->textureOffset = init->textureOffset;
- dev_priv->textureSize = init->textureSize;
- dev_priv->cpp = init->cpp;
- dev_priv->sgram = init->sgram;
- dev_priv->stride = init->stride;
-
- dev_priv->frontOrg = init->frontOrg;
- dev_priv->backOrg = init->backOrg;
- dev_priv->depthOrg = init->depthOrg;
- dev_priv->mAccess = init->mAccess;
-
- printk("memcpy\n");
- memcpy(&dev_priv->WarpIndex, &init->WarpIndex,
- sizeof(mgaWarpIndex) * MGA_MAX_WARP_PIPES);
- printk("memcpy done\n");
- prim_map = dev->maplist[init->reserved_map_idx];
- dev_priv->prim_phys_head = dev->agp->base + init->reserved_map_agpstart;
- temp = init->warp_ucode_size + dev_priv->primary_size;
- temp = ((temp + PAGE_SIZE - 1) /
- PAGE_SIZE) * PAGE_SIZE;
- printk("temp : %x\n", temp);
- printk("dev->agp->base: %lx\n", dev->agp->base);
- printk("init->reserved_map_agpstart: %x\n", init->reserved_map_agpstart);
-
-
- dev_priv->ioremap = drm_ioremap(dev->agp->base + init->reserved_map_agpstart,
- temp);
- if(dev_priv->ioremap == NULL) {
- printk("Ioremap failed\n");
- mga_dma_cleanup(dev);
- return -ENOMEM;
- }
-
-
+ return 0;
+}
- dev_priv->prim_head = (u32 *)dev_priv->ioremap;
- printk("dev_priv->prim_head : %p\n", dev_priv->prim_head);
- dev_priv->current_dma_ptr = dev_priv->prim_head;
- dev_priv->prim_num_dwords = 0;
- dev_priv->prim_max_dwords = dev_priv->primary_size / 4;
-
- printk("dma initialization\n");
+static void mga_freelist_cleanup(drm_device_t *dev)
+{
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_freelist_t *item;
+ drm_mga_freelist_t *prev;
- /* Private is now filled in, initialize the hardware */
- {
- PRIMLOCALS;
- PRIMRESET( dev_priv );
- PRIMGETPTR( dev_priv );
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DWGSYNC, 0);
- PRIMOUTREG(MGAREG_SOFTRAP, 0);
- PRIMADVANCE( dev_priv );
+ DRM_DEBUG("%s\n", __FUNCTION__);
- /* Poll for the first buffer to insure that
- * the status register will be correct
- */
- printk("phys_head : %lx\n", phys_head);
+ item = dev_priv->head;
+ while(item) {
+ prev = item;
+ item = item->next;
+ drm_free(prev, sizeof(drm_mga_freelist_t), DRM_MEM_DRIVER);
+ }
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
+ dev_priv->head = dev_priv->tail = NULL;
+}
- while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) {
- int i;
- for(i = 0 ; i < 4096; i++) mga_delay();
+/* Frees dispatch lock */
+static inline void mga_dma_quiescent(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned long end;
+ int i;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ end = jiffies + (HZ*3);
+ while(1) {
+ if(!test_and_set_bit(MGA_IN_DISPATCH,
+ &dev_priv->dispatch_status)) {
+ break;
}
-
- MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
-
- MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) |
- PDEA_pagpxfer_enable));
-
- while(MGA_READ(MGAREG_DWGSYNC) == MGA_SYNC_TAG) {
- int i;
- for(i = 0; i < 4096; i++) mga_delay();
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup\n");
+ goto out_nolock;
+ }
+ for (i = 0 ; i < 2000 ; i++) mga_delay();
+ }
+ end = jiffies + (HZ*3);
+ DRM_DEBUG("quiescent status : %x\n", MGA_READ(MGAREG_STATUS));
+ while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup\n");
+ goto out_status;
}
+ for (i = 0 ; i < 2000 ; i++) mga_delay();
+ }
+ sarea_priv->dirty |= MGA_DMA_FLUSH;
+
+out_status:
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+out_nolock:
+}
+static void mga_reset_freelist(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ int i;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[ i ];
+ buf_priv = buf->dev_private;
+ buf_priv->my_freelist->age = MGA_BUF_FREE;
}
-
- printk("dma init was successful\n");
- return 0;
}
-int mga_dma_init(struct inode *inode, struct file *filp,
- unsigned int cmd, unsigned long arg)
+/* Least recently used :
+ * These operations are not atomic b/c they are protected by the
+ * hardware lock */
+
+drm_buf_t *mga_freelist_get(drm_device_t *dev)
{
- drm_file_t *priv = filp->private_data;
- drm_device_t *dev = priv->dev;
- drm_mga_init_t init;
+ DECLARE_WAITQUEUE(entry, current);
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_freelist_t *prev;
+ drm_mga_freelist_t *next;
+ static int failed = 0;
+
+ DRM_DEBUG("%s : tail->age : %d last_prim_age : %d\n", __FUNCTION__,
+ dev_priv->tail->age, dev_priv->last_prim_age);
- copy_from_user_ret(&init, (drm_mga_init_t *)arg, sizeof(init), -EFAULT);
+ if(failed >= 1000 && dev_priv->tail->age >= dev_priv->last_prim_age) {
+ DRM_DEBUG("I'm waiting on the freelist!!! %d\n",
+ dev_priv->last_prim_age);
+ set_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
+ current->state = TASK_INTERRUPTIBLE;
+ add_wait_queue(&dev_priv->buf_queue, &entry);
+ for (;;) {
+ mga_dma_schedule(dev, 0);
+ if(!test_bit(MGA_IN_GETBUF,
+ &dev_priv->dispatch_status))
+ break;
+ atomic_inc(&dev->total_sleeps);
+ schedule();
+ if (signal_pending(current)) {
+ clear_bit(MGA_IN_GETBUF,
+ &dev_priv->dispatch_status);
+ goto failed_getbuf;
+ }
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev_priv->buf_queue, &entry);
+ }
- switch(init.func) {
- case MGA_INIT_DMA:
- return mga_dma_initialize(dev, &init);
- case MGA_CLEANUP_DMA:
- return mga_dma_cleanup(dev);
+ if(dev_priv->tail->age < dev_priv->last_prim_age) {
+ prev = dev_priv->tail->prev;
+ next = dev_priv->tail;
+ prev->next = NULL;
+ next->prev = next->next = NULL;
+ dev_priv->tail = prev;
+ next->age = MGA_BUF_USED;
+ failed = 0;
+ return next->buf;
}
- return -EINVAL;
+failed_getbuf:
+ failed++;
+ return NULL;
}
-#define MGA_ILOAD_CMD (DC_opcod_iload | DC_atype_rpl | \
- DC_linear_linear | DC_bltmod_bfcol | \
- (0xC << DC_bop_SHIFT) | DC_sgnzero_enable | \
- DC_shftzero_enable | DC_clipdis_enable)
-
-static void __mga_iload_small(drm_device_t *dev,
- drm_buf_t *buf,
- int use_agp)
+int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf)
{
- drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
drm_mga_buf_priv_t *buf_priv = buf->dev_private;
- drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- unsigned long address = (unsigned long)buf->bus_address;
- int length = buf->used;
- int y1 = buf_priv->boxes[0].y1;
- int x1 = buf_priv->boxes[0].x1;
- int y2 = buf_priv->boxes[0].y2;
- int x2 = buf_priv->boxes[0].x2;
- int dstorg = buf_priv->ContextState[MGA_CTXREG_DSTORG];
- int maccess = buf_priv->ContextState[MGA_CTXREG_MACCESS];
- PRIMLOCALS;
-
- PRIMRESET(dev_priv);
- PRIMGETPTR(dev_priv);
+ drm_mga_freelist_t *prev;
+ drm_mga_freelist_t *head;
+ drm_mga_freelist_t *next;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(buf_priv->my_freelist->age == MGA_BUF_USED) {
+ /* Discarded buffer, put it on the tail */
+ next = buf_priv->my_freelist;
+ next->age = MGA_BUF_FREE;
+ prev = dev_priv->tail;
+ prev->next = next;
+ next->prev = prev;
+ next->next = NULL;
+ dev_priv->tail = next;
+ DRM_DEBUG("Discarded\n");
+ } else {
+ /* Normally aged buffer, put it on the head + 1,
+ * as the real head is a sentinal element
+ */
+ next = buf_priv->my_freelist;
+ head = dev_priv->head;
+ prev = head->next;
+ head->next = next;
+ prev->prev = next;
+ next->prev = head;
+ next->next = prev;
+ }
- PRIMOUTREG(MGAREG_DSTORG, dstorg | use_agp);
- PRIMOUTREG(MGAREG_MACCESS, maccess);
- PRIMOUTREG(MGAREG_PITCH, (1 << 15));
- PRIMOUTREG(MGAREG_YDST, y1 * (x2 - x1));
- PRIMOUTREG(MGAREG_LEN, 1);
- PRIMOUTREG(MGAREG_FXBNDRY, ((x2 - x1) * (y2 - y1) - 1) << 16);
- PRIMOUTREG(MGAREG_AR0, (x2 - x1) * (y2 - y1) - 1);
- PRIMOUTREG(MGAREG_AR3, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DWGCTL+MGAREG_MGA_EXEC, MGA_ILOAD_CMD);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_SECADDRESS, address | TT_BLIT);
- PRIMOUTREG(MGAREG_SECEND, (address + length) | use_agp);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DWGSYNC, 0);
- PRIMOUTREG(MGAREG_SOFTRAP, 0);
- PRIMADVANCE(dev_priv);
-#if 0
- /* For now we need to set this in the ioctl */
- sarea_priv->dirty |= MGASAREA_NEW_CONTEXT;
-#endif
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
- while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ;
-
- MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL);
- MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
+ return 0;
}
-static void __mga_iload_xy(drm_device_t *dev,
- drm_buf_t *buf,
- int use_agp)
+static int mga_init_primary_bufs(drm_device_t *dev, drm_mga_init_t *init)
{
- drm_mga_private_t *dev_priv = dev->dev_private;
- drm_mga_buf_priv_t *buf_priv = buf->dev_private;
- drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- unsigned long address = (unsigned long)buf->bus_address;
- int length = buf->used;
- int y1 = buf_priv->boxes[0].y1;
- int x1 = buf_priv->boxes[0].x1;
- int y2 = buf_priv->boxes[0].y2;
- int x2 = buf_priv->boxes[0].x2;
- int dstorg = buf_priv->ContextState[MGA_CTXREG_DSTORG];
- int maccess = buf_priv->ContextState[MGA_CTXREG_MACCESS];
- int pitch = buf_priv->ServerState[MGA_2DREG_PITCH];
- int width, height;
- int texperdword = 0;
- PRIMLOCALS;
-
- width = (x2 - x1);
- height = (y2 - y1);
- switch((maccess & 0x00000003)) {
- case 0:
- texperdword = 4;
- break;
- case 1:
- texperdword = 2;
- break;
- case 2:
- texperdword = 1;
- break;
- default:
- DRM_ERROR("Invalid maccess value passed to __mga_iload_xy\n");
- return;
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_prim_buf_t *prim_buffer;
+ int i, temp, size_of_buf;
+ int offset = init->reserved_map_agpstart;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ dev_priv->primary_size = ((init->primary_size + PAGE_SIZE - 1) /
+ PAGE_SIZE) * PAGE_SIZE;
+ size_of_buf = dev_priv->primary_size / MGA_NUM_PRIM_BUFS;
+ dev_priv->warp_ucode_size = init->warp_ucode_size;
+ dev_priv->prim_bufs = drm_alloc(sizeof(drm_mga_prim_buf_t *) *
+ (MGA_NUM_PRIM_BUFS + 1),
+ DRM_MEM_DRIVER);
+ if(dev_priv->prim_bufs == NULL) {
+ DRM_ERROR("Unable to allocate memory for prim_buf\n");
+ return -ENOMEM;
}
+ memset(dev_priv->prim_bufs,
+ 0, sizeof(drm_mga_prim_buf_t *) * (MGA_NUM_PRIM_BUFS + 1));
- x2 = x1 + width;
- x2 = (x2 + (texperdword - 1)) & ~(texperdword - 1);
- x1 = (x1 + (texperdword - 1)) & ~(texperdword - 1);
- width = x2 - x1;
-
- PRIMRESET(dev_priv);
- PRIMGETPTR(dev_priv);
- PRIMOUTREG(MGAREG_DSTORG, dstorg | use_agp);
- PRIMOUTREG(MGAREG_MACCESS, maccess);
- PRIMOUTREG(MGAREG_PITCH, pitch);
- PRIMOUTREG(MGAREG_YDSTLEN, (y1 << 16) | height);
-
- PRIMOUTREG(MGAREG_FXBNDRY, ((x1+width-1) << 16) | x1);
- PRIMOUTREG(MGAREG_AR0, width * height - 1);
- PRIMOUTREG(MGAREG_AR3, 0 );
- PRIMOUTREG(MGAREG_DWGCTL+MGAREG_MGA_EXEC, MGA_ILOAD_CMD);
-
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_SECADDRESS, address | TT_BLIT);
- PRIMOUTREG(MGAREG_SECEND, (address + length) | use_agp);
+ temp = init->warp_ucode_size + dev_priv->primary_size;
+ temp = ((temp + PAGE_SIZE - 1) / PAGE_SIZE) * PAGE_SIZE;
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DMAPAD, 0);
- PRIMOUTREG(MGAREG_DWGSYNC, 0);
- PRIMOUTREG(MGAREG_SOFTRAP, 0);
- PRIMADVANCE(dev_priv);
-#if 0
- /* For now we need to set this in the ioctl */
- sarea_priv->dirty |= MGASAREA_NEW_CONTEXT;
-#endif
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
- while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ;
-
- MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL);
- MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
+ dev_priv->ioremap = drm_ioremap(dev->agp->base + offset,
+ temp);
+ if(dev_priv->ioremap == NULL) {
+ DRM_DEBUG("Ioremap failed\n");
+ return -ENOMEM;
+ }
+ init_waitqueue_head(&dev_priv->wait_queue);
+
+ for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) {
+ prim_buffer = drm_alloc(sizeof(drm_mga_prim_buf_t),
+ DRM_MEM_DRIVER);
+ if(prim_buffer == NULL) return -ENOMEM;
+ memset(prim_buffer, 0, sizeof(drm_mga_prim_buf_t));
+ prim_buffer->phys_head = offset + dev->agp->base;
+ prim_buffer->current_dma_ptr =
+ prim_buffer->head =
+ (u32 *) (dev_priv->ioremap +
+ offset -
+ init->reserved_map_agpstart);
+ prim_buffer->num_dwords = 0;
+ prim_buffer->max_dwords = size_of_buf / sizeof(u32);
+ prim_buffer->max_dwords -= 5; /* Leave room for the softrap */
+ prim_buffer->sec_used = 0;
+ prim_buffer->idx = i;
+ prim_buffer->prim_age = i + 1;
+ offset = offset + size_of_buf;
+ dev_priv->prim_bufs[i] = prim_buffer;
+ }
+ dev_priv->current_prim_idx = 0;
+ dev_priv->next_prim =
+ dev_priv->last_prim =
+ dev_priv->current_prim =
+ dev_priv->prim_bufs[0];
+ dev_priv->next_prim_age = 2;
+ dev_priv->last_prim_age = 1;
+ set_bit(MGA_BUF_IN_USE, &dev_priv->current_prim->buffer_status);
+ return 0;
}
-static void mga_dma_dispatch_iload(drm_device_t *dev, drm_buf_t *buf)
+void mga_fire_primary(drm_device_t *dev, drm_mga_prim_buf_t *prim)
{
- drm_mga_buf_priv_t *buf_priv = buf->dev_private;
-
- int use_agp = PDEA_pagpxfer_enable;
- int x1 = buf_priv->boxes[0].x1;
- int x2 = buf_priv->boxes[0].x2;
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ int use_agp = PDEA_pagpxfer_enable;
+ unsigned long end;
+ int i;
+ int next_idx;
+ PRIMLOCALS;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ dev_priv->last_prim = prim;
- if((x2 - x1) < 32) {
- printk("using iload small\n");
- __mga_iload_small(dev, buf, use_agp);
+ /* We never check for overflow, b/c there is always room */
+ PRIMPTR(prim);
+ if(num_dwords <= 0) {
+ DRM_DEBUG("num_dwords == 0 when dispatched\n");
+ goto out_prim_wait;
+ }
+ PRIMOUTREG( MGAREG_DMAPAD, 0);
+ PRIMOUTREG( MGAREG_DMAPAD, 0);
+ PRIMOUTREG( MGAREG_DMAPAD, 0);
+ PRIMOUTREG( MGAREG_SOFTRAP, 0);
+ PRIMFINISH(prim);
+
+ end = jiffies + (HZ*3);
+ if(sarea_priv->dirty & MGA_DMA_FLUSH) {
+ DRM_DEBUG("Dma top flush\n");
+ while((MGA_READ(MGAREG_STATUS) & 0x00030001) != 0x00020000) {
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup in fire primary "
+ "(Dma Top Flush)\n");
+ goto out_prim_wait;
+ }
+
+ for (i = 0 ; i < 4096 ; i++) mga_delay();
+ }
+ sarea_priv->dirty &= ~(MGA_DMA_FLUSH);
} else {
- printk("using iload xy\n");
- __mga_iload_xy(dev, buf, use_agp);
- }
-}
-
-static void mga_dma_dispatch_vertex(drm_device_t *dev, drm_buf_t *buf)
-{
- drm_mga_private_t *dev_priv = dev->dev_private;
- drm_mga_buf_priv_t *buf_priv = buf->dev_private;
- unsigned long address = (unsigned long)buf->bus_address;
- int length = buf->used;
- int use_agp = PDEA_pagpxfer_enable;
- int i, count;
- PRIMLOCALS;
-
- PRIMRESET(dev_priv);
-
- count = buf_priv->nbox;
- if (count == 0)
- count = 1;
-
- mgaEmitState( dev_priv, buf_priv );
-
- for (i = 0 ; i < count ; i++) {
- if (i < buf_priv->nbox)
- mgaEmitClipRect( dev_priv, &buf_priv->boxes[i] );
-
- PRIMGETPTR(dev_priv);
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_SECADDRESS, address | TT_VERTEX);
- PRIMOUTREG( MGAREG_SECEND, (address + length) | use_agp);
-
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_DWGSYNC, 0);
- PRIMOUTREG( MGAREG_SOFTRAP, 0);
- PRIMADVANCE(dev_priv);
+ DRM_DEBUG("Status wait\n");
+ while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) {
+ if((signed)(end - jiffies) <= 0) {
+ DRM_ERROR("irqs: %d wanted %d\n",
+ atomic_read(&dev->total_irq),
+ atomic_read(&dma->total_lost));
+ DRM_ERROR("lockup in fire primary "
+ "(Status Wait)\n");
+ goto out_prim_wait;
+ }
+
+ for (i = 0 ; i < 4096 ; i++) mga_delay();
+ }
}
- PRIMGETPTR( dev_priv );
-
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
- while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ;
-
- MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL);
- MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
+ mga_flush_write_combine();
+ atomic_inc(&dev_priv->pending_bufs);
+ MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
+ MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
+ prim->num_dwords = 0;
+ sarea_priv->last_enqueue = prim->prim_age;
+
+ next_idx = prim->idx + 1;
+ if(next_idx >= MGA_NUM_PRIM_BUFS)
+ next_idx = 0;
+
+ dev_priv->next_prim = dev_priv->prim_bufs[next_idx];
+ return;
+
+ out_prim_wait:
+ prim->num_dwords = 0;
+ prim->sec_used = 0;
+ clear_bit(MGA_BUF_IN_USE, &prim->buffer_status);
+ wake_up_interruptible(&dev_priv->wait_queue);
+ clear_bit(MGA_BUF_SWAP_PENDING, &prim->buffer_status);
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
}
-
-/* Used internally for the small buffers generated from client state
- * information.
- */
-static void mga_dma_dispatch_general(drm_device_t *dev, drm_buf_t *buf)
+int mga_advance_primary(drm_device_t *dev)
{
+ DECLARE_WAITQUEUE(entry, current);
drm_mga_private_t *dev_priv = dev->dev_private;
- unsigned long address = (unsigned long)buf->bus_address;
- int length = buf->used;
- int use_agp = PDEA_pagpxfer_enable;
- PRIMLOCALS;
-
- PRIMRESET(dev_priv);
- PRIMGETPTR(dev_priv);
-
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_SECADDRESS, address | TT_GENERAL);
- PRIMOUTREG( MGAREG_SECEND, (address + length) | use_agp);
-
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_DMAPAD, 0);
- PRIMOUTREG( MGAREG_DWGSYNC, 0);
- PRIMOUTREG( MGAREG_SOFTRAP, 0);
- PRIMADVANCE(dev_priv);
+ drm_mga_prim_buf_t *prim_buffer;
+ drm_device_dma_t *dma = dev->dma;
+ int next_prim_idx;
+ int ret = 0;
+
+ /* This needs to reset the primary buffer if available,
+ * we should collect stats on how many times it bites
+ * it's tail */
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ next_prim_idx = dev_priv->current_prim_idx + 1;
+ if(next_prim_idx >= MGA_NUM_PRIM_BUFS)
+ next_prim_idx = 0;
+ prim_buffer = dev_priv->prim_bufs[next_prim_idx];
+ set_bit(MGA_IN_WAIT, &dev_priv->dispatch_status);
+
+ /* In use is cleared in interrupt handler */
+
+ if(test_and_set_bit(MGA_BUF_IN_USE, &prim_buffer->buffer_status)) {
+ add_wait_queue(&dev_priv->wait_queue, &entry);
+ current->state = TASK_INTERRUPTIBLE;
+
+ for (;;) {
+ mga_dma_schedule(dev, 0);
+ if(!test_and_set_bit(MGA_BUF_IN_USE,
+ &prim_buffer->buffer_status))
+ break;
+ atomic_inc(&dev->total_sleeps);
+ atomic_inc(&dma->total_missed_sched);
+ schedule();
+ if (signal_pending(current)) {
+ ret = -ERESTARTSYS;
+ break;
+ }
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev_priv->wait_queue, &entry);
+ if(ret) return ret;
+ }
+ clear_bit(MGA_IN_WAIT, &dev_priv->dispatch_status);
+
+ /* This primary buffer is now free to use */
+ prim_buffer->current_dma_ptr = prim_buffer->head;
+ prim_buffer->num_dwords = 0;
+ prim_buffer->sec_used = 0;
+ prim_buffer->prim_age = dev_priv->next_prim_age++;
+ if(prim_buffer->prim_age == 0 || prim_buffer->prim_age == 0xffffffff) {
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+ mga_reset_freelist(dev);
+ prim_buffer->prim_age = (dev_priv->next_prim_age += 2);
+ }
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
- while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ;
+ /* Reset all buffer status stuff */
+ clear_bit(MGA_BUF_NEEDS_OVERFLOW, &prim_buffer->buffer_status);
+ clear_bit(MGA_BUF_FORCE_FIRE, &prim_buffer->buffer_status);
+ clear_bit(MGA_BUF_SWAP_PENDING, &prim_buffer->buffer_status);
- MGA_WRITE(MGAREG_PRIMADDRESS, dev_priv->prim_phys_head | TT_GENERAL);
- MGA_WRITE(MGAREG_PRIMEND, (phys_head + num_dwords * 4) | use_agp);
+ dev_priv->current_prim = prim_buffer;
+ dev_priv->current_prim_idx = next_prim_idx;
+ return 0;
}
-/* Frees dispatch lock */
-static inline void mga_dma_quiescent(drm_device_t *dev)
+/* More dynamic performance decisions */
+static inline int mga_decide_to_fire(drm_device_t *dev)
{
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
- while(1) {
- atomic_inc(&dev_priv->dispatch_lock);
- if(atomic_read(&dev_priv->dispatch_lock) == 1) {
- break;
- } else {
- atomic_dec(&dev_priv->dispatch_lock);
- }
- }
- while((MGA_READ(MGAREG_STATUS) & 0x00020001) != 0x00020000) ;
-#if 0
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
-#endif
- while(MGA_READ(MGAREG_DWGSYNC) == MGA_SYNC_TAG) ;
- MGA_WRITE(MGAREG_DWGSYNC, MGA_SYNC_TAG);
- while(MGA_READ(MGAREG_DWGSYNC) != MGA_SYNC_TAG) ;
- atomic_dec(&dev_priv->dispatch_lock);
-}
+ DRM_DEBUG("%s\n", __FUNCTION__);
-/* Keeps dispatch lock held */
+ if(test_bit(MGA_BUF_FORCE_FIRE, &dev_priv->next_prim->buffer_status)) {
+ atomic_inc(&dma->total_prio);
+ return 1;
+ }
-static inline int mga_dma_is_ready(drm_device_t *dev)
-{
- drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
-
- atomic_inc(&dev_priv->dispatch_lock);
- if(atomic_read(&dev_priv->dispatch_lock) == 1) {
- /* We got the lock */
- return 1;
- } else {
- atomic_dec(&dev_priv->dispatch_lock);
- return 0;
+ if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
+ dev_priv->next_prim->num_dwords) {
+ atomic_inc(&dma->total_prio);
+ return 1;
}
-}
-static inline int mga_dma_is_ready_no_hold(drm_device_t *dev)
-{
- drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ if (test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) &&
+ dev_priv->next_prim->num_dwords) {
+ atomic_inc(&dma->total_prio);
+ return 1;
+ }
- atomic_inc(&dev_priv->dispatch_lock);
- if(atomic_read(&dev_priv->dispatch_lock) == 1) {
- /* We got the lock, but free it */
- atomic_dec(&dev_priv->dispatch_lock);
- return 1;
- } else {
- atomic_dec(&dev_priv->dispatch_lock);
- return 0;
+ if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS - 1) {
+ if(test_bit(MGA_BUF_SWAP_PENDING,
+ &dev_priv->next_prim->buffer_status)) {
+ atomic_inc(&dma->total_dmas);
+ return 1;
+ }
}
-}
-static void mga_dma_service(int irq, void *device, struct pt_regs *regs)
-{
- drm_device_t *dev = (drm_device_t *)device;
- drm_device_dma_t *dma = dev->dma;
- drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
-
- atomic_dec(&dev_priv->dispatch_lock);
- atomic_inc(&dev->total_irq);
- MGA_WRITE(MGAREG_ICLEAR, 0xfa7);
-
- /* Free previous buffer */
- if (test_and_set_bit(0, &dev->dma_flag)) {
- atomic_inc(&dma->total_missed_free);
- return;
- }
- if (dma->this_buffer) {
- drm_free_buffer(dev, dma->this_buffer);
- dma->this_buffer = NULL;
+ if(atomic_read(&dev_priv->pending_bufs) <= MGA_NUM_PRIM_BUFS / 2) {
+ if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 8) {
+ atomic_inc(&dma->total_hit);
+ return 1;
+ }
}
- clear_bit(0, &dev->dma_flag);
- /* Dispatch new buffer */
- queue_task(&dev->tq, &tq_immediate);
- mark_bh(IMMEDIATE_BH);
+ if(atomic_read(&dev_priv->pending_bufs) >= MGA_NUM_PRIM_BUFS / 2) {
+ if(dev_priv->next_prim->sec_used >= MGA_DMA_BUF_NR / 4) {
+ atomic_inc(&dma->total_missed_free);
+ return 1;
+ }
+ }
+ atomic_inc(&dma->total_tried);
+ return 0;
}
-/* Only called by mga_dma_schedule. */
-static int mga_do_dma(drm_device_t *dev, int locked)
+int mga_dma_schedule(drm_device_t *dev, int locked)
{
- drm_buf_t *buf;
- int retcode = 0;
- drm_device_dma_t *dma = dev->dma;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
- drm_mga_buf_priv_t *buf_priv;
+ drm_device_dma_t *dma = dev->dma;
+ int retval = 0;
- printk("mga_do_dma\n");
- if (test_and_set_bit(0, &dev->dma_flag)) {
+ if (test_and_set_bit(0, &dev->dma_flag)) {
atomic_inc(&dma->total_missed_dma);
- return -EBUSY;
- }
-
- if (!dma->next_buffer) {
- DRM_ERROR("No next_buffer\n");
- clear_bit(0, &dev->dma_flag);
- return -EINVAL;
- }
-
- buf = dma->next_buffer;
-
- printk("context %d, buffer %d\n", buf->context, buf->idx);
-
- if (buf->list == DRM_LIST_RECLAIM) {
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
- clear_bit(0, &dev->dma_flag);
- return -EINVAL;
+ retval = -EBUSY;
+ goto sch_out_wakeup;
}
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
- if (!buf->used) {
- DRM_ERROR("0 length buffer\n");
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
- clear_bit(0, &dev->dma_flag);
- return 0;
- }
-
- if (mga_dma_is_ready(dev) == 0) {
- clear_bit(0, &dev->dma_flag);
- return -EBUSY;
+ if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) ||
+ test_bit(MGA_IN_WAIT, &dev_priv->dispatch_status) ||
+ test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
+ locked = 1;
}
- /* Always hold the hardware lock while dispatching.
- */
- if (!locked && !drm_lock_take(&dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT)) {
- atomic_inc(&dma->total_missed_lock);
- clear_bit(0, &dev->dma_flag);
- atomic_dec(&dev_priv->dispatch_lock);
- return -EBUSY;
+ if (!locked &&
+ !drm_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) {
+ atomic_inc(&dma->total_missed_lock);
+ clear_bit(0, &dev->dma_flag);
+ DRM_DEBUG("Not locked\n");
+ retval = -EBUSY;
+ goto sch_out_wakeup;
}
-
- dma->next_queue = dev->queuelist[DRM_KERNEL_CONTEXT];
- drm_clear_next_buffer(dev);
- buf->pending = 1;
- buf->waiting = 0;
- buf->list = DRM_LIST_PEND;
-
- buf_priv = buf->dev_private;
-
- printk("dispatch!\n");
- switch (buf_priv->dma_type) {
- case MGA_DMA_GENERAL:
- mga_dma_dispatch_general(dev, buf);
- break;
- case MGA_DMA_VERTEX:
- mga_dma_dispatch_vertex(dev, buf);
- break;
-/* case MGA_DMA_SETUP: */
-/* mga_dma_dispatch_setup(dev, address, length); */
-/* break; */
- case MGA_DMA_ILOAD:
- mga_dma_dispatch_iload(dev, buf);
- break;
- default:
- printk("bad buffer type %x in dispatch\n", buf_priv->dma_type);
- break;
+ DRM_DEBUG("I'm locked\n");
+
+ if(!test_and_set_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status)) {
+ /* Fire dma buffer */
+ if(mga_decide_to_fire(dev)) {
+ DRM_DEBUG("idx :%d\n", dev_priv->next_prim->idx);
+ clear_bit(MGA_BUF_FORCE_FIRE,
+ &dev_priv->next_prim->buffer_status);
+ if(dev_priv->current_prim == dev_priv->next_prim) {
+ /* Schedule overflow for a later time */
+ set_bit(MGA_BUF_NEEDS_OVERFLOW,
+ &dev_priv->next_prim->buffer_status);
+ }
+ mga_fire_primary(dev, dev_priv->next_prim);
+ } else {
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+ }
+ } else {
+ DRM_DEBUG("I can't get the dispatch lock\n");
}
- atomic_dec(&dev_priv->pending_bufs);
-
- drm_free_buffer(dev, dma->this_buffer);
- dma->this_buffer = buf;
-
- atomic_add(buf->used, &dma->total_bytes);
- atomic_inc(&dma->total_dmas);
-
+
if (!locked) {
if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT)) {
@@ -692,90 +624,242 @@ static int mga_do_dma(drm_device_t *dev, int locked)
}
}
- clear_bit(0, &dev->dma_flag);
-
- if(!atomic_read(&dev_priv->pending_bufs)) {
- wake_up_interruptible(&dev->queuelist[DRM_KERNEL_CONTEXT]->flush_queue);
- }
-
-#if 0
- wake_up_interruptible(&dev->lock.lock_queue);
-#endif
-
- /* We hold the dispatch lock until the interrupt handler
- * frees it
- */
- return retcode;
+sch_out_wakeup:
+ if(test_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status) &&
+ atomic_read(&dev_priv->pending_bufs) == 0) {
+ /* Everything has been processed by the hardware */
+ clear_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status);
+ wake_up_interruptible(&dev_priv->flush_queue);
+ }
+
+ if(test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status) &&
+ dev_priv->tail->age < dev_priv->last_prim_age) {
+ clear_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status);
+ DRM_DEBUG("Waking up buf queue\n");
+ wake_up_interruptible(&dev_priv->buf_queue);
+ } else if (test_bit(MGA_IN_GETBUF, &dev_priv->dispatch_status)) {
+ DRM_DEBUG("Not waking buf_queue on %d %d\n",
+ atomic_read(&dev->total_irq),
+ dev_priv->last_prim_age);
+ }
+
+ clear_bit(0, &dev->dma_flag);
+ return retval;
}
-static void mga_dma_schedule_timer_wrapper(unsigned long dev)
+static void mga_dma_service(int irq, void *device, struct pt_regs *regs)
{
- mga_dma_schedule((drm_device_t *)dev, 0);
+ drm_device_t *dev = (drm_device_t *)device;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_prim_buf_t *last_prim_buffer;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ atomic_inc(&dev->total_irq);
+ if((MGA_READ(MGAREG_STATUS) & 0x00000001) != 0x00000001) return;
+ MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
+ last_prim_buffer = dev_priv->last_prim;
+ last_prim_buffer->num_dwords = 0;
+ last_prim_buffer->sec_used = 0;
+ dev_priv->sarea_priv->last_dispatch =
+ dev_priv->last_prim_age = last_prim_buffer->prim_age;
+ clear_bit(MGA_BUF_IN_USE, &last_prim_buffer->buffer_status);
+ wake_up_interruptible(&dev_priv->wait_queue);
+ clear_bit(MGA_BUF_SWAP_PENDING, &last_prim_buffer->buffer_status);
+ clear_bit(MGA_IN_DISPATCH, &dev_priv->dispatch_status);
+ atomic_dec(&dev_priv->pending_bufs);
+ queue_task(&dev->tq, &tq_immediate);
+ mark_bh(IMMEDIATE_BH);
}
-static void mga_dma_schedule_tq_wrapper(void *dev)
+static void mga_dma_task_queue(void *device)
{
- mga_dma_schedule(dev, 0);
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ mga_dma_schedule((drm_device_t *)device, 0);
}
-int mga_dma_schedule(drm_device_t *dev, int locked)
+int mga_dma_cleanup(drm_device_t *dev)
{
- drm_queue_t *q;
- drm_buf_t *buf;
- int retcode = 0;
- int processed = 0;
- int missed;
- int expire = 20;
- drm_device_dma_t *dma = dev->dma;
-
- printk("mga_dma_schedule\n");
-
- if (test_and_set_bit(0, &dev->interrupt_flag)) {
- /* Not reentrant */
- atomic_inc(&dma->total_missed_sched);
- return -EBUSY;
- }
- missed = atomic_read(&dma->total_missed_sched);
+ DRM_DEBUG("%s\n", __FUNCTION__);
-again:
- /* There is only one queue:
- */
- if (!dma->next_buffer && DRM_WAITCOUNT(dev, DRM_KERNEL_CONTEXT)) {
- q = dev->queuelist[DRM_KERNEL_CONTEXT];
- buf = drm_waitlist_get(&q->waitlist);
- dma->next_buffer = buf;
- dma->next_queue = q;
- if (buf && buf->list == DRM_LIST_RECLAIM) {
- drm_clear_next_buffer(dev);
- drm_free_buffer(dev, buf);
+ if(dev->dev_private) {
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+
+ if(dev_priv->ioremap) {
+ int temp = (dev_priv->warp_ucode_size +
+ dev_priv->primary_size +
+ PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE;
+
+ drm_ioremapfree((void *) dev_priv->ioremap, temp);
+ }
+ if(dev_priv->status_page != NULL) {
+ iounmap(dev_priv->status_page);
}
+ if(dev_priv->real_status_page != 0UL) {
+ mga_free_page(dev, dev_priv->real_status_page);
+ }
+ if(dev_priv->prim_bufs != NULL) {
+ int i;
+ for(i = 0; i < MGA_NUM_PRIM_BUFS; i++) {
+ if(dev_priv->prim_bufs[i] != NULL) {
+ drm_free(dev_priv->prim_bufs[i],
+ sizeof(drm_mga_prim_buf_t),
+ DRM_MEM_DRIVER);
+ }
+ }
+ drm_free(dev_priv->prim_bufs, sizeof(void *) *
+ (MGA_NUM_PRIM_BUFS + 1),
+ DRM_MEM_DRIVER);
+ }
+ if(dev_priv->head != NULL) {
+ mga_freelist_cleanup(dev);
+ }
+
+
+ drm_free(dev->dev_private, sizeof(drm_mga_private_t),
+ DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
}
- if (dma->next_buffer) {
- if (!(retcode = mga_do_dma(dev, locked)))
- ++processed;
+ return 0;
+}
+
+static int mga_dma_initialize(drm_device_t *dev, drm_mga_init_t *init) {
+ drm_mga_private_t *dev_priv;
+ drm_map_t *sarea_map = NULL;
+ int i;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ dev_priv = drm_alloc(sizeof(drm_mga_private_t), DRM_MEM_DRIVER);
+ if(dev_priv == NULL) return -ENOMEM;
+ dev->dev_private = (void *) dev_priv;
+
+ memset(dev_priv, 0, sizeof(drm_mga_private_t));
+
+ if((init->reserved_map_idx >= dev->map_count) ||
+ (init->buffer_map_idx >= dev->map_count)) {
+ mga_dma_cleanup(dev);
+ DRM_DEBUG("reserved_map or buffer_map are invalid\n");
+ return -EINVAL;
}
+
+ dev_priv->reserved_map_idx = init->reserved_map_idx;
+ dev_priv->buffer_map_idx = init->buffer_map_idx;
+ sarea_map = dev->maplist[0];
+ dev_priv->sarea_priv = (drm_mga_sarea_t *)
+ ((u8 *)sarea_map->handle +
+ init->sarea_priv_offset);
- /* Try again if we succesfully dispatched a buffer, or if someone
- * tried to schedule while we were working.
- */
- if (--expire) {
- if (missed != atomic_read(&dma->total_missed_sched)) {
- atomic_inc(&dma->total_lost);
- if (mga_dma_is_ready_no_hold(dev))
- goto again;
- }
+ /* Scale primary size to the next page */
+ dev_priv->chipset = init->chipset;
+ dev_priv->frontOffset = init->frontOffset;
+ dev_priv->backOffset = init->backOffset;
+ dev_priv->depthOffset = init->depthOffset;
+ dev_priv->textureOffset = init->textureOffset;
+ dev_priv->textureSize = init->textureSize;
+ dev_priv->cpp = init->cpp;
+ dev_priv->sgram = init->sgram;
+ dev_priv->stride = init->stride;
- if (processed && mga_dma_is_ready_no_hold(dev)) {
- atomic_inc(&dma->total_lost);
- processed = 0;
- goto again;
- }
+ dev_priv->mAccess = init->mAccess;
+ init_waitqueue_head(&dev_priv->flush_queue);
+ init_waitqueue_head(&dev_priv->buf_queue);
+ dev_priv->WarpPipe = -1;
+
+ DRM_DEBUG("chipset: %d ucode_size: %d backOffset: %x depthOffset: %x\n",
+ dev_priv->chipset, dev_priv->warp_ucode_size,
+ dev_priv->backOffset, dev_priv->depthOffset);
+ DRM_DEBUG("cpp: %d sgram: %d stride: %d maccess: %x\n",
+ dev_priv->cpp, dev_priv->sgram, dev_priv->stride,
+ dev_priv->mAccess);
+
+ memcpy(&dev_priv->WarpIndex, &init->WarpIndex,
+ sizeof(drm_mga_warp_index_t) * MGA_MAX_WARP_PIPES);
+
+ for (i = 0 ; i < MGA_MAX_WARP_PIPES ; i++)
+ DRM_DEBUG("warp pipe %d: installed: %d phys: %lx size: %x\n",
+ i,
+ dev_priv->WarpIndex[i].installed,
+ dev_priv->WarpIndex[i].phys_addr,
+ dev_priv->WarpIndex[i].size);
+
+ if(mga_init_primary_bufs(dev, init) != 0) {
+ DRM_ERROR("Can not initialize primary buffers\n");
+ mga_dma_cleanup(dev);
+ return -ENOMEM;
}
-
- clear_bit(0, &dev->interrupt_flag);
-
- return retcode;
+ dev_priv->real_status_page = mga_alloc_page(dev);
+ if(dev_priv->real_status_page == 0UL) {
+ mga_dma_cleanup(dev);
+ DRM_ERROR("Can not allocate status page\n");
+ return -ENOMEM;
+ }
+
+ dev_priv->status_page =
+ ioremap_nocache(virt_to_bus((void *)dev_priv->real_status_page),
+ PAGE_SIZE);
+
+ if(dev_priv->status_page == NULL) {
+ mga_dma_cleanup(dev);
+ DRM_ERROR("Can not remap status page\n");
+ return -ENOMEM;
+ }
+
+ /* Write status page when secend or softrap occurs */
+ MGA_WRITE(MGAREG_PRIMPTR,
+ virt_to_bus((void *)dev_priv->real_status_page) | 0x00000003);
+
+
+ /* Private is now filled in, initialize the hardware */
+ {
+ PRIMLOCALS;
+ PRIMGETPTR( dev_priv );
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x0100);
+ PRIMOUTREG(MGAREG_SOFTRAP, 0);
+ /* Poll for the first buffer to insure that
+ * the status register will be correct
+ */
+
+ mga_flush_write_combine();
+ MGA_WRITE(MGAREG_PRIMADDRESS, phys_head | TT_GENERAL);
+
+ MGA_WRITE(MGAREG_PRIMEND, ((phys_head + num_dwords * 4) |
+ PDEA_pagpxfer_enable));
+
+ while(MGA_READ(MGAREG_DWGSYNC) != 0x0100) ;
+ }
+
+ if(mga_freelist_init(dev) != 0) {
+ DRM_ERROR("Could not initialize freelist\n");
+ mga_dma_cleanup(dev);
+ return -ENOMEM;
+ }
+ return 0;
+}
+
+int mga_dma_init(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_mga_init_t init;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ copy_from_user_ret(&init, (drm_mga_init_t *)arg, sizeof(init), -EFAULT);
+
+ switch(init.func) {
+ case MGA_INIT_DMA:
+ return mga_dma_initialize(dev, &init);
+ case MGA_CLEANUP_DMA:
+ return mga_dma_cleanup(dev);
+ }
+
+ return -EINVAL;
}
int mga_irq_install(drm_device_t *dev, int irq)
@@ -792,7 +876,7 @@ int mga_irq_install(drm_device_t *dev, int irq)
dev->irq = irq;
up(&dev->struct_sem);
- printk("install irq handler %d\n", irq);
+ DRM_DEBUG("install irq handler %d\n", irq);
dev->context_flag = 0;
dev->interrupt_flag = 0;
@@ -802,17 +886,15 @@ int mga_irq_install(drm_device_t *dev, int irq)
dev->dma->this_buffer = NULL;
dev->tq.next = NULL;
dev->tq.sync = 0;
- dev->tq.routine = mga_dma_schedule_tq_wrapper;
+ dev->tq.routine = mga_dma_task_queue;
dev->tq.data = dev;
/* Before installing handler */
- MGA_WRITE(MGAREG_ICLEAR, 0xfa7);
MGA_WRITE(MGAREG_IEN, 0);
-
/* Install handler */
if ((retcode = request_irq(dev->irq,
mga_dma_service,
- 0,
+ SA_SHIRQ,
dev->devname,
dev))) {
down(&dev->struct_sem);
@@ -820,11 +902,9 @@ int mga_irq_install(drm_device_t *dev, int irq)
up(&dev->struct_sem);
return retcode;
}
-
/* After installing handler */
- MGA_WRITE(MGAREG_ICLEAR, 0xfa7);
+ MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
MGA_WRITE(MGAREG_IEN, 0x00000001);
-
return 0;
}
@@ -838,19 +918,13 @@ int mga_irq_uninstall(drm_device_t *dev)
up(&dev->struct_sem);
if (!irq) return -EINVAL;
-
- printk("remove irq handler %d\n", irq);
-
- MGA_WRITE(MGAREG_ICLEAR, 0xfa7);
+ DRM_DEBUG("remove irq handler %d\n", irq);
+ MGA_WRITE(MGAREG_ICLEAR, 0x00000001);
MGA_WRITE(MGAREG_IEN, 0);
- MGA_WRITE(MGAREG_ICLEAR, 0xfa7);
-
free_irq(irq, dev);
-
return 0;
}
-
int mga_control(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@@ -859,7 +933,9 @@ int mga_control(struct inode *inode, struct file *filp, unsigned int cmd,
drm_control_t ctl;
copy_from_user_ret(&ctl, (drm_control_t *)arg, sizeof(ctl), -EFAULT);
-
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
switch (ctl.func) {
case DRM_INST_HANDLER:
return mga_irq_install(dev, ctl.irq);
@@ -870,36 +946,69 @@ int mga_control(struct inode *inode, struct file *filp, unsigned int cmd,
}
}
-int mga_flush_queue(drm_device_t *dev)
+static int mga_flush_queue(drm_device_t *dev)
{
DECLARE_WAITQUEUE(entry, current);
- drm_queue_t *q = dev->queuelist[DRM_KERNEL_CONTEXT];
- drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
int ret = 0;
-
- printk("mga_flush_queue\n");
- if(atomic_read(&dev_priv->pending_bufs) != 0) {
- current->state = TASK_INTERRUPTIBLE;
- add_wait_queue(&q->flush_queue, &entry);
- for (;;) {
- if (!atomic_read(&dev_priv->pending_bufs)) break;
- printk("Calling schedule from flush_queue : %d\n",
- atomic_read(&dev_priv->pending_bufs));
- mga_dma_schedule(dev, 1);
- schedule();
- if (signal_pending(current)) {
- ret = -EINTR; /* Can't restart */
- break;
- }
- }
- printk("Exited out of schedule from flush_queue\n");
- current->state = TASK_RUNNING;
- remove_wait_queue(&q->flush_queue, &entry);
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if(dev_priv == NULL) {
+ return 0;
}
+ if(dev_priv->next_prim->num_dwords != 0) {
+ current->state = TASK_INTERRUPTIBLE;
+ add_wait_queue(&dev_priv->flush_queue, &entry);
+ set_bit(MGA_IN_FLUSH, &dev_priv->dispatch_status);
+ mga_dma_schedule(dev, 0);
+ for (;;) {
+ if (!test_bit(MGA_IN_FLUSH,
+ &dev_priv->dispatch_status))
+ break;
+ atomic_inc(&dev->total_sleeps);
+ schedule();
+ if (signal_pending(current)) {
+ ret = -EINTR; /* Can't restart */
+ clear_bit(MGA_IN_FLUSH,
+ &dev_priv->dispatch_status);
+ break;
+ }
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev_priv->flush_queue, &entry);
+ }
return ret;
}
+/* Must be called with the lock held */
+void mga_reclaim_buffers(drm_device_t *dev, pid_t pid)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ if (!dma) return;
+ if(dev->dev_private == NULL) return;
+ if(dma->buflist == NULL) return;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ mga_flush_queue(dev);
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[ i ];
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+
+ /* Only buffers that need to get reclaimed ever
+ * get set to free
+ */
+ if (buf->pid == pid && buf_priv) {
+ if(buf_priv->my_freelist->age == MGA_BUF_USED)
+ buf_priv->my_freelist->age = MGA_BUF_FREE;
+ }
+ }
+}
+
int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
@@ -909,6 +1018,7 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
int ret = 0;
drm_lock_t lock;
+ DRM_DEBUG("%s\n", __FUNCTION__);
copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
if (lock.context == DRM_KERNEL_CONTEXT) {
@@ -916,16 +1026,15 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
current->pid, lock.context);
return -EINVAL;
}
-
- printk("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
- lock.context, current->pid, dev->lock.hw_lock->lock,
- lock.flags);
-
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, current->pid, dev->lock.hw_lock->lock,
+ lock.flags);
if (lock.context < 0) {
return -EINVAL;
}
-
+
/* Only one queue:
*/
@@ -948,8 +1057,6 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
/* Contention */
atomic_inc(&dev->total_sleeps);
current->state = TASK_INTERRUPTIBLE;
- current->policy |= SCHED_YIELD;
- printk("Calling lock schedule\n");
schedule();
if (signal_pending(current)) {
ret = -ERESTARTSYS;
@@ -962,17 +1069,47 @@ int mga_lock(struct inode *inode, struct file *filp, unsigned int cmd,
if (!ret) {
if (lock.flags & _DRM_LOCK_QUIESCENT) {
- printk("_DRM_LOCK_QUIESCENT\n");
- ret = mga_flush_queue(dev);
- if(ret != 0) {
- drm_lock_free(dev, &dev->lock.hw_lock->lock,
- lock.context);
- } else {
- mga_dma_quiescent(dev);
- }
+ DRM_DEBUG("_DRM_LOCK_QUIESCENT\n");
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
}
}
- printk("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
return ret;
}
+int mga_flush_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_lock_t lock;
+ drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+ copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+
+ if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_flush_ioctl called without lock held\n");
+ return -EINVAL;
+ }
+
+ if(lock.flags & _DRM_LOCK_FLUSH || lock.flags & _DRM_LOCK_FLUSH_ALL) {
+ drm_mga_prim_buf_t *temp_buf;
+
+ temp_buf = dev_priv->current_prim;
+
+ if(temp_buf && temp_buf->num_dwords) {
+ set_bit(MGA_BUF_FORCE_FIRE, &temp_buf->buffer_status);
+ mga_advance_primary(dev);
+ }
+ mga_dma_schedule(dev, 1);
+ }
+ if(lock.flags & _DRM_LOCK_QUIESCENT) {
+ mga_flush_queue(dev);
+ mga_dma_quiescent(dev);
+ }
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h
new file mode 100644
index 000000000..e75e91a4f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drm.h
@@ -0,0 +1,269 @@
+/* mga_drm.h -- Public header for the Matrox g200/g400 driver -*- linux-c -*-
+ * Created: Tue Jan 25 01:50:01 1999 by jhartmann@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Jeff Hartmann <jhartmann@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
+ *
+ */
+
+#ifndef _MGA_DRM_H_
+#define _MGA_DRM_H_
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmMga.h)
+ */
+#ifndef _MGA_DEFINES_
+#define _MGA_DEFINES_
+
+#define MGA_F 0x1 /* fog */
+#define MGA_A 0x2 /* alpha */
+#define MGA_S 0x4 /* specular */
+#define MGA_T2 0x8 /* multitexture */
+
+#define MGA_WARP_TGZ 0
+#define MGA_WARP_TGZF (MGA_F)
+#define MGA_WARP_TGZA (MGA_A)
+#define MGA_WARP_TGZAF (MGA_F|MGA_A)
+#define MGA_WARP_TGZS (MGA_S)
+#define MGA_WARP_TGZSF (MGA_S|MGA_F)
+#define MGA_WARP_TGZSA (MGA_S|MGA_A)
+#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
+#define MGA_WARP_T2GZ (MGA_T2)
+#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
+#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
+#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
+#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
+#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
+#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
+#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
+
+#define MGA_MAX_G400_PIPES 16
+#define MGA_MAX_G200_PIPES 8 /* no multitex */
+#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
+
+#define MGA_CARD_TYPE_G200 1
+#define MGA_CARD_TYPE_G400 2
+
+#define MGA_FRONT 0x1
+#define MGA_BACK 0x2
+#define MGA_DEPTH 0x4
+
+/* 3d state excluding texture units:
+ */
+#define MGA_CTXREG_DSTORG 0 /* validated */
+#define MGA_CTXREG_MACCESS 1
+#define MGA_CTXREG_PLNWT 2
+#define MGA_CTXREG_DWGCTL 3
+#define MGA_CTXREG_ALPHACTRL 4
+#define MGA_CTXREG_FOGCOLOR 5
+#define MGA_CTXREG_WFLAG 6
+#define MGA_CTXREG_TDUAL0 7
+#define MGA_CTXREG_TDUAL1 8
+#define MGA_CTXREG_FCOL 9
+#define MGA_CTX_SETUP_SIZE 10
+
+/* 2d state
+ */
+#define MGA_2DREG_PITCH 0
+#define MGA_2D_SETUP_SIZE 1
+
+/* Each texture unit has a state:
+ */
+#define MGA_TEXREG_CTL 0
+#define MGA_TEXREG_CTL2 1
+#define MGA_TEXREG_FILTER 2
+#define MGA_TEXREG_BORDERCOL 3
+#define MGA_TEXREG_ORG 4 /* validated */
+#define MGA_TEXREG_ORG1 5
+#define MGA_TEXREG_ORG2 6
+#define MGA_TEXREG_ORG3 7
+#define MGA_TEXREG_ORG4 8
+#define MGA_TEXREG_WIDTH 9
+#define MGA_TEXREG_HEIGHT 10
+#define MGA_TEX_SETUP_SIZE 11
+
+/* What needs to be changed for the current vertex dma buffer?
+ */
+#define MGA_UPLOAD_CTX 0x1
+#define MGA_UPLOAD_TEX0 0x2
+#define MGA_UPLOAD_TEX1 0x4
+#define MGA_UPLOAD_PIPE 0x8
+#define MGA_UPLOAD_TEX0IMAGE 0x10 /* handled client-side */
+#define MGA_UPLOAD_TEX1IMAGE 0x20 /* handled client-side */
+#define MGA_UPLOAD_2D 0x40
+#define MGA_WAIT_AGE 0x80 /* handled client-side */
+#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
+#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
+ quiescent */
+
+/* 32 buffers of 64k each, total 2 meg.
+ */
+#define MGA_DMA_BUF_ORDER 16
+#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER)
+#define MGA_DMA_BUF_NR 31
+
+/* Keep these small for testing.
+ */
+#define MGA_NR_SAREA_CLIPRECTS 8
+
+/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
+ * regions, subject to a minimum region size of (1<<16) == 64k.
+ *
+ * Clients may subdivide regions internally, but when sharing between
+ * clients, the region size is the minimum granularity.
+ */
+
+#define MGA_CARD_HEAP 0
+#define MGA_AGP_HEAP 1
+#define MGA_NR_TEX_HEAPS 2
+#define MGA_NR_TEX_REGIONS 16
+#define MGA_LOG_MIN_TEX_REGION_SIZE 16
+#endif
+
+typedef struct _drm_mga_warp_index {
+ int installed;
+ unsigned long phys_addr;
+ int size;
+} drm_mga_warp_index_t;
+
+typedef struct drm_mga_init {
+ enum {
+ MGA_INIT_DMA = 0x01,
+ MGA_CLEANUP_DMA = 0x02
+ } func;
+ int reserved_map_agpstart;
+ int reserved_map_idx;
+ int buffer_map_idx;
+ int sarea_priv_offset;
+ int primary_size;
+ int warp_ucode_size;
+ unsigned int frontOffset;
+ unsigned int backOffset;
+ unsigned int depthOffset;
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ unsigned int agpTextureOffset;
+ unsigned int agpTextureSize;
+ unsigned int cpp;
+ unsigned int stride;
+ int sgram;
+ int chipset;
+ drm_mga_warp_index_t WarpIndex[MGA_MAX_WARP_PIPES];
+ unsigned int mAccess;
+} drm_mga_init_t;
+
+/* Warning: if you change the sarea structure, you must change the Xserver
+ * structures as well */
+
+typedef struct _drm_mga_tex_region {
+ unsigned char next, prev;
+ unsigned char in_use;
+ unsigned int age;
+} drm_mga_tex_region_t;
+
+typedef struct _drm_mga_sarea {
+ /* The channel for communication of state information to the kernel
+ * on firing a vertex dma buffer.
+ */
+ unsigned int ContextState[MGA_CTX_SETUP_SIZE];
+ unsigned int ServerState[MGA_2D_SETUP_SIZE];
+ unsigned int TexState[2][MGA_TEX_SETUP_SIZE];
+ unsigned int WarpPipe;
+ unsigned int dirty;
+
+ unsigned int nbox;
+ drm_clip_rect_t boxes[MGA_NR_SAREA_CLIPRECTS];
+
+
+ /* Information about the most recently used 3d drawable. The
+ * client fills in the req_* fields, the server fills in the
+ * exported_ fields and puts the cliprects into boxes, above.
+ *
+ * The client clears the exported_drawable field before
+ * clobbering the boxes data.
+ */
+ unsigned int req_drawable; /* the X drawable id */
+ unsigned int req_draw_buffer; /* MGA_FRONT or MGA_BACK */
+
+ unsigned int exported_drawable;
+ unsigned int exported_index;
+ unsigned int exported_stamp;
+ unsigned int exported_buffers;
+ unsigned int exported_nfront;
+ unsigned int exported_nback;
+ int exported_back_x, exported_front_x, exported_w;
+ int exported_back_y, exported_front_y, exported_h;
+ drm_clip_rect_t exported_boxes[MGA_NR_SAREA_CLIPRECTS];
+
+ /* Counters for aging textures and for client-side throttling.
+ */
+ unsigned int last_enqueue; /* last time a buffer was enqueued */
+ unsigned int last_dispatch; /* age of the most recently dispatched buffer */
+ unsigned int last_quiescent; /* */
+
+
+ /* LRU lists for texture memory in agp space and on the card
+ */
+ drm_mga_tex_region_t texList[MGA_NR_TEX_HEAPS][MGA_NR_TEX_REGIONS+1];
+ unsigned int texAge[MGA_NR_TEX_HEAPS];
+
+ /* Mechanism to validate card state.
+ */
+ int ctxOwner;
+} drm_mga_sarea_t;
+
+/* Device specific ioctls:
+ */
+typedef struct _drm_mga_clear {
+ unsigned int clear_color;
+ unsigned int clear_depth;
+ unsigned int flags;
+} drm_mga_clear_t;
+
+typedef struct _drm_mga_swap {
+ int dummy;
+} drm_mga_swap_t;
+
+typedef struct _drm_mga_iload {
+ int idx;
+ int length;
+ unsigned int destOrg;
+} drm_mga_iload_t;
+
+typedef struct _drm_mga_vertex {
+ int idx; /* buffer to queue */
+ int used; /* bytes in use */
+ int discard; /* client finished with buffer? */
+} drm_mga_vertex_t;
+
+typedef struct _drm_mga_indices {
+ int idx; /* buffer to queue */
+ unsigned int start;
+ unsigned int end;
+ int discard; /* client finished with buffer? */
+} drm_mga_indices_t;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c
index 8bc25617e..e77d827b0 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,13 +24,13 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.c,v 1.1 2000/02/11 17:26:07 dawes Exp $
*
*/
+#include <linux/config.h>
#define EXPORT_SYMTAB
#include "drmP.h"
#include "mga_drv.h"
@@ -39,9 +40,9 @@ EXPORT_SYMBOL(mga_cleanup);
#define MGA_NAME "mga"
#define MGA_DESC "Matrox g200/g400"
#define MGA_DATE "19991213"
-#define MGA_MAJOR 0
+#define MGA_MAJOR 1
#define MGA_MINOR 0
-#define MGA_PATCHLEVEL 1
+#define MGA_PATCHLEVEL 0
static drm_device_t mga_device;
drm_ctx_t mga_res_ctx;
@@ -54,6 +55,7 @@ static struct file_operations mga_fops = {
mmap: drm_mmap,
read: drm_read,
fasync: drm_fasync,
+ poll: drm_poll,
};
static struct miscdevice mga_misc = {
@@ -105,9 +107,12 @@ static drm_ioctl_desc_t mga_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
[DRM_IOCTL_NR(DRM_IOCTL_MGA_INIT)] = { mga_dma_init, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)] = { mga_clear_bufs, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)] = { mga_swap_bufs, 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_iload, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_SWAP)] = { mga_swap_bufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_CLEAR)] = { mga_clear_bufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_ILOAD)] = { mga_iload, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_VERTEX)] = { mga_vertex, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_FLUSH)] = { mga_flush_ioctl, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MGA_INDICES)] = { mga_indices, 1, 0 },
};
#define MGA_IOCTL_COUNT DRM_ARRAY_SIZE(mga_ioctls)
@@ -380,6 +385,21 @@ int mga_init(void)
drm_proc_init(dev);
DRM_DEBUG("doing agp init\n");
dev->agp = drm_agp_init();
+ if(dev->agp == NULL) {
+ DRM_INFO("The mga drm module requires the agpgart module"
+ " to function correctly\nPlease load the agpgart"
+ " module before you load the mga module\n");
+ drm_proc_cleanup();
+ misc_deregister(&mga_misc);
+ mga_takedown(dev);
+ return -ENOMEM;
+ }
+#ifdef CONFIG_MTRR
+ dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size * 1024 * 1024,
+ MTRR_TYPE_WRCOMB,
+ 1);
+#endif
DRM_DEBUG("doing ctxbitmap init\n");
if((retcode = drm_ctxbitmap_init(dev))) {
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
@@ -416,6 +436,16 @@ void mga_cleanup(void)
}
drm_ctxbitmap_cleanup(dev);
mga_dma_cleanup(dev);
+#ifdef CONFIG_MTRR
+ if(dev->agp && dev->agp->agp_mtrr) {
+ int retval;
+ retval = mtrr_del(dev->agp->agp_mtrr,
+ dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size * 1024*1024);
+ DRM_DEBUG("mtrr_del = %d\n", retval);
+ }
+#endif
+
mga_takedown(dev);
if (dev->agp) {
drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
@@ -482,27 +512,86 @@ int mga_release(struct inode *inode, struct file *filp)
drm_device_t *dev = priv->dev;
int retcode = 0;
- DRM_DEBUG("open_count = %d\n", dev->open_count);
- if (!(retcode = drm_release(inode, filp))) {
- MOD_DEC_USE_COUNT;
- atomic_inc(&dev->total_close);
- spin_lock(&dev->count_lock);
- if (!--dev->open_count) {
- if (atomic_read(&dev->ioctl_count) || dev->blocked) {
- DRM_ERROR("Device busy: %d %d\n",
- atomic_read(&dev->ioctl_count),
- dev->blocked);
- spin_unlock(&dev->count_lock);
- return -EBUSY;
+ DRM_DEBUG("pid = %d, device = 0x%x, open_count = %d\n",
+ current->pid, dev->device, dev->open_count);
+
+ if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
+ && dev->lock.pid == current->pid) {
+ mga_reclaim_buffers(dev, priv->pid);
+ DRM_ERROR("Process %d dead, freeing lock for context %d\n",
+ current->pid,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ drm_lock_free(dev,
+ &dev->lock.hw_lock->lock,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+
+ /* FIXME: may require heavy-handed reset of
+ hardware at this point, possibly
+ processed via a callback to the X
+ server. */
+ } else if (dev->lock.hw_lock) {
+ /* The lock is required to reclaim buffers */
+ DECLARE_WAITQUEUE(entry, current);
+ add_wait_queue(&dev->lock.lock_queue, &entry);
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ retcode = -EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ dev->lock.pid = priv->pid;
+ dev->lock.lock_time = jiffies;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ current->state = TASK_INTERRUPTIBLE;
+ schedule();
+ if (signal_pending(current)) {
+ retcode = -ERESTARTSYS;
+ break;
}
- spin_unlock(&dev->count_lock);
- return mga_takedown(dev);
}
- spin_unlock(&dev->count_lock);
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->lock.lock_queue, &entry);
+ if(!retcode) {
+ mga_reclaim_buffers(dev, priv->pid);
+ drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT);
+ }
}
+ drm_fasync(-1, filp, 0);
+
+ down(&dev->struct_sem);
+ if (priv->prev) priv->prev->next = priv->next;
+ else dev->file_first = priv->next;
+ if (priv->next) priv->next->prev = priv->prev;
+ else dev->file_last = priv->prev;
+ up(&dev->struct_sem);
+
+ drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
+ MOD_DEC_USE_COUNT;
+ atomic_inc(&dev->total_close);
+ spin_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ spin_unlock(&dev->count_lock);
+ return mga_takedown(dev);
+ }
+ spin_unlock(&dev->count_lock);
return retcode;
}
+
/* drm_ioctl is called whenever a process performs an ioctl on /dev/drm. */
int mga_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h
index bc7808b0a..f217acb97 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h
@@ -2,6 +2,7 @@
* Created: Mon Dec 13 01:50:01 1999 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,51 +24,81 @@
* 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@precisioninsight.com>
- * Jeff Hartmann <jhartmann@precisioninsight.com>
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
*
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_drv.h,v 1.1 2000/02/11 17:26:08 dawes Exp $
*/
#ifndef _MGA_DRV_H_
#define _MGA_DRV_H_
-#include "mga_drm_public.h"
+
+#define MGA_BUF_IN_USE 0
+#define MGA_BUF_SWAP_PENDING 1
+#define MGA_BUF_FORCE_FIRE 2
+#define MGA_BUF_NEEDS_OVERFLOW 3
+
+typedef struct {
+ u32 buffer_status;
+ unsigned int num_dwords;
+ unsigned int max_dwords;
+ u32 *current_dma_ptr;
+ u32 *head;
+ u32 phys_head;
+ unsigned int prim_age;
+ int sec_used;
+ int idx;
+} drm_mga_prim_buf_t;
+
+typedef struct _drm_mga_freelist {
+ unsigned int age;
+ drm_buf_t *buf;
+ struct _drm_mga_freelist *next;
+ struct _drm_mga_freelist *prev;
+} drm_mga_freelist_t;
+
+#define MGA_IN_DISPATCH 0
+#define MGA_IN_FLUSH 1
+#define MGA_IN_WAIT 2
+#define MGA_IN_GETBUF 3
typedef struct _drm_mga_private {
+ u32 dispatch_status;
+ unsigned int next_prim_age;
+ __volatile__ unsigned int last_prim_age;
int reserved_map_idx;
int buffer_map_idx;
drm_mga_sarea_t *sarea_priv;
int primary_size;
int warp_ucode_size;
int chipset;
- int fbOffset;
- int backOffset;
- int depthOffset;
- int textureOffset;
- int textureSize;
+ unsigned int frontOffset;
+ unsigned int backOffset;
+ unsigned int depthOffset;
+ unsigned int textureOffset;
+ unsigned int textureSize;
int cpp;
- int stride;
+ unsigned int stride;
int sgram;
int use_agp;
- mgaWarpIndex WarpIndex[MGA_MAX_G400_PIPES];
- __volatile__ unsigned long softrap_age;
- atomic_t dispatch_lock;
+ drm_mga_warp_index_t WarpIndex[MGA_MAX_G400_PIPES];
+ unsigned int WarpPipe;
atomic_t pending_bufs;
- void *ioremap;
- u32 *prim_head;
- u32 *current_dma_ptr;
- u32 prim_phys_head;
- int prim_num_dwords;
- int prim_max_dwords;
-
-
+ void *status_page;
+ unsigned long real_status_page;
+ u8 *ioremap;
+ drm_mga_prim_buf_t **prim_bufs;
+ drm_mga_prim_buf_t *next_prim;
+ drm_mga_prim_buf_t *last_prim;
+ drm_mga_prim_buf_t *current_prim;
+ int current_prim_idx;
+ drm_mga_freelist_t *head;
+ drm_mga_freelist_t *tail;
+ wait_queue_head_t flush_queue; /* Processes waiting until flush */
+ wait_queue_head_t wait_queue; /* Processes waiting until interrupt */
+ wait_queue_head_t buf_queue; /* Processes waiting for a free buf */
/* Some validated register values:
*/
- u32 frontOrg;
- u32 backOrg;
- u32 depthOrg;
u32 mAccess;
-
} drm_mga_private_t;
/* mga_drv.c */
@@ -92,16 +123,19 @@ extern int mga_control(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int mga_lock(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
-#if 0
-extern void mga_dma_init(drm_device_t *dev);
-extern void mga_dma_cleanup(drm_device_t *dev);
-#endif
+/* mga_dma_init does init and release */
extern int mga_dma_init(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int mga_dma_cleanup(drm_device_t *dev);
-
-/* mga_dma_init does init and release */
+extern int mga_flush_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern void mga_flush_write_combine(void);
+extern unsigned int mga_create_sync_tag(drm_device_t *dev);
+extern drm_buf_t *mga_freelist_get(drm_device_t *dev);
+extern int mga_freelist_put(drm_device_t *dev, drm_buf_t *buf);
+extern int mga_advance_primary(drm_device_t *dev);
+extern void mga_reclaim_buffers(drm_device_t *dev, pid_t pid);
/* mga_bufs.c */
@@ -124,6 +158,10 @@ extern int mga_swap_bufs(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
extern int mga_iload(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
+extern int mga_vertex(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int mga_indices(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
/* mga_context.c */
extern int mga_resctx(struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg);
@@ -144,13 +182,124 @@ extern int mga_context_switch(drm_device_t *dev, int old, int new);
extern int mga_context_switch_complete(drm_device_t *dev, int new);
+typedef enum {
+ TT_GENERAL,
+ TT_BLIT,
+ TT_VECTOR,
+ TT_VERTEX
+} transferType_t;
+
+typedef struct {
+ drm_mga_freelist_t *my_freelist;
+ int discard;
+ int dispatched;
+} drm_mga_buf_priv_t;
+
+#define DWGREG0 0x1c00
+#define DWGREG0_END 0x1dff
+#define DWGREG1 0x2c00
+#define DWGREG1_END 0x2dff
+
+#define ISREG0(r) (r >= DWGREG0 && r <= DWGREG0_END)
+#define ADRINDEX0(r) (u8)((r - DWGREG0) >> 2)
+#define ADRINDEX1(r) (u8)(((r - DWGREG1) >> 2) | 0x80)
+#define ADRINDEX(r) (ISREG0(r) ? ADRINDEX0(r) : ADRINDEX1(r))
+
+#define MGA_VERBOSE 0
+#define MGA_NUM_PRIM_BUFS 8
+
+#define PRIMLOCALS u8 tempIndex[4]; u32 *dma_ptr; u32 phys_head; \
+ int outcount, num_dwords
+
+#define PRIM_OVERFLOW(dev, dev_priv, length) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ if( test_bit(MGA_BUF_NEEDS_OVERFLOW, \
+ &tmp_buf->buffer_status)) { \
+ mga_advance_primary(dev); \
+ mga_dma_schedule(dev, 1); \
+ } else if( tmp_buf->max_dwords - tmp_buf->num_dwords < length ||\
+ tmp_buf->sec_used > MGA_DMA_BUF_NR/2) { \
+ set_bit(MGA_BUF_FORCE_FIRE, &tmp_buf->buffer_status); \
+ mga_advance_primary(dev); \
+ mga_dma_schedule(dev, 1); \
+ } \
+} while(0)
+
+#define PRIMGETPTR(dev_priv) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ if(MGA_VERBOSE) \
+ DRM_DEBUG("PRIMGETPTR in %s\n", __FUNCTION__); \
+ dma_ptr = tmp_buf->current_dma_ptr; \
+ num_dwords = tmp_buf->num_dwords; \
+ phys_head = tmp_buf->phys_head; \
+ outcount = 0; \
+} while(0)
+
+#define PRIMPTR(prim_buf) do { \
+ if(MGA_VERBOSE) \
+ DRM_DEBUG("PRIMPTR in %s\n", __FUNCTION__); \
+ dma_ptr = prim_buf->current_dma_ptr; \
+ num_dwords = prim_buf->num_dwords; \
+ phys_head = prim_buf->phys_head; \
+ outcount = 0; \
+} while(0)
+
+#define PRIMFINISH(prim_buf) do { \
+ if (MGA_VERBOSE) { \
+ DRM_DEBUG( "PRIMFINISH in %s\n", __FUNCTION__); \
+ if (outcount & 3) \
+ DRM_DEBUG(" --- truncation\n"); \
+ } \
+ prim_buf->num_dwords = num_dwords; \
+ prim_buf->current_dma_ptr = dma_ptr; \
+} while(0)
+
+#define PRIMADVANCE(dev_priv) do { \
+drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ if (MGA_VERBOSE) { \
+ DRM_DEBUG("PRIMADVANCE in %s\n", __FUNCTION__); \
+ if (outcount & 3) \
+ DRM_DEBUG(" --- truncation\n"); \
+ } \
+ tmp_buf->num_dwords = num_dwords; \
+ tmp_buf->current_dma_ptr = dma_ptr; \
+} while (0)
+
+#define PRIMUPDATE(dev_priv) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ tmp_buf->sec_used++; \
+} while (0)
+
+#define AGEBUF(dev_priv, buf_priv) do { \
+ drm_mga_prim_buf_t *tmp_buf = \
+ dev_priv->prim_bufs[dev_priv->current_prim_idx]; \
+ buf_priv->my_freelist->age = tmp_buf->prim_age; \
+} while (0)
+
+
+#define PRIMOUTREG(reg, val) do { \
+ tempIndex[outcount]=ADRINDEX(reg); \
+ dma_ptr[1+outcount] = val; \
+ if (MGA_VERBOSE) \
+ DRM_DEBUG(" PRIMOUT %d: 0x%x -- 0x%x\n", \
+ num_dwords + 1 + outcount, ADRINDEX(reg), val); \
+ if( ++outcount == 4) { \
+ outcount = 0; \
+ dma_ptr[0] = *(u32 *)tempIndex; \
+ dma_ptr+=5; \
+ num_dwords += 5; \
+ } \
+}while (0)
+
+/* A reduced set of the mga registers.
+ */
#define MGAREG_MGA_EXEC 0x0100
-#define MGAREG_AGP_PLL 0x1e4c
#define MGAREG_ALPHACTRL 0x2c7c
-#define MGAREG_ALPHASTART 0x2c70
-#define MGAREG_ALPHAXINC 0x2c74
-#define MGAREG_ALPHAYINC 0x2c78
#define MGAREG_AR0 0x1c60
#define MGAREG_AR1 0x1c64
#define MGAREG_AR2 0x1c68
@@ -158,39 +307,16 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new);
#define MGAREG_AR4 0x1c70
#define MGAREG_AR5 0x1c74
#define MGAREG_AR6 0x1c78
-#define MGAREG_BCOL 0x1c20
#define MGAREG_CXBNDRY 0x1c80
#define MGAREG_CXLEFT 0x1ca0
#define MGAREG_CXRIGHT 0x1ca4
#define MGAREG_DMAPAD 0x1c54
-#define MGAREG_DR0_Z32LSB 0x2c50
-#define MGAREG_DR0_Z32MSB 0x2c54
-#define MGAREG_DR2_Z32LSB 0x2c60
-#define MGAREG_DR2_Z32MSB 0x2c64
-#define MGAREG_DR3_Z32LSB 0x2c68
-#define MGAREG_DR3_Z32MSB 0x2c6c
-#define MGAREG_DR0 0x1cc0
-#define MGAREG_DR2 0x1cc8
-#define MGAREG_DR3 0x1ccc
-#define MGAREG_DR4 0x1cd0
-#define MGAREG_DR6 0x1cd8
-#define MGAREG_DR7 0x1cdc
-#define MGAREG_DR8 0x1ce0
-#define MGAREG_DR10 0x1ce8
-#define MGAREG_DR11 0x1cec
-#define MGAREG_DR12 0x1cf0
-#define MGAREG_DR14 0x1cf8
-#define MGAREG_DR15 0x1cfc
#define MGAREG_DSTORG 0x2cb8
-#define MGAREG_DWG_INDIR_WT 0x1e80
#define MGAREG_DWGCTL 0x1c00
#define MGAREG_DWGSYNC 0x2c4c
#define MGAREG_FCOL 0x1c24
#define MGAREG_FIFOSTATUS 0x1e10
#define MGAREG_FOGCOL 0x1cf4
-#define MGAREG_FOGSTART 0x1cc4
-#define MGAREG_FOGXINC 0x1cd4
-#define MGAREG_FOGYINC 0x1ce4
#define MGAREG_FXBNDRY 0x1c84
#define MGAREG_FXLEFT 0x1ca8
#define MGAREG_FXRIGHT 0x1cac
@@ -198,44 +324,22 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new);
#define MGAREG_IEN 0x1e1c
#define MGAREG_LEN 0x1c5c
#define MGAREG_MACCESS 0x1c04
-#define MGAREG_MCTLWTST 0x1c08
-#define MGAREG_MEMRDBK 0x1e44
-#define MGAREG_OPMODE 0x1e54
-#define MGAREG_PAT0 0x1c10
-#define MGAREG_PAT1 0x1c14
#define MGAREG_PITCH 0x1c8c
#define MGAREG_PLNWT 0x1c1c
#define MGAREG_PRIMADDRESS 0x1e58
#define MGAREG_PRIMEND 0x1e5c
#define MGAREG_PRIMPTR 0x1e50
-#define MGAREG_RST 0x1e40
#define MGAREG_SECADDRESS 0x2c40
#define MGAREG_SECEND 0x2c44
#define MGAREG_SETUPADDRESS 0x2cd0
#define MGAREG_SETUPEND 0x2cd4
-#define MGAREG_SGN 0x1c58
-#define MGAREG_SHIFT 0x1c50
#define MGAREG_SOFTRAP 0x2c48
-#define MGAREG_SPECBSTART 0x2c98
-#define MGAREG_SPECBXINC 0x2c9c
-#define MGAREG_SPECBYINC 0x2ca0
-#define MGAREG_SPECGSTART 0x2c8c
-#define MGAREG_SPECGXINC 0x2c90
-#define MGAREG_SPECGYINC 0x2c94
-#define MGAREG_SPECRSTART 0x2c80
-#define MGAREG_SPECRXINC 0x2c84
-#define MGAREG_SPECRYINC 0x2c88
-#define MGAREG_SRC0 0x1c30
-#define MGAREG_SRC1 0x1c34
-#define MGAREG_SRC2 0x1c38
-#define MGAREG_SRC3 0x1c3c
#define MGAREG_SRCORG 0x2cb4
#define MGAREG_STATUS 0x1e14
#define MGAREG_STENCIL 0x2cc8
#define MGAREG_STENCILCTL 0x2ccc
#define MGAREG_TDUALSTAGE0 0x2cf8
#define MGAREG_TDUALSTAGE1 0x2cfc
-#define MGAREG_TEST0 0x1e48
#define MGAREG_TEXBORDERCOL 0x2c5c
#define MGAREG_TEXCTL 0x2c30
#define MGAREG_TEXCTL2 0x2c3c
@@ -249,18 +353,6 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new);
#define MGAREG_TEXTRANS 0x2c34
#define MGAREG_TEXTRANSHIGH 0x2c38
#define MGAREG_TEXWIDTH 0x2c28
-#define MGAREG_TMR0 0x2c00
-#define MGAREG_TMR1 0x2c04
-#define MGAREG_TMR2 0x2c08
-#define MGAREG_TMR3 0x2c0c
-#define MGAREG_TMR4 0x2c10
-#define MGAREG_TMR5 0x2c14
-#define MGAREG_TMR6 0x2c18
-#define MGAREG_TMR7 0x2c1c
-#define MGAREG_TMR8 0x2c20
-#define MGAREG_VBIADDR0 0x3e08
-#define MGAREG_VBIADDR1 0x3e0c
-#define MGAREG_VCOUNT 0x1e20
#define MGAREG_WACCEPTSEQ 0x1dd4
#define MGAREG_WCODEADDR 0x1e6c
#define MGAREG_WFLAG 0x1dc4
@@ -270,18 +362,8 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new);
#define MGAREG_WGETMSB 0x1dc8
#define MGAREG_WIADDR 0x1dc0
#define MGAREG_WIADDR2 0x1dd8
-#define MGAREG_WIADDRNB 0x1e60
-#define MGAREG_WIADDRNB1 0x1e04
-#define MGAREG_WIADDRNB2 0x1e00
-#define MGAREG_WIMEMADDR 0x1e68
-#define MGAREG_WIMEMDATA 0x2000
-#define MGAREG_WIMEMDATA1 0x2100
#define MGAREG_WMISC 0x1e70
-#define MGAREG_WR 0x2d00
#define MGAREG_WVRTXSZ 0x1dcc
-#define MGAREG_XDST 0x1cb0
-#define MGAREG_XYEND 0x1c44
-#define MGAREG_XYSTRT 0x1c40
#define MGAREG_YBOT 0x1c9c
#define MGAREG_YDST 0x1c90
#define MGAREG_YDSTLEN 0x1c88
@@ -289,4 +371,77 @@ extern int mga_context_switch_complete(drm_device_t *dev, int new);
#define MGAREG_YTOP 0x1c98
#define MGAREG_ZORG 0x1c0c
+#define PDEA_pagpxfer_enable 0x2
+
+#define WIA_wmode_suspend 0x0
+#define WIA_wmode_start 0x3
+#define WIA_wagp_agp 0x4
+
+#define DC_opcod_line_open 0x0
+#define DC_opcod_autoline_open 0x1
+#define DC_opcod_line_close 0x2
+#define DC_opcod_autoline_close 0x3
+#define DC_opcod_trap 0x4
+#define DC_opcod_texture_trap 0x6
+#define DC_opcod_bitblt 0x8
+#define DC_opcod_iload 0x9
+#define DC_atype_rpl 0x0
+#define DC_atype_rstr 0x10
+#define DC_atype_zi 0x30
+#define DC_atype_blk 0x40
+#define DC_atype_i 0x70
+#define DC_linear_xy 0x0
+#define DC_linear_linear 0x80
+#define DC_zmode_nozcmp 0x0
+#define DC_zmode_ze 0x200
+#define DC_zmode_zne 0x300
+#define DC_zmode_zlt 0x400
+#define DC_zmode_zlte 0x500
+#define DC_zmode_zgt 0x600
+#define DC_zmode_zgte 0x700
+#define DC_solid_disable 0x0
+#define DC_solid_enable 0x800
+#define DC_arzero_disable 0x0
+#define DC_arzero_enable 0x1000
+#define DC_sgnzero_disable 0x0
+#define DC_sgnzero_enable 0x2000
+#define DC_shftzero_disable 0x0
+#define DC_shftzero_enable 0x4000
+#define DC_bop_SHIFT 16
+#define DC_trans_SHIFT 20
+#define DC_bltmod_bmonolef 0x0
+#define DC_bltmod_bmonowf 0x8000000
+#define DC_bltmod_bplan 0x2000000
+#define DC_bltmod_bfcol 0x4000000
+#define DC_bltmod_bu32bgr 0x6000000
+#define DC_bltmod_bu32rgb 0xe000000
+#define DC_bltmod_bu24bgr 0x16000000
+#define DC_bltmod_bu24rgb 0x1e000000
+#define DC_pattern_disable 0x0
+#define DC_pattern_enable 0x20000000
+#define DC_transc_disable 0x0
+#define DC_transc_enable 0x40000000
+#define DC_clipdis_disable 0x0
+#define DC_clipdis_enable 0x80000000
+
+#define SETADD_mode_vertlist 0x0
+
+
+#define MGA_CLEAR_CMD (DC_opcod_trap | DC_arzero_enable | \
+ DC_sgnzero_enable | DC_shftzero_enable | \
+ (0xC << DC_bop_SHIFT) | DC_clipdis_enable | \
+ DC_solid_enable | DC_transc_enable)
+
+
+#define MGA_COPY_CMD (DC_opcod_bitblt | DC_atype_rpl | DC_linear_xy | \
+ DC_solid_disable | DC_arzero_disable | \
+ DC_sgnzero_enable | DC_shftzero_enable | \
+ (0xC << DC_bop_SHIFT) | DC_bltmod_bfcol | \
+ DC_pattern_disable | DC_transc_disable | \
+ DC_clipdis_enable) \
+
+#define MGA_FLUSH_CMD (DC_opcod_texture_trap | (0xF << DC_trans_SHIFT) |\
+ DC_arzero_enable | DC_sgnzero_enable | \
+ DC_atype_i)
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
index d09881bad..723ccc539 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c
@@ -2,6 +2,7 @@
* Created: Thu Jan 27 02:53:43 2000 by jhartmann@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,340 +24,1044 @@
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
- * Authors: Jeff Hartmann <jhartmann@precisioninsight.com>
- * Keith Whitwell <keithw@precisioninsight.com>
- *
- * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/mga_state.c,v 1.1 2000/02/11 17:26:08 dawes Exp $
+ * Authors: Jeff Hartmann <jhartmann@valinux.com>
+ * Keith Whitwell <keithw@valinux.com>
*
*/
-
+
#define __NO_VERSION__
#include "drmP.h"
#include "mga_drv.h"
-#include "mgareg_flags.h"
-#include "mga_dma.h"
-#include "mga_state.h"
#include "drm.h"
-void mgaEmitClipRect( drm_mga_private_t *dev_priv, xf86drmClipRectRec *box )
+static void mgaEmitClipRect(drm_mga_private_t * dev_priv,
+ drm_clip_rect_t * box)
{
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
- PRIMGETPTR( dev_priv );
+ /* This takes 10 dwords */
+ PRIMGETPTR(dev_priv);
- /* The G400 seems to have an issue with the second WARP not
- * stalling clipper register writes. This bothers me, but the only
- * way I could get it to never clip the last triangle under any
- * circumstances is by inserting TWO dwgsync commands.
- */
- if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
- PRIMOUTREG( MGAREG_DWGSYNC, 0 );
- PRIMOUTREG( MGAREG_DWGSYNC, 0 );
- }
+ /* Force reset of dwgctl (eliminates clip disable) */
+#if 0
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+#else
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0x80000000);
+#endif
- PRIMOUTREG( MGAREG_CXBNDRY, ((box->x2)<<16)|(box->x1) );
- PRIMOUTREG( MGAREG_YTOP, box->y1 * dev_priv->stride );
- PRIMOUTREG( MGAREG_YBOT, box->y2 * dev_priv->stride );
- PRIMADVANCE( dev_priv );
-}
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_CXBNDRY, ((box->x2) << 16) | (box->x1));
+ PRIMOUTREG(MGAREG_YTOP, box->y1 * dev_priv->stride / 2);
+ PRIMOUTREG(MGAREG_YBOT, box->y2 * dev_priv->stride / 2);
+ PRIMADVANCE(dev_priv);
+}
-static void mgaEmitContext(drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv)
+static void mgaEmitContext(drm_mga_private_t * dev_priv)
{
- unsigned int *regs = buf_priv->ContextState;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
PRIMLOCALS;
-
- PRIMGETPTR( dev_priv );
- PRIMOUTREG( MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG] );
- PRIMOUTREG( MGAREG_MACCESS, regs[MGA_CTXREG_MACCESS] );
- PRIMOUTREG( MGAREG_PLNWT, regs[MGA_CTXREG_PLNWT] );
- PRIMOUTREG( MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL] );
- PRIMOUTREG( MGAREG_ALPHACTRL, regs[MGA_CTXREG_ALPHACTRL] );
- PRIMOUTREG( MGAREG_FOGCOL, regs[MGA_CTXREG_FOGCOLOR] );
- PRIMOUTREG( MGAREG_WFLAG, regs[MGA_CTXREG_WFLAG] );
-
- if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
- PRIMOUTREG( MGAREG_WFLAG1, regs[MGA_CTXREG_WFLAG] );
- PRIMOUTREG( MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0] );
- PRIMOUTREG( MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1] );
- }
-
- PRIMADVANCE( dev_priv );
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ /* This takes a max of 15 dwords */
+ PRIMGETPTR(dev_priv);
+
+ PRIMOUTREG(MGAREG_DSTORG, regs[MGA_CTXREG_DSTORG]);
+ PRIMOUTREG(MGAREG_MACCESS, regs[MGA_CTXREG_MACCESS]);
+ PRIMOUTREG(MGAREG_PLNWT, regs[MGA_CTXREG_PLNWT]);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+
+ PRIMOUTREG(MGAREG_ALPHACTRL, regs[MGA_CTXREG_ALPHACTRL]);
+ PRIMOUTREG(MGAREG_FOGCOL, regs[MGA_CTXREG_FOGCOLOR]);
+ PRIMOUTREG(MGAREG_WFLAG, regs[MGA_CTXREG_WFLAG]);
+ PRIMOUTREG(MGAREG_ZORG, dev_priv->depthOffset); /* invarient */
+
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
+ PRIMOUTREG(MGAREG_WFLAG1, regs[MGA_CTXREG_WFLAG]);
+ PRIMOUTREG(MGAREG_TDUALSTAGE0, regs[MGA_CTXREG_TDUAL0]);
+ PRIMOUTREG(MGAREG_TDUALSTAGE1, regs[MGA_CTXREG_TDUAL1]);
+ PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]);
+ } else {
+ PRIMOUTREG(MGAREG_FCOL, regs[MGA_CTXREG_FCOL]);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ }
+
+ PRIMADVANCE(dev_priv);
}
-static void mgaG200EmitTex( drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv )
+static void mgaG200EmitTex(drm_mga_private_t * dev_priv)
{
- unsigned int *regs = buf_priv->TexState[0];
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->TexState[0];
PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes 20 dwords */
+
+ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2]);
+ PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
+ PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]);
+ PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]);
+
+ PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]);
+ PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]);
+ PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]);
+ PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]);
+
+ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
+ PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(0x2d00 + 24 * 4, regs[MGA_TEXREG_WIDTH]);
- PRIMGETPTR( dev_priv );
- PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] );
- PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL] );
- PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER] );
- PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL] );
- PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG] );
- PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1] );
- PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2] );
- PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3] );
- PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4] );
- PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH] );
- PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT] );
-
- PRIMOUTREG(0x2d00 + 24*4, regs[MGA_TEXREG_WIDTH] );
- PRIMOUTREG(0x2d00 + 34*4, regs[MGA_TEXREG_HEIGHT] );
-
- PRIMADVANCE( dev_priv );
+ PRIMOUTREG(0x2d00 + 34 * 4, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
+ PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMADVANCE(dev_priv);
}
-static void mgaG400EmitTex0( drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv )
+static void mgaG400EmitTex0(drm_mga_private_t * dev_priv)
{
- unsigned int *regs = buf_priv->TexState[0];
- int multitex = buf_priv->WarpPipe & MGA_T2;
-
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->TexState[0];
+ int multitex = sarea_priv->WarpPipe & MGA_T2;
PRIMLOCALS;
- PRIMGETPTR( dev_priv );
-
- PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] );
- PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL] );
- PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER] );
- PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL] );
- PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG] );
- PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1] );
- PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2] );
- PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3] );
- PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4] );
- PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH] );
- PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT] );
-
- PRIMOUTREG(0x2d00 + 49*4, 0);
- PRIMOUTREG(0x2d00 + 57*4, 0);
- PRIMOUTREG(0x2d00 + 53*4, 0);
- PRIMOUTREG(0x2d00 + 61*4, 0);
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ PRIMGETPTR(dev_priv);
+
+ /* This takes a max of 30 dwords */
+
+ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000);
+ PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
+ PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]);
+ PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]);
+
+ PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]);
+ PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]);
+ PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]);
+ PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]);
+
+ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
+ PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(0x2d00 + 49 * 4, 0);
+
+ PRIMOUTREG(0x2d00 + 57 * 4, 0);
+ PRIMOUTREG(0x2d00 + 53 * 4, 0);
+ PRIMOUTREG(0x2d00 + 61 * 4, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
if (!multitex) {
- PRIMOUTREG(0x2d00 + 52*4, 0x40 );
- PRIMOUTREG(0x2d00 + 60*4, 0x40 );
- }
+ PRIMOUTREG(0x2d00 + 52 * 4, 0x40);
+ PRIMOUTREG(0x2d00 + 60 * 4, 0x40);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ }
- PRIMOUTREG(0x2d00 + 54*4, regs[MGA_TEXREG_WIDTH] | 0x40 );
- PRIMOUTREG(0x2d00 + 62*4, regs[MGA_TEXREG_HEIGHT] | 0x40 );
+ PRIMOUTREG(0x2d00 + 54 * 4, regs[MGA_TEXREG_WIDTH] | 0x40);
+ PRIMOUTREG(0x2d00 + 62 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
+ PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
- PRIMADVANCE( dev_priv );
+ PRIMADVANCE(dev_priv);
}
-#define TMC_map1_enable 0x80000000
-
+#define TMC_map1_enable 0x80000000
-static void mgaG400EmitTex1( drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv )
+static void mgaG400EmitTex1(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->TexState[1];
-
PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
PRIMGETPTR(dev_priv);
- PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | TMC_map1_enable);
- PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL] );
- PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER] );
- PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL] );
- PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG] );
- PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1] );
- PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2] );
- PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3] );
- PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4] );
- PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH] );
- PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT] );
-
- PRIMOUTREG(0x2d00 + 49*4, 0);
- PRIMOUTREG(0x2d00 + 57*4, 0);
- PRIMOUTREG(0x2d00 + 53*4, 0);
- PRIMOUTREG(0x2d00 + 61*4, 0);
-
- PRIMOUTREG(0x2d00 + 52*4, regs[MGA_TEXREG_WIDTH] | 0x40 );
- PRIMOUTREG(0x2d00 + 60*4, regs[MGA_TEXREG_HEIGHT] | 0x40 );
-
- PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] );
-
- PRIMADVANCE( dev_priv );
-}
+ /* This takes 25 dwords */
+
+ PRIMOUTREG(MGAREG_TEXCTL2,
+ regs[MGA_TEXREG_CTL2] | TMC_map1_enable | 0x00008000);
+ PRIMOUTREG(MGAREG_TEXCTL, regs[MGA_TEXREG_CTL]);
+ PRIMOUTREG(MGAREG_TEXFILTER, regs[MGA_TEXREG_FILTER]);
+ PRIMOUTREG(MGAREG_TEXBORDERCOL, regs[MGA_TEXREG_BORDERCOL]);
+
+ PRIMOUTREG(MGAREG_TEXORG, regs[MGA_TEXREG_ORG]);
+ PRIMOUTREG(MGAREG_TEXORG1, regs[MGA_TEXREG_ORG1]);
+ PRIMOUTREG(MGAREG_TEXORG2, regs[MGA_TEXREG_ORG2]);
+ PRIMOUTREG(MGAREG_TEXORG3, regs[MGA_TEXREG_ORG3]);
+
+ PRIMOUTREG(MGAREG_TEXORG4, regs[MGA_TEXREG_ORG4]);
+ PRIMOUTREG(MGAREG_TEXWIDTH, regs[MGA_TEXREG_WIDTH]);
+ PRIMOUTREG(MGAREG_TEXHEIGHT, regs[MGA_TEXREG_HEIGHT]);
+ PRIMOUTREG(0x2d00 + 49 * 4, 0);
+ PRIMOUTREG(0x2d00 + 57 * 4, 0);
+ PRIMOUTREG(0x2d00 + 53 * 4, 0);
+ PRIMOUTREG(0x2d00 + 61 * 4, 0);
+ PRIMOUTREG(0x2d00 + 52 * 4, regs[MGA_TEXREG_WIDTH] | 0x40);
-static void mgaG400EmitPipe(drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv)
+ PRIMOUTREG(0x2d00 + 60 * 4, regs[MGA_TEXREG_HEIGHT] | 0x40);
+ PRIMOUTREG(MGAREG_TEXTRANS, 0xffff);
+ PRIMOUTREG(MGAREG_TEXTRANSHIGH, 0xffff);
+ PRIMOUTREG(MGAREG_TEXCTL2, regs[MGA_TEXREG_CTL2] | 0x00008000);
+
+ PRIMADVANCE(dev_priv);
+}
+
+#define EMIT_PIPE 50
+static void mgaG400EmitPipe(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int pipe = sarea_priv->WarpPipe;
float fParam = 12800.0f;
PRIMLOCALS;
-
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
PRIMGETPTR(dev_priv);
- PRIMOUTREG(MGAREG_WIADDR2, WIA_wmode_suspend);
-
+
+ /* This takes 50 dwords */
+
/* Establish vertex size.
*/
+ PRIMOUTREG(MGAREG_WIADDR2, WIA_wmode_suspend);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
if (pipe & MGA_T2) {
PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001e09);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x1e000000);
} else {
+ if (dev_priv->WarpPipe & MGA_T2) {
+ /* Flush the WARP pipe */
+ PRIMOUTREG(MGAREG_YDST, 0);
+ PRIMOUTREG(MGAREG_FXLEFT, 0);
+ PRIMOUTREG(MGAREG_FXRIGHT, 1);
+ PRIMOUTREG(MGAREG_DWGCTL, MGA_FLUSH_CMD);
+
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 1);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x7000);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(MGAREG_TEXCTL2, 0 | 0x00008000);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0);
+ PRIMOUTREG(MGAREG_TEXCTL2, 0x80 | 0x00008000);
+ PRIMOUTREG(MGAREG_LEN + MGAREG_MGA_EXEC, 0);
+ }
+
PRIMOUTREG(MGAREG_WVRTXSZ, 0x00001807);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
+ PRIMOUTREG(MGAREG_WACCEPTSEQ, 0);
PRIMOUTREG(MGAREG_WACCEPTSEQ, 0x18000000);
}
-
+
PRIMOUTREG(MGAREG_WFLAG, 0);
PRIMOUTREG(MGAREG_WFLAG1, 0);
-
- PRIMOUTREG(0x2d00 + 56*4, *((u32 *)(&fParam)));
- PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(0x2d00 + 56 * 4, *((u32 *) (&fParam)));
PRIMOUTREG(MGAREG_DMAPAD, 0);
-
- PRIMOUTREG(0x2d00 + 49*4, 0); /* Tex stage 0 */
- PRIMOUTREG(0x2d00 + 57*4, 0); /* Tex stage 0 */
- PRIMOUTREG(0x2d00 + 53*4, 0); /* Tex stage 1 */
- PRIMOUTREG(0x2d00 + 61*4, 0); /* Tex stage 1 */
-
- PRIMOUTREG(0x2d00 + 54*4, 0x40); /* Tex stage 0 : w */
- PRIMOUTREG(0x2d00 + 62*4, 0x40); /* Tex stage 0 : h */
- PRIMOUTREG(0x2d00 + 52*4, 0x40); /* Tex stage 1 : w */
- PRIMOUTREG(0x2d00 + 60*4, 0x40); /* Tex stage 1 : h */
-
+
+ PRIMOUTREG(0x2d00 + 49 * 4, 0); /* Tex stage 0 */
+ PRIMOUTREG(0x2d00 + 57 * 4, 0); /* Tex stage 0 */
+ PRIMOUTREG(0x2d00 + 53 * 4, 0); /* Tex stage 1 */
+ PRIMOUTREG(0x2d00 + 61 * 4, 0); /* Tex stage 1 */
+
+ PRIMOUTREG(0x2d00 + 54 * 4, 0x40); /* Tex stage 0 : w */
+ PRIMOUTREG(0x2d00 + 62 * 4, 0x40); /* Tex stage 0 : h */
+ PRIMOUTREG(0x2d00 + 52 * 4, 0x40); /* Tex stage 1 : w */
+ PRIMOUTREG(0x2d00 + 60 * 4, 0x40); /* Tex stage 1 : h */
+
/* Dma pading required due to hw bug */
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
- PRIMOUTREG(MGAREG_WIADDR2, (dev_priv->WarpIndex[pipe].phys_addr |
- WIA_wmode_start | WIA_wagp_agp));
+ PRIMOUTREG(MGAREG_WIADDR2,
+ (u32) (dev_priv->WarpIndex[pipe].
+ phys_addr | WIA_wmode_start | WIA_wagp_agp));
PRIMADVANCE(dev_priv);
}
-static void mgaG200EmitPipe( drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv )
+static void mgaG200EmitPipe(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int pipe = sarea_priv->WarpPipe;
PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
PRIMGETPTR(dev_priv);
+
+ /* This takes 15 dwords */
+
PRIMOUTREG(MGAREG_WIADDR, WIA_wmode_suspend);
PRIMOUTREG(MGAREG_WVRTXSZ, 7);
PRIMOUTREG(MGAREG_WFLAG, 0);
- PRIMOUTREG(0x2d00 + 24*4, 0); /* tex w/h */
-
- PRIMOUTREG(0x2d00 + 25*4, 0x100);
- PRIMOUTREG(0x2d00 + 34*4, 0); /* tex w/h */
- PRIMOUTREG(0x2d00 + 42*4, 0xFFFF);
- PRIMOUTREG(0x2d00 + 60*4, 0xFFFF);
-
+ PRIMOUTREG(0x2d00 + 24 * 4, 0); /* tex w/h */
+
+ PRIMOUTREG(0x2d00 + 25 * 4, 0x100);
+ PRIMOUTREG(0x2d00 + 34 * 4, 0); /* tex w/h */
+ PRIMOUTREG(0x2d00 + 42 * 4, 0xFFFF);
+ PRIMOUTREG(0x2d00 + 60 * 4, 0xFFFF);
+
/* Dma pading required due to hw bug */
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
PRIMOUTREG(MGAREG_DMAPAD, 0xffffffff);
- PRIMOUTREG(MGAREG_WIADDR, (dev_priv->WarpIndex[pipe].phys_addr |
- WIA_wmode_start | WIA_wagp_agp));
+ PRIMOUTREG(MGAREG_WIADDR,
+ (u32) (dev_priv->WarpIndex[pipe].
+ phys_addr | WIA_wmode_start | WIA_wagp_agp));
- PRIMADVANCE(dev_priv);
+ PRIMADVANCE( dev_priv );
}
-void mgaEmitState( drm_mga_private_t *dev_priv, drm_mga_buf_priv_t *buf_priv )
+static void mgaEmitState(drm_mga_private_t * dev_priv)
{
- unsigned int dirty = buf_priv->dirty;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int dirty = sarea_priv->dirty;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
+ int multitex = sarea_priv->WarpPipe & MGA_T2;
+
+ if (sarea_priv->WarpPipe != dev_priv->WarpPipe) {
+ mgaG400EmitPipe(dev_priv);
+ dev_priv->WarpPipe = sarea_priv->WarpPipe;
+ }
- if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
- if (dirty & MGASAREA_NEW_CONTEXT)
- mgaEmitContext( dev_priv, buf_priv );
+ if (dirty & MGA_UPLOAD_CTX) {
+ mgaEmitContext(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_CTX;
+ }
- if (dirty & MGASAREA_NEW_TEX1)
- mgaG400EmitTex1( dev_priv, buf_priv );
-
- if (dirty & MGASAREA_NEW_TEX0)
- mgaG400EmitTex0( dev_priv, buf_priv );
+ if (dirty & MGA_UPLOAD_TEX0) {
+ mgaG400EmitTex0(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_TEX0;
+ }
- if (dirty & MGASAREA_NEW_PIPE)
- mgaG400EmitPipe( dev_priv, buf_priv );
+ if ((dirty & MGA_UPLOAD_TEX1) && multitex) {
+ mgaG400EmitTex1(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_TEX1;
+ }
} else {
- if (dirty & MGASAREA_NEW_CONTEXT)
- mgaEmitContext( dev_priv, buf_priv );
+ if (sarea_priv->WarpPipe != dev_priv->WarpPipe) {
+ mgaG200EmitPipe(dev_priv);
+ dev_priv->WarpPipe = sarea_priv->WarpPipe;
+ }
- if (dirty & MGASAREA_NEW_TEX0)
- mgaG200EmitTex( dev_priv, buf_priv );
+ if (dirty & MGA_UPLOAD_CTX) {
+ mgaEmitContext(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_CTX;
+ }
- if (dirty & MGASAREA_NEW_PIPE)
- mgaG200EmitPipe( dev_priv, buf_priv );
- }
+ if (dirty & MGA_UPLOAD_TEX0) {
+ mgaG200EmitTex(dev_priv);
+ sarea_priv->dirty &= ~MGA_UPLOAD_TEX0;
+ }
+ }
}
-
/* Disallow all write destinations except the front and backbuffer.
*/
-static int mgaCopyContext(drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv)
+static int mgaVerifyContext(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
unsigned int *regs = sarea_priv->ContextState;
-
- if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOrg &&
- regs[MGA_CTXREG_DSTORG] != dev_priv->backOrg)
+
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (regs[MGA_CTXREG_DSTORG] != dev_priv->frontOffset &&
+ regs[MGA_CTXREG_DSTORG] != dev_priv->backOffset) {
+ DRM_DEBUG("BAD DSTORG: %x (front %x, back %x)\n\n",
+ regs[MGA_CTXREG_DSTORG], dev_priv->frontOffset,
+ dev_priv->backOffset);
+ regs[MGA_CTXREG_DSTORG] = 0;
return -1;
+ }
- memcpy(buf_priv->ContextState, sarea_priv->ContextState,
- sizeof(buf_priv->ContextState));
return 0;
}
-
/* Disallow texture reads from PCI space.
*/
-static int mgaCopyTex(drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv,
- int unit)
+static int mgaVerifyTex(drm_mga_private_t * dev_priv, int unit)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1)
- return -1;
+ DRM_DEBUG("%s\n", __FUNCTION__);
- memcpy(buf_priv->TexState[unit], sarea_priv->TexState[unit],
- sizeof(buf_priv->TexState[0]));
+ if ((sarea_priv->TexState[unit][MGA_TEXREG_ORG] & 0x3) == 0x1) {
+ DRM_DEBUG("BAD TEXREG_ORG: %x, unit %d\n",
+ sarea_priv->TexState[unit][MGA_TEXREG_ORG],
+ unit);
+ sarea_priv->TexState[unit][MGA_TEXREG_ORG] = 0;
+ return -1;
+ }
return 0;
}
-
-int mgaCopyAndVerifyState( drm_mga_private_t *dev_priv,
- drm_mga_buf_priv_t *buf_priv )
+static int mgaVerifyState(drm_mga_private_t * dev_priv)
{
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
- unsigned int dirty = sarea_priv->dirty ;
+ unsigned int dirty = sarea_priv->dirty;
int rv = 0;
- buf_priv->dirty = sarea_priv->dirty;
- buf_priv->WarpPipe = sarea_priv->WarpPipe;
-
- if (dirty & MGASAREA_NEW_CONTEXT)
- rv |= mgaCopyContext( dev_priv, buf_priv );
-
- if (dirty & MGASAREA_NEW_TEX0)
- rv |= mgaCopyTex( dev_priv, buf_priv, 0 );
-
- if (dev_priv->chipset == MGA_CARD_TYPE_G400)
- {
- if (dirty & MGASAREA_NEW_TEX1)
- rv |= mgaCopyTex( dev_priv, buf_priv, 1 );
-
- if (dirty & MGASAREA_NEW_PIPE)
- rv |= (buf_priv->WarpPipe > MGA_MAX_G400_PIPES);
- }
- else
- {
- if (dirty & MGASAREA_NEW_PIPE)
- rv |= (buf_priv->WarpPipe > MGA_MAX_G200_PIPES);
- }
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
+ sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
+
+ if (dirty & MGA_UPLOAD_CTX)
+ rv |= mgaVerifyContext(dev_priv);
+
+ if (dirty & MGA_UPLOAD_TEX0)
+ rv |= mgaVerifyTex(dev_priv, 0);
+
+ if (dev_priv->chipset == MGA_CARD_TYPE_G400) {
+ if (dirty & MGA_UPLOAD_TEX1)
+ rv |= mgaVerifyTex(dev_priv, 1);
+
+ if (dirty & MGA_UPLOAD_PIPE)
+ rv |= (sarea_priv->WarpPipe > MGA_MAX_G400_PIPES);
+ } else {
+ if (dirty & MGA_UPLOAD_PIPE)
+ rv |= (sarea_priv->WarpPipe > MGA_MAX_G200_PIPES);
+ }
return rv == 0;
}
+static int mgaVerifyIload(drm_mga_private_t * dev_priv,
+ unsigned long bus_address,
+ unsigned int dstOrg, int length)
+{
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (dstOrg < dev_priv->textureOffset ||
+ dstOrg + length >
+ (dev_priv->textureOffset + dev_priv->textureSize)) {
+ return -EINVAL;
+ }
+ if (length % 64) {
+ return -EINVAL;
+ }
+ return 0;
+}
+
+/* This copies a 64 byte aligned agp region to the frambuffer
+ * with a standard blit, the ioctl needs to do checking */
+
+static void mga_dma_dispatch_tex_blit(drm_device_t * dev,
+ unsigned long bus_address,
+ int length, unsigned int destOrg)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ int use_agp = PDEA_pagpxfer_enable | 0x00000001;
+ u16 y2;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ y2 = length / 64;
+
+ PRIM_OVERFLOW(dev, dev_priv, 30);
+ PRIMGETPTR(dev_priv);
+
+ PRIMOUTREG(MGAREG_DSTORG, destOrg);
+ PRIMOUTREG(MGAREG_MACCESS, 0x00000000);
+ DRM_DEBUG("srcorg : %lx\n", bus_address | use_agp);
+ PRIMOUTREG(MGAREG_SRCORG, (u32) bus_address | use_agp);
+ PRIMOUTREG(MGAREG_AR5, 64);
+
+ PRIMOUTREG(MGAREG_PITCH, 64);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, MGA_COPY_CMD);
+
+ PRIMOUTREG(MGAREG_AR0, 63);
+ PRIMOUTREG(MGAREG_AR3, 0);
+ PRIMOUTREG(MGAREG_FXBNDRY, (63 << 16));
+ PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC, y2);
+
+ PRIMOUTREG(MGAREG_SRCORG, 0);
+ PRIMOUTREG(MGAREG_PITCH, dev_priv->stride / dev_priv->cpp);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMADVANCE(dev_priv);
+}
+
+static void mga_dma_dispatch_vertex(drm_device_t * dev, drm_buf_t * buf)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned long address = (unsigned long) buf->bus_address;
+ int length = buf->used;
+ int use_agp = PDEA_pagpxfer_enable;
+ int i = 0;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ DRM_DEBUG("dispatch vertex %d addr 0x%lx, "
+ "length 0x%x nbox %d dirty %x\n",
+ buf->idx, address, length,
+ sarea_priv->nbox, sarea_priv->dirty);
+
+ DRM_DEBUG("used : %d, total : %d\n", buf->used, buf->total);
+
+ if (buf->used) {
+ /* WARNING: if you change any of the state functions verify
+ * these numbers (Overestimating this doesn't hurt).
+ */
+ buf_priv->dispatched = 1;
+ primary_needed = (50 + 15 + 15 + 30 + 25 +
+ 10 + 15 * MGA_NR_SAREA_CLIPRECTS);
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ mgaEmitState(dev_priv);
+ do {
+ if (i < sarea_priv->nbox) {
+ DRM_DEBUG("idx %d Emit box %d/%d:"
+ "%d,%d - %d,%d\n",
+ buf->idx,
+ i, sarea_priv->nbox,
+ sarea_priv->boxes[i].x1,
+ sarea_priv->boxes[i].y1,
+ sarea_priv->boxes[i].x2,
+ sarea_priv->boxes[i].y2);
+
+ mgaEmitClipRect(dev_priv,
+ &sarea_priv->boxes[i]);
+ }
+
+ PRIMGETPTR(dev_priv);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_SECADDRESS,
+ ((u32) address) | TT_VERTEX);
+ PRIMOUTREG(MGAREG_SECEND,
+ (((u32) (address + length)) | use_agp));
+ PRIMADVANCE(dev_priv);
+ } while (++i < sarea_priv->nbox);
+ }
+ if (buf_priv->discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+
+
+}
+
+
+static void mga_dma_dispatch_indices(drm_device_t * dev,
+ drm_buf_t * buf,
+ unsigned int start, unsigned int end)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_buf_priv_t *buf_priv = buf->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int address = (unsigned int) buf->bus_address;
+ int use_agp = PDEA_pagpxfer_enable;
+ int i = 0;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ DRM_DEBUG("dispatch indices %d addr 0x%x, "
+ "start 0x%x end 0x%x nbox %d dirty %x\n",
+ buf->idx, address, start, end,
+ sarea_priv->nbox, sarea_priv->dirty);
+
+ if (start != end) {
+ /* WARNING: if you change any of the state functions verify
+ * these numbers (Overestimating this doesn't hurt).
+ */
+ buf_priv->dispatched = 1;
+ primary_needed = (50 + 15 + 15 + 30 + 25 +
+ 10 + 15 * MGA_NR_SAREA_CLIPRECTS);
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ mgaEmitState(dev_priv);
+
+ do {
+ if (i < sarea_priv->nbox) {
+ DRM_DEBUG("idx %d Emit box %d/%d:"
+ "%d,%d - %d,%d\n",
+ buf->idx,
+ i, sarea_priv->nbox,
+ sarea_priv->boxes[i].x1,
+ sarea_priv->boxes[i].y1,
+ sarea_priv->boxes[i].x2,
+ sarea_priv->boxes[i].y2);
+
+ mgaEmitClipRect(dev_priv,
+ &sarea_priv->boxes[i]);
+ }
+
+ PRIMGETPTR(dev_priv);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_SETUPADDRESS,
+ ((address + start) |
+ SETADD_mode_vertlist));
+ PRIMOUTREG(MGAREG_SETUPEND,
+ ((address + end) | use_agp));
+ PRIMADVANCE(dev_priv);
+ } while (++i < sarea_priv->nbox);
+ }
+ if (buf_priv->discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+}
+
+
+static void mga_dma_dispatch_clear(drm_device_t * dev, int flags,
+ unsigned int clear_color,
+ unsigned int clear_zval)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+ int nbox = sarea_priv->nbox;
+ drm_clip_rect_t *pbox = sarea_priv->boxes;
+ unsigned int cmd;
+ int i;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (dev_priv->sgram)
+ cmd = MGA_CLEAR_CMD | DC_atype_blk;
+ else
+ cmd = MGA_CLEAR_CMD | DC_atype_rstr;
+
+ primary_needed = nbox * 70;
+ if (primary_needed == 0)
+ primary_needed = 70;
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ PRIMGETPTR(dev_priv);
+
+ for (i = 0; i < nbox; i++) {
+ unsigned int height = pbox[i].y2 - pbox[i].y1;
+
+ DRM_DEBUG("dispatch clear %d,%d-%d,%d flags %x!\n",
+ pbox[i].x1, pbox[i].y1, pbox[i].x2,
+ pbox[i].y2, flags);
+
+ if (flags & MGA_FRONT) {
+ DRM_DEBUG("clear front\n");
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_YDSTLEN,
+ (pbox[i].y1 << 16) | height);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ (pbox[i].x2 << 16) | pbox[i].x1);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_FCOL, clear_color);
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset);
+ PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd);
+ }
+
+ if (flags & MGA_BACK) {
+ DRM_DEBUG("clear back\n");
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_YDSTLEN,
+ (pbox[i].y1 << 16) | height);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ (pbox[i].x2 << 16) | pbox[i].x1);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_FCOL, clear_color);
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->backOffset);
+ PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd);
+ }
+
+ if (flags & MGA_DEPTH) {
+ DRM_DEBUG("clear depth\n");
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_YDSTLEN,
+ (pbox[i].y1 << 16) | height);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ (pbox[i].x2 << 16) | pbox[i].x1);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_FCOL, clear_zval);
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->depthOffset);
+ PRIMOUTREG(MGAREG_DWGCTL + MGAREG_MGA_EXEC, cmd);
+ }
+ }
+
+ /* Force reset of DWGCTL */
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+ PRIMADVANCE(dev_priv);
+}
+
+static void mga_dma_dispatch_swap(drm_device_t * dev)
+{
+ drm_mga_private_t *dev_priv = dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ unsigned int *regs = sarea_priv->ContextState;
+ int nbox = sarea_priv->nbox;
+ drm_clip_rect_t *pbox = sarea_priv->boxes;
+ int i;
+ int primary_needed;
+ PRIMLOCALS;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ primary_needed = nbox * 5;
+ primary_needed += 65;
+ PRIM_OVERFLOW(dev, dev_priv, primary_needed);
+ PRIMGETPTR(dev_priv);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x7100);
+ PRIMOUTREG(MGAREG_DWGSYNC, 0x7000);
+
+ PRIMOUTREG(MGAREG_DSTORG, dev_priv->frontOffset);
+ PRIMOUTREG(MGAREG_MACCESS, dev_priv->mAccess);
+ PRIMOUTREG(MGAREG_SRCORG, dev_priv->backOffset);
+ PRIMOUTREG(MGAREG_AR5, dev_priv->stride / 2);
+
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, MGA_COPY_CMD);
+
+ for (i = 0; i < nbox; i++) {
+ unsigned int h = pbox[i].y2 - pbox[i].y1;
+ unsigned int start = pbox[i].y1 * dev_priv->stride / 2;
+
+ DRM_DEBUG("dispatch swap %d,%d-%d,%d!\n",
+ pbox[i].x1, pbox[i].y1, pbox[i].x2, pbox[i].y2);
+
+ PRIMOUTREG(MGAREG_AR0, start + pbox[i].x2 - 1);
+ PRIMOUTREG(MGAREG_AR3, start + pbox[i].x1);
+ PRIMOUTREG(MGAREG_FXBNDRY,
+ pbox[i].x1 | ((pbox[i].x2 - 1) << 16));
+ PRIMOUTREG(MGAREG_YDSTLEN + MGAREG_MGA_EXEC,
+ (pbox[i].y1 << 16) | h);
+ }
+
+ /* Force reset of DWGCTL */
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_DMAPAD, 0);
+ PRIMOUTREG(MGAREG_SRCORG, 0);
+ PRIMOUTREG(MGAREG_DWGCTL, regs[MGA_CTXREG_DWGCTL]);
+
+ PRIMADVANCE(dev_priv);
+}
+
+int mga_clear_bufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ drm_mga_clear_t clear;
+
+ copy_from_user_ret(&clear, (drm_mga_clear_t *) arg, sizeof(clear),
+ -EFAULT);
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_clear_bufs called without lock held\n");
+ return -EINVAL;
+ }
+
+ if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
+ sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
+
+ /* Make sure we restore the 3D state next time.
+ */
+ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX;
+ mga_dma_dispatch_clear(dev, clear.flags,
+ clear.clear_color, clear.clear_depth);
+ PRIMUPDATE(dev_priv);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+int mga_swap_bufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_swap_bufs called without lock held\n");
+ return -EINVAL;
+ }
+
+ if (sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS)
+ sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
+
+ /* Make sure we restore the 3D state next time.
+ */
+ dev_priv->sarea_priv->dirty |= MGA_UPLOAD_CTX;
+ mga_dma_dispatch_swap(dev);
+ PRIMUPDATE(dev_priv);
+ set_bit(MGA_BUF_SWAP_PENDING,
+ &dev_priv->current_prim->buffer_status);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+int mga_iload(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_iload_t iload;
+ unsigned long bus_address;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ DRM_DEBUG("Starting Iload\n");
+ copy_from_user_ret(&iload, (drm_mga_iload_t *) arg, sizeof(iload),
+ -EFAULT);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_iload called without lock held\n");
+ return -EINVAL;
+ }
+
+ buf = dma->buflist[iload.idx];
+ buf_priv = buf->dev_private;
+ bus_address = buf->bus_address;
+ DRM_DEBUG("bus_address %lx, length %d, destorg : %x\n",
+ bus_address, iload.length, iload.destOrg);
+
+ if (mgaVerifyIload(dev_priv,
+ bus_address, iload.destOrg, iload.length)) {
+ mga_freelist_put(dev, buf);
+ return -EINVAL;
+ }
+
+ sarea_priv->dirty |= MGA_UPLOAD_CTX;
+
+ mga_dma_dispatch_tex_blit(dev, bus_address, iload.length,
+ iload.destOrg);
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->discard = 1;
+ mga_freelist_put(dev, buf);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+int mga_vertex(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_vertex_t vertex;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ copy_from_user_ret(&vertex, (drm_mga_vertex_t *) arg,
+ sizeof(vertex), -EFAULT);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_vertex called without lock held\n");
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("mga_vertex\n");
+
+ buf = dma->buflist[vertex.idx];
+ buf_priv = buf->dev_private;
+
+ buf->used = vertex.used;
+ buf_priv->discard = vertex.discard;
+
+ if (!mgaVerifyState(dev_priv)) {
+ if (vertex.discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+ DRM_DEBUG("bad state\n");
+ return -EINVAL;
+ }
+
+ mga_dma_dispatch_vertex(dev, buf);
+
+ PRIMUPDATE(dev_priv);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+
+int mga_indices(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_mga_private_t *dev_priv =
+ (drm_mga_private_t *) dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_t *buf;
+ drm_mga_buf_priv_t *buf_priv;
+ drm_mga_indices_t indices;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ copy_from_user_ret(&indices, (drm_mga_indices_t *) arg,
+ sizeof(indices), -EFAULT);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_indices called without lock held\n");
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("mga_indices\n");
+
+ buf = dma->buflist[indices.idx];
+ buf_priv = buf->dev_private;
+
+ buf_priv->discard = indices.discard;
+
+ if (!mgaVerifyState(dev_priv)) {
+ if (indices.discard) {
+ if (buf_priv->dispatched == 1)
+ AGEBUF(dev_priv, buf_priv);
+ buf_priv->dispatched = 0;
+ mga_freelist_put(dev, buf);
+ }
+ return -EINVAL;
+ }
+
+ mga_dma_dispatch_indices(dev, buf, indices.start, indices.end);
+
+ PRIMUPDATE(dev_priv);
+ mga_flush_write_combine();
+ mga_dma_schedule(dev, 1);
+ return 0;
+}
+
+
+
+static int mga_dma_get_buffers(drm_device_t * dev, drm_dma_t * d)
+{
+ int i;
+ drm_buf_t *buf;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ for (i = d->granted_count; i < d->request_count; i++) {
+ buf = mga_freelist_get(dev);
+ if (!buf)
+ break;
+ buf->pid = current->pid;
+ copy_to_user_ret(&d->request_indices[i],
+ &buf->idx, sizeof(buf->idx), -EFAULT);
+ copy_to_user_ret(&d->request_sizes[i],
+ &buf->total, sizeof(buf->total), -EFAULT);
+ ++d->granted_count;
+ }
+ return 0;
+}
+
+int mga_dma(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ drm_dma_t d;
+ DRM_DEBUG("%s\n", __FUNCTION__);
+
+ copy_from_user_ret(&d, (drm_dma_t *) arg, sizeof(d), -EFAULT);
+ DRM_DEBUG("%d %d: %d send, %d req\n",
+ current->pid, d.context, d.send_count, d.request_count);
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("mga_dma called without lock held\n");
+ return -EINVAL;
+ }
+
+ /* Please don't send us buffers.
+ */
+ if (d.send_count != 0) {
+ DRM_ERROR
+ ("Process %d trying to send %d buffers via drmDMA\n",
+ current->pid, d.send_count);
+ return -EINVAL;
+ }
+
+ /* We'll send you buffers.
+ */
+ if (d.request_count < 0 || d.request_count > dma->buf_count) {
+ DRM_ERROR
+ ("Process %d trying to get %d buffers (of %d max)\n",
+ current->pid, d.request_count, dma->buf_count);
+ return -EINVAL;
+ }
+ d.granted_count = 0;
+
+ if (d.request_count) {
+ retcode = mga_dma_get_buffers(dev, &d);
+ }
+
+ DRM_DEBUG("%d returning, granted = %d\n",
+ current->pid, d.granted_count);
+ copy_to_user_ret((drm_dma_t *) arg, &d, sizeof(d), -EFAULT);
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c
index ecdb2c15a..0bd8bfd57 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/picker.c
@@ -9,6 +9,16 @@
#define CONFIG_MODVERSIONS 0
#endif
+#ifndef CONFIG_AGP_MODULE
+#define CONFIG_AGP_MODULE 0
+#endif
+
+#ifndef CONFIG_AGP
+#define CONFIG_AGP 0
+#endif
+
SMP = CONFIG_SMP
MODVERSIONS = CONFIG_MODVERSIONS
+AGP = CONFIG_AGP
+AGP_MODULE = CONFIG_AGP_MODULE
RELEASE = UTS_RELEASE
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c
index 54aba58c4..ba6dee00d 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/proc.c
@@ -1,8 +1,8 @@
/* proc.c -- /proc support for DRM -*- linux-c -*-
* Created: Mon Jan 11 09:48:47 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:41:04 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -23,9 +23,9 @@
* OTHER LIABILITY, WHETHER IN AN ACTION 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/linux/drm/kernel/proc.c,v 1.6 2000/02/23 04:47:30 martin Exp $
*
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*/
#define __NO_VERSION__
@@ -164,7 +164,10 @@ static int _drm_vm_info(char *buf, char **start, off_t offset, int len,
{
drm_device_t *dev = (drm_device_t *)data;
drm_map_t *map;
- const char *types[] = { "FB", "REG", "SHM" };
+ /* Hardcoded from _DRM_FRAME_BUFFER,
+ _DRM_REGISTERS, _DRM_SHM, and
+ _DRM_AGP. */
+ const char *types[] = { "FB", "REG", "SHM", "AGP" };
const char *type;
int i;
@@ -175,7 +178,7 @@ static int _drm_vm_info(char *buf, char **start, off_t offset, int len,
"address mtrr\n\n");
for (i = 0; i < dev->map_count; i++) {
map = dev->maplist[i];
- if (map->type < 0 || map->type > 2) type = "??";
+ if (map->type < 0 || map->type > 3) type = "??";
else type = types[map->type];
DRM_PROC_PRINT("%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx ",
i,
@@ -397,6 +400,7 @@ static int _drm_vma_info(char *buf, char **start, off_t offset, int len,
pgprot & _PAGE_GLOBAL ? 'g' : 'l' );
#endif
DRM_PROC_PRINT("\n");
+#if 0
for (i = vma->vm_start; i < vma->vm_end; i += PAGE_SIZE) {
pgd = pgd_offset(vma->vm_mm, i);
pmd = pmd_offset(pgd, i);
@@ -417,6 +421,7 @@ static int _drm_vma_info(char *buf, char **start, off_t offset, int len,
DRM_PROC_PRINT(" 0x%08lx\n", i);
}
}
+#endif
}
return len;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c
new file mode 100644
index 000000000..e8ff4df43
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_bufs.c
@@ -0,0 +1,308 @@
+/* r128_bufs.c -- IOCTLs to manage buffers -*- linux-c -*-
+ * Created: Wed Apr 12 16:19:08 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Kevin E. Martin <martin@valinux.com>
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Jeff Hartmann <jhartmann@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "r128_drv.h"
+#include "linux/un.h"
+
+
+#ifdef DRM_AGP
+int r128_addbufs_agp(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_device_dma_t *dma = dev->dma;
+ drm_buf_desc_t request;
+ drm_buf_entry_t *entry;
+ drm_buf_t *buf;
+ unsigned long offset;
+ unsigned long agp_offset;
+ int count;
+ int order;
+ int size;
+ int alignment;
+ int page_order;
+ int total;
+ int byte_count;
+ int i;
+
+ if (!dma) return -EINVAL;
+
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+ count = request.count;
+ order = drm_order(request.size);
+ size = 1 << order;
+
+ alignment = (request.flags & _DRM_PAGE_ALIGN) ? PAGE_ALIGN(size):size;
+ page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
+ total = PAGE_SIZE << page_order;
+
+ byte_count = 0;
+ agp_offset = dev->agp->base + request.agp_start;
+
+ DRM_DEBUG("count: %d\n", count);
+ DRM_DEBUG("order: %d\n", order);
+ DRM_DEBUG("size: %d\n", size);
+ DRM_DEBUG("agp_offset: %ld\n", agp_offset);
+ DRM_DEBUG("alignment: %d\n", alignment);
+ DRM_DEBUG("page_order: %d\n", page_order);
+ DRM_DEBUG("total: %d\n", total);
+
+ if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER) return -EINVAL;
+ if (dev->queue_count) return -EBUSY; /* Not while in use */
+
+ spin_lock(&dev->count_lock);
+ if (dev->buf_use) {
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ atomic_inc(&dev->buf_alloc);
+ spin_unlock(&dev->count_lock);
+
+ down(&dev->struct_sem);
+ entry = &dma->bufs[order];
+ if (entry->buf_count) {
+ up(&dev->struct_sem);
+ atomic_dec(&dev->buf_alloc);
+ return -ENOMEM; /* May only call once for each order */
+ }
+
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
+ if (!entry->buflist) {
+ up(&dev->struct_sem);
+ atomic_dec(&dev->buf_alloc);
+ return -ENOMEM;
+ }
+ memset(entry->buflist, 0, count * sizeof(*entry->buflist));
+
+ entry->buf_size = size;
+ entry->page_order = page_order;
+ offset = 0;
+
+ for (offset = 0;
+ entry->buf_count < count;
+ offset += alignment, ++entry->buf_count) {
+ buf = &entry->buflist[entry->buf_count];
+ buf->idx = dma->buf_count + entry->buf_count;
+ buf->total = alignment;
+ buf->order = order;
+ buf->used = 0;
+ buf->offset = (dma->byte_count + offset);
+ buf->address = (void *)(agp_offset + offset);
+ buf->next = NULL;
+ buf->waiting = 0;
+ buf->pending = 0;
+ init_waitqueue_head(&buf->dma_wait);
+ buf->pid = 0;
+
+ buf->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ buf->dev_private = drm_alloc(sizeof(drm_r128_buf_priv_t),
+ DRM_MEM_BUFS);
+ memset(buf->dev_private, 0, buf->dev_priv_size);
+
+#if DRM_DMA_HISTOGRAM
+ buf->time_queued = 0;
+ buf->time_dispatched = 0;
+ buf->time_completed = 0;
+ buf->time_freed = 0;
+#endif
+
+ byte_count += PAGE_SIZE << page_order;
+
+ DRM_DEBUG("buffer %d @ %p\n",
+ entry->buf_count, buf->address);
+ }
+
+ DRM_DEBUG("byte_count: %d\n", byte_count);
+
+ dma->buflist = drm_realloc(dma->buflist,
+ dma->buf_count * sizeof(*dma->buflist),
+ (dma->buf_count + entry->buf_count)
+ * sizeof(*dma->buflist),
+ DRM_MEM_BUFS);
+ for (i = dma->buf_count; i < dma->buf_count + entry->buf_count; i++)
+ dma->buflist[i] = &entry->buflist[i - dma->buf_count];
+
+ dma->buf_count += entry->buf_count;
+ dma->byte_count += byte_count;
+
+ drm_freelist_create(&entry->freelist, entry->buf_count);
+ for (i = 0; i < entry->buf_count; i++) {
+ drm_freelist_put(dev, &entry->freelist, &entry->buflist[i]);
+ }
+
+ up(&dev->struct_sem);
+
+ request.count = entry->buf_count;
+ request.size = size;
+
+ copy_to_user_ret((drm_buf_desc_t *)arg,
+ &request,
+ sizeof(request),
+ -EFAULT);
+
+ dma->flags = _DRM_DMA_USE_AGP;
+
+ atomic_dec(&dev->buf_alloc);
+ return 0;
+}
+#endif
+
+int r128_addbufs(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_buf_desc_t request;
+
+ if (!dev_priv || dev_priv->is_pci) return -EINVAL;
+
+ copy_from_user_ret(&request,
+ (drm_buf_desc_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+#ifdef DRM_AGP
+ if (request.flags & _DRM_AGP_BUFFER)
+ return r128_addbufs_agp(inode, filp, cmd, arg);
+ else
+#endif
+ return -EINVAL;
+}
+
+int r128_mapbufs(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ const int zero = 0;
+ unsigned long virtual;
+ unsigned long address;
+ drm_buf_map_t request;
+ int i;
+
+ if (!dma || !dev_priv || dev_priv->is_pci) return -EINVAL;
+
+ DRM_DEBUG("\n");
+
+ spin_lock(&dev->count_lock);
+ if (atomic_read(&dev->buf_alloc)) {
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ ++dev->buf_use; /* Can't allocate more after this call */
+ spin_unlock(&dev->count_lock);
+
+ copy_from_user_ret(&request,
+ (drm_buf_map_t *)arg,
+ sizeof(request),
+ -EFAULT);
+
+ if (request.count >= dma->buf_count) {
+ if (dma->flags & _DRM_DMA_USE_AGP) {
+ drm_map_t *map;
+
+ map = dev_priv->agp_vertbufs;
+ if (!map) {
+ retcode = -EINVAL;
+ goto done;
+ }
+
+ down(&current->mm->mmap_sem);
+ virtual = do_mmap(filp, 0, map->size,
+ PROT_READ|PROT_WRITE,
+ MAP_SHARED,
+ (unsigned long)map->offset);
+ up(&current->mm->mmap_sem);
+ } else {
+ down(&current->mm->mmap_sem);
+ virtual = do_mmap(filp, 0, dma->byte_count,
+ PROT_READ|PROT_WRITE, MAP_SHARED, 0);
+ up(&current->mm->mmap_sem);
+ }
+ if (virtual > -1024UL) {
+ /* Real error */
+ retcode = (signed long)virtual;
+ goto done;
+ }
+ request.virtual = (void *)virtual;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ if (copy_to_user(&request.list[i].idx,
+ &dma->buflist[i]->idx,
+ sizeof(request.list[0].idx))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ if (copy_to_user(&request.list[i].total,
+ &dma->buflist[i]->total,
+ sizeof(request.list[0].total))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ if (copy_to_user(&request.list[i].used,
+ &zero,
+ sizeof(zero))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ address = virtual + dma->buflist[i]->offset;
+ if (copy_to_user(&request.list[i].address,
+ &address,
+ sizeof(address))) {
+ retcode = -EFAULT;
+ goto done;
+ }
+ }
+ }
+ done:
+ request.count = dma->buf_count;
+ DRM_DEBUG("%d buffers, retcode = %d\n", request.count, retcode);
+
+ copy_to_user_ret((drm_buf_map_t *)arg,
+ &request,
+ sizeof(request),
+ -EFAULT);
+
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c
new file mode 100644
index 000000000..f11453ba1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_context.c
@@ -0,0 +1,213 @@
+/* r128_context.c -- IOCTLs for r128 contexts -*- linux-c -*-
+ * Created: Mon Dec 13 09:51:35 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ */
+
+#include <linux/sched.h>
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "r128_drv.h"
+
+extern drm_ctx_t r128_res_ctx;
+
+static int r128_alloc_queue(drm_device_t *dev)
+{
+#if 0
+ static int context = 0;
+#endif
+
+ return drm_ctxbitmap_next(dev);
+}
+
+int r128_context_switch(drm_device_t *dev, int old, int new)
+{
+ char buf[64];
+
+ atomic_inc(&dev->total_ctx);
+
+ if (test_and_set_bit(0, &dev->context_flag)) {
+ DRM_ERROR("Reentering -- FIXME\n");
+ return -EBUSY;
+ }
+
+#if DRM_DMA_HISTOGRAM
+ dev->ctx_start = get_cycles();
+#endif
+
+ DRM_DEBUG("Context switch from %d to %d\n", old, new);
+
+ if (new == dev->last_context) {
+ clear_bit(0, &dev->context_flag);
+ return 0;
+ }
+
+ if (drm_flags & DRM_FLAG_NOCTX) {
+ r128_context_switch_complete(dev, new);
+ } else {
+ sprintf(buf, "C %d %d\n", old, new);
+ drm_write_string(dev, buf);
+ }
+
+ return 0;
+}
+
+int r128_context_switch_complete(drm_device_t *dev, int new)
+{
+ dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
+ dev->last_switch = jiffies;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) {
+ DRM_ERROR("Lock isn't held after context switch\n");
+ }
+
+ /* If a context switch is ever initiated
+ when the kernel holds the lock, release
+ that lock here. */
+#if DRM_DMA_HISTOGRAM
+ atomic_inc(&dev->histo.ctx[drm_histogram_slot(get_cycles()
+ - dev->ctx_start)]);
+
+#endif
+ clear_bit(0, &dev->context_flag);
+ wake_up(&dev->context_wait);
+
+ return 0;
+}
+
+
+int r128_resctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_res_t res;
+ drm_ctx_t ctx;
+ int i;
+
+ DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
+ copy_from_user_ret(&res, (drm_ctx_res_t *)arg, sizeof(res), -EFAULT);
+ if (res.count >= DRM_RESERVED_CONTEXTS) {
+ memset(&ctx, 0, sizeof(ctx));
+ for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
+ ctx.handle = i;
+ copy_to_user_ret(&res.contexts[i],
+ &i,
+ sizeof(i),
+ -EFAULT);
+ }
+ }
+ res.count = DRM_RESERVED_CONTEXTS;
+ copy_to_user_ret((drm_ctx_res_t *)arg, &res, sizeof(res), -EFAULT);
+ return 0;
+}
+
+
+int r128_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ if ((ctx.handle = r128_alloc_queue(dev)) == DRM_KERNEL_CONTEXT) {
+ /* Skip kernel's context and get a new one. */
+ ctx.handle = r128_alloc_queue(dev);
+ }
+ DRM_DEBUG("%d\n", ctx.handle);
+ if (ctx.handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
+ /* Should this return -EBUSY instead? */
+ return -ENOMEM;
+ }
+
+ copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT);
+ return 0;
+}
+
+int r128_modctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT);
+ if (ctx.flags==_DRM_CONTEXT_PRESERVED)
+ r128_res_ctx.handle=ctx.handle;
+ return 0;
+}
+
+int r128_getctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t*)arg, sizeof(ctx), -EFAULT);
+ /* This is 0, because we don't hanlde any context flags */
+ ctx.flags = 0;
+ copy_to_user_ret((drm_ctx_t*)arg, &ctx, sizeof(ctx), -EFAULT);
+ return 0;
+}
+
+int r128_switchctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ return r128_context_switch(dev, dev->last_context, ctx.handle);
+}
+
+int r128_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ r128_context_switch_complete(dev, ctx.handle);
+
+ return 0;
+}
+
+int r128_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_ctx_t ctx;
+
+ copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
+ DRM_DEBUG("%d\n", ctx.handle);
+ drm_ctxbitmap_free(dev, ctx.handle);
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c
new file mode 100644
index 000000000..16f79c1f6
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c
@@ -0,0 +1,922 @@
+/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
+ * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#define __NO_VERSION__
+#include "drmP.h"
+#include "r128_drv.h"
+
+#include <linux/interrupt.h> /* For task queue support */
+#include <linux/delay.h>
+
+
+
+#define DO_REMAP(_m) (_m)->handle = drm_ioremap((_m)->offset, (_m)->size)
+
+#define DO_REMAPFREE(_m) \
+ do { \
+ if ((_m)->handle && (_m)->size) \
+ drm_ioremapfree((_m)->handle, (_m)->size); \
+ } while (0)
+
+#define DO_FIND_MAP(_m, _o) \
+ do { \
+ int _i; \
+ for (_i = 0; _i < dev->map_count; _i++) { \
+ if (dev->maplist[_i]->offset == _o) { \
+ _m = dev->maplist[_i]; \
+ break; \
+ } \
+ } \
+ } while (0)
+
+
+#define R128_MAX_VBUF_AGE 0x10000000
+#define R128_VB_AGE_REG R128_GUI_SCRATCH_REG0
+
+int R128_READ_PLL(drm_device_t *dev, int addr)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ R128_WRITE8(R128_CLOCK_CNTL_INDEX, addr & 0x1f);
+ return R128_READ(R128_CLOCK_CNTL_DATA);
+}
+
+static void r128_flush_write_combine(void)
+{
+ int xchangeDummy;
+
+ __asm__ volatile("push %%eax ;"
+ "xchg %%eax, %0 ;"
+ "pop %%eax" : : "m" (xchangeDummy));
+ __asm__ volatile("push %%eax ;"
+ "push %%ebx ;"
+ "push %%ecx ;"
+ "push %%edx ;"
+ "movl $0,%%eax ;"
+ "cpuid ;"
+ "pop %%edx ;"
+ "pop %%ecx ;"
+ "pop %%ebx ;"
+ "pop %%eax" : /* no outputs */ : /* no inputs */ );
+}
+
+static void r128_status(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ printk("GUI_STAT = 0x%08x\n",
+ (unsigned int)R128_READ(R128_GUI_STAT));
+ printk("PM4_STAT = 0x%08x\n",
+ (unsigned int)R128_READ(R128_PM4_STAT));
+ printk("PM4_BUFFER_DL_WPTR = 0x%08x\n",
+ (unsigned int)R128_READ(R128_PM4_BUFFER_DL_WPTR));
+ printk("PM4_BUFFER_DL_RPTR = 0x%08x\n",
+ (unsigned int)R128_READ(R128_PM4_BUFFER_DL_RPTR));
+}
+
+static int r128_do_cleanup_cce(drm_device_t *dev)
+{
+ if (dev->dev_private) {
+ drm_r128_private_t *dev_priv = dev->dev_private;
+
+ if (!dev_priv->is_pci) {
+ DO_REMAPFREE(dev_priv->agp_ring);
+ DO_REMAPFREE(dev_priv->agp_read_ptr);
+ DO_REMAPFREE(dev_priv->agp_vertbufs);
+ DO_REMAPFREE(dev_priv->agp_indbufs);
+ DO_REMAPFREE(dev_priv->agp_textures);
+ }
+
+ drm_free(dev->dev_private, sizeof(drm_r128_private_t),
+ DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ }
+
+ return 0;
+}
+
+static int r128_do_init_cce(drm_device_t *dev, drm_r128_init_t *init)
+{
+ drm_r128_private_t *dev_priv;
+ int i;
+
+ dev_priv = drm_alloc(sizeof(drm_r128_private_t), DRM_MEM_DRIVER);
+ if (dev_priv == NULL) return -ENOMEM;
+ dev->dev_private = (void *)dev_priv;
+
+ memset(dev_priv, 0, sizeof(drm_r128_private_t));
+
+ dev_priv->is_pci = init->is_pci;
+
+ dev_priv->usec_timeout = init->usec_timeout;
+ if (dev_priv->usec_timeout < 1 ||
+ dev_priv->usec_timeout > R128_MAX_USEC_TIMEOUT) {
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ return -EINVAL;
+ }
+
+ dev_priv->cce_mode = init->cce_mode;
+ dev_priv->cce_fifo_size = init->cce_fifo_size;
+ dev_priv->cce_is_bm_mode =
+ ((init->cce_mode == R128_PM4_192BM) ||
+ (init->cce_mode == R128_PM4_128BM_64INDBM) ||
+ (init->cce_mode == R128_PM4_64BM_128INDBM) ||
+ (init->cce_mode == R128_PM4_64BM_64VCBM_64INDBM));
+ dev_priv->cce_secure = init->cce_secure;
+
+ if (dev_priv->cce_is_bm_mode && dev_priv->is_pci) {
+ drm_free(dev_priv, sizeof(*dev_priv), DRM_MEM_DRIVER);
+ dev->dev_private = NULL;
+ return -EINVAL;
+ }
+
+ for (i = 0; i < dev->map_count; i++) {
+ if (dev->maplist[i]->type == _DRM_SHM) {
+ dev_priv->sarea = dev->maplist[i];
+ break;
+ }
+ }
+
+ DO_FIND_MAP(dev_priv->fb, init->fb_offset);
+ if (!dev_priv->is_pci) {
+ DO_FIND_MAP(dev_priv->agp_ring, init->agp_ring_offset);
+ DO_FIND_MAP(dev_priv->agp_read_ptr, init->agp_read_ptr_offset);
+ DO_FIND_MAP(dev_priv->agp_vertbufs, init->agp_vertbufs_offset);
+ DO_FIND_MAP(dev_priv->agp_indbufs, init->agp_indbufs_offset);
+ DO_FIND_MAP(dev_priv->agp_textures, init->agp_textures_offset);
+ }
+ DO_FIND_MAP(dev_priv->mmio, init->mmio_offset);
+
+ dev_priv->sarea_priv =
+ (drm_r128_sarea_t *)((u8 *)dev_priv->sarea->handle +
+ init->sarea_priv_offset);
+
+ if (!dev_priv->is_pci) {
+ DO_REMAP(dev_priv->agp_ring);
+ DO_REMAP(dev_priv->agp_read_ptr);
+ DO_REMAP(dev_priv->agp_vertbufs);
+#if 0
+ DO_REMAP(dev_priv->agp_indirectbufs);
+ DO_REMAP(dev_priv->agp_textures);
+#endif
+
+ dev_priv->ring_size = init->ring_size;
+ dev_priv->ring_sizel2qw = drm_order(init->ring_size/8);
+ dev_priv->ring_entries = init->ring_size/sizeof(u32);
+ dev_priv->ring_read_ptr = ((__volatile__ u32 *)
+ dev_priv->agp_read_ptr->handle);
+ dev_priv->ring_start = (u32 *)dev_priv->agp_ring->handle;
+ dev_priv->ring_end = ((u32 *)dev_priv->agp_ring->handle
+ + dev_priv->ring_entries);
+ }
+
+ dev_priv->submit_age = 0;
+ R128_WRITE(R128_VB_AGE_REG, dev_priv->submit_age);
+
+ return 0;
+}
+
+int r128_init_cce(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_init_t init;
+
+ copy_from_user_ret(&init, (drm_r128_init_t *)arg, sizeof(init),
+ -EFAULT);
+
+ switch (init.func) {
+ case R128_INIT_CCE:
+ return r128_do_init_cce(dev, &init);
+ case R128_CLEANUP_CCE:
+ return r128_do_cleanup_cce(dev);
+ }
+
+ return -EINVAL;
+}
+
+static void r128_mark_vertbufs_done(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ int i;
+
+ for (i = 0; i < dma->buf_count; i++) {
+ drm_buf_t *buf = dma->buflist[i];
+ drm_r128_buf_priv_t *buf_priv = buf->dev_private;
+ buf_priv->age = 0;
+ }
+}
+
+static int r128_do_pixcache_flush(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 tmp;
+ int i;
+
+ tmp = R128_READ(R128_PC_NGUI_CTLSTAT) | R128_PC_FLUSH_ALL;
+ R128_WRITE(R128_PC_NGUI_CTLSTAT, tmp);
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ if (!(R128_READ(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY))
+ return 0;
+ udelay(1);
+ }
+
+ return -EBUSY;
+}
+
+static int r128_do_wait_for_fifo(drm_device_t *dev, int entries)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ int slots = R128_READ(R128_GUI_STAT) & R128_GUI_FIFOCNT_MASK;
+ if (slots >= entries) return 0;
+ udelay(1);
+ }
+ return -EBUSY;
+}
+
+static int r128_do_wait_for_idle(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i, ret;
+
+ if (!(ret = r128_do_wait_for_fifo(dev, 64))) return ret;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ if (!(R128_READ(R128_GUI_STAT) & R128_GUI_ACTIVE)) {
+ (void)r128_do_pixcache_flush(dev);
+ return 0;
+ }
+ udelay(1);
+ }
+ return -EBUSY;
+}
+
+int r128_do_engine_reset(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 clock_cntl_index, mclk_cntl, gen_reset_cntl;
+
+ (void)r128_do_pixcache_flush(dev);
+
+ clock_cntl_index = R128_READ(R128_CLOCK_CNTL_INDEX);
+ mclk_cntl = R128_READ_PLL(dev, R128_MCLK_CNTL);
+
+ R128_WRITE_PLL(R128_MCLK_CNTL,
+ mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CP);
+
+ gen_reset_cntl = R128_READ(R128_GEN_RESET_CNTL);
+
+ R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI);
+ (void)R128_READ(R128_GEN_RESET_CNTL);
+ R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI);
+ (void)R128_READ(R128_GEN_RESET_CNTL);
+
+ R128_WRITE_PLL(R128_MCLK_CNTL, mclk_cntl);
+ R128_WRITE(R128_CLOCK_CNTL_INDEX, clock_cntl_index);
+ R128_WRITE(R128_GEN_RESET_CNTL, gen_reset_cntl);
+
+ /* For CCE ring buffer only */
+ if (dev_priv->cce_is_bm_mode) {
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, 0);
+ R128_WRITE(R128_PM4_BUFFER_DL_RPTR, 0);
+ *dev_priv->ring_read_ptr = 0;
+ dev_priv->sarea_priv->ring_write = 0;
+ }
+
+ /* Reset the CCE mode */
+ (void)r128_do_wait_for_idle(dev);
+ R128_WRITE(R128_PM4_BUFFER_CNTL,
+ dev_priv->cce_mode | dev_priv->ring_sizel2qw);
+ (void)R128_READ(R128_PM4_BUFFER_ADDR); /* as per the sample code */
+ R128_WRITE(R128_PM4_MICRO_CNTL, R128_PM4_MICRO_FREERUN);
+
+ r128_mark_vertbufs_done(dev);
+ return 0;
+}
+
+int r128_eng_reset(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_eng_reset called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ return r128_do_engine_reset(dev);
+}
+
+static int r128_do_engine_flush(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 tmp;
+
+ tmp = R128_READ(R128_PM4_BUFFER_DL_WPTR);
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, tmp | R128_PM4_BUFFER_DL_DONE);
+
+ return 0;
+}
+
+int r128_eng_flush(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_eng_flush called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ return r128_do_engine_flush(dev);
+}
+
+static int r128_do_cce_wait_for_fifo(drm_device_t *dev, int entries)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ int slots = R128_READ(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK;
+ if (slots >= entries) return 0;
+ udelay(1);
+ }
+ return -EBUSY;
+}
+
+int r128_do_cce_wait_for_idle(drm_device_t *dev)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+
+ if (dev_priv->cce_is_bm_mode) {
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ if (*dev_priv->ring_read_ptr == dev_priv->sarea_priv->ring_write) {
+ int pm4stat = R128_READ(R128_PM4_STAT);
+ if ((pm4stat & R128_PM4_FIFOCNT_MASK) >= dev_priv->cce_fifo_size &&
+ !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
+ return r128_do_pixcache_flush(dev);
+ }
+ }
+ udelay(1);
+ }
+ return -EBUSY;
+ } else {
+ int ret = r128_do_cce_wait_for_fifo(dev, dev_priv->cce_fifo_size);
+ if (ret < 0) return ret;
+
+ for (i = 0; i < dev_priv->usec_timeout; i++) {
+ int pm4stat = R128_READ(R128_PM4_STAT);
+ if (!(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) {
+ return r128_do_pixcache_flush(dev);
+ }
+ udelay(1);
+ }
+ return -EBUSY;
+ }
+}
+
+int r128_cce_idle(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_wait_idle called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ return r128_do_cce_wait_for_idle(dev);
+}
+
+static int r128_submit_packets_ring_secure(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int write = dev_priv->sarea_priv->ring_write;
+ int *write_ptr = dev_priv->ring_start + write;
+ int c = *count;
+ u32 tmp = 0;
+ int psize = 0;
+ int writing = 1;
+ int timeout;
+
+ while (c > 0) {
+ tmp = *commands++;
+ if (!psize) {
+ writing = 1;
+
+ if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ }
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <=
+ (0x1004 << 9)) {
+ if ((tmp & R128_CCE_PACKET1_REG1_MASK) !=
+ (R128_PM4_VC_FPU_SETUP << 9)) {
+ writing = 0;
+ }
+ }
+ psize = 3;
+ } else {
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ }
+ }
+ psize--;
+
+ if (writing) {
+ write++;
+ *write_ptr++ = tmp;
+ }
+ if (write >= dev_priv->ring_entries) {
+ write = 0;
+ write_ptr = dev_priv->ring_start;
+ }
+ timeout = 0;
+ while (write == *dev_priv->ring_read_ptr) {
+ (void)R128_READ(R128_PM4_BUFFER_DL_RPTR);
+ if (timeout++ >= dev_priv->usec_timeout)
+ return -EBUSY;
+ udelay(1);
+ }
+ c--;
+ }
+
+ if (write < 32)
+ memcpy(dev_priv->ring_end,
+ dev_priv->ring_start,
+ write * sizeof(u32));
+
+ /* Make sure WC cache has been flushed */
+ r128_flush_write_combine();
+
+ dev_priv->sarea_priv->ring_write = write;
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write);
+
+ *count = 0;
+
+ return 0;
+}
+
+static int r128_submit_packets_pio_secure(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ u32 tmp = 0;
+ int psize = 0;
+ int writing = 1;
+ int addr = R128_PM4_FIFO_DATA_EVEN;
+ int ret;
+
+ while (*count > 0) {
+ tmp = *commands++;
+ if (!psize) {
+ writing = 1;
+
+ if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET0_REG_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ }
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) {
+ if ((tmp & R128_CCE_PACKET1_REG0_MASK) !=
+ (R128_PM4_VC_FPU_SETUP >> 2)) {
+ writing = 0;
+ }
+ } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <=
+ (0x1004 << 9)) {
+ if ((tmp & R128_CCE_PACKET1_REG1_MASK) !=
+ (R128_PM4_VC_FPU_SETUP << 9)) {
+ writing = 0;
+ }
+ }
+ psize = 3;
+ } else {
+ psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2;
+ }
+ }
+ psize--;
+
+ if (writing) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0)
+ return ret;
+ R128_WRITE(addr, tmp);
+ addr ^= 0x0004;
+ }
+
+ *count -= 1;
+ }
+
+ if (addr == R128_PM4_FIFO_DATA_ODD) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 1)) < 0) return ret;
+ R128_WRITE(addr, R128_CCE_PACKET2);
+ }
+
+ return 0;
+}
+
+static int r128_submit_packets_ring(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int write = dev_priv->sarea_priv->ring_write;
+ int *write_ptr = dev_priv->ring_start + write;
+ int c = *count;
+ int timeout;
+
+ while (c > 0) {
+ write++;
+ *write_ptr++ = *commands++;
+ if (write >= dev_priv->ring_entries) {
+ write = 0;
+ write_ptr = dev_priv->ring_start;
+ }
+ timeout = 0;
+ while (write == *dev_priv->ring_read_ptr) {
+ (void)R128_READ(R128_PM4_BUFFER_DL_RPTR);
+ if (timeout++ >= dev_priv->usec_timeout)
+ return -EBUSY;
+ udelay(1);
+ }
+ c--;
+ }
+
+ if (write < 32)
+ memcpy(dev_priv->ring_end,
+ dev_priv->ring_start,
+ write * sizeof(u32));
+
+ /* Make sure WC cache has been flushed */
+ r128_flush_write_combine();
+
+ dev_priv->sarea_priv->ring_write = write;
+ R128_WRITE(R128_PM4_BUFFER_DL_WPTR, write);
+
+ *count = 0;
+
+ return 0;
+}
+
+static int r128_submit_packets_pio(drm_device_t *dev,
+ u32 *commands, int *count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int ret;
+
+ while (*count > 1) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret;
+ R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++);
+ R128_WRITE(R128_PM4_FIFO_DATA_ODD, *commands++);
+ *count -= 2;
+ }
+
+ if (*count) {
+ if ((ret = r128_do_cce_wait_for_fifo(dev, 2)) < 0) return ret;
+ R128_WRITE(R128_PM4_FIFO_DATA_EVEN, *commands++);
+ R128_WRITE(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2);
+ *count = 0;
+ }
+
+ return 0;
+}
+
+static int r128_do_submit_packets(drm_device_t *dev, u32 *buffer, int count)
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int c = count;
+ int ret;
+
+ if (dev_priv->cce_is_bm_mode) {
+ int left = 0;
+
+ if (c >= dev_priv->ring_entries) {
+ c = dev_priv->ring_entries-1;
+ left = count - c;
+ }
+
+ /* Since this is only used by the kernel we can use the
+ insecure ring buffer submit packet routine */
+ ret = r128_submit_packets_ring(dev, buffer, &c);
+
+ c += left;
+ } else {
+ /* Since this is only used by the kernel we can use the
+ insecure PIO submit packet routine */
+ ret = r128_submit_packets_pio(dev, buffer, &c);
+ }
+
+ if (ret < 0) return ret;
+ else return c;
+}
+
+int r128_submit_pkt(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_r128_packet_t packet;
+ u32 *buffer;
+ int c;
+ int size;
+ int ret = 0;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_submit_pkt called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ copy_from_user_ret(&packet, (drm_r128_packet_t *)arg, sizeof(packet),
+ -EFAULT);
+
+ c = packet.count;
+ size = c * sizeof(*buffer);
+
+ if (dev_priv->cce_is_bm_mode) {
+ int left = 0;
+
+ if (c >= dev_priv->ring_entries) {
+ c = dev_priv->ring_entries-1;
+ size = c * sizeof(*buffer);
+ left = packet.count - c;
+ }
+
+ if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM;
+ copy_from_user_ret(buffer, packet.buffer, size, -EFAULT);
+
+ if (dev_priv->cce_secure)
+ ret = r128_submit_packets_ring_secure(dev, buffer, &c);
+ else
+ ret = r128_submit_packets_ring(dev, buffer, &c);
+
+ c += left;
+ } else {
+ if ((buffer = kmalloc(size, 0)) == NULL) return -ENOMEM;
+ copy_from_user_ret(buffer, packet.buffer, size, -EFAULT);
+
+ if (dev_priv->cce_secure)
+ ret = r128_submit_packets_pio_secure(dev, buffer, &c);
+ else
+ ret = r128_submit_packets_pio(dev, buffer, &c);
+ }
+
+ kfree(buffer);
+
+ packet.count = c;
+ copy_to_user_ret((drm_r128_packet_t *)arg, &packet, sizeof(packet),
+ -EFAULT);
+
+ if (ret) return ret;
+ else if (c > 0) return -EAGAIN;
+
+ return 0;
+}
+
+static int r128_send_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_r128_buf_priv_t *buf_priv;
+ drm_buf_t *buf;
+ int i, ret;
+ u32 cce[2];
+
+ /* Make sure we have valid data */
+ for (i = 0; i < v->send_count; i++) {
+ int idx = v->send_indices[i];
+
+ if (idx < 0 || idx >= dma->buf_count) {
+ DRM_ERROR("Index %d (of %d max)\n",
+ idx, dma->buf_count - 1);
+ return -EINVAL;
+ }
+ buf = dma->buflist[idx];
+ if (buf->pid != current->pid) {
+ DRM_ERROR("Process %d using buffer owned by %d\n",
+ current->pid, buf->pid);
+ return -EINVAL;
+ }
+ if (buf->pending) {
+ DRM_ERROR("Sending pending buffer:"
+ " buffer %d, offset %d\n",
+ v->send_indices[i], i);
+ return -EINVAL;
+ }
+ }
+
+ /* Wait for idle, if we've wrapped to make sure that all pending
+ buffers have been processed */
+ if (dev_priv->submit_age == R128_MAX_VBUF_AGE) {
+ if ((ret = r128_do_cce_wait_for_idle(dev)) < 0) return ret;
+ dev_priv->submit_age = 0;
+ r128_mark_vertbufs_done(dev);
+ }
+
+ /* Make sure WC cache has been flushed (if in PIO mode) */
+ if (!dev_priv->cce_is_bm_mode) r128_flush_write_combine();
+
+ /* FIXME: Add support for sending vertex buffer to the CCE here
+ instead of in client code. The v->prim holds the primitive
+ type that should be drawn. Loop over the list buffers in
+ send_indices[] and submit a packet for each VB.
+
+ This will require us to loop over the clip rects here as
+ well, which implies that we extend the kernel driver to allow
+ cliprects to be stored here. Note that the cliprects could
+ possibly come from the X server instead of the client, but
+ this will require additional changes to the DRI to allow for
+ this optimization. */
+
+ /* Submit a CCE packet that writes submit_age to R128_VB_AGE_REG */
+ cce[0] = R128CCE0(R128_CCE_PACKET0, R128_VB_AGE_REG, 0);
+ cce[1] = dev_priv->submit_age;
+ if ((ret = r128_do_submit_packets(dev, cce, 2)) < 0) {
+ /* Until we add support for sending VBs to the CCE in
+ this routine, we can recover from this error. After
+ we add that support, we won't be able to easily
+ recover, so we will probably have to implement
+ another mechanism for handling timeouts from packets
+ submitted directly by the kernel. */
+ return ret;
+ }
+
+ /* Now that the submit packet request has succeeded, we can mark
+ the buffers as pending */
+ for (i = 0; i < v->send_count; i++) {
+ buf = dma->buflist[v->send_indices[i]];
+ buf->pending = 1;
+
+ buf_priv = buf->dev_private;
+ buf_priv->age = dev_priv->submit_age;
+ }
+
+ dev_priv->submit_age++;
+
+ return 0;
+}
+
+static drm_buf_t *r128_freelist_get(drm_device_t *dev)
+{
+ drm_device_dma_t *dma = dev->dma;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_r128_buf_priv_t *buf_priv;
+ drm_buf_t *buf;
+ int i, t;
+
+ /* FIXME: Optimize -- use freelist code */
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[i];
+ buf_priv = buf->dev_private;
+ if (buf->pid == 0) return buf;
+ }
+
+ for (t = 0; t < dev_priv->usec_timeout; t++) {
+ u32 done_age = R128_READ(R128_VB_AGE_REG);
+
+ for (i = 0; i < dma->buf_count; i++) {
+ buf = dma->buflist[i];
+ buf_priv = buf->dev_private;
+ if (buf->pending && buf_priv->age <= done_age) {
+ /* The buffer has been processed, so it
+ can now be used */
+ buf->pending = 0;
+ return buf;
+ }
+ }
+ udelay(1);
+ }
+
+ r128_status(dev);
+ return NULL;
+}
+
+
+static int r128_get_vertbufs(drm_device_t *dev, drm_r128_vertex_t *v)
+{
+ drm_buf_t *buf;
+ int i;
+
+ for (i = v->granted_count; i < v->request_count; i++) {
+ buf = r128_freelist_get(dev);
+ if (!buf) break;
+ buf->pid = current->pid;
+ copy_to_user_ret(&v->request_indices[i],
+ &buf->idx,
+ sizeof(buf->idx),
+ -EFAULT);
+ copy_to_user_ret(&v->request_sizes[i],
+ &buf->total,
+ sizeof(buf->total),
+ -EFAULT);
+ ++v->granted_count;
+ }
+ return 0;
+}
+
+int r128_vertex_buf(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ drm_device_dma_t *dma = dev->dma;
+ int retcode = 0;
+ drm_r128_vertex_t v;
+
+ if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||
+ dev->lock.pid != current->pid) {
+ DRM_ERROR("r128_vertex_buf called without holding the lock\n");
+ return -EINVAL;
+ }
+
+ if (!dev_priv || dev_priv->is_pci) {
+ DRM_ERROR("r128_vertex_buf called with a PCI card\n");
+ return -EINVAL;
+ }
+
+ copy_from_user_ret(&v, (drm_r128_vertex_t *)arg, sizeof(v), -EFAULT);
+ DRM_DEBUG("%d: %d send, %d req\n",
+ current->pid, v.send_count, v.request_count);
+
+ if (v.send_count < 0 || v.send_count > dma->buf_count) {
+ DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n",
+ current->pid, v.send_count, dma->buf_count);
+ return -EINVAL;
+ }
+ if (v.request_count < 0 || v.request_count > dma->buf_count) {
+ DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n",
+ current->pid, v.request_count, dma->buf_count);
+ return -EINVAL;
+ }
+
+ if (v.send_count) {
+ retcode = r128_send_vertbufs(dev, &v);
+ }
+
+ v.granted_count = 0;
+
+ if (!retcode && v.request_count) {
+ retcode = r128_get_vertbufs(dev, &v);
+ }
+
+ DRM_DEBUG("%d returning, granted = %d\n",
+ current->pid, v.granted_count);
+ copy_to_user_ret((drm_r128_vertex_t *)arg, &v, sizeof(v), -EFAULT);
+
+ return retcode;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
new file mode 100644
index 000000000..ac6f73bcd
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
@@ -0,0 +1,111 @@
+/* r128_drm.h -- Public header for the r128 driver -*- linux-c -*-
+ * Created: Wed Apr 5 19:24:19 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef _R128_DRM_H_
+#define _R128_DRM_H_
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (xf86drmR128.h)
+ */
+typedef struct drm_r128_init {
+ enum {
+ R128_INIT_CCE = 0x01,
+ R128_CLEANUP_CCE = 0x02
+ } func;
+ int sarea_priv_offset;
+ int is_pci;
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_secure;
+ int ring_size;
+ int usec_timeout;
+
+ int fb_offset;
+ int agp_ring_offset;
+ int agp_read_ptr_offset;
+ int agp_vertbufs_offset;
+ int agp_indbufs_offset;
+ int agp_textures_offset;
+ int mmio_offset;
+} drm_r128_init_t;
+
+typedef struct drm_r128_packet {
+ unsigned long *buffer;
+ int count;
+ int flags;
+} drm_r128_packet_t;
+
+typedef enum drm_r128_prim {
+ _DRM_R128_PRIM_NONE = 0x0001,
+ _DRM_R128_PRIM_POINT = 0x0002,
+ _DRM_R128_PRIM_LINE = 0x0004,
+ _DRM_R128_PRIM_POLY_LINE = 0x0008,
+ _DRM_R128_PRIM_TRI_LIST = 0x0010,
+ _DRM_R128_PRIM_TRI_FAN = 0x0020,
+ _DRM_R128_PRIM_TRI_STRIP = 0x0040,
+ _DRM_R128_PRIM_TRI_TYPE2 = 0x0080
+} drm_r128_prim_t;
+
+typedef struct drm_r128_vertex {
+ /* Indices here refer to the offset into
+ buflist in drm_buf_get_t. */
+ int send_count; /* Number of buffers to send */
+ int *send_indices; /* List of handles to buffers */
+ int *send_sizes; /* Lengths of data to send */
+ drm_r128_prim_t prim; /* Primitive type */
+ int request_count; /* Number of buffers requested */
+ int *request_indices; /* Buffer information */
+ int *request_sizes;
+ int granted_count; /* Number of buffers granted */
+} drm_r128_vertex_t;
+
+/* WARNING: If you change any of these defines, make sure to change the
+ * defines in the Xserver file (r128_sarea.h)
+ */
+#define R128_LOCAL_TEX_HEAP 0
+#define R128_AGP_TEX_HEAP 1
+#define R128_NR_TEX_HEAPS 2
+#define R128_NR_TEX_REGIONS 64
+#define R128_LOG_TEX_GRANULARITY 16
+
+typedef struct drm_tex_region {
+ unsigned char next, prev;
+ unsigned char in_use;
+ int age;
+} drm_tex_region_t;
+
+typedef struct drm_r128_sarea {
+ drm_tex_region_t tex_list[R128_NR_TEX_HEAPS][R128_NR_TEX_REGIONS+1];
+ int tex_age[R128_NR_TEX_HEAPS];
+ int ctx_owner;
+ int ring_write;
+} drm_r128_sarea_t;
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
new file mode 100644
index 000000000..8b669888a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c
@@ -0,0 +1,737 @@
+/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
+ * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#include <linux/config.h>
+#define EXPORT_SYMTAB
+#include "drmP.h"
+#include "r128_drv.h"
+EXPORT_SYMBOL(r128_init);
+EXPORT_SYMBOL(r128_cleanup);
+
+#define R128_NAME "r128"
+#define R128_DESC "r128"
+#define R128_DATE "20000607"
+#define R128_MAJOR 1
+#define R128_MINOR 0
+#define R128_PATCHLEVEL 0
+
+static drm_device_t r128_device;
+drm_ctx_t r128_res_ctx;
+
+static struct file_operations r128_fops = {
+ open: r128_open,
+ flush: drm_flush,
+ release: r128_release,
+ ioctl: r128_ioctl,
+ mmap: drm_mmap,
+ read: drm_read,
+ fasync: drm_fasync,
+ poll: drm_poll,
+};
+
+static struct miscdevice r128_misc = {
+ minor: MISC_DYNAMIC_MINOR,
+ name: R128_NAME,
+ fops: &r128_fops,
+};
+
+static drm_ioctl_desc_t r128_ioctls[] = {
+ [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { r128_version, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { drm_getunique, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { drm_getmagic, 0, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_busid, 0, 1 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { drm_setunique, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { drm_block, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { drm_unblock, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { drm_authmagic, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { drm_addmap, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { r128_addbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { drm_markbufs, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { drm_infobufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { r128_mapbufs, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { drm_freebufs, 1, 0 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { r128_addctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { r128_rmctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { r128_modctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { r128_getctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { r128_switchctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { r128_newctx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { r128_resctx, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { drm_adddraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { drm_rmdraw, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { r128_lock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { r128_unlock, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
+
+#ifdef DRM_AGP
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { drm_agp_acquire, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { drm_agp_release, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { drm_agp_enable, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { drm_agp_info, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { drm_agp_alloc, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { drm_agp_free, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { drm_agp_bind, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { drm_agp_unbind, 1, 1 },
+#endif
+
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_INIT)] = { r128_init_cce, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_eng_reset, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_FLUSH)] = { r128_eng_flush, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_submit_pkt, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_IDLE)] = { r128_cce_idle, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_vertex_buf, 1, 0 },
+};
+#define R128_IOCTL_COUNT DRM_ARRAY_SIZE(r128_ioctls)
+
+#ifdef MODULE
+int init_module(void);
+void cleanup_module(void);
+static char *r128 = NULL;
+
+MODULE_AUTHOR("Precision Insight, Inc., Cedar Park, Texas.");
+MODULE_DESCRIPTION("r128");
+MODULE_PARM(r128, "s");
+
+/* init_module is called when insmod is used to load the module */
+
+int init_module(void)
+{
+ return r128_init();
+}
+
+/* cleanup_module is called when rmmod is used to unload the module */
+
+void cleanup_module(void)
+{
+ r128_cleanup();
+}
+#endif
+
+#ifndef MODULE
+/* r128_setup is called by the kernel to parse command-line options passed
+ * via the boot-loader (e.g., LILO). It calls the insmod option routine,
+ * drm_parse_drm.
+ *
+ * This is not currently supported, since it requires changes to
+ * linux/init/main.c. */
+
+
+void __init r128_setup(char *str, int *ints)
+{
+ if (ints[0] != 0) {
+ DRM_ERROR("Illegal command line format, ignored\n");
+ return;
+ }
+ drm_parse_options(str);
+}
+#endif
+
+static int r128_setup(drm_device_t *dev)
+{
+ int i;
+
+ atomic_set(&dev->ioctl_count, 0);
+ atomic_set(&dev->vma_count, 0);
+ dev->buf_use = 0;
+ atomic_set(&dev->buf_alloc, 0);
+
+ drm_dma_setup(dev);
+
+ atomic_set(&dev->total_open, 0);
+ atomic_set(&dev->total_close, 0);
+ atomic_set(&dev->total_ioctl, 0);
+ atomic_set(&dev->total_irq, 0);
+ atomic_set(&dev->total_ctx, 0);
+ atomic_set(&dev->total_locks, 0);
+ atomic_set(&dev->total_unlocks, 0);
+ atomic_set(&dev->total_contends, 0);
+ atomic_set(&dev->total_sleeps, 0);
+
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ dev->magiclist[i].head = NULL;
+ dev->magiclist[i].tail = NULL;
+ }
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ dev->vmalist = NULL;
+ dev->lock.hw_lock = NULL;
+ init_waitqueue_head(&dev->lock.lock_queue);
+ dev->queue_count = 0;
+ dev->queue_reserved = 0;
+ dev->queue_slots = 0;
+ dev->queuelist = NULL;
+ dev->irq = 0;
+ dev->context_flag = 0;
+ dev->interrupt_flag = 0;
+ dev->dma_flag = 0;
+ dev->last_context = 0;
+ dev->last_switch = 0;
+ dev->last_checked = 0;
+ init_timer(&dev->timer);
+ init_waitqueue_head(&dev->context_wait);
+
+ dev->ctx_start = 0;
+ dev->lck_start = 0;
+
+ dev->buf_rp = dev->buf;
+ dev->buf_wp = dev->buf;
+ dev->buf_end = dev->buf + DRM_BSZ;
+ dev->buf_async = NULL;
+ init_waitqueue_head(&dev->buf_readers);
+ init_waitqueue_head(&dev->buf_writers);
+
+ r128_res_ctx.handle=-1;
+
+ DRM_DEBUG("\n");
+
+ /* The kernel's context could be created here, but is now created
+ in drm_dma_enqueue. This is more resource-efficient for
+ hardware that does not do DMA, but may mean that
+ drm_select_queue fails between the time the interrupt is
+ initialized and the time the queues are initialized. */
+
+ return 0;
+}
+
+
+static int r128_takedown(drm_device_t *dev)
+{
+ int i;
+ drm_magic_entry_t *pt, *next;
+ drm_map_t *map;
+ drm_vma_entry_t *vma, *vma_next;
+
+ DRM_DEBUG("\n");
+
+ down(&dev->struct_sem);
+ del_timer(&dev->timer);
+
+ if (dev->devname) {
+ drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER);
+ dev->devname = NULL;
+ }
+
+ if (dev->unique) {
+ drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER);
+ dev->unique = NULL;
+ dev->unique_len = 0;
+ }
+ /* Clear pid list */
+ for (i = 0; i < DRM_HASH_SIZE; i++) {
+ for (pt = dev->magiclist[i].head; pt; pt = next) {
+ next = pt->next;
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ }
+ dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
+ }
+
+#ifdef DRM_AGP
+ /* Clear AGP information */
+ if (dev->agp) {
+ drm_agp_mem_t *entry;
+ drm_agp_mem_t *nexte;
+
+ /* Remove AGP resources, but leave dev->agp
+ intact until r128_cleanup is called. */
+ for (entry = dev->agp->memory; entry; entry = nexte) {
+ nexte = entry->next;
+ if (entry->bound) drm_unbind_agp(entry->memory);
+ drm_free_agp(entry->memory, entry->pages);
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
+ }
+ dev->agp->memory = NULL;
+
+ if (dev->agp->acquired && drm_agp.release)
+ (*drm_agp.release)();
+
+ dev->agp->acquired = 0;
+ dev->agp->enabled = 0;
+ }
+#endif
+
+ /* Clear vma list (only built for debugging) */
+ if (dev->vmalist) {
+ for (vma = dev->vmalist; vma; vma = vma_next) {
+ vma_next = vma->next;
+ drm_free(vma, sizeof(*vma), DRM_MEM_VMAS);
+ }
+ dev->vmalist = NULL;
+ }
+
+ /* Clear map area and mtrr information */
+ if (dev->maplist) {
+ for (i = 0; i < dev->map_count; i++) {
+ map = dev->maplist[i];
+ switch (map->type) {
+ case _DRM_REGISTERS:
+ case _DRM_FRAME_BUFFER:
+#ifdef CONFIG_MTRR
+ if (map->mtrr >= 0) {
+ int retcode;
+ retcode = mtrr_del(map->mtrr,
+ map->offset,
+ map->size);
+ DRM_DEBUG("mtrr_del = %d\n", retcode);
+ }
+#endif
+ drm_ioremapfree(map->handle, map->size);
+ break;
+ case _DRM_SHM:
+ drm_free_pages((unsigned long)map->handle,
+ drm_order(map->size)
+ - PAGE_SHIFT,
+ DRM_MEM_SAREA);
+ break;
+ case _DRM_AGP:
+ /* Do nothing here, because this is all
+ handled in the AGP/GART driver. */
+ break;
+ }
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
+ }
+ drm_free(dev->maplist,
+ dev->map_count * sizeof(*dev->maplist),
+ DRM_MEM_MAPS);
+ dev->maplist = NULL;
+ dev->map_count = 0;
+ }
+
+ drm_dma_takedown(dev);
+
+ dev->queue_count = 0;
+ if (dev->lock.hw_lock) {
+ dev->lock.hw_lock = NULL; /* SHM removed */
+ dev->lock.pid = 0;
+ wake_up_interruptible(&dev->lock.lock_queue);
+ }
+ up(&dev->struct_sem);
+
+ return 0;
+}
+
+/* r128_init is called via init_module at module load time, or via
+ * linux/init/main.c (this is not currently supported). */
+
+int r128_init(void)
+{
+ int retcode;
+ drm_device_t *dev = &r128_device;
+
+ DRM_DEBUG("\n");
+
+ memset((void *)dev, 0, sizeof(*dev));
+ dev->count_lock = SPIN_LOCK_UNLOCKED;
+ sema_init(&dev->struct_sem, 1);
+
+#ifdef MODULE
+ drm_parse_options(r128);
+#endif
+
+ if ((retcode = misc_register(&r128_misc))) {
+ DRM_ERROR("Cannot register \"%s\"\n", R128_NAME);
+ return retcode;
+ }
+ dev->device = MKDEV(MISC_MAJOR, r128_misc.minor);
+ dev->name = R128_NAME;
+
+ drm_mem_init();
+ drm_proc_init(dev);
+
+#ifdef DRM_AGP
+ dev->agp = drm_agp_init();
+
+#ifdef CONFIG_MTRR
+ dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base,
+ dev->agp->agp_info.aper_size*1024*1024,
+ MTRR_TYPE_WRCOMB,
+ 1);
+#endif
+#endif
+
+ if((retcode = drm_ctxbitmap_init(dev))) {
+ DRM_ERROR("Cannot allocate memory for context bitmap.\n");
+ drm_proc_cleanup();
+ misc_deregister(&r128_misc);
+ r128_takedown(dev);
+ return retcode;
+ }
+
+ DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+ R128_NAME,
+ R128_MAJOR,
+ R128_MINOR,
+ R128_PATCHLEVEL,
+ R128_DATE,
+ r128_misc.minor);
+
+ return 0;
+}
+
+/* r128_cleanup is called via cleanup_module at module unload time. */
+
+void r128_cleanup(void)
+{
+ drm_device_t *dev = &r128_device;
+
+ DRM_DEBUG("\n");
+
+ drm_proc_cleanup();
+ if (misc_deregister(&r128_misc)) {
+ DRM_ERROR("Cannot unload module\n");
+ } else {
+ DRM_INFO("Module unloaded\n");
+ }
+ drm_ctxbitmap_cleanup(dev);
+ r128_takedown(dev);
+#ifdef DRM_AGP
+ if (dev->agp) {
+ /* FIXME -- free other information, too */
+ drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ dev->agp = NULL;
+ }
+#endif
+}
+
+int r128_version(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_version_t version;
+ int len;
+
+ copy_from_user_ret(&version,
+ (drm_version_t *)arg,
+ sizeof(version),
+ -EFAULT);
+
+#define DRM_COPY(name,value) \
+ len = strlen(value); \
+ if (len > name##_len) len = name##_len; \
+ name##_len = strlen(value); \
+ if (len && name) { \
+ copy_to_user_ret(name, value, len, -EFAULT); \
+ }
+
+ version.version_major = R128_MAJOR;
+ version.version_minor = R128_MINOR;
+ version.version_patchlevel = R128_PATCHLEVEL;
+
+ DRM_COPY(version.name, R128_NAME);
+ DRM_COPY(version.date, R128_DATE);
+ DRM_COPY(version.desc, R128_DESC);
+
+ copy_to_user_ret((drm_version_t *)arg,
+ &version,
+ sizeof(version),
+ -EFAULT);
+ return 0;
+}
+
+int r128_open(struct inode *inode, struct file *filp)
+{
+ drm_device_t *dev = &r128_device;
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+ if (!(retcode = drm_open_helper(inode, filp, dev))) {
+ MOD_INC_USE_COUNT;
+ atomic_inc(&dev->total_open);
+ spin_lock(&dev->count_lock);
+ if (!dev->open_count++) {
+ spin_unlock(&dev->count_lock);
+ return r128_setup(dev);
+ }
+ spin_unlock(&dev->count_lock);
+ }
+ return retcode;
+}
+
+int r128_release(struct inode *inode, struct file *filp)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ int retcode = 0;
+
+ DRM_DEBUG("open_count = %d\n", dev->open_count);
+ if (!(retcode = drm_release(inode, filp))) {
+ MOD_DEC_USE_COUNT;
+ atomic_inc(&dev->total_close);
+ spin_lock(&dev->count_lock);
+ if (!--dev->open_count) {
+ if (atomic_read(&dev->ioctl_count) || dev->blocked) {
+ DRM_ERROR("Device busy: %d %d\n",
+ atomic_read(&dev->ioctl_count),
+ dev->blocked);
+ spin_unlock(&dev->count_lock);
+ return -EBUSY;
+ }
+ spin_unlock(&dev->count_lock);
+ return r128_takedown(dev);
+ }
+ spin_unlock(&dev->count_lock);
+ }
+ return retcode;
+}
+
+/* r128_ioctl is called whenever a process performs an ioctl on /dev/drm. */
+
+int r128_ioctl(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ int nr = DRM_IOCTL_NR(cmd);
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ int retcode = 0;
+ drm_ioctl_desc_t *ioctl;
+ drm_ioctl_t *func;
+
+ atomic_inc(&dev->ioctl_count);
+ atomic_inc(&dev->total_ioctl);
+ ++priv->ioctl_count;
+
+ DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n",
+ current->pid, cmd, nr, dev->device, priv->authenticated);
+
+ if (nr >= R128_IOCTL_COUNT) {
+ retcode = -EINVAL;
+ } else {
+ ioctl = &r128_ioctls[nr];
+ func = ioctl->func;
+
+ if (!func) {
+ DRM_DEBUG("no function\n");
+ retcode = -EINVAL;
+ } else if ((ioctl->root_only && !capable(CAP_SYS_ADMIN))
+ || (ioctl->auth_needed && !priv->authenticated)) {
+ retcode = -EACCES;
+ } else {
+ retcode = (func)(inode, filp, cmd, arg);
+ }
+ }
+
+ atomic_dec(&dev->ioctl_count);
+ return retcode;
+}
+
+int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ DECLARE_WAITQUEUE(entry, current);
+ int ret = 0;
+ drm_lock_t lock;
+#if DRM_DMA_HISTOGRAM
+ cycles_t start;
+
+ dev->lck_start = start = get_cycles();
+#endif
+
+ copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ current->pid, lock.context);
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
+ lock.context, current->pid, dev->lock.hw_lock->lock,
+ lock.flags);
+
+#if 0
+ /* dev->queue_count == 0 right now for
+ r128. FIXME? */
+ if (lock.context < 0 || lock.context >= dev->queue_count)
+ return -EINVAL;
+#endif
+
+ if (!ret) {
+#if 0
+ if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)
+ != lock.context) {
+ long j = jiffies - dev->lock.lock_time;
+
+ if (lock.context == r128_res_ctx.handle &&
+ j >= 0 && j < DRM_LOCK_SLICE) {
+ /* Can't take lock if we just had it and
+ there is contention. */
+ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n",
+ lock.context, current->pid, j,
+ dev->lock.lock_time, jiffies);
+ current->state = TASK_INTERRUPTIBLE;
+ current->policy |= SCHED_YIELD;
+ schedule_timeout(DRM_LOCK_SLICE-j);
+ DRM_DEBUG("jiffies=%d\n", jiffies);
+ }
+ }
+#endif
+ add_wait_queue(&dev->lock.lock_queue, &entry);
+ for (;;) {
+ if (!dev->lock.hw_lock) {
+ /* Device has been unregistered */
+ ret = -EINTR;
+ break;
+ }
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ lock.context)) {
+ dev->lock.pid = current->pid;
+ dev->lock.lock_time = jiffies;
+ atomic_inc(&dev->total_locks);
+ break; /* Got lock */
+ }
+
+ /* Contention */
+ atomic_inc(&dev->total_sleeps);
+ current->state = TASK_INTERRUPTIBLE;
+#if 1
+ current->policy |= SCHED_YIELD;
+#endif
+ schedule();
+ if (signal_pending(current)) {
+ ret = -ERESTARTSYS;
+ break;
+ }
+ }
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->lock.lock_queue, &entry);
+ }
+
+#if 0
+ if (!ret && dev->last_context != lock.context &&
+ lock.context != r128_res_ctx.handle &&
+ dev->last_context != r128_res_ctx.handle) {
+ add_wait_queue(&dev->context_wait, &entry);
+ current->state = TASK_INTERRUPTIBLE;
+ /* PRE: dev->last_context != lock.context */
+ r128_context_switch(dev, dev->last_context, lock.context);
+ /* POST: we will wait for the context
+ switch and will dispatch on a later call
+ when dev->last_context == lock.context
+ NOTE WE HOLD THE LOCK THROUGHOUT THIS
+ TIME! */
+ current->policy |= SCHED_YIELD;
+ schedule();
+ current->state = TASK_RUNNING;
+ remove_wait_queue(&dev->context_wait, &entry);
+ if (signal_pending(current)) {
+ ret = -EINTR;
+ } else if (dev->last_context != lock.context) {
+ DRM_ERROR("Context mismatch: %d %d\n",
+ dev->last_context, lock.context);
+ }
+ }
+#endif
+
+ if (!ret) {
+ if (lock.flags & _DRM_LOCK_READY) {
+ /* Wait for space in DMA/FIFO */
+ }
+ if (lock.flags & _DRM_LOCK_QUIESCENT) {
+ /* Make hardware quiescent */
+#if 0
+ r128_quiescent(dev);
+#endif
+ }
+ }
+
+#if 0
+ DRM_ERROR("pid = %5d, old counter = %5ld\n",
+ current->pid, current->counter);
+#endif
+ if (lock.context != r128_res_ctx.handle) {
+ current->counter = 5;
+ current->priority = DEF_PRIORITY/4;
+ }
+#if 0
+ while (current->counter > 25)
+ current->counter >>= 1; /* decrease time slice */
+ DRM_ERROR("pid = %5d, new counter = %5ld\n",
+ current->pid, current->counter);
+#endif
+ DRM_DEBUG("%d %s\n", lock.context, ret ? "interrupted" : "has lock");
+
+#if DRM_DMA_HISTOGRAM
+ atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]);
+#endif
+
+ return ret;
+}
+
+
+int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd,
+ unsigned long arg)
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_lock_t lock;
+
+ copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT);
+
+ if (lock.context == DRM_KERNEL_CONTEXT) {
+ DRM_ERROR("Process %d using kernel context %d\n",
+ current->pid, lock.context);
+ return -EINVAL;
+ }
+
+ DRM_DEBUG("%d frees lock (%d holds)\n",
+ lock.context,
+ _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
+ atomic_inc(&dev->total_unlocks);
+ if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock))
+ atomic_inc(&dev->total_contends);
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
+ /* FIXME: Try to send data to card here */
+ if (!dev->context_flag) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ DRM_ERROR("\n");
+ }
+ }
+
+#if 0
+ current->policy |= SCHED_YIELD;
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(1000);
+#endif
+
+ if (lock.context != r128_res_ctx.handle) {
+ current->counter = 5;
+ current->priority = DEF_PRIORITY;
+ }
+#if 0
+ current->state = TASK_INTERRUPTIBLE;
+ schedule_timeout(10);
+#endif
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
new file mode 100644
index 000000000..81390bb8b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h
@@ -0,0 +1,226 @@
+/* r128_drv.h -- Private header for r128 driver -*- linux-c -*-
+ * Created: Mon Dec 13 09:51:11 1999 by faith@precisioninsight.com
+ *
+ * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
+ * All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifndef _R128_DRV_H_
+#define _R128_DRV_H_
+
+typedef struct drm_r128_private {
+ int is_pci;
+
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_is_bm_mode;
+ int cce_secure;
+
+ drm_r128_sarea_t *sarea_priv;
+
+ __volatile__ u32 *ring_read_ptr;
+
+ u32 *ring_start;
+ u32 *ring_end;
+ int ring_size;
+ int ring_sizel2qw;
+ int ring_entries;
+
+ int submit_age;
+
+ int usec_timeout;
+
+ drm_map_t *sarea;
+ drm_map_t *fb;
+ drm_map_t *agp_ring;
+ drm_map_t *agp_read_ptr;
+ drm_map_t *agp_vertbufs;
+ drm_map_t *agp_indbufs;
+ drm_map_t *agp_textures;
+ drm_map_t *mmio;
+} drm_r128_private_t;
+
+typedef struct drm_r128_buf_priv {
+ u32 age;
+} drm_r128_buf_priv_t;
+
+ /* r128_drv.c */
+extern int r128_init(void);
+extern void r128_cleanup(void);
+extern int r128_version(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_open(struct inode *inode, struct file *filp);
+extern int r128_release(struct inode *inode, struct file *filp);
+extern int r128_ioctl(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_lock(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_unlock(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+ /* r128_dma.c */
+extern int r128_init_cce(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_eng_reset(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_eng_flush(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_submit_pkt(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_cce_idle(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_vertex_buf(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+ /* r128_bufs.c */
+extern int r128_addbufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_mapbufs(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+ /* r128_context.c */
+extern int r128_resctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_addctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_modctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_getctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_switchctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_newctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+extern int r128_rmctx(struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg);
+
+extern int r128_context_switch(drm_device_t *dev, int old, int new);
+extern int r128_context_switch_complete(drm_device_t *dev, int new);
+
+
+/* Register definitions, register access macros and drmAddMap constants
+ * for Rage 128 kernel driver.
+ */
+
+#define R128_PC_NGUI_CTLSTAT 0x0184
+# define R128_PC_FLUSH_ALL 0x00ff
+# define R128_PC_BUSY (1 << 31)
+
+#define R128_CLOCK_CNTL_INDEX 0x0008
+#define R128_CLOCK_CNTL_DATA 0x000c
+# define R128_PLL_WR_EN (1 << 7)
+
+#define R128_MCLK_CNTL 0x000f
+# define R128_FORCE_GCP (1 << 16)
+# define R128_FORCE_PIPE3D_CP (1 << 17)
+# define R128_FORCE_RCP (1 << 18)
+
+#define R128_GEN_RESET_CNTL 0x00f0
+# define R128_SOFT_RESET_GUI (1 << 0)
+
+#define R128_PM4_BUFFER_CNTL 0x0704
+# define R128_PM4_NONPM4 (0 << 28)
+# define R128_PM4_192PIO (1 << 28)
+# define R128_PM4_192BM (2 << 28)
+# define R128_PM4_128PIO_64INDBM (3 << 28)
+# define R128_PM4_128BM_64INDBM (4 << 28)
+# define R128_PM4_64PIO_128INDBM (5 << 28)
+# define R128_PM4_64BM_128INDBM (6 << 28)
+# define R128_PM4_64PIO_64VCBM_64INDBM (7 << 28)
+# define R128_PM4_64BM_64VCBM_64INDBM (8 << 28)
+# define R128_PM4_64PIO_64VCPIO_64INDPIO (15 << 28)
+
+
+#define R128_PM4_BUFFER_DL_RPTR 0x0710
+#define R128_PM4_BUFFER_DL_WPTR 0x0714
+# define R128_PM4_BUFFER_DL_DONE (1 << 31)
+
+#define R128_PM4_VC_FPU_SETUP 0x071c
+
+#define R128_PM4_STAT 0x07b8
+# define R128_PM4_FIFOCNT_MASK 0x0fff
+# define R128_PM4_BUSY (1 << 16)
+# define R128_PM4_GUI_ACTIVE (1 << 31)
+
+#define R128_PM4_BUFFER_ADDR 0x07f0
+#define R128_PM4_MICRO_CNTL 0x07fc
+# define R128_PM4_MICRO_FREERUN (1 << 30)
+
+#define R128_PM4_FIFO_DATA_EVEN 0x1000
+#define R128_PM4_FIFO_DATA_ODD 0x1004
+
+#define R128_GUI_SCRATCH_REG0 0x15e0
+#define R128_GUI_SCRATCH_REG1 0x15e4
+#define R128_GUI_SCRATCH_REG2 0x15e8
+#define R128_GUI_SCRATCH_REG3 0x15ec
+#define R128_GUI_SCRATCH_REG4 0x15f0
+#define R128_GUI_SCRATCH_REG5 0x15f4
+
+#define R128_GUI_STAT 0x1740
+# define R128_GUI_FIFOCNT_MASK 0x0fff
+# define R128_GUI_ACTIVE (1 << 31)
+
+
+/* CCE command packets */
+#define R128_CCE_PACKET0 0x00000000
+#define R128_CCE_PACKET1 0x40000000
+#define R128_CCE_PACKET2 0x80000000
+# define R128_CCE_PACKET_MASK 0xC0000000
+# define R128_CCE_PACKET_COUNT_MASK 0x3fff0000
+# define R128_CCE_PACKET0_REG_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG0_MASK 0x000007ff
+# define R128_CCE_PACKET1_REG1_MASK 0x003ff800
+
+
+#define R128_MAX_USEC_TIMEOUT 100000 /* 100 ms */
+
+
+#define R128_BASE(reg) ((u32)(dev_priv->mmio->handle))
+#define R128_ADDR(reg) (R128_BASE(reg) + reg)
+
+#define R128_DEREF(reg) *(__volatile__ int *)R128_ADDR(reg)
+#define R128_READ(reg) R128_DEREF(reg)
+#define R128_WRITE(reg,val) do { R128_DEREF(reg) = val; } while (0)
+
+#define R128_DEREF8(reg) *(__volatile__ char *)R128_ADDR(reg)
+#define R128_READ8(reg) R128_DEREF8(reg)
+#define R128_WRITE8(reg,val) do { R128_DEREF8(reg) = val; } while (0)
+
+#define R128_WRITE_PLL(addr,val) \
+do { \
+ R128_WRITE8(R128_CLOCK_CNTL_INDEX, ((addr) & 0x1f) | R128_PLL_WR_EN); \
+ R128_WRITE(R128_CLOCK_CNTL_DATA, (val)); \
+} while (0)
+
+extern int R128_READ_PLL(drm_device_t *dev, int addr);
+
+#define R128CCE0(p,r,n) ((p) | ((n) << 16) | ((r) >> 2))
+#define R128CCE1(p,r1,r2) ((p) | (((r2) >> 2) << 11) | ((r1) >> 2))
+#define R128CCE2(p) ((p))
+#define R128CCE3(p,n) ((p) | ((n) << 16))
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c
index 842d6f5d5..c8d6e50ea 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_context.c
@@ -1,8 +1,8 @@
/* tdfx_context.c -- IOCTLs for tdfx contexts -*- linux-c -*-
* Created: Thu Oct 7 10:50:22 1999 by faith@precisioninsight.com
- * Revised: Sat Oct 9 23:39:56 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,8 +24,10 @@
* 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/linux/drm/kernel/tdfx_context.c,v 1.2 2000/02/23 04:47:30 martin Exp $
- *
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
+ *
*/
#include <linux/sched.h>
@@ -38,9 +40,7 @@ extern drm_ctx_t tdfx_res_ctx;
static int tdfx_alloc_queue(drm_device_t *dev)
{
- static int context = 0;
-
- return ++context; /* Should this reuse contexts in the future? */
+ return drm_ctxbitmap_next(dev);
}
int tdfx_context_switch(drm_device_t *dev, int old, int new)
@@ -137,6 +137,12 @@ int tdfx_addctx(struct inode *inode, struct file *filp, unsigned int cmd,
ctx.handle = tdfx_alloc_queue(dev);
}
DRM_DEBUG("%d\n", ctx.handle);
+ if (ctx.handle == -1) {
+ DRM_DEBUG("Not enough free contexts.\n");
+ /* Should this return -EBUSY instead? */
+ return -ENOMEM;
+ }
+
copy_to_user_ret((drm_ctx_t *)arg, &ctx, sizeof(ctx), -EFAULT);
return 0;
}
@@ -193,13 +199,13 @@ int tdfx_newctx(struct inode *inode, struct file *filp, unsigned int cmd,
int tdfx_rmctx(struct inode *inode, struct file *filp, unsigned int cmd,
unsigned long arg)
{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
drm_ctx_t ctx;
copy_from_user_ret(&ctx, (drm_ctx_t *)arg, sizeof(ctx), -EFAULT);
DRM_DEBUG("%d\n", ctx.handle);
- /* This is currently a noop because we
- don't reuse context values. Perhaps we
- should? */
-
+ drm_ctxbitmap_free(dev, ctx.handle);
+
return 0;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c
index 57c1c719d..582832b54 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.c
@@ -1,8 +1,8 @@
/* tdfx.c -- tdfx driver -*- linux-c -*-
* Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
- * Revised: Tue Oct 12 08:51:35 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,10 +24,13 @@
* 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/linux/drm/kernel/tdfx_drv.c,v 1.3 2000/02/23 04:47:31 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
+ * Daryll Strauss <daryll@valinux.com>
*
*/
+#include <linux/config.h>
#define EXPORT_SYMTAB
#include "drmP.h"
#include "tdfx_drv.h"
@@ -37,9 +40,9 @@ EXPORT_SYMBOL(tdfx_cleanup);
#define TDFX_NAME "tdfx"
#define TDFX_DESC "tdfx"
#define TDFX_DATE "19991009"
-#define TDFX_MAJOR 0
+#define TDFX_MAJOR 1
#define TDFX_MINOR 0
-#define TDFX_PATCHLEVEL 1
+#define TDFX_PATCHLEVEL 0
static drm_device_t tdfx_device;
drm_ctx_t tdfx_res_ctx;
@@ -85,6 +88,16 @@ static drm_ioctl_desc_t tdfx_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { tdfx_lock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { tdfx_unlock, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { drm_finish, 1, 0 },
+#ifdef DRM_AGP
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = {drm_agp_acquire, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = {drm_agp_release, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = {drm_agp_enable, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = {drm_agp_info, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = {drm_agp_alloc, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = {drm_agp_free, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = {drm_agp_unbind, 1, 1},
+ [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = {drm_agp_bind, 1, 1},
+#endif
};
#define TDFX_IOCTL_COUNT DRM_ARRAY_SIZE(tdfx_ioctls)
@@ -228,7 +241,24 @@ static int tdfx_takedown(drm_device_t *dev)
}
dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
}
-
+#ifdef DRM_AGP
+ /* Clear AGP information */
+ if (dev->agp) {
+ drm_agp_mem_t *temp;
+ drm_agp_mem_t *temp_next;
+
+ temp = dev->agp->memory;
+ while(temp != NULL) {
+ temp_next = temp->next;
+ drm_free_agp(temp->memory, temp->pages);
+ drm_free(temp, sizeof(*temp), DRM_MEM_AGPLISTS);
+ temp = temp_next;
+ }
+ if(dev->agp->acquired) (*drm_agp.release)();
+ drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS);
+ dev->agp = NULL;
+ }
+#endif
/* Clear vma list (only built for debugging) */
if (dev->vmalist) {
for (vma = dev->vmalist; vma; vma = vma_next) {
@@ -262,6 +292,10 @@ static int tdfx_takedown(drm_device_t *dev)
- PAGE_SHIFT,
DRM_MEM_SAREA);
break;
+ case _DRM_AGP:
+ /* Do nothing here, because this is all
+ handled in the AGP/GART driver. */
+ break;
}
drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
@@ -309,6 +343,16 @@ int tdfx_init(void)
drm_mem_init();
drm_proc_init(dev);
+#ifdef DRM_AGP
+ dev->agp = drm_agp_init();
+#endif
+ if((retcode = drm_ctxbitmap_init(dev))) {
+ DRM_ERROR("Cannot allocate memory for context bitmap.\n");
+ drm_proc_cleanup();
+ misc_deregister(&tdfx_misc);
+ tdfx_takedown(dev);
+ return retcode;
+ }
DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
TDFX_NAME,
@@ -335,6 +379,7 @@ void tdfx_cleanup(void)
} else {
DRM_INFO("Module unloaded\n");
}
+ drm_ctxbitmap_cleanup(dev);
tdfx_takedown(dev);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h
index 3866010a8..879e6d37a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/tdfx_drv.h
@@ -1,8 +1,8 @@
/* tdfx_drv.h -- Private header for tdfx driver -*- linux-c -*-
* Created: Thu Oct 7 10:40:04 1999 by faith@precisioninsight.com
- * Revised: Sat Oct 9 23:38:19 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,9 @@
* 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/linux/drm/kernel/tdfx_drv.h,v 1.2 2000/02/23 04:47:31 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@precisioninsight.com>
+ * Daryll Strauss <daryll@precisioninsight.com>
*
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
index 85470ac52..0b2b00e0a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/vm.c
@@ -1,8 +1,8 @@
/* vm.c -- Memory mapping for DRM -*- linux-c -*-
* Created: Mon Jan 4 08:58:31 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:16:45 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/vm.c,v 1.5 2000/02/23 04:47:31 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
*/
@@ -246,13 +247,26 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
/* Check for valid size. */
if (map->size != vma->vm_end - vma->vm_start) return -EINVAL;
+ if (!capable(CAP_SYS_ADMIN) && (map->flags & _DRM_READ_ONLY)) {
+ vma->vm_flags &= VM_MAYWRITE;
+#if defined(__i386__)
+ pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
+#else
+ /* Ye gads this is ugly. With more thought
+ we could move this up higher and use
+ `protection_map' instead. */
+ vma->vm_page_prot = __pgprot(pte_val(pte_wrprotect(
+ __pte(pgprot_val(vma->vm_page_prot)))));
+#endif
+ }
switch (map->type) {
case _DRM_FRAME_BUFFER:
case _DRM_REGISTERS:
+ case _DRM_AGP:
if (VM_OFFSET(vma) >= __pa(high_memory)) {
#if defined(__i386__)
- if (boot_cpu_data.x86 > 3) {
+ if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) {
pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
pgprot_val(vma->vm_page_prot) &= ~_PAGE_PWT;
}
@@ -264,6 +278,10 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_end - vma->vm_start,
vma->vm_page_prot))
return -EAGAIN;
+ DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx,"
+ " offset = 0x%lx\n",
+ map->type,
+ vma->vm_start, vma->vm_end, VM_OFFSET(vma));
vma->vm_ops = &drm_vm_ops;
break;
case _DRM_SHM:
@@ -276,19 +294,7 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
return -EINVAL; /* This should never happen. */
}
vma->vm_flags |= VM_LOCKED | VM_SHM; /* Don't swap */
- if (map->flags & _DRM_READ_ONLY) {
-#if defined(__i386__)
- pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW;
-#else
- /* Ye gads this is ugly. With more thought
- we could move this up higher and use
- `protection_map' instead. */
- vma->vm_page_prot = __pgprot(pte_val(pte_wrprotect(
- __pte(pgprot_val(vma->vm_page_prot)))));
-#endif
- }
-
#if LINUX_VERSION_CODE < 0x020203 /* KERNEL_VERSION(2,2,3) */
/* In Linux 2.2.3 and above, this is
handled in do_mmap() in mm/mmap.c. */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
index 3b0f98acd..e4bc53bc3 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c
@@ -1,8 +1,8 @@
/* xf86drm.c -- User-level interface to DRM device
* Created: Tue Jan 5 08:16:21 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:43:32 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,10 @@
* 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/linux/drm/xf86drm.c,v 1.10 2000/02/23 04:47:23 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ * Kevin E. Martin <martin@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.14 2000/06/27 16:42:07 alanh Exp $
*
*/
@@ -65,15 +68,35 @@ extern int xf86RemoveSIGIOHandler(int fd);
# endif
#endif
+#ifdef __alpha__
+extern unsigned long _bus_base(void);
+#define BUS_BASE _bus_base()
+#else
+#define BUS_BASE (0)
+#endif
+
/* Not all systems have MAP_FAILED defined */
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#endif
-#include <sys/sysmacros.h> /* for makedev() */
#include "xf86drm.h"
#include "drm.h"
+#define DRM_FIXED_DEVICE_MAJOR 145
+
+#ifdef __linux__
+#include <sys/sysmacros.h> /* for makedev() */
+#endif
+
+#ifndef makedev
+ /* This definition needs to be changed on
+ some systems if dev_t is a structure.
+ If there is a header file we can get it
+ from, there would be best. */
+#define makedev(x,y) ((dev_t)(((x) << 8) | (y)))
+#endif
+
static void *drmHashTable = NULL; /* Context switch callbacks */
typedef struct drmHashEntry {
@@ -94,9 +117,16 @@ void drmFree(void *pt)
if (pt) _DRM_FREE(pt);
}
+/* drmStrdup can't use strdup(3), since it doesn't call _DRM_MALLOC... */
static char *drmStrdup(const char *s)
{
- return s ? strdup(s) : NULL;
+ char *retval = NULL;
+
+ if (s) {
+ retval = _DRM_MALLOC(strlen(s)+1);
+ strcpy(retval, s);
+ }
+ return retval;
}
@@ -133,7 +163,7 @@ static drmHashEntry *drmGetEntry(int fd)
return entry;
}
-/* drm_open is used to open the /dev/drm device */
+/* drm_open is used to open the /dev/dri device */
static int drm_open(const char *file)
{
@@ -143,14 +173,6 @@ static int drm_open(const char *file)
return -errno;
}
-/* drmAvailable looks for /proc/drm, and returns 1 if it is present. */
-
-int drmAvailable(void)
-{
- if (!access("/proc/dri/0", R_OK)) return 1;
- return 0;
-}
-
static int drmOpenDevice(const char *path, long dev,
mode_t mode, uid_t user, gid_t group)
{
@@ -160,7 +182,16 @@ static int drmOpenDevice(const char *path, long dev,
struct stat st;
#endif
- if (!stat(path, &st) && st.st_rdev == dev) return drm_open(path);
+ /* Fiddle mode to remove execute bits */
+ mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH);
+
+ if (!stat(path, &st) && st.st_rdev == dev) {
+ if (!geteuid()) {
+ chown(path, user, group);
+ chmod(path, mode);
+ }
+ return drm_open(path);
+ }
if (geteuid()) return DRM_ERR_NOT_ROOT;
remove(path);
@@ -173,6 +204,38 @@ static int drmOpenDevice(const char *path, long dev,
return drm_open(path);
}
+/* drmAvailable looks for /proc/dri, and returns 1 if it is present. On
+ OSs that do not have a Linux-like /proc, this information will not be
+ available, and we'll have to create a device and check if the driver is
+ loaded that way. */
+
+int drmAvailable(void)
+{
+ char dev_name[64];
+ drmVersionPtr version;
+ int retval = 0;
+ int fd;
+
+ if (!access("/proc/dri/0", R_OK)) return 1;
+
+ sprintf(dev_name, "/dev/dri-temp-%d", getpid());
+
+ remove(dev_name);
+ if ((fd = drmOpenDevice(dev_name, makedev(DRM_FIXED_DEVICE_MAJOR, 0),
+ S_IRUSR, geteuid(), getegid())) >= 0) {
+ /* Read version to make sure this is
+ actually a DRI device. */
+ if ((version = drmGetVersion(fd))) {
+ retval = 1;
+ drmFreeVersion(version);
+ }
+ close(fd);
+ }
+ remove(dev_name);
+
+ return retval;
+}
+
static int drmOpenByBusid(const char *busid)
{
int i;
@@ -214,7 +277,21 @@ static int drmOpenByName(const char *name)
#if defined(XFree86Server)
mode = xf86ConfigDRI.mode ? xf86ConfigDRI.mode : DRM_DEV_MODE;
- group = xf86ConfigDRI.group ? xf86ConfigDRI.group : DRM_DEV_GID;
+ group = (xf86ConfigDRI.group >= 0) ? xf86ConfigDRI.group : DRM_DEV_GID;
+#endif
+
+#if defined(XFree86Server)
+ if (!drmAvailable()) {
+ /* try to load the kernel module now */
+ if (!xf86LoadKernelModule(name)) {
+ ErrorF("[drm] failed to load kernel module \"%s\"\n",
+ name);
+ return -1;
+ }
+ }
+#else
+ if (!drmAvailable())
+ return -1;
#endif
if (!geteuid()) {
@@ -253,7 +330,24 @@ static int drmOpenByName(const char *name)
}
}
}
- } else remove(dev_name);
+ } else {
+ drmVersionPtr version;
+ /* /proc/dri not available, possibly
+ because we aren't on a Linux system.
+ So, try to create the next device and
+ see if it's active. */
+ dev = makedev(DRM_FIXED_DEVICE_MAJOR, i);
+ if ((fd = drmOpenDevice(dev_name, dev, mode, user, group))) {
+ if ((version = drmGetVersion(fd))) {
+ if (!strcmp(version->name, name)) {
+ drmFreeVersion(version);
+ return fd;
+ }
+ drmFreeVersion(version);
+ }
+ }
+ remove(dev_name);
+ }
}
return -1;
}
@@ -288,7 +382,7 @@ static void drmFreeKernelVersion(drm_version_t *v)
drmFree(v);
}
-static void drmCopyVersion(drmVersionPtr d, drm_version_t *s)
+static void drmCopyVersion(drmVersionPtr d, const drm_version_t *s)
{
d->version_major = s->version_major;
d->version_minor = s->version_minor;
@@ -302,7 +396,7 @@ static void drmCopyVersion(drmVersionPtr d, drm_version_t *s)
}
/* drmVersion obtains the version information via an ioctl. Similar
- * information is available via /proc/drm. */
+ * information is available via /proc/dri. */
drmVersionPtr drmGetVersion(int fd)
{
@@ -409,6 +503,10 @@ int drmAddMap(int fd,
drm_map_t map;
map.offset = offset;
+#ifdef __alpha__
+ if (!(type & DRM_SHM))
+ map.offset += BUS_BASE;
+#endif
map.size = size;
map.handle = 0;
map.type = type;
@@ -418,7 +516,8 @@ int drmAddMap(int fd,
return 0;
}
-int drmAddBufs(int fd, int count, int size, int flags)
+int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags,
+ int agp_offset)
{
drm_buf_desc_t request;
@@ -427,6 +526,8 @@ int drmAddBufs(int fd, int count, int size, int flags)
request.low_mark = 0;
request.high_mark = 0;
request.flags = flags;
+ request.agp_start = agp_offset;
+
if (ioctl(fd, DRM_IOCTL_ADD_BUFS, &request)) return -errno;
return request.count;
}
@@ -744,6 +845,143 @@ int drmDestroyDrawable(int fd, drmDrawable handle)
return 0;
}
+int drmAgpAcquire(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_AGP_ACQUIRE, NULL)) return -errno;
+ return 0;
+}
+
+int drmAgpRelease(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_AGP_RELEASE, NULL)) return -errno;
+ return 0;
+}
+
+int drmAgpEnable(int fd, unsigned long mode)
+{
+ drm_agp_mode_t m;
+
+ m.mode = mode;
+ if (ioctl(fd, DRM_IOCTL_AGP_ENABLE, &m)) return -errno;
+ return 0;
+}
+
+int drmAgpAlloc(int fd, unsigned long size, unsigned long type,
+ unsigned long *address, unsigned long *handle)
+{
+ drm_agp_buffer_t b;
+ *handle = 0;
+ b.size = size;
+ b.handle = 0;
+ b.type = type;
+ if (ioctl(fd, DRM_IOCTL_AGP_ALLOC, &b)) return -errno;
+ if (address != 0UL) *address = b.physical;
+ *handle = b.handle;
+ return 0;
+}
+
+int drmAgpFree(int fd, unsigned long handle)
+{
+ drm_agp_buffer_t b;
+
+ b.size = 0;
+ b.handle = handle;
+ if (ioctl(fd, DRM_IOCTL_AGP_FREE, &b)) return -errno;
+ return 0;
+}
+
+int drmAgpBind(int fd, unsigned long handle, unsigned long offset)
+{
+ drm_agp_binding_t b;
+
+ b.handle = handle;
+ b.offset = offset;
+ if (ioctl(fd, DRM_IOCTL_AGP_BIND, &b)) return -errno;
+ return 0;
+}
+
+int drmAgpUnbind(int fd, unsigned long handle)
+{
+ drm_agp_binding_t b;
+
+ b.handle = handle;
+ b.offset = 0;
+ if (ioctl(fd, DRM_IOCTL_AGP_UNBIND, &b)) return -errno;
+ return 0;
+}
+
+int drmAgpVersionMajor(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno;
+ return i.agp_version_major;
+}
+
+int drmAgpVersionMinor(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return -errno;
+ return i.agp_version_minor;
+}
+
+unsigned long drmAgpGetMode(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.mode;
+}
+
+unsigned long drmAgpBase(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.aperture_base;
+}
+
+unsigned long drmAgpSize(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.aperture_size;
+}
+
+unsigned long drmAgpMemoryUsed(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.memory_used;
+}
+
+unsigned long drmAgpMemoryAvail(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.memory_allowed;
+}
+
+unsigned int drmAgpVendorId(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.id_vendor;
+}
+
+unsigned int drmAgpDeviceId(int fd)
+{
+ drm_agp_info_t i;
+
+ if (ioctl(fd, DRM_IOCTL_AGP_INFO, &i)) return 0;
+ return i.id_device;
+}
+
int drmError(int err, const char *label)
{
switch (err) {
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c
index c08a5f4c4..24b698cce 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c
@@ -1,6 +1,5 @@
/* xf86drmHash.c -- Small hash table support for integer -> integer mapping
* Created: Sun Apr 18 09:35:45 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 3 16:11:06 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
@@ -24,7 +23,9 @@
* 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/linux/drm/xf86drmHash.c,v 1.2 2000/02/23 04:47:23 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmHash.c,v 1.3 2000/06/17 00:03:34 martin Exp $
*
* DESCRIPTION
*
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c
new file mode 100644
index 000000000..b2489eeed
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmI810.c
@@ -0,0 +1,87 @@
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include <sys/sysmacros.h> /* for makedev() */
+#include "xf86drm.h"
+#include "xf86drmI810.h"
+#include "drm.h"
+
+Bool drmI810CleanupDma(int driSubFD)
+{
+ drm_i810_init_t init;
+
+ memset(&init, 0, sizeof(drm_i810_init_t));
+ init.func = I810_CLEANUP_DMA;
+
+ if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool drmI810InitDma(int driSubFD, drmI810Init *info)
+{
+ drm_i810_init_t init;
+
+ memset(&init, 0, sizeof(drm_i810_init_t));
+
+ init.func = I810_INIT_DMA;
+ init.ring_map_idx = info->ring_map_idx;
+ init.buffer_map_idx = info->buffer_map_idx;
+ init.ring_start = info->start;
+ init.ring_end = info->end;
+ init.ring_size = info->size;
+ init.sarea_priv_offset = info->sarea_off;
+ init.front_offset = info->front_offset;
+ init.back_offset = info->back_offset;
+ init.depth_offset = info->depth_offset;
+ init.w = info->w;
+ init.h = info->h;
+ init.pitch = info->pitch;
+ init.pitch_bits = info->pitch_bits;
+
+ if(ioctl(driSubFD, DRM_IOCTL_I810_INIT, &init)) {
+ return FALSE;
+ }
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c
new file mode 100644
index 000000000..5957ffe33
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmMga.c
@@ -0,0 +1,117 @@
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include <sys/sysmacros.h> /* for makedev() */
+#include "xf86drm.h"
+#include "xf86drmMga.h"
+#include "drm.h"
+
+Bool drmMgaCleanupDma(int driSubFD)
+{
+ drm_mga_init_t init;
+ memset(&init, 0, sizeof(drm_mga_init_t));
+ init.func = MGA_CLEANUP_DMA;
+ if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool drmMgaLockUpdate(int driSubFD, drmLockFlags flags)
+{
+ drm_lock_t lock;
+
+ memset(&lock, 0, sizeof(drm_lock_t));
+
+ if (flags & DRM_LOCK_QUIESCENT) lock.flags |= _DRM_LOCK_QUIESCENT;
+ if (flags & DRM_LOCK_FLUSH) lock.flags |= _DRM_LOCK_FLUSH;
+ if (flags & DRM_LOCK_FLUSH_ALL) lock.flags |= _DRM_LOCK_FLUSH_ALL;
+
+ if(ioctl(driSubFD, DRM_IOCTL_MGA_FLUSH, &lock)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+Bool drmMgaInitDma(int driSubFD, drmMgaInit *info)
+{
+ drm_mga_init_t init;
+ int i;
+
+ memset(&init, 0, sizeof(drm_mga_init_t));
+ init.func = MGA_INIT_DMA;
+ init.reserved_map_agpstart = info->reserved_map_agpstart;
+ init.reserved_map_idx = info->reserved_map_idx;
+ init.buffer_map_idx = info->buffer_map_idx;
+ init.sarea_priv_offset = info->sarea_priv_offset;
+ init.primary_size = info->primary_size;
+ init.warp_ucode_size = info->warp_ucode_size;
+ init.frontOffset = info->frontOffset;
+ init.backOffset = info->backOffset;
+ init.depthOffset = info->depthOffset;
+ init.textureOffset = info->textureOffset;
+ init.textureSize = info->textureSize;
+ init.agpTextureSize = info->agpTextureSize;
+ init.agpTextureOffset = info->agpTextureOffset;
+ init.cpp = info->cpp;
+ init.stride = info->stride;
+ init.sgram = info->sgram;
+ init.chipset = info->chipset;
+
+ for(i = 0; i < MGA_MAX_WARP_PIPES; i++) {
+ init.WarpIndex[i].installed = info->WarpIndex[i].installed;
+ init.WarpIndex[i].phys_addr = info->WarpIndex[i].phys_addr;
+ init.WarpIndex[i].size = info->WarpIndex[i].size;
+ }
+
+ init.mAccess = info->mAccess;
+
+
+
+ if(ioctl(driSubFD, DRM_IOCTL_MGA_INIT, &init)) {
+ return FALSE;
+ }
+ return TRUE;
+}
+
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
new file mode 100644
index 000000000..05b3d0d36
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
@@ -0,0 +1,197 @@
+/* xf86drmR128.c -- User-level interface to Rage 128 DRM device
+ * Created: Sun Apr 9 18:13:54 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 1999, 2000 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.
+ *
+ * Author: Kevin E. Martin <martin@valinux.com>
+ *
+ */
+
+#ifdef XFree86Server
+# include "xf86.h"
+# include "xf86_OSproc.h"
+# include "xf86_ansic.h"
+# include "xf86Priv.h"
+# define _DRM_MALLOC xalloc
+# define _DRM_FREE xfree
+# ifndef XFree86LOADER
+# include <sys/stat.h>
+# include <sys/mman.h>
+# endif
+#else
+# include <stdio.h>
+# include <stdlib.h>
+# include <unistd.h>
+# include <string.h>
+# include <ctype.h>
+# include <fcntl.h>
+# include <errno.h>
+# include <signal.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+# include <sys/ioctl.h>
+# include <sys/mman.h>
+# include <sys/time.h>
+# ifdef DRM_USE_MALLOC
+# define _DRM_MALLOC malloc
+# define _DRM_FREE free
+extern int xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *);
+extern int xf86RemoveSIGIOHandler(int fd);
+# else
+# include <Xlibint.h>
+# define _DRM_MALLOC Xmalloc
+# define _DRM_FREE Xfree
+# endif
+#endif
+
+/* Not all systems have MAP_FAILED defined */
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
+
+#include <sys/sysmacros.h> /* for makedev() */
+#include "xf86drm.h"
+#include "xf86drmR128.h"
+#include "drm.h"
+
+int drmR128InitCCE(int fd, drmR128Init *info)
+{
+ drm_r128_init_t init;
+
+ memset(&init, 0, sizeof(drm_r128_init_t));
+
+ init.func = R128_INIT_CCE;
+ init.sarea_priv_offset = info->sarea_priv_offset;
+ init.is_pci = info->is_pci;
+ init.cce_mode = info->cce_mode;
+ init.cce_fifo_size = info->cce_fifo_size;
+ init.cce_secure = info->cce_secure;
+ init.ring_size = info->ring_size;
+ init.usec_timeout = info->usec_timeout;
+
+ init.fb_offset = info->fb_offset;
+ init.agp_ring_offset = info->agp_ring_offset;
+ init.agp_read_ptr_offset = info->agp_read_ptr_offset;
+ init.agp_vertbufs_offset = info->agp_vertbufs_offset;
+ init.agp_indbufs_offset = info->agp_indbufs_offset;
+ init.agp_textures_offset = info->agp_textures_offset;
+ init.mmio_offset = info->mmio_offset;
+
+ if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
+
+ return 0;
+}
+
+int drmR128CleanupCCE(int fd)
+{
+ drm_r128_init_t init;
+
+ memset(&init, 0, sizeof(drm_r128_init_t));
+
+ init.func = R128_CLEANUP_CCE;
+
+ if (ioctl(fd, DRM_IOCTL_R128_INIT, &init)) return -errno;
+
+ return 0;
+}
+
+int drmR128EngineReset(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_RESET, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128EngineFlush(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_FLUSH, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128WaitForIdle(int fd)
+{
+ if (ioctl(fd, DRM_IOCTL_R128_IDLE, NULL)) return -errno;
+
+ return 0;
+}
+
+int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags)
+{
+ drm_r128_packet_t packet;
+ int ret;
+
+ memset(&packet, 0, sizeof(drm_r128_packet_t));
+
+ packet.count = *count;
+ packet.flags = flags;
+
+ while (packet.count > 0) {
+ packet.buffer = buffer + (*count - packet.count);
+ ret = ioctl(fd, DRM_IOCTL_R128_PACKET, &packet);
+ if (ret < 0 && ret != -EAGAIN) {
+ *count = packet.count;
+ return -errno;
+ }
+ }
+
+ *count = 0;
+ return 0;
+}
+
+int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes)
+{
+ drm_r128_vertex_t v;
+
+ v.send_count = 0;
+ v.send_indices = NULL;
+ v.send_sizes = NULL;
+ v.prim = DRM_R128_PRIM_NONE;
+ v.request_count = count;
+ v.request_indices = indices;
+ v.request_sizes = sizes;
+ v.granted_count = 0;
+
+ if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v)) return -errno;
+
+ return v.granted_count;
+}
+
+int drmR128FlushVertexBuffers(int fd, int count, int *indices,
+ int *sizes, drmR128PrimType prim)
+{
+ drm_r128_vertex_t v;
+
+ v.send_count = count;
+ v.send_indices = indices;
+ v.send_sizes = sizes;
+ v.prim = prim;
+ v.request_count = 0;
+ v.request_indices = NULL;
+ v.request_sizes = NULL;
+ v.granted_count = 0;
+
+ if (ioctl(fd, DRM_IOCTL_R128_VERTEX, &v) < 0) return -errno;
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c
index f42698c48..9e1e9ee2c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c
@@ -1,6 +1,5 @@
/* xf86drmRandom.c -- "Minimal Standard" PRNG Implementation
* Created: Mon Apr 19 08:28:13 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 24 14:53:45 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
@@ -24,7 +23,9 @@
* 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/linux/drm/xf86drmRandom.c,v 1.3 2000/02/23 04:47:23 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmRandom.c,v 1.4 2000/06/17 00:03:34 martin Exp $
*
* DESCRIPTION
*
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c
index 56059384f..dd634c30f 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c
@@ -1,6 +1,5 @@
/* xf86drmSL.c -- Skip list support
* Created: Mon May 10 09:28:13 1999 by faith@precisioninsight.com
- * Revised: Thu Jun 3 16:13:01 1999 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
@@ -24,7 +23,9 @@
* 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/linux/drm/xf86drmSL.c,v 1.2 2000/02/23 04:47:24 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmSL.c,v 1.3 2000/06/17 00:03:34 martin Exp $
*
* DESCRIPTION
*
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile
index ddc9bff0f..de4314ef0 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile,v 1.9 2000/02/15 02:00:15 eich Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/Imakefile,v 1.10 2000/03/31 22:55:54 dawes Exp $
#define IHaveModules
@@ -102,8 +102,6 @@ all::
InstallDriverSDKLibraryModule(int10,$(DRIVERSDKMODULEDIR),.)
-InstallDriverSDKNonExecFile(../../int10/xf86int10.h,$(DRIVERSDKINCLUDEDIR))
-
#endif
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c
index 3e6f39685..820ad7805 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.8 2000/02/29 03:09:26 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/int10/linux.c,v 1.11 2000/05/31 07:15:10 eich Exp $ */
/*
* linux specific part of the int10 module
* Copyright 1999 Egbert Eich
@@ -62,7 +62,6 @@ xf86InitInt10(int entityIndex)
char *base;
char *base_high;
int pagesize;
- int alloc_entries;
legacyVGARec vga;
screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
@@ -111,7 +110,6 @@ xf86InitInt10(int entityIndex)
goto error0;
pInt->mem = &linuxMem;
pagesize = getpagesize();
- alloc_entries = ALLOC_ENTRIES(pagesize);
pInt->private = (pointer)xnfcalloc(1,sizeof(linuxInt10Priv));
((linuxInt10Priv*)pInt->private)->screen = screen;
((linuxInt10Priv*)pInt->private)->alloc =
@@ -155,28 +153,24 @@ xf86InitInt10(int entityIndex)
#endif
if (xf86IsEntityPrimary(entityIndex)) {
+ int size;
int cs = ((CARD16*)0)[(0x10<<1)+1];
CARD8 *bios_base = (unsigned char *)(cs << 4);
- int size;
- xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segment is: 0x%x\n",cs);
- if (xf86ReadBIOS(cs << 4,0,bios_base, 0x10) < 0) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS\n");
- goto error3;
- }
- if (!(*bios_base == 0x55 && *(bios_base + 1) == 0xAA)) {
- xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
- goto error3;
- }
- size = *(bios_base + 2) * 512;
- if (xf86ReadBIOS(cs << 4,0,bios_base, size) < 0) {
- xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS\n");
- goto error3;
- }
- if (bios_checksum(bios_base,size)) {
- xf86DrvMsg(screen,X_ERROR,"Bad checksum of V_BIOS \n");
- goto error3;
+ if (!int10_read_bios(screen,cs,bios_base)) {
+ int cs = ((CARD16*)0)[(0x42<<1)+1];
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_read_bios(screen,cs,bios_base)) {
+ cs = V_BIOS >> 4;
+ bios_base = (unsigned char *)(cs << 4);
+ if (!int10_read_bios(screen,cs,bios_base)) {
+ xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
+ goto error3;
+ }
+ }
}
+ xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segment is: 0x%x\n",cs);
+
pInt->BIOSseg = cs;
set_return_trap(pInt);
} else {
@@ -430,7 +424,7 @@ vm86_rep(struct vm86_struct *ptr)
:"=a" (__res)
:"n" ((int)113), "r" ((struct vm86_struct *)ptr));
#else
- __asm__ __volatile__("int $0x80"
+ __asm__ __volatile__("int $0x80\n\t"
:"=a" (__res):"a" ((int)113),
"b" ((struct vm86_struct *)ptr));
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c
index 72ab22f8a..4e22a12cb 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c,v 3.7 2000/03/06 22:59:33 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnxResource.c,v 3.9 2000/06/13 02:28:36 dawes Exp $ */
/* Resource information code */
@@ -150,7 +150,7 @@ xf86AccResFromOS(resPtr ret)
return ret;
}
-#elif defined(__powerpc__)
+#elif defined(__powerpc__) || defined(__sparc__) || defined(__mips__)
/* XXX this isn't exactly correct but it will get the server working
* for now until we get something better.
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c
index 38c354ee3..a4f22690c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c,v 3.5 2000/03/01 00:25:26 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_apm.c,v 3.6 2000/03/31 22:55:52 dawes Exp $ */
#include "X.h"
#include "os.h"
@@ -78,6 +78,8 @@ lnxPMGetEventFromOs(int fd, pmEvent *events, int num)
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]) {
@@ -96,17 +98,13 @@ lnxPMConfirmEventToOs(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;
+ ioctl( fd, APM_IOC_STANDBY, NULL );
+ 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 ) == 0)
- return PM_WAIT;
- else
- return PM_NONE;
+ ioctl( fd, APM_IOC_SUSPEND, NULL );
+ return PM_CONTINUE;
case XF86_APM_STANDBY_RESUME:
case XF86_APM_NORMAL_RESUME:
case XF86_APM_CRITICAL_RESUME:
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
index 98a0edf66..0d3e28b65 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.15 2000/02/12 20:45:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.17 2000/06/09 07:53:25 eich Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* Copyright 1993 by David Dawes <dawes@xfree86.org>
@@ -72,7 +72,7 @@ xf86GetKbdLeds()
static int
KDKBDREP_ioctl_ok(int rate, int delay) {
-#ifdef KDKBDREP
+#if defined(KDKBDREP) && !defined(__sparc__)
/* This ioctl is defined in <linux/kd.h> but is not
implemented anywhere - must be in some m68k patches. */
struct kbd_repeat kbdrep_s;
@@ -100,7 +100,6 @@ KDKBDREP_ioctl_ok(int rate, int delay) {
}
return 1; /* success! */
-
#else /* no KDKBDREP */
return 0;
#endif /* KDKBDREP */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c
new file mode 100644
index 000000000..bd1a4b657
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_kmod.c
@@ -0,0 +1,90 @@
+#include <errno.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/wait.h>
+#include <signal.h>
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+
+
+#define MODPROBE_PATH_FILE "/proc/sys/kernel/modprobe"
+#define MAX_PATH 1024
+
+
+/* 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
+
+
+/*
+ * 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
+ */
+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 */
+ xf86strcpy(mpPath, "/sbin/modprobe");
+ }
+
+ /* now fork/exec the modprobe command */
+ switch (pid = fork()) {
+ case 0: /* child */
+ n = execl(mpPath, "modprobe", modName, NULL);
+ 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/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c
index dc485367a..061f2361c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.32 2000/02/22 01:02:37 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_video.c,v 3.36 2000/06/27 21:41:37 mvojkovi Exp $ */
/*
* Copyright 1992 by Orest Zborowski <obz@Kodak.com>
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
@@ -334,7 +334,11 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size)
pointer base;
int fd;
+#if defined(__ia64__)
+ if ((fd = open("/dev/mem", O_RDWR | O_SYNC)) < 0) {
+#else
if ((fd = open("/dev/mem", O_RDWR)) < 0) {
+#endif
FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
strerror(errno));
}
@@ -370,12 +374,13 @@ volatile unsigned char *ioBase = MAP_FAILED;
void
ppc_flush_icache(char *addr)
{
- /* cut+paste from linux glibc */
- __asm__ volatile (" dcbf 0,3");
- __asm__ volatile (" icbi 0,3");
- __asm__ volatile (" addi 3,3,32");
- __asm__ volatile (" dcbf 0,3");
- __asm__ volatile (" icbi 0,3");
+ __asm__ volatile (
+ "dcbf 0,%0;"
+ "sync;"
+ "icbi 0,%0;"
+ "sync;"
+ "isync;"
+ : : "r"(addr) : "memory");
}
#endif
@@ -385,8 +390,8 @@ xf86EnableIO(void)
if (ExtendedEnabled)
return;
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__)
- if (iopl(3))
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__)
+ if (ioperm(0, 1024, 1) || iopl(3))
FatalError("%s: Failed to set IOPL for I/O\n",
"xf86EnableIOPorts");
#endif
@@ -401,8 +406,9 @@ xf86DisableIO(void)
if (!ExtendedEnabled)
return;
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__)
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__)
iopl(0);
+ ioperm(0, 1024, 0);
#endif
ExtendedEnabled = FALSE;
@@ -418,11 +424,11 @@ Bool
xf86DisableInterrupts()
{
if (!ExtendedEnabled)
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__)
- if (iopl(3))
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__)
+ if (iopl(3) || ioperm(0, 1024, 1))
return (FALSE);
#endif
-#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__)
+#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__)
#else
#ifdef __GNUC__
#if defined(__ia64__)
@@ -434,9 +440,12 @@ xf86DisableInterrupts()
asm("cli");
#endif
#endif
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__)
- if (!ExtendedEnabled)
- iopl(0);
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__)
+ if (!ExtendedEnabled) {
+ iopl(0);
+ ioperm(0, 1024, 0);
+ }
+
#endif
return (TRUE);
}
@@ -445,11 +454,11 @@ void
xf86EnableInterrupts()
{
if (!ExtendedEnabled)
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__)
- if (iopl(3))
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__)
+ if (iopl(3) || ioperm(0, 1024, 1))
return;
#endif
-#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__)
+#if defined(__alpha__) || defined(__mc68000__) || defined(__powerpc__) || defined(__sparc__) || defined(__mips__)
#else
#ifdef __GNUC__
#if defined(__ia64__)
@@ -461,10 +470,11 @@ xf86EnableInterrupts()
asm("sti");
#endif
#endif
-#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__)
- if (!ExtendedEnabled)
-
- iopl(0);
+#if !defined(__mc68000__) && !defined(__powerpc__) && !defined(__sparc__) && !defined(__mips__)
+ if (!ExtendedEnabled) {
+ iopl(0);
+ ioperm(0, 1024, 0);
+ }
#endif
return;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile
index 6c91ffbfc..4f44b4e62 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile,v 3.18 2000/02/13 03:36:09 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/Imakefile,v 3.20 2000/06/27 14:27:30 tsi Exp $
#include <Server.tmpl>
#if !defined(PpcArchitecture)
@@ -17,15 +17,15 @@ PPC_OBJS=lynx_noinline.o lynx_ppc.o
MOUSESRC = lynx_mouse.c
MOUSEOBJ = lynx_mouse.o
-SRCS = lynx_init.c lynx_video.c lynx_io.c lynx_mmap.c mapVT_noop.c \
+SRCS = lynx_init.c lynx_video.c lynx_io.c lynx_mmap.c \
VTsw_usl.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
$(IOPERM_SRCS) $(PPC_SRCS) libc_wrapper.c stdResource.c stdPci.c \
- vidmem.c sigio.c pm_noop.c
+ vidmem.c sigio.c pm_noop.c kmod_noop.c
-OBJS = lynx_init.o lynx_video.o lynx_io.o lynx_mmap.o mapVT_noop.o \
+OBJS = lynx_init.o lynx_video.o lynx_io.o lynx_mmap.o \
VTsw_usl.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
$(IOPERM_OBJS) $(PPC_OBJS) libc_wrapper.o stdResource.o stdPci.o \
- vidmem.o sigio.o pm_noop.o
+ vidmem.o sigio.o pm_noop.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC)
@@ -40,7 +40,6 @@ NormalLibraryObjectRule()
#if !defined(PpcArchitecture)
LinkSourceFile(ioperm_noop.c,../shared)
#endif
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(VTsw_usl.c,../shared)
LinkSourceFile(std_kbdEv.c,../shared)
LinkSourceFile(posix_tty.c,../shared)
@@ -50,5 +49,6 @@ LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(vidmem.c,../shared)
LinkSourceFile(sigio.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c b/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c
index 5bf3628d2..7ffd9056c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c
@@ -21,7 +21,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.15 2000/03/03 20:02:20 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/lynxos/lynx_video.c,v 3.16 2000/04/17 16:30:13 eich Exp $ */
#include "X.h"
#include "input.h"
@@ -34,6 +34,8 @@
#if defined(__powerpc__)
#include <machine/absolute.h>
+
+void ppcPciIoMap(int bus);
#endif
#ifdef HAS_MTRR_SUPPORT
@@ -71,7 +73,7 @@ static _SMEMS smems[MAX_SMEMS];
#endif
static void
-smemCleanup()
+smemCleanup(void)
{
int i;
@@ -225,10 +227,13 @@ xf86EnableInterrupts()
#if defined(__powerpc__)
volatile unsigned char *ioBase = MAP_FAILED;
+volatile unsigned char *pciConfBase = MAP_FAILED;
+
static int IOEnabled;
+
static void
-removeIOSmem()
+removeIOSmem(void)
{
smem_create(NULL, (char *) ioBase, 0, SM_DETACH);
smem_remove("IOBASE");
@@ -239,7 +244,7 @@ void
xf86EnableIO()
{
if (IOEnabled++ == 0) {
- ioBase = (unsigned char *) smem_create("IOBASE",
+ ioBase = (unsigned char *) smem_create("IOBASE",
(char *)0x80000000, 64*1024, SM_READ|SM_WRITE);
if (ioBase == MAP_FAILED) {
--IOEnabled;
@@ -256,19 +261,19 @@ xf86DisableIO()
if (!IOEnabled)
return;
- if (--IOEnabled == 0) {
+ if (--IOEnabled == 0)
removeIOSmem();
- }
return;
}
+#if 0
void
-xf86DisableIOPrivs()
+xf86DisableIOPrivs(void)
{
return;
}
-
-void *
+#endif
+void
ppcPciIoMap(int bus)
{
xf86EnableIO();
@@ -280,7 +285,9 @@ ppcPciIoMap(int bus)
#ifdef HAS_MTRR_SUPPORT
/* memory range (MTRR) support for LynxOS (taken from BSD MTRR support) */
-/* #define DEBUG /* */
+#if 0
+#define DEBUG
+#endif
/*
* This code is experimental. Some parts may be overkill, and other parts
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile
index 01f2843fc..6b12f3c9c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile,v 3.1 1996/12/23 06:50:09 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/mach/Imakefile,v 3.3 2000/06/27 14:27:30 tsi Exp $
@@ -13,11 +13,11 @@ BIOS_MOD = bios_devmem
BIOS_MOD = bios_mmap
#endif
-SRCS = mach_init.c mach_video.c mach_io.c $(BIOS_MOD).c mapVT_noop.c \
- VTsw_noop.c
+SRCS = mach_init.c mach_video.c mach_io.c $(BIOS_MOD).c \
+ VTsw_noop.c kmod_noop.c
-OBJS = mach_init.o mach_video.o mach_io.o $(BIOS_MOD).o mapVT_noop.o \
- VTsw_noop.o
+OBJS = mach_init.o mach_video.o mach_io.o $(BIOS_MOD).o \
+ VTsw_noop.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -28,8 +28,8 @@ NormalLibraryObjectRule()
#if defined(OsfArchitecture)
ObjectFromSpecialSource(bios_devmem,../shared/bios_devmem,/**/)
#endif
-ObjectFromSpecialSource(mapVT_noop,../shared/mapVT_noop,/**/)
ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
+ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile
index 5022a0ce6..aca4c717c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile,v 3.4 1996/12/23 06:50:15 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/minix/Imakefile,v 3.6 2000/06/27 14:27:30 tsi Exp $
@@ -8,11 +8,11 @@ XCOMM $XConsortium: Imakefile /main/5 1996/09/28 17:24:04 rws $
#include <Server.tmpl>
-SRCS = mnx_init.c mnx_video.c mnx_io.c bios_devmem.c mapVT_noop.c \
- ioperm_noop.c VTsw_noop.c std_mouse.c posix_tty.c
+SRCS = mnx_init.c mnx_video.c mnx_io.c bios_devmem.c \
+ ioperm_noop.c VTsw_noop.c std_mouse.c posix_tty.c kmod_noop.c
-OBJS = mnx_init.o mnx_video.o mnx_io.o bios_devmem.o mapVT_noop.o \
- ioperm_noop.o VTsw_noop.o posix_tty.o
+OBJS = mnx_init.o mnx_video.o mnx_io.o bios_devmem.o \
+ ioperm_noop.o VTsw_noop.o posix_tty.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -21,9 +21,9 @@ SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
NormalAsmObjectRule()
-ObjectFromSpecialSource(mapVT_noop,../shared/mapVT_noop,/**/)
ObjectFromSpecialSource(ioperm_noop,../shared/ioperm_noop,/**/)
ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
ObjectFromSpecialSource(posix_tty,../shared/posix_tty,/**/)
+ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile
index 078406136..18bdea822 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile
@@ -1,14 +1,14 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v 1.2 1999/12/27 00:45:44 robin Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/nto/Imakefile,v 1.4 2000/06/27 14:27:30 tsi Exp $
XCOMM
#include <Server.tmpl>
-SRCS = nto_io.c nto_init.c nto_kbdEv.c mapVT_noop.c nto_ioperm.c nto_video.c \
- VTsw_noop.c posix_tty.c std_mseEv.c std_mouse.c
+SRCS = nto_io.c nto_init.c nto_kbdEv.c nto_ioperm.c nto_video.c \
+ VTsw_noop.c posix_tty.c std_mseEv.c std_mouse.c kmod_noop.c
-OBJS = nto_io.o nto_init.o nto_kbdEv.o mapVT_noop.o nto_ioperm.o nto_video.o \
- VTsw_noop.o posix_tty.o std_mseEv.o std_mouse.o
+OBJS = nto_io.o nto_init.o nto_kbdEv.o nto_ioperm.o nto_video.o \
+ VTsw_noop.o posix_tty.o std_mseEv.o std_mouse.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -18,10 +18,10 @@ NormalLibraryObjectRule()
ObjectFromSpecialSource(IO_utils,../shared/IO_utils,/**/)
-ObjectFromSpecialSource(mapVT_noop,../shared/mapVT_noop,/**/)
ObjectFromSpecialSource(VTsw_noop,../shared/VTsw_noop,/**/)
ObjectFromSpecialSource(posix_tty,../shared/posix_tty,/**/)
ObjectFromSpecialSource(std_mseEv,../shared/std_mseEv,/**/)
ObjectFromSpecialSource(std_mouse,../shared/std_mouse,/**/)
+ObjectFromSpecialSource(kmod_noop,../shared/kmod_noop,/**/)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile
index 0e17f9146..1d052d344 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile
@@ -4,20 +4,20 @@ XCOMM $XConsortium: Imakefile /main/7 1996/09/28 17:24:18 rws $
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile,v 3.14 2000/02/13 03:36:09 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/Imakefile,v 3.16 2000/06/27 14:27:31 tsi Exp $
#include <Server.tmpl>
BIOS_MOD = os2_bios
-SRCS = os2_init.c os2_video.c os2_io.c $(BIOS_MOD).c mapVT_noop.c \
+SRCS = os2_init.c os2_video.c os2_io.c $(BIOS_MOD).c \
os2_ioperm.c os2_VTsw.c os2_mouse.c os2_KbdEv.c os2_stubs.c \
os2_select.c os2_diag.c libc_wrapper.c stdResource.c stdPci.c \
- vidmem.c sigiostubs.c pm_noop.c
+ vidmem.c sigiostubs.c pm_noop.c kmod_noop.c
-OBJS = os2_init.o os2_video.o os2_io.o $(BIOS_MOD).o mapVT_noop.o \
+OBJS = os2_init.o os2_video.o os2_io.o $(BIOS_MOD).o \
os2_ioperm.o os2_VTsw.o os2_mouse.o os2_kbdEv.o os2_stubs.o \
os2_select.o os2_diag.o libc_wrapper.o stdResource.o stdPci.o \
- vidmem.o sigiostubs.o pm_noop.o
+ vidmem.o sigiostubs.o pm_noop.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -30,7 +30,6 @@ SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
NormalAsmObjectRule()
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(VTsw_noop.c,../shared)
LinkSourceFile(libc_wrapper.c,../shared)
LinkSourceFile(stdResource.c,../shared)
@@ -38,5 +37,6 @@ LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(vidmem.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile
new file mode 100644
index 000000000..2509e0742
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile
@@ -0,0 +1,110 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/Imakefile,v 1.1 2000/04/05 18:13:55 dawes Exp $
+
+#define IHaveModules
+
+#include <Server.tmpl>
+
+SRCS1 = pci.c xf86int10module.c helper_exec.c helper_mem.c xf86int10.c
+OBJS1 = pci.o xf86int10module.o helper_exec.o helper_mem.o xf86int10.o
+
+LinkSourceFile(helper_mem.c,$(XF86SRC)/int10)
+LinkSourceFile(helper_exec.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10.c,$(XF86SRC)/int10)
+LinkSourceFile(pci.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86int10module.c,$(XF86SRC)/int10)
+LinkSourceFile(xf86x86emu.c,$(XF86SRC)/int10)
+LinkSourceFile(generic.c,$(XF86SRC)/int10)
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86SRC)/int10 \
+ -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC)
+
+DEFINES=-DHAVE_SYSV_IPC
+
+#if 0
+/* debugging stuff */
+#DEFINES =-D_PC
+#undef XF86INT10_BUILD
+#define XF86INT10_BUILD X86EMU_GENERIC
+#define X86EMU_LIBPATH /usr/local/lib
+#endif
+
+#if defined(i386Architecture)
+DEFINES =-D_PC
+#endif
+
+/* XXX keep this temporarily for reference */
+#if 0
+#if (XF86INT10_BUILD == X86EMU_GENERIC)
+
+SRCS = $(SRCS1) xf86x86emu.c generic.c
+OBJS = $(OBJS1) xf86x86emu.o generic.o x86emu.o
+SpecialObjectRule(pci.o, pci.c, -D_X86EMU)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES)
+SpecialObjectRule(generic.o, generic.c, -D_X86EMU)
+SpecialObjectRule(xf86x86emu.o, xf86x86emu.c, -D_X86EMU)
+BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu)
+#endif
+#endif
+
+#if defined(XF86INT10_BUILD) && (XF86INT10_BUILD == X86VM)
+
+SRCS = $(SRCS1) linux.c
+OBJS = $(OBJS1) linux.o
+SpecialObjectRule(pci.o, pci.c, -D_VM86_LINUX)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_VM86_LINUX)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_VM86_LINUX -DSHOW_ALL_DEVICES)
+SpecialObjectRule(linux.o, linux.c, -D_VM86_LINUX -DHAVE_SYSV_IPC)
+
+#elif (XF86INT10_BUILD == X86EMU_OS)
+
+SpecialObjectRule(pci.o, pci.c, -D_X86EMU)
+SpecialObjectRule(helper_exec.o, helper_exec.c, -D_X86EMU)
+SpecialObjectRule(xf86int10.o, xf86int10.c, -D_X86EMU -DSHOW_ALL_DEVICES)
+SpecialObjectRule(linux.o, linux.c, -D_X86EMU -DHAVE_SYSV_IPC)
+
+X86TOPDIR = $(TOP)/extras/x86emu
+X86SRCDIR = $(X86TOPDIR)/src/x86emu
+X86EMUINCLUDES = -I$(X86TOPDIR)/include -I$(X86SRCDIR)
+
+# if !defined(X86EMU_LIBPATH)
+X86EMUSRCS = debug.c decode.c fpu.c ops.c ops2.c prim_ops.c sys.c
+X86EMUOBJS = debug.o decode.o fpu.o ops.o ops2.o prim_ops.o sys.o
+
+LinkSourceFile(debug.c,$(X86SRCDIR))
+LinkSourceFile(decode.c,$(X86SRCDIR))
+LinkSourceFile(fpu.c,$(X86SRCDIR))
+LinkSourceFile(ops.c,$(X86SRCDIR))
+LinkSourceFile(ops2.c,$(X86SRCDIR))
+LinkSourceFile(prim_ops.c,$(X86SRCDIR))
+LinkSourceFile(sys.c,$(X86SRCDIR))
+# else
+BuildObjectFromLibraryWithPath(X86EMU_LIBPATH,x86emu,x86emu)
+X86EMUOBJS = x86emu.o
+# endif
+
+SRCS = $(SRCS1) xf86x86emu.c linux.c $(X86EMUSRCS)
+OBJS = $(OBJS1) xf86x86emu.o linux.o $(X86EMUOBJS)
+
+#endif
+
+#if defined(XF86INT10_BUILD) && XF86INT10_BUILD > X86EMU_GENERIC
+
+LibraryModuleTarget(int10, $(OBJS))
+
+InstallLibraryModule(int10,$(MODULEDIR),linux)
+
+all::
+ (set -x; cd ../..; \
+ RemoveFile(LibraryTargetName(int10)); \
+ $(LN) linux/int10/LibraryTargetName(int10) . )
+
+InstallDriverSDKLibraryModule(int10,$(DRIVERSDKMODULEDIR),.)
+
+InstallDriverSDKNonExecFile(../../int10/xf86int10.h,$(DRIVERSDKINCLUDEDIR))
+
+#endif
+
+DependTarget()
+
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c
new file mode 100644
index 000000000..6a7610d36
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c
@@ -0,0 +1,451 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/int10/os2.c,v 1.1 2000/04/05 18:13:55 dawes Exp $ */
+/*
+ * XFree86 int10 module
+ * execute BIOS int 10h calls in x86 real mode environment
+ * Copyright 1999 Egbert Eich
+ */
+#include "xf86.h"
+#include "xf86str.h"
+#include "xf86_OSproc.h"
+#include "xf86_ansic.h"
+#include "xf86Pci.h"
+#include "compiler.h"
+#define _INT10_PRIVATE
+#include "xf86int10.h"
+#include "int10Defines.h"
+
+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 pagesize_1;
+ int entries;
+ void* vRam;
+ memType *alloc_rec;
+} 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);
+static void setupTable(xf86Int10InfoPtr pInt, memType address,
+ int loc,int size);
+
+static void *sysMem = NULL;
+
+xf86Int10InfoPtr
+xf86InitInt10(int entityIndex)
+{
+ xf86Int10InfoPtr pInt;
+ int screen;
+ void* intMem;
+ void* vbiosMem;
+ int pagesize;
+ int entries;
+ int shift;
+ legacyVGARec vga;
+
+ screen = (xf86FindScreenForEntity(entityIndex))->scrnIndex;
+
+ if (int10skip(xf86Screens[screen],entityIndex))
+ return NULL;
+
+ pInt = (xf86Int10InfoPtr)xnfcalloc(1,sizeof(xf86Int10InfoRec));
+ pInt->entityIndex = entityIndex;
+ if (!xf86Int10ExecSetup(pInt))
+ goto error0;
+ pInt->mem = &genericMem;
+ pagesize = xf86getpagesize();
+ pInt->private = (pointer)xnfcalloc(1,sizeof(genericInt10Priv));
+ entries = SYS_SIZE / pagesize;
+
+ pInt->scrnIndex = screen;
+ INTPriv(pInt)->pagesize_1 = pagesize - 1;
+ INTPriv(pInt)->entries = entries;
+ INTPriv(pInt)->alloc_rec =
+ xnfcalloc(1,sizeof(memType) * entries);
+ for (shift = 0 ; (pagesize >> shift) ; shift++) {};
+ shift -= 1;
+ INTPriv(pInt)->shift = shift;
+
+ /*
+ * we need to map video RAM MMIO as some chipsets map mmio
+ * registers into this range.
+ */
+
+ MapVRam(pInt);
+ intMem = xnfalloc(pagesize);
+ setupTable(pInt,(memType)intMem,0,pagesize);
+ vbiosMem = xnfalloc(V_BIOS_SIZE);
+
+#ifdef _PC
+ if (!sysMem)
+ sysMem = xf86MapVidMem(screen,VIDMEM_FRAMEBUFFER,SYS_BIOS,BIOS_SIZE);
+ setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE);
+ if (xf86ReadBIOS(0,0,(unsigned char *)intMem,LOW_PAGE_SIZE) < 0) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read int vect\n");
+ goto error1;
+ }
+ if (xf86IsEntityPrimary(entityIndex)) {
+ int size;
+ int cs = MEM_RW(pInt,((0x10<<2)+2));
+
+int i,k,m;
+char buf[100], hx[10];
+for (i=0; i<0x100; i+=16) {
+sprintf(buf,"%04x: ",i);
+for (k=0; k<16; k++) {
+ m = MEM_RB(pInt,i+k);
+ sprintf(hx,"%02x ",((unsigned)m)&0xff);
+ strcat(buf,hx);
+}
+xf86DrvMsg(screen,X_INFO,"%s\n",buf);
+}
+
+
+
+ xf86DrvMsg(screen,X_INFO,"Primary V_BIOS segmant is: 0x%x\n",cs);
+ if (xf86ReadBIOS(cs << 4,0,(unsigned char *)vbiosMem,
+ 0x10) < 0) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (1)\n");
+ goto error1;
+ }
+ if (!((*(CARD8*)vbiosMem == 0x55)
+ && (*((CARD8*)vbiosMem + 1) == 0xAA))) {
+ xf86DrvMsg(screen,X_ERROR,"No V_BIOS found\n");
+ goto error1;
+ }
+
+ size = *((CARD8*)vbiosMem + 2) * 512;
+ if (xf86ReadBIOS(cs << 4,0,vbiosMem, size) < 0) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (2)\n");
+ goto error1;
+ }
+ if (bios_checksum(vbiosMem,size)) {
+ xf86DrvMsg(screen,X_ERROR,"Bad checksum of V_BIOS \n");
+ goto error1;
+ }
+
+ setupTable(pInt,(memType)vbiosMem,cs<<4,size);
+ set_return_trap(pInt);
+ pInt->BIOSseg = cs;
+ } else {
+ reset_int_vect(pInt);
+ set_return_trap(pInt);
+ if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (3)\n");
+ goto error1;
+ }
+ setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE);
+ pInt->BIOSseg = V_BIOS >> 4;
+ pInt->num = 0xe6;
+ LockLegacyVGA(screen, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(screen, &vga);
+ }
+#else
+ if (!sysMem) {
+ sysMem = xnfalloc(BIOS_SIZE);
+ setup_system_bios((memType)sysMem);
+ }
+ setupTable(pInt,(memType)sysMem,SYS_BIOS,BIOS_SIZE);
+ setup_int_vect(pInt);
+ set_return_trap(pInt);
+ if (!mapPciRom(pInt,(unsigned char *)(vbiosMem))) {
+ xf86DrvMsg(screen,X_ERROR,"Cannot read V_BIOS (4)\n");
+ goto error1;
+ }
+ setupTable(pInt,(memType)vbiosMem,V_BIOS,V_BIOS_SIZE);
+ pInt->BIOSseg = V_BIOS >> 4;
+ pInt->num = 0xe6;
+ LockLegacyVGA(screen, &vga);
+ xf86ExecX86int10(pInt);
+ UnlockLegacyVGA(screen, &vga);
+#endif
+ return pInt;
+
+ error1:
+ xfree(vbiosMem);
+ xfree(intMem);
+ UnmapVRam(pInt);
+ xfree(INTPriv(pInt)->alloc_rec);
+ xfree(pInt->private);
+ error0:
+ xfree(pInt);
+
+ return NULL;
+}
+
+static void
+MapVRam(xf86Int10InfoPtr pInt)
+{
+ int screen = pInt->scrnIndex;
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
+ INTPriv(pInt)->vRam = xf86MapVidMem(screen,VIDMEM_MMIO,V_RAM,size);
+}
+
+static void
+UnmapVRam(xf86Int10InfoPtr pInt)
+{
+ int screen = pInt->scrnIndex;
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int size = ((VRAM_SIZE + pagesize - 1)/pagesize) * pagesize;
+
+ xf86UnMapVidMem(screen,INTPriv(pInt)->vRam,size);
+}
+
+void
+MapCurrentInt10(xf86Int10InfoPtr pInt)
+{
+ /* nothing to do here */
+}
+
+void
+xf86FreeInt10(xf86Int10InfoPtr pInt)
+{
+ int pagesize;
+
+ if (!pInt)
+ return;
+ pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ if (Int10Current == pInt)
+ Int10Current = NULL;
+ xfree(INTPriv(pInt)->alloc_rec[V_BIOS/pagesize]);
+ xfree(INTPriv(pInt)->alloc_rec[0]);
+ UnmapVRam(pInt);
+ xfree(INTPriv(pInt)->alloc_rec);
+ xfree(pInt->private);
+ xfree(pInt);
+}
+
+void *
+xf86Int10AllocPages(xf86Int10InfoPtr pInt,int num, int *off)
+{
+ void* addr;
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int num_pages = INTPriv(pInt)->entries;
+ int i,j;
+
+ for (i=0;i<num_pages - num;i++) {
+ if (INTPriv(pInt)->alloc_rec[i] == 0) {
+ for (j=i;j < num + i;j++)
+ if ((INTPriv(pInt)->alloc_rec[j] != 0))
+ break;
+ if (j == num + i)
+ break;
+ else
+ i = i + num;
+ }
+ }
+ if (i == num_pages - num)
+ return NULL;
+
+ *off = i * pagesize;
+ addr = xnfalloc(pagesize * num);
+ setupTable(pInt,(memType)addr,*off,pagesize * num);
+
+ return addr;
+}
+
+void
+xf86Int10FreePages(xf86Int10InfoPtr pInt, void *pbase, int num)
+{
+ int num_pages = INTPriv(pInt)->entries;
+ int i,j;
+ for (i = 0;i<num_pages - num; i++)
+ if (INTPriv(pInt)->alloc_rec[i]==(memType)pbase) {
+ for (j = 0; j < num; j++)
+ INTPriv(pInt)->alloc_rec[i] = 0;
+ break;
+ }
+ xfree(pbase);
+ return;
+}
+
+static void
+setupTable(xf86Int10InfoPtr pInt, memType address,int loc,int size)
+{
+ int pagesize = INTPriv(pInt)->pagesize_1 + 1;
+ int i,j,num;
+
+ i = loc / pagesize;
+ num = (size + pagesize - 1)/ pagesize; /* round up to the nearest page */
+ /* boudary if size is not */
+ /* multiple of pagesize */
+ for (j = 0; j<num; j++) {
+ INTPriv(pInt)->alloc_rec[i+j] = address;
+ address += pagesize;
+ }
+}
+
+#define OFF(addr) \
+ ((addr) & (INTPriv(pInt)->pagesize_1))
+#define SHIFT \
+ (INTPriv(pInt)->shift)
+#define BASE(addr,shift) \
+ (INTPriv(pInt)->alloc_rec[addr >> shift])
+#define V_ADDR(addr,shift,off) \
+ (BASE(addr,shift) + (off))
+#define VRAM_ADDR(addr) (addr - 0xA0000)
+#define VRAM_BASE (INTPriv(pInt)->vRam)
+
+#define VRAM(addr) ((addr >= 0xA0000) && (addr <= 0xBFFFF))
+#define V_ADDR_RB(addr,shift,off) \
+ (VRAM(addr)) ? MMIO_IN8((CARD8*)VRAM_BASE,VRAM_ADDR(addr)) \
+ : *(CARD8*) V_ADDR(addr,shift,off)
+#define V_ADDR_RW(addr,shift,off) \
+ (VRAM(addr)) ? MMIO_IN16((CARD16*)VRAM_BASE,VRAM_ADDR(addr)) \
+ : ldw_u((pointer)V_ADDR(addr,shift,off))
+#define V_ADDR_RL(addr,shift,off) \
+ (VRAM(addr)) ? MMIO_IN32((CARD32*)VRAM_BASE,VRAM_ADDR(addr)) \
+ : ldl_u((pointer)V_ADDR(addr,shift,off))
+
+#define V_ADDR_WB(addr,shift,off,val) \
+ if(VRAM(addr)) \
+ MMIO_OUT8((CARD8*)VRAM_BASE,VRAM_ADDR(addr),val); \
+ else \
+ *(CARD8*) V_ADDR(addr,shift,off) = val;
+#define V_ADDR_WW(addr,shift,off,val) \
+ if(VRAM(addr)) \
+ MMIO_OUT16((CARD16*)VRAM_BASE,VRAM_ADDR(addr),val); \
+ else \
+ stw_u((val),(pointer)(V_ADDR(addr,shift,off)));
+
+#define V_ADDR_WL(addr,shift,off,val) \
+ if (VRAM(addr)) \
+ MMIO_OUT32((CARD32*)VRAM_BASE,VRAM_ADDR(addr),val); \
+ else \
+ stl_u(val,(pointer)(V_ADDR(addr,shift,off)));
+
+static CARD8
+read_b(xf86Int10InfoPtr pInt, int addr)
+{
+ if (!BASE(addr,SHIFT)) return 0xff;
+
+ return V_ADDR_RB(addr,SHIFT,OFF(addr));
+}
+
+static CARD16
+read_w(xf86Int10InfoPtr pInt, int addr)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+
+ if (!BASE(addr,shift)) return 0xffff;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ return ((V_ADDR_RB(addr,shift,off))
+ || ((V_ADDR_RB(addr,shift,off + 1)) << 8));
+#else
+ if (OFF(addr + 1) > 0) {
+ return V_ADDR_RW(addr,SHIFT,OFF(addr));
+ } else {
+ return ((V_ADDR_RB(addr,shift,off + 1))
+ || ((V_ADDR_RB(addr,shift,off)) << 8));
+ }
+#endif
+}
+
+static CARD32
+read_l(xf86Int10InfoPtr pInt, int addr)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+
+ if (!BASE(addr,shift)) return 0xffffffff;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ return ((V_ADDR_RB(addr,shift,off))
+ || ((V_ADDR_RB(addr,shift,off + 1)) << 8)
+ || ((V_ADDR_RB(addr,shift,off + 2)) << 16)
+ || ((V_ADDR_RB(addr,shift,off + 3)) << 24));
+#else
+ if (OFF(addr + 3) > 2) {
+ return V_ADDR_RL(addr,SHIFT,OFF(addr));
+ } else {
+ return ((V_ADDR_RB(addr,shift,off + 3))
+ || ((V_ADDR_RB(addr,shift,off + 2)) << 8)
+ || ((V_ADDR_RB(addr,shift,off + 1)) << 16)
+ || ((V_ADDR_RB(addr,shift,off)) << 24));
+ }
+#endif
+}
+
+static void
+write_b(xf86Int10InfoPtr pInt, int addr, CARD8 val)
+{
+ if (!BASE(addr,SHIFT)) return;
+
+ V_ADDR_WB(addr,SHIFT,OFF(addr),val);
+}
+
+static void
+write_w(xf86Int10InfoPtr pInt, int addr, CARD16 val)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+
+ if (!BASE(addr,shift)) return;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ V_ADDR_WB(addr,shift,off,val);
+ V_ADDR_WB(addr,shift,off + 1,val >> 8);
+#else
+ if (OFF(addr + 1) > 0) {
+ V_ADDR_WW(addr,shift,OFF(addr),val);
+ } else {
+ V_ADDR_WB(addr,shift,off + 1,val);
+ V_ADDR_WB(addr,shift,off,val >> 8);
+ }
+#endif
+}
+
+static void
+write_l(xf86Int10InfoPtr pInt, int addr, CARD32 val)
+{
+ int shift = SHIFT;
+ int off = OFF(addr);
+ if (!BASE(addr,shift)) return;
+
+#if X_BYTE_ORDER == X_BIG_ENDIAN
+ V_ADDR_WB(addr,shift,off,val);
+ V_ADDR_WB(addr,shift,off + 1, val >> 8);
+ V_ADDR_WB(addr,shift,off + 2, val >> 16);
+ V_ADDR_WB(addr,shift,off + 3, val >> 24);
+#else
+ if (OFF(addr + 3) > 2) {
+ V_ADDR_WL(addr,shift,OFF(addr),val);
+ } else {
+ V_ADDR_WB(addr,shift,off + 3, val);
+ V_ADDR_WB(addr,shift,off + 2, val >> 8);
+ V_ADDR_WB(addr,shift,off + 1, val >> 16);
+ V_ADDR_WB(addr,shift,off, val >> 24);
+ }
+#endif
+}
+
+pointer
+xf86int10Addr(xf86Int10InfoPtr pInt, CARD32 addr)
+{
+ return (pointer) V_ADDR(addr,SHIFT,OFF(addr));
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c
index a2fc5952c..e979b2e19 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c,v 3.9 1999/04/29 09:13:47 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_VTsw.c,v 3.10 2000/04/05 18:13:51 dawes Exp $ */
/*
* Copyright 1993 by David Wexelblat <dwex@goblin.org>
* Modified 1996 by Sebastien Marineau <marineau@genie.uottawa.ca>
@@ -190,13 +190,47 @@ void * arg;
/* End of thread */
}
-void os2ServerVideoAccess()
+static BOOL is_redirected = FALSE;
+
+static void
+redirect_output(void)
+{
+ /* hv300996 create redirect file on boot drive, instead
+ * anywhere you are just standing
+ */
+ char buf[20],dr[3];
+ ULONG drive;
+ APIRET rc;
+
+ if (is_redirected) return;
+
+ if ((rc = DosQuerySysInfo(5,5,&drive,sizeof(drive))) != 0)
+ dr[0] = 0;
+ else {
+ dr[0] = drive+96;
+ dr[1] = ':';
+ dr[2] = 0;
+ }
+ sprintf(buf,"%s\\xf86log.os2",dr);
+
+ ErrorF("\nThis is the XFree86/OS2-4.0 server\n");
+ ErrorF("\nAll output from now on will be redirected to %s\n",buf);
+ freopen(buf,"w",stderr);
+
+ is_redirected = TRUE;
+}
+
+void
+os2ServerVideoAccess()
{
APIRET rc;
ULONG fgSession;
ULONG length=4;
CHAR Status;
+ /* Redirect output as early as possible */
+ redirect_output();
+
/* Wait for screen access. This is called at server reset or at server startup */
/* Here we do some waiting until this session comes in the foreground before *
* going any further. This is because we may have been started in the bg */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c
index 8b08a437f..81397fbf6 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c,v 3.9 1999/12/14 03:38:55 robin Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_bios.c,v 3.10 2000/04/05 18:13:52 dawes Exp $ */
/*
* (c) Copyright 1994 by Holger Veit
* <Holger.Veit@gmd.de>
@@ -107,7 +107,7 @@ int Len;
Len -= chunksz;
rc = doioctl(fd,(ULONG)Phys_address,chunksz,dta+off);
if (rc != 0) {
- ErrorF("xf86ReadBIOS: BIOS map failed, addr=%lx, rc=%d\n",
+ FatalError("xf86ReadBIOS: BIOS map failed, addr=%lx, rc=%d\n",
Phys_address,rc);
xfree(dta);
DosClose(fd);
@@ -120,11 +120,13 @@ int Len;
* Sanity check... No longer fatal, as some PS/1 and PS/2 fail here but still work.
* S. Marineau, 10/10/96
*/
+#if 0
if ((Phys_address & 0x7fff) != 0 &&
(dta[0] != 0x55 || dta[1] != 0xaa)) {
FatalError("BIOS sanity check failed, addr=%x\nPlease report if you encounter problems\n",
Phys_address);
}
+#endif
/* copy data to buffer */
memcpy(Buf, dta, lensave);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c
index af554c6e8..b2654a82b 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c,v 3.6 1999/04/29 09:13:48 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_diag.c,v 3.7 2000/04/05 18:13:52 dawes Exp $ */
/*
* (c) Copyright 1997 by Holger Veit
* <Holger.Veit@gmd.de>
@@ -59,7 +59,8 @@
static BOOL diag_checks = FALSE;
/* from Eberhard to check for the right EMX version */
-static void check_emx (void)
+static void
+check_emx (void)
{
ULONG rc;
HMODULE hmod;
@@ -80,7 +81,8 @@ static void check_emx (void)
}
}
-static void check_bsl(const char *var)
+static void
+check_bsl(const char *var)
{
char *t1 = strrchr(var,'\\');
if (strchr(var,'/')) {
@@ -96,7 +98,8 @@ static void check_bsl(const char *var)
}
-static void check_fsl(const char *var)
+static void
+check_fsl(const char *var)
{
char *t1 = strrchr(var,'/');
if (strchr(var,'\\')) {
@@ -107,7 +110,8 @@ static void check_fsl(const char *var)
}
-static void check_long(const char* path)
+static void
+check_long(const char* path)
{
FILE *f;
char n[300];
@@ -124,7 +128,8 @@ static void check_long(const char* path)
}
}
-char *check_env_present(const char *env)
+static char *
+check_env_present(const char *env)
{
char *e = getenv(env);
if (!e) {
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c
index 550c0a5b1..e7d1d96de 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c,v 3.13 1999/04/29 09:13:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_io.c,v 3.14 2000/04/05 18:13:52 dawes Exp $ */
/*
* (c) Copyright 1994,1999 by Holger Veit
* <Holger.Veit@gmd.de>
@@ -141,6 +141,7 @@ int xf86KbdOff()
return -1;
}
+#if 0 /*OBSOLETE*/
void xf86MouseInit(mouse)
MouseDevPtr mouse;
{
@@ -163,7 +164,9 @@ MouseDevPtr mouse;
if (rc == 0)
xf86Msg(X_INFO,"OsMouse has %d button(s).\n",nbut);
}
+#endif
+#if 0 /*OBSOLETE*/
int xf86MouseOn(mouse)
MouseDevPtr mouse;
{
@@ -194,10 +197,12 @@ MouseDevPtr mouse;
return (mouse->mseFd);
#endif
}
+#endif
+#if 0 /*OBSOLETE*/
/* This table is a bit irritating, because these mouse types are infact
* defined in the OS/2 kernel, but I want to force the user to put
- * ïOsMouseï in the config file, and not worry about the particular mouse
+ * "OsMouse" in the config file, and not worry about the particular mouse
* type that is connected.
*/
Bool xf86SupportedMouseTypes[] =
@@ -214,3 +219,4 @@ Bool xf86SupportedMouseTypes[] =
int xf86NumMouseTypes = sizeof(xf86SupportedMouseTypes) /
sizeof(xf86SupportedMouseTypes[0]);
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c
index b24a46748..d7c4bb7f4 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c
@@ -1,6 +1,6 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c,v 3.15 1999/04/29 09:13:50 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_mouse.c,v 3.16 2000/04/05 18:13:53 dawes Exp $ */
/*
- * (c) Copyright 1994,1999 by Holger Veit
+ * (c) Copyright 1994,1999,2000 by Holger Veit
* <Holger.Veit@gmd.de>
* Modified (c) 1996 Sebastien Marineau <marineau@genie.uottawa.ca>
*
@@ -48,167 +48,83 @@
#include "xf86_OSlib.h"
#include "xf86Config.h"
-extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
- unsigned long start, unsigned long stop,
- ScreenPtr pScreen);
+#include "xf86Xinput.h"
+#include "xf86OSmouse.h"
+#include "mipointer.h"
-HMOU hMouse=65535;
-HEV hMouseSem;
-HQUEUE hMouseQueue;
-int MouseTid;
-BOOL HandleValid=FALSE;
-extern BOOL SwitchedToWPS;
-extern CARD32 LastSwitchTime;
-void os2MouseEventThread();
-
-int xf86MouseOff(MouseDevPtr mouse, Bool doclose)
+static int
+SupportedInterfaces(void)
{
- return -1;
+ return MSE_MISC;
}
-void xf86SetMouseSpeed(MouseDevPtr mouse, int old, int new, unsigned cflag)
-{
- /* not required */
-}
+static const char* internalNames[] = {
+ "OS2Mouse",
+ NULL
+};
-void xf86OsMouseOption(token, lex_ptr)
-int token;
-pointer lex_ptr;
+static const char**
+BuiltinNames(void)
{
- /* no options, anything seen ignored */
+ return internalNames;
}
-/* almost everything stolen from sco_mouse.c */
-int xf86OsMouseProc(DeviceIntPtr pPointer, int what)
+static Bool
+CheckProtocol(const char *protocol)
{
- APIRET rc = 0;
- USHORT nbutton, state;
- unsigned char *map;
int i;
- MouseDevPtr priv = (MouseDevPtr)((DeviceIntPtr)pPointer)->public.devicePrivate;
- switch (what) {
- case DEVICE_INIT:
- pPointer->public.on = FALSE;
- if (hMouse == 65535)
- rc = MouOpen((PSZ)0, &hMouse);
- if (rc != 0)
- FatalError("Cannot open mouse, rc=%d\n", rc);
- xf86Info.mouseDev->mseFd = -1;
-
- /* flush mouse queue */
- MouFlushQue(hMouse);
-
- /* check buttons */
- rc = MouGetNumButtons(&nbutton, hMouse);
- if (rc == 0)
- xf86Msg(X_INFO,
- "OsMouse has %d button(s).\n",nbutton);
- if (nbutton==2) nbutton++;
- map = xalloc(nbutton + 1);
- if (map == 0)
- FatalError("Failed to allocate OsMouse map structure\n");
-
- for (i = 1; i<=nbutton; i++)
- map[i] = i;
-
- InitPointerDeviceStruct((DevicePtr)pPointer, map, nbutton,
- miPointerGetMotionEvents, (PtrCtrlProcPtr)xf86MseCtrl,
- miPointerGetMotionBufferSize());
-
- xfree(map);
-
-#ifdef XINPUT
- InitValuatorAxisStruct(pPointer,
- 0,
- 0, /* min val */
- screenInfo.screens[0]->width, /* max val */
- 1, /* resolution */
- 0, /* min_res */
- 1); /* max_res */
- InitValuatorAxisStruct(pPointer,
- 1,
- 0, /* min val */
- screenInfo.screens[0]->height, /* max val */
- 1, /* resolution */
- 0, /* min_res */
- 1); /* max_res */
- /* Initialize valuator values in synch
- * with dix/event.c DefineInitialRootWindow
- */
- *pPointer->valuator->axisVal = screenInfo.screens[0]->width / 2;
- *(pPointer->valuator->axisVal+1) = screenInfo.screens[0]->height / 2;
-#endif
+ for (i = 0; internalNames[i]; i++)
+ if (xf86NameCmp(protocol, internalNames[i]) == 0)
+ return TRUE;
+ return FALSE;
+}
- /* OK, we are ready to start up the mouse thread ! */
- if (!HandleValid) {
- rc = DosCreateEventSem(NULL,&hMouseSem,DC_SEM_SHARED,TRUE);
- if (rc != 0)
- FatalError("xf86OpenMouse: could not create mouse queue semaphore, rc=%d\n",rc);
- MouseTid = _beginthread(os2MouseEventThread,NULL,0x4000,(void *)NULL);
- xf86Msg(X_INFO,
- "Started Mouse event thread, Tid=%d\n",MouseTid);
- DosSetPriority(2,3,0,MouseTid);
- }
- HandleValid=TRUE;
- break;
-
- case DEVICE_ON:
- /*AddEnabledDevice(xf86Info.mouseDev->mseFd);*/
- if (!HandleValid) return -1;
- xf86Info.mouseDev->lastButtons = 0;
- xf86Info.mouseDev->emulateState = 0;
- pPointer->public.on = TRUE;
- state = 0x300;
- rc = MouSetDevStatus(&state,hMouse);
- state = 0x7f;
- rc = MouSetEventMask(&state,hMouse);
- MouFlushQue(hMouse);
- break;
+static const char *
+DefaultProtocol(void)
+{
+ return "OS2Mouse";
+}
- case DEVICE_CLOSE:
- case DEVICE_OFF:
- if (!HandleValid) return -1;
- pPointer->public.on = FALSE;
- state = 0x300;
- MouSetDevStatus(&state,hMouse);
- state = 0;
- MouSetEventMask(&state,hMouse);
- /*RemoveEnabledDevice(xf86Info.mouseDev->mseFd);*/
- if (what == DEVICE_CLOSE) {
-/* Comment out for now as this seems to break server */
-#if 0
- MouClose(hMouse);
- hMouse = 65535;
- xf86Info.mouseDev.mseFd = -1;
- HandleValid = FALSE;
-#endif
- }
- break;
- }
- return Success;
+static const char *
+SetupAuto(InputInfoPtr pInfo, int *protoPara)
+{
+ return "OS2Mouse";
}
-void xf86OsMouseEvents()
+HMOU hMouse=65535;
+HEV hMouseSem;
+HQUEUE hMouseQueue;
+InputInfoPtr iinfoPtr;
+int MouseTid;
+BOOL HandleValid=FALSE;
+extern BOOL SwitchedToWPS;
+extern CARD32 LastSwitchTime;
+void os2MouseEventThread(void* arg);
+
+static void
+os2MouseReadInput(InputInfoPtr pInfo)
{
APIRET rc;
ULONG postCount,dataLength;
PVOID dummy;
int buttons;
int state;
- int i, col, row;
+ int i, dx,dy;
BYTE elemPriority;
REQUESTDATA requestData;
+ MouseDevPtr pMse = pInfo->private;
+
if (!HandleValid) return;
while((rc = DosReadQueue(hMouseQueue,
&requestData,&dataLength,&dummy,
0L,1L,&elemPriority,hMouseSem)) == 0) {
- col = requestData.ulData;
+ dx = requestData.ulData;
(void)DosReadQueue(hMouseQueue,
&requestData,&dataLength,&dummy,
0L,1L,&elemPriority,hMouseSem);
- row = requestData.ulData;
+ dy = requestData.ulData;
(void)DosReadQueue(hMouseQueue,
&requestData,&dataLength,&dummy,
0L,1L,&elemPriority,hMouseSem);
@@ -228,73 +144,252 @@ void xf86OsMouseEvents()
buttons = ((state & 0x06) ? 4 : 0) |
((state & 0x18) ? 1 : 0) |
((state & 0x60) ? 2 : 0);
- xf86PostMseEvent(xf86Info.pMouse, buttons, col, row);
+ pMse->PostEvent(pInfo, buttons, dx, dy, 0, 0);
}
DosResetEventSem(hMouseSem,&postCount);
- xf86Info.inputPending = TRUE;
}
-int os2MouseQueueQuery()
+int os2MouseProc(DeviceIntPtr pPointer, int what)
{
- /* Now we check for activity on mouse handles */
- ULONG numElements,postCount;
+ APIRET rc = 0;
+ USHORT nbuttons, state;
+ unsigned char map[MSE_MAXBUTTONS + 1];
+ int i;
- if (!HandleValid) return(1);
- DosResetEventSem(hMouseSem,&postCount);
- (void)DosQueryQueue(hMouseQueue,&numElements);
- if (numElements>0) { /* Something in mouse queue! */
- return 0; /* Will this work? */
+ InputInfoPtr pInfo = pPointer->public.devicePrivate;
+ MouseDevPtr pMse = pInfo->private;
+ pMse->device = pPointer;
+
+ switch (what) {
+ case DEVICE_INIT:
+ pPointer->public.on = FALSE;
+ if (hMouse == 65535)
+ rc = MouOpen((PSZ)0, &hMouse);
+ if (rc != 0)
+ xf86Msg(X_WARNING,"%s: cannot open mouse, rc=%d\n",
+ pInfo->name,rc);
+ else {
+ pInfo->fd = hMouse;
+
+ /* flush mouse queue */
+ MouFlushQue(hMouse);
+
+ /* check buttons */
+ rc = MouGetNumButtons(&nbuttons, hMouse);
+ if (rc == 0)
+ xf86Msg(X_INFO,"%s: Mouse has %d button(s).\n",
+ pInfo->name,nbuttons);
+ if (nbuttons==2) nbuttons++;
+
+ for (i = 1; i<=nbuttons; i++)
+ map[i] = i;
+
+ InitPointerDeviceStruct((DevicePtr)pPointer, map, nbuttons,
+ miPointerGetMotionEvents, pMse->Ctrl,
+ miPointerGetMotionBufferSize());
+
+ /* X valuator */
+ xf86InitValuatorAxisStruct(pPointer, 0, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 0);
+ /* y Valuator */
+ InitValuatorAxisStruct(pPointer, 1, 0, -1, 1, 0, 1);
+ xf86InitValuatorDefaults(pPointer, 1);
+ xf86MotionHistoryAllocate(pInfo);
+
+ /* OK, we are ready to start up the mouse thread ! */
+ if (!HandleValid) {
+ rc = DosCreateEventSem(NULL,&hMouseSem,DC_SEM_SHARED,TRUE);
+ if (rc != 0)
+ xf86Msg(X_ERROR,"%s: could not create mouse queue semaphore, rc=%d\n",
+ pInfo->name,rc);
+ MouseTid = _beginthread(os2MouseEventThread,NULL,0x4000,(void *)pInfo);
+ xf86Msg(X_INFO,
+ "%s: Started Mouse event thread, Tid=%d\n",
+ pInfo->name, MouseTid);
+ DosSetPriority(2,3,0,MouseTid);
+ }
+ HandleValid=TRUE;
+ }
+ break;
+
+ case DEVICE_ON:
+ if (!HandleValid) return -1;
+ pMse->lastButtons = 0;
+ pMse->emulateState = 0;
+ pPointer->public.on = TRUE;
+ state = 0x300;
+ rc = MouSetDevStatus(&state,hMouse);
+ state = 0x7f;
+ rc = MouSetEventMask(&state,hMouse);
+ MouFlushQue(hMouse);
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ if (!HandleValid) return -1;
+ pPointer->public.on = FALSE;
+ state = 0x300;
+ MouSetDevStatus(&state,hMouse);
+ state = 0;
+ MouSetEventMask(&state,hMouse);
+ if (what == DEVICE_CLOSE) {
+/* Comment out for now as this seems to break server */
+#if 0
+ MouClose(hMouse);
+ hMouse = 65535;
+ pInfo->fd = -1;
+ HandleValid = FALSE;
+#endif
}
- return 1;
+ break;
+ }
+ return Success;
+}
+
+int os2MouseQueueQuery()
+{
+ /* Now we check for activity on mouse handles */
+ ULONG numElements,postCount;
+
+ if (!HandleValid) return(1);
+ DosResetEventSem(hMouseSem,&postCount);
+ (void)DosQueryQueue(hMouseQueue,&numElements);
+ if (numElements>0) { /* Something in mouse queue! */
+ return 0; /* Will this work? */
+ }
+ return 1;
}
void os2MouseEventThread(void *arg)
{
+ APIRET rc;
+ MOUEVENTINFO mev;
+ ULONG queueParam;
+ USHORT waitflg;
+ char queueName[128];
+ MouseDevPtr pMse;
+
+ iinfoPtr = (InputInfoPtr)arg;
+ pMse = iinfoPtr->private;
+
+ sprintf(queueName,"\\QUEUES\\XF86MOU\\%d",getpid());
+ rc = DosCreateQueue(&hMouseQueue,0L,queueName);
+ xf86Msg(X_INFO,"Mouse Queue created, rc=%d\n",rc);
+ (void)DosPurgeQueue(hMouseQueue);
+
+ while(1) {
+ waitflg = 1;
+ rc = MouReadEventQue(&mev,&waitflg,hMouse);
+ if (rc) {
+ xf86Msg(X_ERROR,
+ "Bad return code from mouse driver, rc=%d\n",
+ rc);
+ xf86Msg(X_ERROR,"Mouse aborting!\n");
+ break;
+ }
+
+ queueParam = mev.col;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ queueParam = mev.row;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ queueParam = mev.fs;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ queueParam = 0xFFFFFFFF;
+ if ((rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L)))
+ break;
+ }
+ xf86Msg(X_ERROR,
+ "An unrecoverable error in mouse queue has occured, rc=%d. Mouse is shutting down.\n",
+ rc);
+ DosCloseQueue(hMouseQueue);
+}
+
+
+static Bool
+os2MousePreInit(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);
+
+ /* Process common mouse options (like Emulate3Buttons, etc). */
+ pMse->CommonOptions(pInfo);
+
+ /* Setup the local procs. */
+ pInfo->device_control = os2MouseProc;
+ pInfo->read_input = os2MouseReadInput;
+
+ pInfo->flags |= XI86_CONFIGURED;
+ return TRUE;
+}
+
+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 = os2MousePreInit;
+ p->SetupAuto = SetupAuto;
+ return p;
+}
+
+void xf86OsMouseEvents()
+{
APIRET rc;
- MOUEVENTINFO mev;
- ULONG queueParam;
- USHORT waitflg;
- char queueName[128];
-
- sprintf(queueName,"\\QUEUES\\XF86MOU\\%d",getpid());
- rc = DosCreateQueue(&hMouseQueue,0L,queueName);
- xf86Msg(X_INFO,"Mouse Queue created, rc=%d\n",rc);
- (void)DosPurgeQueue(hMouseQueue);
-
- while(1) {
- waitflg = 1;
- rc = MouReadEventQue(&mev,&waitflg,hMouse);
- if (rc) {
+ ULONG postCount,dataLength;
+ PVOID dummy;
+ int buttons;
+ int state;
+ int i, dx,dy;
+ BYTE elemPriority;
+ REQUESTDATA requestData;
+
+ MouseDevPtr pMse = iinfoPtr->private;
+
+ if (!HandleValid) return;
+ while((rc = DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem)) == 0) {
+ dx = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ dy = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ state = requestData.ulData;
+ (void)DosReadQueue(hMouseQueue,
+ &requestData,&dataLength,&dummy,
+ 0L,1L,&elemPriority,hMouseSem);
+ if (requestData.ulData != 0xFFFFFFFF)
xf86Msg(X_ERROR,
- "Bad return code from mouse driver, rc=%d\n",
- rc);
- xf86Msg(X_ERROR,"Mouse aborting!\n");
- break;
- }
-
- /* Format of mouse packet is the following:
- * first queued message is mev.col,
- * second is mev.row,
- * third is state and
- * last is FFFFFFFF for "end-of-record".
- * We could pack this better but it is a good start...
- */
-
- queueParam = mev.col;
- rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L);
- if (rc) break;
- queueParam = mev.row;
- rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L);
- if (rc) break;
- queueParam = mev.fs;
- rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L);
- if (rc) break;
- queueParam = 0xFFFFFFFF;
- rc = DosWriteQueue(hMouseQueue,queueParam,0L,NULL,0L);
- if (rc) break;
+ "Unexpected mouse event tag, %d\n",
+ requestData.ulData);
+
+ /* Contrary to other systems, OS/2 has mouse buttons *
+ * in the proper order, so we reverse them before *
+ * sending the event. */
+
+ buttons = ((state & 0x06) ? 4 : 0) |
+ ((state & 0x18) ? 1 : 0) |
+ ((state & 0x60) ? 2 : 0);
+ pMse->PostEvent(iinfoPtr, buttons, dx, dy, 0, 0);
}
- xf86Msg(X_ERROR,
- "An unrecoverable error in mouse queue has occured, rc=%d. Mouse is shutting down.\n",
- rc);
- DosCloseQueue(hMouseQueue);
+ DosResetEventSem(hMouseSem,&postCount);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c
index 74924c65e..e98e753cf 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c
@@ -3,7 +3,7 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c,v 3.7 1999/04/29 09:13:50 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_select.c,v 3.8 2000/04/05 18:13:53 dawes Exp $ */
/*
* (c) Copyright 1996 by Sebastien Marineau
@@ -45,21 +45,22 @@
#include <sys/errno.h>
#include <emx/io.h>
+#define I_NEED_OS2_H
#define INCL_DOSSEMAPHORES
#define INCL_DOSPROFILE
#define INCL_DOSPROCESS
#define INCL_DOSFILEMGR
#define INCL_DOSMISC
#define INCL_DOSMODULEMGR
-#include <os2.h>
-#include "os2_select.h"
#include "Xpoll.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86_OSlib.h"
+#include "os2_select.h"
+
int os2MouseQueueQuery();
int os2KbdQueueQuery();
void os2RecoverFromPopup();
@@ -337,7 +338,7 @@ fd_set *readfds,*writefds;
sd->socket_nwrite, 0, 0);
if(e == 0) return(e);
-/* We have something ready? */
+ /* We have something ready? */
if(e>0){
j = 0; n = 0;
for (i = 0; i < sd->socket_nread; ++i, ++j)
@@ -370,10 +371,10 @@ int os2_check_pipes(sd,readfds,writefds)
struct select_data *sd;
fd_set *readfds,*writefds;
{
-int i,e;
-ULONG ulPostCount;
-PIPESEMSTATE pipeSemState[128];
-APIRET rc;
+ int i,e;
+ ULONG ulPostCount;
+ PIPESEMSTATE pipeSemState[128];
+ APIRET rc;
e = 0;
rc = DosResetEventSem(hPipeSem,&ulPostCount);
rc = DosQueryNPipeSemState((HSEM) hPipeSem, (PPIPESEMSTATE)&pipeSemState,
@@ -404,8 +405,8 @@ APIRET rc;
i++;
} /* endwhile */
-errno = 0;
-return(e);
+ errno = 0;
+ return(e);
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c
index 0ac4baab9..d218b094d 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c,v 1.2 1999/11/19 13:55:01 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_serial.c,v 1.3 2000/04/05 18:13:53 dawes Exp $ */
/*
* (c) Copyright 1999 by Holger Veit
* <Holger.Veit@gmd.de>
@@ -274,7 +274,7 @@ int xf86ReadSerial (int fd, void *buf, int count)
return rc ? -1 : (int)nread;
}
-int xf86WriteSerial (int fd, void *buf, int count)
+int xf86WriteSerial (int fd, const void *buf, int count)
{
ULONG nwrite;
APIRET rc = DosWrite((HFILE)fd,(PVOID)buf,(ULONG)count,&nwrite);
@@ -337,3 +337,177 @@ int xf86FlushInput(int fd)
}
return 0;
}
+
+static struct states {
+ int xf;
+ int os;
+} modemStates[] = {
+ { XF86_M_DTR, 0x01 },
+ { XF86_M_RTS, 0x02 },
+ { XF86_M_CTS, 0x10 },
+ { XF86_M_DSR, 0x20 },
+ { XF86_M_RNG, 0x40 },
+ { XF86_M_CAR, 0x80 },
+};
+
+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;
+
+static
+int _get_modem_state(int fd,ULONG* state)
+{
+ ULONG state1,len;
+
+ if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMOUTPUT,
+ NULL,0,NULL, state, sizeof(BYTE), &len) != 0 ||
+ DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMINPUT,
+ NULL,0,NULL, &state1, sizeof(BYTE), &len) != 0)
+ return -1;
+ *state |= state1;
+ *state &= 0xff;
+ return 0;
+}
+
+static
+int _set_modem_state(int fd,ULONG state,ULONG mask)
+{
+ int len;
+ struct {
+ BYTE onmask;
+ BYTE offmask;
+ } modemctrl;
+ modemctrl.onmask = state;
+ modemctrl.offmask = mask;
+
+ if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_SETMODEMCTRL,
+ NULL,0,NULL, (PULONG)&modemctrl, sizeof(modemctrl), &len) != 0)
+ return -1;
+ else
+ return 0;
+}
+
+int
+xf86SetSerialModemState(int fd, int state)
+{
+ ULONG s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ if (!osStateMask)
+ osStateMask = getOsStateMask();
+
+ state = xf2osState(state);
+
+ if (_get_modem_state(fd,&s) != 0)
+ return -1;
+
+ s &= ~osStateMask;
+ s |= state;
+
+ return _set_modem_state(fd,s,0x03);
+}
+
+int
+xf86GetSerialModemState(int fd)
+{
+ ULONG s;
+
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ if (_get_modem_state(fd,&s) != 0)
+ return -1;
+
+ return os2xfState(s);
+}
+
+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;
+
+ s = xf2osState(bits);
+ return _set_modem_state(fd,s,0x03);
+}
+
+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;
+
+ s = xf2osState(bits);
+ return _set_modem_state(fd, 0, ~s & 0xff);
+}
+
+int
+xf86SetSerialSpeed (int fd, int speed)
+{
+ if (fd < 0)
+ return -1;
+
+ /* Don't try to set parameters for non-tty devices. */
+ if (!isatty(fd))
+ return 0;
+
+ return _set_baudrate(fd,speed);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c
index bed44c3c0..fce28d654 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.12 1999/04/29 09:13:51 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/os2/os2_video.c,v 3.13 2000/04/05 18:13:54 dawes Exp $ */
/*
* (c) Copyright 1994,1999 by Holger Veit
* <Holger.Veit@gmd.de>
@@ -116,33 +116,15 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size)
plen = sizeof(par);
dlen = sizeof(dta);
- /* First, redirect stderr to file so that video calls do not block */
- if (!ErrRedir) {
- /* hv300996 create redirect file on boot drive, instead
- * anywhere you are just standing
- */
- char buf[20],dr[3];
- ULONG drive;
- APIRET rc = DosQuerySysInfo(5,5,&drive,sizeof(drive));
- if (rc) dr[0] = 0;
- else { dr[0] = drive+96;
- dr[1] = ':';
- dr[2] = 0;
- }
- sprintf(buf,"%s\\xf86log.os2",dr);
- freopen(buf,"w",stderr);
- ErrRedir=TRUE;
- }
-
open_mmap();
if (mapdev == -1)
- FatalError("xf86MapVidMem: install DEVICE=path\\XF86SUP.SYS!");
+ FatalError("mapVidMem: install DEVICE=path\\XF86SUP.SYS!");
if ((rc=DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x44,
(PVOID)&par, (ULONG)plen, (PULONG)&plen,
(PVOID)&dta, (ULONG)dlen, (PULONG)&dlen)) == 0) {
- xf86Msg(X_INFO, xf86MapVidMem succeeded: (ScreenNum= %d, Base= 0x%x, Size= 0x%x\n",
- ScreenNum, Base, Size);
+ xf86Msg(X_INFO,"mapVidMem succeeded: (ScreenNum= %d, Base= 0x%x, Size= 0x%x,paddr=0x%x)\n",
+ ScreenNum, Base, Size, dta.addr);
if (dlen==sizeof(dta)) {
return (pointer)dta.addr;
}
@@ -150,7 +132,7 @@ mapVidMem(int ScreenNum, unsigned long Base, unsigned long Size)
}
/* fail */
- FatalError("xf86MapVidMem FAILED!!: rc = %d (ScreenNum= %d, Base= 0x%x, Size= 0x%x return len %d\n",
+ FatalError("mapVidMem FAILED!!: rc = %d (ScreenNum= %d, Base= 0x%x, Size= 0x%x return len %d)\n",
rc, ScreenNum, Base, Size,dlen);
return (pointer)0;
}
@@ -179,7 +161,7 @@ unmapVidMem(int ScreenNum, pointer Base, unsigned long Size)
DosDevIOCtl(mapdev, (ULONG)0x76, (ULONG)0x46,
(PVOID)&par, (ULONG)plen, (PULONG)&plen,
&vmaddr, sizeof(ULONG), &plen);
- xf86Msg(X_INFO,"Unmapping physical memory at base %x, virtual address %x\n",Base,vmaddr);
+ xf86Msg(X_INFO,"unmapVidMem: Unmap phys memory at base %x, virtual address %x\n",Base,vmaddr);
/* Now if more than one region has been allocated and we close the driver,
* the other pointers will immediately become invalid. We avoid closing
@@ -218,9 +200,11 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
pVidMem->linearSupported = TRUE;
pVidMem->mapMem = mapVidMem;
pVidMem->unmapMem = unmapVidMem;
+#if 0
pVidMem->mapMemSparse = 0;
pVidMem->unmapMemSparse = 0;
- pVidMem->setWC = 0;
+#endif
+ pVidMem->setWC = 0; /* no MTRR support */
pVidMem->undoWC = 0;
pVidMem->initialised = TRUE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile
index 00be6f4c6..9441ffd8a 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile
@@ -1,5 +1,5 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile,v 1.8 2000/02/13 03:36:10 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/Imakefile,v 1.9 2000/06/17 00:03:41 martin Exp $
#include <Server.tmpl>
@@ -9,12 +9,15 @@ MOUSEOBJ = pmax_mouse.o
SRCS = pmax_devs.c pmax_init.c pmax_map.c pmax_pci.c pmax_ppc.c \
bios_V4mmap.c VTsw_usl.c sysv_kbd.c std_kbdEv.c \
posix_tty.c $(MOUSESRC) xqueue.c ioperm_noop.c \
- libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c
+ libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c \
+ kmod_noop.c
OBJS = pmax_devs.o pmax_init.o pmax_map.o pmax_pci.o pmax_ppc.o \
bios_V4mmap.o VTsw_usl.o sysv_kbd.o std_kbdEv.o \
posix_tty.o $(MOUSESRC) xqueue.o ioperm_noop.o \
- libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o
+
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86OSSRC)/bus -I. \
-I$(SERVERSRC)/include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I../sysv
@@ -36,6 +39,7 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
LinkSourceFile(bios_V4mmap.c,../sysv)
LinkSourceFile(xqueue.c,../sysv)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c b/xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c
index 5fc98aa92..9e5698982 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c,v 1.6 2000/02/11 22:36:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/pmax/pmax_map.c,v 1.7 2000/06/27 14:27:31 tsi Exp $ */
/*
* Copyright 1998 by Concurrent Computer Corporation
*
@@ -148,24 +148,6 @@ xf86UnMapVidMem(int ScreenNum, pointer Base, unsigned long Size)
munmap(Base, Size);
}
-#if 0
-/* ARGSUSED */
-void xf86MapDisplay(ScreenNum, Region)
-int ScreenNum;
-int Region;
-{
- return;
-}
-
-/* ARGSUSED */
-void xf86UnMapDisplay(ScreenNum, Region)
-int ScreenNum;
-int Region;
-{
- return;
-}
-#endif
-
/*
* Read BIOS via mmap()ing /dev/iomem.
*/
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile
index 712ff178f..58fdd559d 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile
@@ -1,17 +1,17 @@
-XCOMM
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile,v 1.3 2000/02/13 03:36:10 dawes Exp $
-XCOMM
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/qnx4/Imakefile,v 1.5 2000/06/27 14:27:31 tsi Exp $
#include <Server.tmpl>
-SRCS = qnx_io.c qnx_init.c qnx_utils.c mapVT_noop.c ioperm_noop.c qnx_video.c \
+SRCS = qnx_io.c qnx_init.c qnx_utils.c ioperm_noop.c qnx_video.c \
qnx_VTsw.c qnx_kbd.c posix_tty.c qnx_mouse.c qnx_select.c \
- libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c
+ libc_wrapper.c stdResource.c stdPci.c sigiostubs.c pm_noop.c \
+ kmod_noop.c
-OBJS = qnx_io.o qnx_init.o qnx_utils.o mapVT_noop.o ioperm_noop.o qnx_video.o \
+OBJS = qnx_io.o qnx_init.o qnx_utils.o ioperm_noop.o qnx_video.o \
qnx_VTsw.o qnx_kbd.o posix_tty.o qnx_mouse.o qnx_select.o \
- libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -26,11 +26,11 @@ NormalLibraryObjectRule()
LinkSourceFile(libc_wrapper.c,../shared)
LinkSourceFile(posix_tty.c,../shared)
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(ioperm_noop.c,../shared)
LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile
index 3db9b9f3c..ccd0290ce 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile,v 3.7 2000/02/13 03:36:11 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sco/Imakefile,v 3.9 2000/06/27 14:27:31 tsi Exp $
@@ -7,13 +7,15 @@ XCOMM $XConsortium: Imakefile /main/4 1996/09/28 17:24:25 rws $
#include <Server.tmpl>
-SRCS = sco_init.c sco_video.c sco_io.c bios_devmem.c mapVT_noop.c VTsw_sco.c \
+SRCS = sco_init.c sco_video.c sco_io.c bios_devmem.c VTsw_sco.c \
sysv_kbd.c std_kbdEv.c sysv_tty.c std_mseEv.c sco_mouse.c \
- libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c
+ libc_wrapper.c stdResource.c stdPci.o sigiostubs.c pm_noop.c \
+ kmod_noop.c
-OBJS = sco_init.o sco_video.o sco_io.o bios_devmem.o mapVT_noop.o VTsw_sco.o \
+OBJS = sco_init.o sco_video.o sco_io.o bios_devmem.o VTsw_sco.o \
sysv_kbd.o std_kbdEv.o sysv_tty.o std_mseEv.o sco_mouse.o \
- libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o
+ libc_wrapper.o stdResource.o stdPci.o sigiostubs.o pm_noop.o \
+ kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC)
@@ -26,7 +28,6 @@ SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
LinkSourceFile(bios_devmem.c,../shared)
-LinkSourceFile(mapVT_noop.c,../shared)
LinkSourceFile(sysv_kbd.c,../shared)
LinkSourceFile(std_kbdEv.c,../shared)
LinkSourceFile(sysv_tty.c,../shared)
@@ -36,6 +37,7 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
index 7b8e88265..4affcc415 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
@@ -1,8 +1,8 @@
/* drm.h -- Header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- * Revised: Mon Feb 14 00:15:23 2000 by kevin@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,8 @@
* 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/linux/drm/kernel/drm.h,v 1.5 2000/02/23 04:47:26 martin Exp $
+ * Authors:
+ * Rickard E. (Rik) Faith <faith@valinux.com>
*
* Acknowledgements:
* Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic cmpxchg.
@@ -61,6 +62,20 @@ typedef unsigned int drm_context_t;
typedef unsigned int drm_drawable_t;
typedef unsigned int drm_magic_t;
+/* Warning: If you change this structure, make sure you change
+ * XF86DRIClipRectRec in the server as well */
+
+typedef struct drm_clip_rect {
+ unsigned short x1;
+ unsigned short y1;
+ unsigned short x2;
+ unsigned short y2;
+} drm_clip_rect_t;
+
+/* Seperate include files for the i810/mga/r128 specific structures */
+#include "mga_drm.h"
+#include "i810_drm.h"
+#include "r128_drm.h"
typedef struct drm_version {
int version_major; /* Major version */
@@ -101,7 +116,8 @@ typedef struct drm_control {
typedef enum drm_map_type {
_DRM_FRAME_BUFFER = 0, /* WC (no caching), no core dump */
_DRM_REGISTERS = 1, /* no caching, no core dump */
- _DRM_SHM = 2 /* shared, cached */
+ _DRM_SHM = 2, /* shared, cached */
+ _DRM_AGP = 3 /* AGP/GART */
} drm_map_type_t;
typedef enum drm_map_flags {
@@ -165,8 +181,11 @@ typedef struct drm_buf_desc {
int low_mark; /* Low water mark */
int high_mark; /* High water mark */
enum {
- DRM_PAGE_ALIGN = 0x01 /* Align on page boundaries for DMA */
+ _DRM_PAGE_ALIGN = 0x01, /* Align on page boundaries for DMA */
+ _DRM_AGP_BUFFER = 0x02 /* Buffer is in agp space */
} flags;
+ unsigned long agp_start; /* Start address of where the agp buffers
+ * are in the agp aperture */
} drm_buf_desc_t;
typedef struct drm_buf_info {
@@ -237,6 +256,38 @@ typedef struct drm_irq_busid {
int funcnum;
} drm_irq_busid_t;
+typedef struct drm_agp_mode {
+ unsigned long mode;
+} drm_agp_mode_t;
+
+ /* For drm_agp_alloc -- allocated a buffer */
+typedef struct drm_agp_buffer {
+ unsigned long size; /* In bytes -- will round to page boundary */
+ unsigned long handle; /* Used for BIND/UNBIND ioctls */
+ unsigned long type; /* Type of memory to allocate */
+ unsigned long physical; /* Physical used by i810 */
+} drm_agp_buffer_t;
+
+ /* For drm_agp_bind */
+typedef struct drm_agp_binding {
+ unsigned long handle; /* From drm_agp_buffer */
+ unsigned long offset; /* In bytes -- will round to page boundary */
+} drm_agp_binding_t;
+
+typedef struct drm_agp_info {
+ int agp_version_major;
+ int agp_version_minor;
+ unsigned long mode;
+ unsigned long aperture_base; /* physical address */
+ unsigned long aperture_size; /* bytes */
+ unsigned long memory_allowed; /* bytes */
+ unsigned long memory_used;
+
+ /* PCI information */
+ unsigned short id_vendor;
+ unsigned short id_device;
+} drm_agp_info_t;
+
#define DRM_IOCTL_BASE 'd'
#define DRM_IOCTL_NR(n) _IOC_NR(n)
#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)
@@ -247,7 +298,7 @@ typedef struct drm_irq_busid {
#define DRM_IOCTL_VERSION DRM_IOWR(0x00, drm_version_t)
#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, drm_unique_t)
-#define DRM_IOCTL_GET_MAGIC DRM_IOW( 0x02, drm_auth_t)
+#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, drm_auth_t)
#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, drm_irq_busid_t)
#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, drm_unique_t)
@@ -276,4 +327,39 @@ typedef struct drm_irq_busid {
#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, drm_lock_t)
#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, drm_lock_t)
+#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
+#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
+#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, drm_agp_mode_t)
+#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, drm_agp_info_t)
+#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, drm_agp_buffer_t)
+#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, drm_agp_buffer_t)
+#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, drm_agp_binding_t)
+#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, drm_agp_binding_t)
+
+/* Mga specific ioctls */
+#define DRM_IOCTL_MGA_INIT DRM_IOW( 0x40, drm_mga_init_t)
+#define DRM_IOCTL_MGA_SWAP DRM_IOW( 0x41, drm_mga_swap_t)
+#define DRM_IOCTL_MGA_CLEAR DRM_IOW( 0x42, drm_mga_clear_t)
+#define DRM_IOCTL_MGA_ILOAD DRM_IOW( 0x43, drm_mga_iload_t)
+#define DRM_IOCTL_MGA_VERTEX DRM_IOW( 0x44, drm_mga_vertex_t)
+#define DRM_IOCTL_MGA_FLUSH DRM_IOW( 0x45, drm_lock_t )
+#define DRM_IOCTL_MGA_INDICES DRM_IOW( 0x46, drm_mga_indices_t)
+
+/* I810 specific ioctls */
+#define DRM_IOCTL_I810_INIT DRM_IOW( 0x40, drm_i810_init_t)
+#define DRM_IOCTL_I810_VERTEX DRM_IOW( 0x41, drm_i810_vertex_t)
+#define DRM_IOCTL_I810_CLEAR DRM_IOW( 0x42, drm_i810_clear_t)
+#define DRM_IOCTL_I810_FLUSH DRM_IO ( 0x43)
+#define DRM_IOCTL_I810_GETAGE DRM_IO ( 0x44)
+#define DRM_IOCTL_I810_GETBUF DRM_IOWR(0x45, drm_i810_dma_t)
+#define DRM_IOCTL_I810_SWAP DRM_IO ( 0x46)
+
+/* Rage 128 specific ioctls */
+#define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t)
+#define DRM_IOCTL_R128_RESET DRM_IO( 0x41)
+#define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42)
+#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43)
+#define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t)
+#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t)
+
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c
new file mode 100644
index 000000000..80f487593
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/kmod_noop.c
@@ -0,0 +1,8 @@
+
+#include "xf86_OSproc.h"
+
+int xf86LoadKernelModule(const char *pathname)
+{
+ (void) pathname;
+ return 0; /* failure */
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c
index fc08cb51a..b509b7883 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.60 2000/02/09 15:47:50 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/libc_wrapper.c,v 1.65 2000/06/17 00:03:42 martin Exp $ */
/*
* Copyright 1997 by The XFree86 Project, Inc.
*
@@ -32,10 +32,6 @@
#undef _ANSI_SOURCE
#endif
#include <sys/time.h>
-#if defined(__bsdi__)
-#define _POSIX_SOURCE
-#define _ANSI_SOURCE
-#endif
#include <math.h>
#include <stdarg.h>
#include <fcntl.h>
@@ -50,6 +46,7 @@
#include <sys/ioctl.h>
#ifdef __EMX__
#define NO_MMAP
+#include <sys/param.h>
#endif
#ifdef HAS_SVR3_MMAPDRV
#define NO_MMAP
@@ -1088,7 +1085,7 @@ xf86usleep(usec)
}
void
-xf86getsecs(CARD32 * secs, CARD32 * usecs)
+xf86getsecs(long * secs, long * usecs)
{
struct timeval tv;
@@ -1323,7 +1320,9 @@ xfToOsChmodMode(xf86mode_t xfmode)
if (xfmode & XF86_S_ISUID) mode |= S_ISUID;
if (xfmode & XF86_S_ISGID) mode |= S_ISGID;
+#ifndef __EMX__
if (xfmode & XF86_S_ISVTX) mode |= S_ISVTX;
+#endif
if (xfmode & XF86_S_IRUSR) mode |= S_IRUSR;
if (xfmode & XF86_S_IWUSR) mode |= S_IWUSR;
if (xfmode & XF86_S_IXUSR) mode |= S_IXUSR;
@@ -1350,7 +1349,11 @@ xf86chmod(const char *path, xf86mode_t xfmode)
int
xf86chown(const char *path, xf86uid_t owner, xf86gid_t group)
{
+#ifndef __EMX__
int rc = chown(path, owner, group);
+#else
+ int rc = 0;
+#endif
xf86errno = xf86GetErrno();
return rc;
}
@@ -1361,6 +1364,18 @@ xf86geteuid(void)
return geteuid();
}
+xf86gid_t
+xf86getegid(void)
+{
+ return getegid();
+}
+
+int
+xf86getpid(void)
+{
+ return getpid();
+}
+
static mode_t
xfToOsMknodMode(xf86mode_t xfmode)
{
@@ -1368,7 +1383,9 @@ xfToOsMknodMode(xf86mode_t xfmode)
if (xfmode & XF86_S_IFREG) mode |= S_IFREG;
if (xfmode & XF86_S_IFCHR) mode |= S_IFCHR;
+#ifndef __EMX__
if (xfmode & XF86_S_IFBLK) mode |= S_IFBLK;
+#endif
if (xfmode & XF86_S_IFIFO) mode |= S_IFIFO;
return mode;
@@ -1377,8 +1394,11 @@ xfToOsMknodMode(xf86mode_t xfmode)
int xf86mknod(const char *pathname, xf86mode_t xfmode, xf86dev_t dev)
{
mode_t mode = xfToOsMknodMode(xfmode);
+#ifndef __EMX__
int rc = mknod(pathname, mode, dev);
-
+#else
+ int rc = 0;
+#endif
xf86errno = xf86GetErrno();
return rc;
}
@@ -1783,7 +1803,7 @@ xf86GetErrno ()
int
xf86shmget(xf86key_t key, int size, int xf86shmflg)
{
- int shmflg = 0;
+ int shmflg = xf86shmflg & 0777;
if (key == XF86IPC_PRIVATE) key = IPC_PRIVATE;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c
index 15e7e530a..e603af4d7 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c
@@ -1,6 +1,5 @@
/* sigio.c -- Support for SIGIO handler installation and removal
* Created: Thu Jun 3 15:39:18 1999 by faith@precisioninsight.com
- * Revised: Thu Jan 6 10:32:25 2000 by faith@precisioninsight.com
*
* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
* All Rights Reserved.
@@ -24,7 +23,9 @@
* 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/shared/sigio.c,v 1.9 2000/03/02 16:07:53 martin Exp $
+ * Authors: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/sigio.c,v 1.11 2000/06/17 00:03:43 martin Exp $
*
*/
@@ -108,6 +109,16 @@ xf86SIGIO (int sig)
}
int
+xf86IsPipe (int fd)
+{
+ struct stat buf;
+
+ if (fstat (fd, &buf) < 0)
+ return 0;
+ return S_ISFIFO(buf.st_mode);
+}
+
+int
xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
{
struct sigaction sa;
@@ -118,19 +129,8 @@ xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
{
if (!xf86SigIOFuncs[i].f)
{
- 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);
+ if (xf86IsPipe (fd))
+ return 0;
if (fcntl(fd, F_SETOWN, getpid()) == -1) {
#ifdef XFree86Server
xf86Msg(X_WARNING, "fcntl(%d, F_SETOWN): %s\n",
@@ -151,6 +151,19 @@ xf86InstallSIGIOHandler(int fd, void (*f)(int, void *), void *closure)
#endif
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);
return 1;
}
/* Allow overwriting of the closure and callback */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c
index f1414ca94..b078a5121 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c,v 1.14 2000/02/08 13:13:31 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/stdResource.c,v 1.15 2000/04/23 19:27:03 tsi Exp $ */
/* Standard resource information code */
@@ -85,6 +85,9 @@ xf86StdAccResFromOS(resPtr ret)
* 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 */
@@ -96,10 +99,12 @@ xf86StdAccResFromOS(resPtr ret)
ret = xf86AddResToList(ret, &range, -1);
RANGE(range,0x100000,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);
+#endif
RANGE(range,0xffe00000,0xffffffff,ResExcMemBlock | ResBios);
ret = xf86AddResToList(ret, &range, -1);
@@ -111,4 +116,3 @@ xf86StdAccResFromOS(resPtr ret)
/* XXX add others */
return ret;
}
-
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c b/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c
index 9e26ce3ff..c6f5e9b5d 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.10 2000/02/15 02:00:15 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/vidmem.c,v 1.11 2000/05/03 00:44:20 tsi Exp $ */
/*
* Copyright 1993-1999 by The XFree86 Project, Inc
*
@@ -113,19 +113,18 @@ static OptionInfoRec opts[] =
{ -1, NULL, OPTV_NONE, {0}, FALSE }
};
+#define nopts (sizeof(opts) / sizeof(opts[0]))
+
static void
checkMtrrOption(VidMapPtr vp)
{
if (!vp->mtrrOptChecked && vp->pScrn->options != NULL) {
- /*
- * We get called once for each screen, so reset
- * the OptionInfoRecs.
- */
- opts[0].found = FALSE;
+ OptionInfoRec options[nopts];
+ (void)memcpy(options, opts, sizeof(opts));
xf86ProcessOptions(vp->pScrn->scrnIndex, vp->pScrn->options,
- opts);
- if (xf86GetOptValBool(opts, OPTION_MTRR, &vp->mtrrEnabled))
+ options);
+ if (xf86GetOptValBool(options, OPTION_MTRR, &vp->mtrrEnabled))
vp->mtrrFrom = X_CONFIG;
vp->mtrrOptChecked = TRUE;
}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile
index 16f465ff4..97005bf4d 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile,v 1.4 2000/02/13 03:36:11 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sol8_x86/Imakefile,v 1.5 2000/06/17 00:03:43 martin Exp $
@@ -19,12 +19,14 @@ MOUSEOBJ = sol8_mouse.o
SRCS = sol8_init.c sol8_vid.c sol8_bios.c sol8_kbd.c sol8_io.c \
VTsw_noop.c sol8_kbd.c sol8_kbdEv.c posix_tty.c $(MOUSESRC) \
libc_wrapper.c $(PROWORKS_INOUT_SRC) stdResource.c stdPci.c \
- sol8_kbdgetmapping.c sol8_postkbdevents.c sigiostubs.c pm_noop.c
+ sol8_kbdgetmapping.c sol8_postkbdevents.c sigiostubs.c pm_noop.c \
+ kmod_noop.c
OBJS = sol8_init.o sol8_vid.o sol8_bios.o sol8_kbd.o sol8_io.o \
VTsw_noop.o sol8_kbd.o sol8_kbdEv.o posix_tty.o $(MOUSEOBJ) \
libc_wrapper.o $(PROWORKS_INOUT_OBJ) stdResource.o stdPci.o \
- sol8_kbdgetmapping.o sol8_postkbdevents.o sigiostubs.o pm_noop.o
+ sol8_kbdgetmapping.o sol8_postkbdevents.o sigiostubs.o pm_noop.o \
+ kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC)
@@ -44,5 +46,6 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile
index 0571a3e43..a6af01b15 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile,v 3.16 2000/02/13 03:36:12 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/solx86/Imakefile,v 3.17 2000/06/17 00:03:43 martin Exp $
@@ -19,12 +19,12 @@ MOUSEOBJ = solx86_mouse.o
SRCS = solx86_init.c solx86_vid.c solx86_bios.c sysv_io.c \
VTsw_usl.c sysv_kbd.c std_kbdEv.c posix_tty.c $(MOUSESRC) \
libc_wrapper.c $(PROWORKS_INOUT_SRC) stdResource.c stdPci.c \
- sigiostubs.c pm_noop.c
+ sigiostubs.c pm_noop.c kmod_noop.c
OBJS = solx86_init.o solx86_vid.o solx86_bios.o sysv_io.o \
VTsw_usl.o sysv_kbd.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) \
libc_wrapper.o $(PROWORKS_INOUT_OBJ) stdResource.o stdPci.o \
- sigiostubs.o pm_noop.o
+ sigiostubs.o pm_noop.o kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC)
@@ -47,5 +47,6 @@ LinkSourceFile(stdResource.c,../shared)
LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile
index 0f9d7042a..08e68785b 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile,v 3.21 2000/02/13 03:36:12 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/sysv/Imakefile,v 3.22 2000/06/17 00:03:43 martin Exp $
@@ -19,11 +19,13 @@ MOUSEOBJ = sysv_mouse.o
SRCS = sysv_init.c sysv_video.c sysv_io.c $(BIOS_MOD).c VTsw_usl.c \
sysv_kbd.c std_kbdEv.c posix_tty.c $(MOUSESRC) xqueue.c \
- libc_wrapper.c stdResource.c stdPci.c vidmem.c sigiostubs.c pm_noop.c
+ libc_wrapper.c stdResource.c stdPci.c vidmem.c sigiostubs.c pm_noop.c \
+ kmod_noop.c
OBJS = sysv_init.o sysv_video.o sysv_io.o $(BIOS_MOD).o VTsw_usl.o \
sysv_kbd.o std_kbdEv.o posix_tty.o $(MOUSEOBJ) xqueue.o \
- libc_wrapper.o stdResource.o stdPci.o vidmem.o sigiostubs.o pm_noop.o
+ libc_wrapper.o stdResource.o stdPci.o vidmem.o sigiostubs.o pm_noop.o \
+ kmod_noop.o
INCLUDES = -I$(XF86COMSRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
-I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/mi
@@ -50,5 +52,6 @@ LinkSourceFile(stdPci.c,../shared)
LinkSourceFile(vidmem.c,../shared)
LinkSourceFile(sigiostubs.c,../shared)
LinkSourceFile(pm_noop.c,../shared)
+LinkSourceFile(kmod_noop.c,../shared)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile
index ca2a48a01..04b459979 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile
@@ -1,6 +1,10 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile,v 1.4 2000/02/09 20:47:15 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/Imakefile,v 1.8 2000/05/23 04:47:49 dawes Exp $
+
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
-#define IHaveModules
#include <Server.tmpl>
SRCS = vbe.c vbe_module.c
@@ -12,16 +16,19 @@ INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
-I$(XF86SRC)/int10 -I$(XF86SRC)/ddc \
-I$(XF86SRC)/i2c
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
+
SubdirLibraryRule($(OBJS))
NormalLibraryObjectRule()
-LibraryModuleTarget(vbe, $(OBJS))
-
-InstallLibraryModule(vbe,$(MODULEDIR),.)
+#if DoLoadableServer
+ForceSubdirs($(SUBDIRS))
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
DependTarget()
-InstallDriverSDKLibraryModule(vbe,$(DRIVERSDKMODULEDIR),.)
-
-InstallDriverSDKNonExecFile(vbe.h,$(DRIVERSDKINCLUDEDIR))
-
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/vbe/module/Imakefile b/xc/programs/Xserver/hw/xfree86/os-support/vbe/module/Imakefile
new file mode 100644
index 000000000..8b67bc852
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/vbe/module/Imakefile
@@ -0,0 +1,31 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/module/Imakefile,v 1.1 2000/04/05 18:13:57 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+SRCS = vbe.c vbe_module.c
+
+OBJS = vbe.o vbe_module.o
+
+INCLUDES = -I. -I$(XF86COMSRC) -I$(XF86OSSRC) \
+ -I$(SERVERSRC)/include -I$(XINCLUDESRC) \
+ -I$(XF86SRC)/int10 -I$(XF86SRC)/ddc \
+ -I$(XF86SRC)/i2c
+
+LinkSourceFile(vbe.c,..)
+LinkSourceFile(vbe.h,..)
+LinkSourceFile(vbe_module.c,..)
+
+SubdirLibraryRule($(OBJS))
+NormalLibraryObjectRule()
+
+LibraryModuleTarget(vbe, $(OBJS))
+
+InstallLibraryModule(vbe,$(MODULEDIR),.)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(vbe,$(DRIVERSDKMODULEDIR),.)
+
+InstallDriverSDKNonExecFile(vbe.h,$(DRIVERSDKINCLUDEDIR))
+
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c b/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c
index 1c9bcc75f..cc067165c 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c,v 1.4 2000/02/08 13:13:32 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.c,v 1.9 2000/05/31 09:39:45 eich Exp $ */
#include "xf86.h"
#include "xf86_ansic.h"
@@ -192,15 +192,34 @@ vbeProbeDDC(vbeInfoPtr pVbe)
return TRUE;
}
+typedef enum {
+ VBEOPT_NOVBE
+} VBEOpts;
+
+static OptionInfoRec VBEOptions[] = {
+ { VBEOPT_NOVBE, "NoVBE", OPTV_BOOLEAN, {0}, FALSE },
+ { -1, NULL, OPTV_NONE, {0}, FALSE },
+};
+
+#define nVBEOptions (sizeof(VBEOptions) / sizeof(VBEOptions[0]))
+
static unsigned char *
vbeReadEDID(vbeInfoPtr pVbe)
{
int RealOff = pVbe->real_mode_base;
pointer page = pVbe->memory;
unsigned char *tmp = NULL;
+ Bool novbe = FALSE;
int screen = pVbe->pInt10->scrnIndex;
+ OptionInfoRec options[nVBEOptions];
if (!page) return NULL;
+
+ (void)memcpy(options, VBEOptions, sizeof(VBEOptions));
+ xf86ProcessOptions(screen, xf86Screens[screen]->options, options);
+ xf86GetOptValBool(options, VBEOPT_NOVBE, &novbe);
+ if (novbe) return NULL;
+
if (!vbeProbeDDC(pVbe)) goto error;
pVbe->pInt10->ax = 0x4F15;
@@ -232,24 +251,33 @@ vbeReadEDID(vbeInfoPtr pVbe)
}
xf86MonPtr
-vbeDoEDID(vbeInfoPtr pVbe)
+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;
+
+ xf86LoaderReqSymLists(ddcSymbols, NULL);
+ }
DDC_data = vbeReadEDID(pVbe);
if (!DDC_data)
return NULL;
- if (!xf86LoadSubModule(xf86Screens[pVbe->pInt10->scrnIndex], "ddc"))
- return NULL;
- xf86LoaderReqSymLists(ddcSymbols, NULL);
+ pMonitor = xf86InterpretEDID(pVbe->pInt10->scrnIndex, DDC_data);
- return xf86InterpretEDID(DDC_data);
+ if (!pDDCModule)
+ xf86UnloadSubModule(pModule);
+ return pMonitor;
}
-
-
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h b/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h
index 070f8e273..2bdfb7952 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h,v 1.3 2000/02/08 13:13:32 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/vbe/vbe.h,v 1.4 2000/04/20 21:28:50 tsi Exp $ */
#ifndef _VBE_H
#define _VBE_H
@@ -27,7 +27,7 @@ typedef struct {
vbeInfoPtr VBEInit(xf86Int10InfoPtr pInt, int entityIndex);
void vbeFree(vbeInfoPtr pVbe);
-xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe);
+xf86MonPtr vbeDoEDID(vbeInfoPtr pVbe, pointer pDDCModule);
#pragma pack(1)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h
index 655217622..85bec091b 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.8 2000/02/10 22:33:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.9 2000/04/17 16:30:12 eich Exp $ */
/*
* Copyright (c) 1997-1999 by The XFree86 Project, Inc.
@@ -100,7 +100,6 @@ typedef struct _MouseDevRec {
const char * protocol;
int protocolID;
int class;
- Bool automatic;
int mseModel;
int baudRate;
int oldBaudRate;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
index 88e2135ef..913258dd7 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.71 2000/02/08 13:13:27 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.72 2000/06/23 22:42:06 dawes Exp $ */
/*
* Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
* Copyright 1992 by David Dawes <dawes@XFree86.org>
@@ -470,11 +470,20 @@ extern int errno;
# if defined(PCVT_SUPPORT)
# if !defined(SYSCONS_SUPPORT)
/* no syscons, so include pcvt specific header file */
-# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# if defined(__FreeBSD__) || defined(__OpenBSD__)
# include <machine/pcvt_ioctl.h>
# else
-# include <sys/pcvt_ioctl.h>
-# endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
+# if defined(__NetBSD__)
+# if defined(WSCONS_SUPPORT)
+ /* NetBSD's wscons has a PCVT-compatibility module. */
+# include <dev/wscons/wsdisplay_usl_io.h>
+# else
+# include <machine/pcvt_ioctl.h>
+# endif /* WSCONS_SUPPORT */
+# else
+# include <sys/pcvt_ioctl.h>
+# endif /* __NetBSD__ */
+# endif /* __FreeBSD__ || __OpenBSD__ */
# else /* pcvt and syscons: hard-code the ID magic */
# define VGAPCVTID _IOWR('V',113, struct pcvtid)
struct pcvtid {
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
index 092cead2f..fcfc32024 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h
@@ -64,7 +64,7 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.39 2000/02/08 13:13:27 eich Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.42 2000/06/24 17:23:57 dawes Exp $ */
#ifndef _XF86_OSPROC_H
#define _XF86_OSPROC_H
@@ -164,7 +164,7 @@ 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);
#if defined(__alpha__)
/* entry points for Mmio memory access routines */
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h
index 23389ea39..6e4956812 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h
@@ -1,5 +1,5 @@
/*
- * Copyright 1997,1998 by The XFree86 Project, Inc
+ * Copyright 1997-2000 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
@@ -22,15 +22,32 @@
*
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h,v 3.36 2000/02/16 15:28:34 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_ansic.h,v 3.40 2000/06/17 00:03:26 martin Exp $ */
#ifndef _XF86_ANSIC_H
#define _XF86_ANSIC_H
-#ifndef FONTMODULE
-#include "misc.h"
-#endif
-#include "xf86_libc.h"
+/* Handle <stdarg.h> */
+
+#ifndef IN_MODULE
+# include <stdarg.h>
+#else /* !IN_MODULE */
+# ifndef __OS2ELF__
+# include <stdarg.h>
+# else /* __OS2ELF__ */
+ /* EMX/gcc_elf under OS/2 does not have native header files */
+# if !defined (_VA_LIST)
+# define _VA_LIST
+ typedef char *va_list;
+# endif
+# define _VA_ROUND(t) ((sizeof (t) + 3) & -4)
+# if !defined (va_start)
+# define va_start(ap,v) ap = (va_list)&v + ((sizeof (v) + 3) & -4)
+# define va_end(ap) (ap = 0, (void)0)
+# define va_arg(ap,t) (ap += _VA_ROUND (t), *(t *)(ap - _VA_ROUND (t)))
+# endif
+# endif /* __OS2ELF__ */
+#endif /* IN_MODULE */
/*
* The first set of definitions are required both for modules and
@@ -64,6 +81,11 @@
#ifndef SHRT_MIN
#define SHRT_MIN ((short)(1 << (x_SHORTBITS - 1)))
#endif
+
+#ifndef FONTMODULE
+#include "misc.h"
+#endif
+#include "xf86_libc.h"
#ifndef SHRT_MAX
#define SHRT_MAX ((short)~SHRT_MIN)
#endif
@@ -107,8 +129,6 @@
#define MAXLONG LONG_MAX
#endif
-#include <stdarg.h>
-
/*
* ANSI C compilers only.
*/
@@ -267,6 +287,8 @@ extern long xf86fpossize(void);
extern int xf86chmod(const char *, xf86mode_t);
extern int xf86chown(const char *, xf86uid_t, xf86gid_t);
extern xf86uid_t xf86geteuid(void);
+extern xf86gid_t xf86getegid(void);
+extern int xf86getpid(void);
extern int xf86mknod(const char *, xf86mode_t, xf86dev_t);
extern int xf86mkdir(const char *, xf86mode_t);
unsigned int xf86sleep(unsigned int seconds);
@@ -296,7 +318,7 @@ extern int xf86shmctl(int id, int xf86cmd, pointer *buf);
extern int xf86getpagesize(void);
extern void xf86usleep(unsigned long);
-extern void xf86getsecs(CARD32 *, CARD32 *);
+extern void xf86getsecs(long *, long *);
#ifndef DONT_DEFINE_WRAPPERS
#undef getpagesize
#define getpagesize() xf86getpagesize()
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h
index 321fd3f13..763952e10 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 3.47 2000/02/08 17:19:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_libc.h,v 3.48 2000/06/17 00:03:26 martin Exp $ */
@@ -421,6 +421,10 @@ typedef int xf86key_t;
#define chown(a,b,c) xf86chown(a,b,c)
#undef geteuid
#define geteuid xf86geteuid
+#undef getegid
+#define getegid xf86getegid
+#undef getpid
+#define getpid xf86getpid
#undef mknod
#define mknod(a,b,c) xf86mknod(a,b,c)
#undef sleep
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
index 61287e3e2..032023c45 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h
@@ -1,8 +1,8 @@
/* xf86drm.h -- OS-independent header for DRM user-level library interface
* Created: Tue Jan 5 08:17:23 1999 by faith@precisioninsight.com
- * Revised: Sun Feb 13 23:46:21 2000 by kevin@precisioninsight.com
*
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
+ * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,7 +24,9 @@
* 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/xf86drm.h,v 1.7 2000/02/23 04:47:21 martin Exp $
+ * Author: Rickard E. (Rik) Faith <faith@valinux.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h,v 1.9 2000/06/20 05:08:48 dawes Exp $
*
*/
@@ -65,7 +67,8 @@ typedef struct _drmVersion {
typedef enum {
DRM_FRAME_BUFFER = 0, /* WC, no caching, no core dump */
DRM_REGISTERS = 1, /* no caching, no core dump */
- DRM_SHM = 2 /* shared, cached */
+ DRM_SHM = 2, /* shared, cached */
+ DRM_AGP = 3 /* AGP/GART */
} drmMapType;
typedef enum {
@@ -95,6 +98,11 @@ typedef enum { /* These values *MUST* match drm.h */
} drmDMAFlags;
typedef enum {
+ DRM_PAGE_ALIGN = 0x01,
+ DRM_AGP_BUFFER = 0x02
+} drmBufDescFlags;
+
+typedef enum {
DRM_LOCK_READY = 0x01, /* Wait until hardware is ready for DMA */
DRM_LOCK_QUIESCENT = 0x02, /* Wait until hardware quiescent */
DRM_LOCK_FLUSH = 0x04, /* Flush this context's DMA queue first */
@@ -195,8 +203,30 @@ typedef struct { unsigned int a[100]; } __drm_dummy_lock_t;
} while (0)
#endif
+#ifdef __sparc__
+#define DRM_CAS(lock,old,new,__ret) \
+do { register unsigned int __old __asm("o0"); \
+ register unsigned int __new __asm("o1"); \
+ register volatile unsigned int *__lock __asm("o2"); \
+ __old = old; \
+ __new = new; \
+ __lock = (volatile unsigned int *)lock; \
+ __asm__ __volatile__( \
+ /*"cas [%2], %3, %0"*/ \
+ ".word 0xd3e29008\n\t" \
+ /*"membar #StoreStore | #StoreLoad"*/ \
+ ".word 0x8143e00a" \
+ : "=&r" (__new) \
+ : "0" (__new), \
+ "r" (__lock), \
+ "r" (__old) \
+ : "memory"); \
+ __ret = (__new != __old); \
+} while(0)
+#endif
+
#ifndef DRM_CAS
-#define DRM_CAS(lock,old,new,ret) /* FAST LOCK FAILS */
+#define DRM_CAS(lock,old,new,ret) do { ret=1; } while (0) /* FAST LOCK FAILS */
#endif
#define DRM_LIGHT_LOCK(fd,lock,context) \
@@ -291,7 +321,9 @@ extern int drmAddMap(int fd,
drmMapType type,
drmMapFlags flags,
drmHandlePtr handle);
-extern int drmAddBufs(int fd, int count, int size, int flags);
+extern int drmAddBufs(int fd, int count, int size,
+ drmBufDescFlags flags,
+ int agp_offset);
extern int drmMarkBufs(int fd, double low, double high);
extern int drmCreateContext(int fd, drmContextPtr handle);
extern int drmSetContextFlags(int fd, drmContext context,
@@ -332,6 +364,29 @@ extern int drmGetLock(int fd,
extern int drmUnlock(int fd, drmContext context);
extern int drmFinish(int fd, int context, drmLockFlags flags);
+/* AGP/GART support: X server (root) only */
+extern int drmAgpAcquire(int fd);
+extern int drmAgpRelease(int fd);
+extern int drmAgpEnable(int fd, unsigned long mode);
+extern int drmAgpAlloc(int fd, unsigned long size,
+ unsigned long type, unsigned long *address,
+ unsigned long *handle);
+extern int drmAgpFree(int fd, unsigned long handle);
+extern int drmAgpBind(int fd, unsigned long handle,
+ unsigned long offset);
+extern int drmAgpUnbind(int fd, unsigned long handle);
+
+/* AGP/GART info: authenticated client and/or X */
+extern int drmAgpVersionMajor(int fd);
+extern int drmAgpVersionMinor(int fd);
+extern unsigned long drmAgpGetMode(int fd);
+extern unsigned long drmAgpBase(int fd); /* Physical location */
+extern unsigned long drmAgpSize(int fd); /* Bytes */
+extern unsigned long drmAgpMemoryUsed(int fd);
+extern unsigned long drmAgpMemoryAvail(int fd);
+extern unsigned int drmAgpVendorId(int fd);
+extern unsigned int drmAgpDeviceId(int fd);
+
/* Support routines */
extern int drmError(int err, const char *label);
extern void *drmMalloc(int size);
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmI810.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmI810.h
new file mode 100644
index 000000000..6c11b7a10
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmI810.h
@@ -0,0 +1,46 @@
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (i810_drm.h)
+ */
+
+#ifndef _XF86DRI_I810_H_
+#define _XF86DRI_I810_H_
+
+#ifndef _I810_DEFINES_
+#define _I810_DEFINES_
+#define I810_USE_BATCH 1
+
+#define I810_DMA_BUF_ORDER 12
+#define I810_DMA_BUF_SZ (1<<I810_DMA_BUF_ORDER)
+#define I810_DMA_BUF_NR 256
+
+#define I810_NR_SAREA_CLIPRECTS 8
+
+/* Each region is a minimum of 64k, and there are at most 64 of them.
+ */
+#define I810_NR_TEX_REGIONS 64
+#define I810_LOG_MIN_TEX_REGION_SIZE 16
+#endif
+
+typedef struct _drmI810Init {
+ unsigned int start;
+ unsigned int end;
+ unsigned int size;
+ int ring_map_idx;
+ int buffer_map_idx;
+ int sarea_off;
+
+ unsigned int front_offset;
+ unsigned int back_offset;
+ unsigned int depth_offset;
+ unsigned int w;
+ unsigned int h;
+ unsigned int pitch;
+ unsigned int pitch_bits;
+} drmI810Init;
+
+
+Bool drmI810CleanupDma(int driSubFD);
+Bool drmI810InitDma(int driSubFD, drmI810Init *info );
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h
new file mode 100644
index 000000000..3b0e4a6fc
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmMga.h
@@ -0,0 +1,147 @@
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (mga_drm.h)
+ */
+
+#ifndef _XF86DRI_MGA_H_
+#define _XF86DRI_MGA_H_
+#ifndef _MGA_DEFINES_
+#define _MGA_DEFINES_
+#define MGA_F 0x1 /* fog */
+#define MGA_A 0x2 /* alpha */
+#define MGA_S 0x4 /* specular */
+#define MGA_T2 0x8 /* multitexture */
+
+#define MGA_WARP_TGZ 0
+#define MGA_WARP_TGZF (MGA_F)
+#define MGA_WARP_TGZA (MGA_A)
+#define MGA_WARP_TGZAF (MGA_F|MGA_A)
+#define MGA_WARP_TGZS (MGA_S)
+#define MGA_WARP_TGZSF (MGA_S|MGA_F)
+#define MGA_WARP_TGZSA (MGA_S|MGA_A)
+#define MGA_WARP_TGZSAF (MGA_S|MGA_F|MGA_A)
+#define MGA_WARP_T2GZ (MGA_T2)
+#define MGA_WARP_T2GZF (MGA_T2|MGA_F)
+#define MGA_WARP_T2GZA (MGA_T2|MGA_A)
+#define MGA_WARP_T2GZAF (MGA_T2|MGA_A|MGA_F)
+#define MGA_WARP_T2GZS (MGA_T2|MGA_S)
+#define MGA_WARP_T2GZSF (MGA_T2|MGA_S|MGA_F)
+#define MGA_WARP_T2GZSA (MGA_T2|MGA_S|MGA_A)
+#define MGA_WARP_T2GZSAF (MGA_T2|MGA_S|MGA_F|MGA_A)
+
+#define MGA_MAX_G400_PIPES 16
+#define MGA_MAX_G200_PIPES 8 /* no multitex */
+
+#define MGA_MAX_WARP_PIPES MGA_MAX_G400_PIPES
+
+#define MGA_CARD_TYPE_G200 1
+#define MGA_CARD_TYPE_G400 2
+#define MGA_FRONT 0x1
+#define MGA_BACK 0x2
+#define MGA_DEPTH 0x4
+
+/* 3d state excluding texture units:
+ */
+#define MGA_CTXREG_DSTORG 0 /* validated */
+#define MGA_CTXREG_MACCESS 1
+#define MGA_CTXREG_PLNWT 2
+#define MGA_CTXREG_DWGCTL 3
+#define MGA_CTXREG_ALPHACTRL 4
+#define MGA_CTXREG_FOGCOLOR 5
+#define MGA_CTXREG_WFLAG 6
+#define MGA_CTXREG_TDUAL0 7
+#define MGA_CTXREG_TDUAL1 8
+#define MGA_CTXREG_FCOL 9
+#define MGA_CTX_SETUP_SIZE 10
+
+/* 2d state
+ */
+#define MGA_2DREG_PITCH 0
+#define MGA_2D_SETUP_SIZE 1
+
+/* Each texture unit has a state:
+ */
+#define MGA_TEXREG_CTL 0
+#define MGA_TEXREG_CTL2 1
+#define MGA_TEXREG_FILTER 2
+#define MGA_TEXREG_BORDERCOL 3
+#define MGA_TEXREG_ORG 4 /* validated */
+#define MGA_TEXREG_ORG1 5
+#define MGA_TEXREG_ORG2 6
+#define MGA_TEXREG_ORG3 7
+#define MGA_TEXREG_ORG4 8
+#define MGA_TEXREG_WIDTH 9
+#define MGA_TEXREG_HEIGHT 10
+#define MGA_TEX_SETUP_SIZE 11
+
+/* What needs to be changed for the current vertex dma buffer?
+ */
+#define MGA_UPLOAD_CTX 0x1
+#define MGA_UPLOAD_TEX0 0x2
+#define MGA_UPLOAD_TEX1 0x4
+#define MGA_UPLOAD_PIPE 0x8
+#define MGA_UPLOAD_TEX0IMAGE 0x10
+#define MGA_UPLOAD_TEX1IMAGE 0x20
+#define MGA_UPLOAD_2D 0x40
+#define MGA_WAIT_AGE 0x80 /* handled client-side */
+#define MGA_UPLOAD_CLIPRECTS 0x100 /* handled client-side */
+#define MGA_DMA_FLUSH 0x200 /* set when someone gets the lock
+ quiescent */
+
+/* 32 buffers of 64k each, total 1 meg.
+ */
+#define MGA_DMA_BUF_ORDER 16
+#define MGA_DMA_BUF_SZ (1<<MGA_DMA_BUF_ORDER)
+#define MGA_DMA_BUF_NR 31
+
+/* Keep these small for testing.
+ */
+#define MGA_NR_SAREA_CLIPRECTS 8
+
+/* 2 heaps (1 for card, 1 for agp), each divided into upto 128
+ * regions, subject to a minimum region size of (1<<16) == 64k.
+ *
+ * Clients may subdivide regions internally, but when sharing between
+ * clients, the region size is the minimum granularity.
+ */
+
+#define MGA_CARD_HEAP 0
+#define MGA_AGP_HEAP 1
+#define MGA_NR_TEX_HEAPS 2
+#define MGA_NR_TEX_REGIONS 16
+#define MGA_LOG_MIN_TEX_REGION_SIZE 16
+#endif
+
+typedef struct _drmMgaWarpIndex {
+ int installed;
+ unsigned long phys_addr;
+ int size;
+} drmMgaWarpIndex;
+
+typedef struct _drmMgaInit {
+ int reserved_map_agpstart;
+ int reserved_map_idx;
+ int buffer_map_idx;
+ int sarea_priv_offset;
+ int primary_size;
+ int warp_ucode_size;
+ unsigned int frontOffset;
+ unsigned int backOffset;
+ unsigned int depthOffset;
+ unsigned int textureOffset;
+ unsigned int textureSize;
+ unsigned int agpTextureSize;
+ unsigned int agpTextureOffset;
+ unsigned int cpp;
+ unsigned int stride;
+ int sgram;
+ int chipset;
+ drmMgaWarpIndex WarpIndex[MGA_MAX_WARP_PIPES];
+ unsigned int mAccess;
+} drmMgaInit;
+
+
+Bool drmMgaCleanupDma(int driSubFD);
+Bool drmMgaLockUpdate(int driSubFD, drmLockFlags flags);
+Bool drmMgaInitDma(int driSubFD, drmMgaInit *info);
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
new file mode 100644
index 000000000..18f8adb0a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
@@ -0,0 +1,80 @@
+/* xf86drm.h -- OS-independent header for DRM user-level library interface
+ * Created: Sun Apr 9 18:16:28 2000 by kevin@precisioninsight.com
+ *
+ * Copyright 1999, 2000 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.
+ *
+ * Author: Kevin E. Martin <kevin@precisioninsight.com>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h,v 3.1 2000/06/17 00:03:26 martin Exp $
+ *
+ */
+
+#ifndef _XF86DRI_R128_H_
+#define _XF86DRI_R128_H_
+
+/* WARNING: If you change any of these defines, make sure to change
+ * the kernel include file as well (r128_drm.h)
+ */
+
+typedef struct _drmR128Init {
+ int sarea_priv_offset;
+ int is_pci;
+ int cce_mode;
+ int cce_fifo_size;
+ int cce_secure;
+ int ring_size;
+ int usec_timeout;
+
+ int fb_offset;
+ int agp_ring_offset;
+ int agp_read_ptr_offset;
+ int agp_vertbufs_offset;
+ int agp_indbufs_offset;
+ int agp_textures_offset;
+ int mmio_offset;
+} drmR128Init;
+
+typedef enum {
+ DRM_R128_PRIM_NONE = 0x0001,
+ DRM_R128_PRIM_POINT = 0x0002,
+ DRM_R128_PRIM_LINE = 0x0004,
+ DRM_R128_PRIM_POLY_LINE = 0x0008,
+ DRM_R128_PRIM_TRI_LIST = 0x0010,
+ DRM_R128_PRIM_TRI_FAN = 0x0020,
+ DRM_R128_PRIM_TRI_STRIP = 0x0040,
+ DRM_R128_PRIM_TRI_TYPE2 = 0x0080
+} drmR128PrimType;
+
+
+extern int drmR128InitCCE(int fd, drmR128Init *info);
+extern int drmR128CleanupCCE(int fd);
+extern int drmR128EngineReset(int fd);
+extern int drmR128EngineFlush(int fd);
+extern int drmR128WaitForIdle(int fd);
+extern int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags);
+extern int drmR128GetVertexBuffers(int fd, int count, int *indices,
+ int *sizes);
+extern int drmR128FlushVertexBuffers(int fd, int count, int *indices,
+ int *sizes, drmR128PrimType prim);
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Configint.h b/xc/programs/Xserver/hw/xfree86/parser/Configint.h
index 532dc0fd9..2f1c08e4e 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Configint.h
+++ b/xc/programs/Xserver/hw/xfree86/parser/Configint.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Configint.h,v 1.14 1999/09/06 11:27:37 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Configint.h,v 1.15 2000/04/04 19:25:20 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -147,7 +147,8 @@ else\
#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 and 1 or 5 \n\tscreen names in quotes."
+"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 \
@@ -180,6 +181,9 @@ else\
"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."
/* Warning messages */
#define OBSOLETE_MSG \
diff --git a/xc/programs/Xserver/hw/xfree86/parser/DRI.c b/xc/programs/Xserver/hw/xfree86/parser/DRI.c
index e120399b9..aca18aa64 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/DRI.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/DRI.c
@@ -24,7 +24,7 @@
* 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/parser/DRI.c,v 1.3 2000/03/05 17:04:19 dawes Exp $
+ * $XFree86: xc/programs/Xserver/hw/xfree86/parser/DRI.c,v 1.6 2000/05/18 00:37:30 dawes Exp $
*
*/
@@ -81,17 +81,22 @@ parseDRISection (void)
{
parsePrologue (XF86ConfDRIPtr, XF86ConfDRIRec);
+ /* Zero is a valid value for this. */
+ ptr->dri_group = -1;
while ((token = xf86GetToken (DRITab)) != ENDSECTION) {
switch (token)
{
case GROUP:
- if (xf86GetToken (NULL) != NUMBER)
- Error (QUOTE_MSG, "Group");
- ptr->dri_group = val.num;
+ if ((token = xf86GetToken (NULL)) == 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 (xf86GetToken (NULL) != NUMBER)
- Error (QUOTE_MSG, "Mode");
+ Error (NUMBER_MSG, "Mode");
ptr->dri_mode = val.num;
break;
case BUFFERS:
@@ -124,7 +129,9 @@ printDRISection (FILE * cf, XF86ConfDRIPtr ptr)
if (ptr == NULL)
return;
- if (ptr->dri_group)
+ 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);
for (bufs = ptr->dri_buffers_lst; bufs; bufs = bufs->list.next) {
fprintf (cf, "\tBuffers %d %d",
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Device.c b/xc/programs/Xserver/hw/xfree86/parser/Device.c
index 8d79dd78c..548e16c1d 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Device.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/Device.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Device.c,v 1.14 2000/03/01 16:01:30 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Device.c,v 1.15 2000/06/20 05:08:48 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -60,6 +60,7 @@ xf86ConfigSymTabRec DeviceTab[] =
{BUSID, "busid"},
{TEXTCLOCKFRQ, "textclockfreq"},
{IRQ, "irq"},
+ {SCREEN, "screen"},
{-1, ""},
};
@@ -224,6 +225,11 @@ parseDeviceSection (void)
Error (QUOTE_MSG, "IRQ");
ptr->dev_irq = val.num;
break;
+ case SCREEN:
+ if (xf86GetToken (NULL) != NUMBER)
+ Error (NUMBER_MSG, "Screen");
+ ptr->dev_screen = val.num;
+ break;
case EOF_TOKEN:
Error (UNEXPECTED_EOF_MSG, NULL);
break;
@@ -311,6 +317,8 @@ printDeviceSection (FILE * cf, XF86ConfDevicePtr ptr)
}
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");
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Flags.c b/xc/programs/Xserver/hw/xfree86/parser/Flags.c
index 770d745da..6fd8df099 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Flags.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/Flags.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Flags.c,v 1.11 2000/01/26 02:00:51 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Flags.c,v 1.12 2000/04/04 22:36:53 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -200,7 +200,7 @@ addNewOption2 (XF86OptionPtr head, char *name, char *val, int used)
if (head != NULL && (old = FindOption(head, name)) != NULL)
new = old;
else
- new = xf86confmalloc (sizeof (XF86OptionRec));
+ new = xf86confcalloc (1, sizeof (XF86OptionRec));
new->opt_name = name;
new->opt_val = val;
new->opt_used = used;
@@ -277,7 +277,7 @@ NewOption(char *name, char *value)
{
XF86OptionPtr opt;
- opt = xf86confmalloc(sizeof (XF86OptionRec));
+ opt = xf86confcalloc(1, sizeof (XF86OptionRec));
if (!opt)
return NULL;
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Layout.c b/xc/programs/Xserver/hw/xfree86/parser/Layout.c
index 70dd22f57..1f11b34f4 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Layout.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/Layout.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Layout.c,v 1.11 2000/01/26 02:00:51 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Layout.c,v 1.12 2000/04/04 22:36:54 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -85,7 +85,7 @@ parseLayoutSection (void)
{
XF86ConfInactivePtr iptr;
- iptr = xf86confmalloc (sizeof (XF86ConfInactiveRec));
+ iptr = xf86confcalloc (1, sizeof (XF86ConfInactiveRec));
iptr->list.next = NULL;
if (xf86GetToken (NULL) != STRING)
Error (INACTIVE_MSG, NULL);
@@ -98,7 +98,7 @@ parseLayoutSection (void)
{
XF86ConfAdjacencyPtr aptr;
- aptr = xf86confmalloc (sizeof (XF86ConfAdjacencyRec));
+ aptr = xf86confcalloc (1, sizeof (XF86ConfAdjacencyRec));
aptr->list.next = NULL;
aptr->adj_scrnum = -1;
aptr->adj_where = CONF_ADJ_OBSOLETE;
@@ -205,7 +205,7 @@ parseLayoutSection (void)
{
XF86ConfInputrefPtr iptr;
- iptr = xf86confmalloc (sizeof (XF86ConfInputrefRec));
+ iptr = xf86confcalloc (1, sizeof (XF86ConfInputrefRec));
iptr->list.next = NULL;
iptr->iref_option_lst = NULL;
if (xf86GetToken (NULL) != STRING)
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Module.c b/xc/programs/Xserver/hw/xfree86/parser/Module.c
index b558ca652..4dd47b430 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Module.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/Module.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Module.c,v 1.4 1999/05/30 14:04:25 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Module.c,v 1.5 2000/04/04 22:36:54 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -198,7 +198,7 @@ addNewLoadDirective (XF86LoadPtr head, char *name, int type, XF86OptionPtr opts)
{
XF86LoadPtr new;
- new = xf86confmalloc (sizeof (XF86LoadRec));
+ new = xf86confcalloc (1, sizeof (XF86LoadRec));
new->load_name = name;
new->load_type = type;
new->load_opt = opts;
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Monitor.c b/xc/programs/Xserver/hw/xfree86/parser/Monitor.c
index 33524177a..2c6da69f8 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Monitor.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/Monitor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Monitor.c,v 1.12 2000/01/26 02:00:51 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Monitor.c,v 1.13 2000/04/04 22:36:54 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -549,7 +549,7 @@ parseMonitorSection (void)
/* add to the end of the list of modes sections
referenced here */
- mptr = xf86confmalloc (sizeof (XF86ConfModesLinkRec));
+ mptr = xf86confcalloc (1, sizeof (XF86ConfModesLinkRec));
mptr->list.next = NULL;
mptr->ml_modes_str = val.str;
mptr->ml_modes = NULL;
diff --git a/xc/programs/Xserver/hw/xfree86/parser/Screen.c b/xc/programs/Xserver/hw/xfree86/parser/Screen.c
index ee945bd07..8884f9054 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/Screen.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/Screen.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Screen.c,v 1.11 2000/02/25 19:07:53 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/Screen.c,v 1.12 2000/04/04 22:36:55 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -138,7 +138,7 @@ parseDisplaySubSection (void)
while ((token = xf86GetToken (DisplayTab)) == STRING)
{
- mptr = xf86confmalloc (sizeof (XF86ModeRec));
+ mptr = xf86confcalloc (1, sizeof (XF86ModeRec));
mptr->mode_name = val.str;
mptr->list.next = NULL;
ptr->disp_mode_lst = (XF86ModePtr)
@@ -280,7 +280,7 @@ parseScreenSection (void)
if (aptr == NULL)
{
- aptr = xf86confmalloc (sizeof (XF86ConfAdaptorLinkRec));
+ aptr = xf86confcalloc (1, sizeof (XF86ConfAdaptorLinkRec));
aptr->list.next = NULL;
aptr->al_adaptor_str = val.str;
ptr->scrn_adaptor_lst = (XF86ConfAdaptorLinkPtr)
diff --git a/xc/programs/Xserver/hw/xfree86/parser/read.c b/xc/programs/Xserver/hw/xfree86/parser/read.c
index 5656ce6dc..d1c2ac164 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/read.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/read.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.11 1999/09/04 13:04:54 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/read.c,v 1.12 2000/04/04 22:36:55 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -49,7 +49,7 @@ xf86ReadConfigFile (void)
int token;
XF86ConfigPtr ptr = NULL;
- if ((ptr = xf86confmalloc (sizeof (XF86ConfigRec))) == NULL)
+ if ((ptr = xf86confcalloc (1, sizeof (XF86ConfigRec))) == NULL)
{
return NULL;
}
diff --git a/xc/programs/Xserver/hw/xfree86/parser/scan.c b/xc/programs/Xserver/hw/xfree86/parser/scan.c
index 8018c5fda..6d8e1b922 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/scan.c
+++ b/xc/programs/Xserver/hw/xfree86/parser/scan.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.10 2000/03/02 17:53:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/scan.c,v 1.12 2000/04/05 18:13:57 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -94,7 +94,7 @@ StrToUL (char *str)
if (*p == '0')
{
p++;
- if (*p == 'x')
+ if ((*p == 'x') || (*p == 'X'))
{
p++;
base = 16;
@@ -205,7 +205,7 @@ xf86GetToken (xf86ConfigSymTabRec * tab)
configRBuf[0] = c;
i = 1;
while (isdigit (c = configBuf[configPos++]) ||
- (c == '.') || (c == 'x') ||
+ (c == '.') || (c == 'x') || (c == 'X') ||
((base == 16) && (((c >= 'a') && (c <= 'f')) ||
((c >= 'A') && (c <= 'F')))))
configRBuf[i++] = c;
@@ -359,6 +359,7 @@ PathIsSafe(const char *path)
* %P projroot
* %M major version number
* %% %
+ * %& EMX only: prepend X11ROOT env var
*/
#ifndef XCONFIGFILE
@@ -407,6 +408,9 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
static const char *env = NULL, *home = NULL;
static char *hostname = NULL;
static char majorvers[3] = "";
+#ifdef __EMX__
+ static char *x11root = NULL;
+#endif
if (!template)
return NULL;
@@ -523,6 +527,16 @@ DoSubstitution(const char *template, const char *cmdline, const char *projroot,
result[l++] = '%';
CHECK_LENGTH;
break;
+#ifdef __EMX__
+ case '&':
+ if (!x11root)
+ x11root = getenv("X11ROOT");
+ if (x11root)
+ APPEND_STR(x11root);
+ else
+ BAIL_OUT;
+ break;
+#endif
default:
fprintf(stderr, "invalid escape %%%c found in path template\n",
template[i]);
diff --git a/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h b/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h
index 6f7ef4079..9c20d8440 100644
--- a/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h
+++ b/xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.19 2000/01/26 02:00:51 alanh Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/parser/xf86Parser.h,v 1.21 2000/06/20 05:08:49 dawes Exp $ */
/*
*
* Copyright (c) 1997 Metro Link Incorporated
@@ -203,6 +203,7 @@ typedef struct
int dev_chipid;
int dev_chiprev;
int dev_irq;
+ int dev_screen;
XF86OptionPtr dev_option_lst;
char *dev_comment;
}
@@ -356,8 +357,9 @@ XF86ConfBuffersRec, *XF86ConfBuffersPtr;
typedef struct
{
+ char *dri_group_name;
int dri_group;
- int dri_mode;
+ int dri_mode;
XF86ConfBuffersPtr dri_buffers_lst;
}
XF86ConfDRIRec, *XF86ConfDRIPtr;
diff --git a/xc/programs/Xserver/hw/xfree86/ramdac/TI.c b/xc/programs/Xserver/hw/xfree86/ramdac/TI.c
index 498df080b..89fb07c0b 100644
--- a/xc/programs/Xserver/hw/xfree86/ramdac/TI.c
+++ b/xc/programs/Xserver/hw/xfree86/ramdac/TI.c
@@ -24,7 +24,7 @@
* Modified from IBM.c to support TI RAMDAC routines
* by Jens Owen, <jens@precisioninsight.com>.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/TI.c,v 1.1 1999/06/14 07:32:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/TI.c,v 1.5 2000/05/02 21:04:46 alanh Exp $ */
#include "xf86.h"
#include "xf86_OSproc.h"
@@ -71,7 +71,7 @@ TIramdacCalculateMNPForClock(
* we don't have to bother checking for this maximum limit.
*/
VCO = (double)ReqClock;
- for ( p = *rP; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ )
+ for ( p = 0; p < 3 && VCO < TI_MIN_VCO_FREQ; ( p )++ )
VCO *= 2.0;
/*
@@ -158,55 +158,55 @@ TIramdacRestore(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
/* 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);
+ /* 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,
+ /* 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,
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
ramdacReg->DacRegs[TIDAC_PIXEL_M]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_pixel_data, 0,
+ (*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,
+ /* 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;
- }
+ 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);
+ /* 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,
+ /* 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,
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
ramdacReg->DacRegs[TIDAC_LOOP_M]);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_loop_data, 0,
+ (*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)) {
+ /* 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 */
@@ -228,38 +228,32 @@ TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
RamDacRegRecPtr ramdacReg)
{
int i;
- unsigned long status;
(*ramdacPtr->ReadAddress)(pScrn, 0);
for (i=0;i<768;i++)
ramdacReg->DAC[i] = (*ramdacPtr->ReadData)(pScrn);
- if (ramdacReg->DacRegs[TIDAC_PIXEL_VALID]) {
- /* 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] =
+ /* 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);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
- ramdacReg->DacRegs[TIDAC_PIXEL_P] =
- (*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_pixel_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x33);
- }
- if (ramdacReg->DacRegs[TIDAC_LOOP_VALID]) {
- /* Read back N,M and P values for loop clock */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0);
- ramdacReg->DacRegs[TIDAC_LOOP_N] =
+
+ /* 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->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->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x22);
+ ramdacReg->DacRegs[TIDAC_LOOP_P] =
(*ramdacPtr->ReadDAC)(pScrn, TIDAC_pll_loop_data);
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_pll_addr, 0, 0x33);
- }
/* Order is important */
TISAVE(TIDAC_latch_ctrl);
@@ -285,7 +279,7 @@ TIramdacSave(ScrnInfoPtr pScrn, RamDacRecPtr ramdacPtr,
}
RamDacHelperRecPtr
-TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRecPtr ramdacPtr*/)
+TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs)
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
RamDacHelperRecPtr ramdacHelperPtr = NULL;
@@ -309,6 +303,10 @@ TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRec
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);
@@ -338,7 +336,11 @@ TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRec
switch (TIramdac_ID) {
case TI3030_RAMDAC:
ramdacHelperPtr->SetBpp = TIramdac3030SetBpp;
- ramdacHelperPtr->HWCursorInit = TIramdac3030HWCursorInit;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
+ break;
+ case TI3026_RAMDAC:
+ ramdacHelperPtr->SetBpp = TIramdac3026SetBpp;
+ ramdacHelperPtr->HWCursorInit = TIramdacHWCursorInit;
break;
}
ramdacPtr->RamDacType = TIramdac_ID;
@@ -350,14 +352,14 @@ TIramdacProbe(ScrnInfoPtr pScrn, RamDacSupportedInfoRecPtr ramdacs/* , RamDacRec
}
void
-TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
+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] = 0x5D;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x5c;
ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
@@ -373,7 +375,7 @@ TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
ramdacReg->DacRegs[TIDAC_key_blue_high] = 0x00;
ramdacReg->DacRegs[TIDAC_key_ctrl] = 0x10;
ramdacReg->DacRegs[TIDAC_sense_test] = 0x00;
- if (ramdacReg->Overlay) {
+ 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;
@@ -404,7 +406,7 @@ TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
break;
case 16:
/* order is important */
-#ifdef NOT_DONE
+#if 0
/* Matrox driver uses this */
ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x07;
#else
@@ -415,20 +417,19 @@ TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
} else {
ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x44;
}
-#ifdef NOT_DONE
+#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;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
#else
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x55;
+ ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x54;
ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
ramdacReg->DacRegs[TIDAC_palette_page] = 0x00;
ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x10;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x2C;
#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;
@@ -446,21 +447,106 @@ TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
/* order is important */
ramdacReg->DacRegs[TIDAC_latch_ctrl] = 0x06;
ramdacReg->DacRegs[TIDAC_true_color_ctrl] = 0x80;
-#ifdef NOT_DONE
- ramdacReg->DacRegs[TIDAC_multiplex_ctrl] = 0x48;
+ 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_multiplex_ctrl] = 0x4d;
- ramdacReg->DacRegs[TIDAC_clock_select] = 0x05;
+ 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;
-#ifdef NOT_DONE
ramdacReg->DacRegs[TIDAC_general_ctrl] = 0x00;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x0C;
#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;
- ramdacReg->DacRegs[TIDAC_misc_ctrl] = 0x1C;
#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;
@@ -470,6 +556,28 @@ TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
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;
@@ -478,25 +586,25 @@ TIramdac3030SetBpp(ScrnInfoPtr pScrn, RamDacRegRecPtr ramdacReg)
}
void
-TIramdac3030ShowCursor(ScrnInfoPtr pScrn)
+TIramdacShowCursor(ScrnInfoPtr pScrn)
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
/* Enable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0x6c, 0x13);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x03);
}
void
-TIramdac3030HideCursor(ScrnInfoPtr pScrn)
+TIramdacHideCursor(ScrnInfoPtr pScrn)
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
/* Disable cursor - X11 mode */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0xfc, 0x00);
+ (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0, 0x00);
}
void
-TIramdac3030SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
+TIramdacSetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
@@ -510,7 +618,7 @@ TIramdac3030SetCursorPosition(ScrnInfoPtr pScrn, int x, int y)
}
void
-TIramdac3030SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
+TIramdacSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
@@ -528,17 +636,16 @@ TIramdac3030SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
}
void
-TIramdac3030LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
+TIramdacLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src)
{
RamDacRecPtr ramdacPtr = RAMDACSCRPTR(pScrn);
int i = 1024;
-int j = 16;
/* reset A9,A8 */
- (*ramdacPtr->WriteDAC)(pScrn, TIDAC_ind_curs_ctrl, 0xf3, 0x00);
+ (*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++));
@@ -546,23 +653,61 @@ int j = 16;
}
static Bool
-TIramdac3030UseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
+TIramdacUseHWCursor(ScreenPtr pScr, CursorPtr pCurs)
{
return TRUE;
}
void
-TIramdac3030HWCursorInit(xf86CursorInfoPtr infoPtr)
+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 = TIramdac3030SetCursorColors;
- infoPtr->SetCursorPosition = TIramdac3030SetCursorPosition;
- infoPtr->LoadCursorImage = TIramdac3030LoadCursorImage;
- infoPtr->HideCursor = TIramdac3030HideCursor;
- infoPtr->ShowCursor = TIramdac3030ShowCursor;
- infoPtr->UseHWCursor = TIramdac3030UseHWCursor;
+ 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);
+ }
+}
}
diff --git a/xc/programs/Xserver/hw/xfree86/ramdac/TI.h b/xc/programs/Xserver/hw/xfree86/ramdac/TI.h
index b754de4ec..12f010be1 100644
--- a/xc/programs/Xserver/hw/xfree86/ramdac/TI.h
+++ b/xc/programs/Xserver/hw/xfree86/ramdac/TI.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/TI.h,v 1.2 1999/11/16 03:46:06 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/TI.h,v 1.4 2000/05/02 21:04:46 alanh Exp $ */
#include <xf86RamDac.h>
@@ -9,14 +9,16 @@ unsigned long TIramdacCalculateMNPForClock(unsigned long RefClock,
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 TIramdac3030HWCursorInit(xf86CursorInfoPtr infoPtr);
+void TIramdacHWCursorInit(xf86CursorInfoPtr infoPtr);
#define TI3030_RAMDAC (VENDOR_TI << 16) | 0x00
+#define TI3026_RAMDAC (VENDOR_TI << 16) | 0x01
/*
* TI Ramdac registers
@@ -84,4 +86,5 @@ void TIramdac3030HWCursorInit(xf86CursorInfoPtr infoPtr);
#define TIDAC_sw_reset 0xff
/* Constants */
+#define TIDAC_TVP_3026_ID 0x26
#define TIDAC_TVP_3030_ID 0x30
diff --git a/xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h b/xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h
index 03d36c4cc..d81552764 100644
--- a/xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h
+++ b/xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h,v 1.1 1999/06/14 07:32:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/TIPriv.h,v 1.2 2000/03/21 21:15:28 alanh Exp $ */
#include "TI.h"
@@ -10,7 +10,8 @@ extern xf86TIramdacInfo TIramdacDeviceInfo[];
#ifdef INIT_TI_RAMDAC_INFO
xf86TIramdacInfo TIramdacDeviceInfo[] = {
- {"TI TVP3030"}
+ {"TI TVP3030"},
+ {"TI TVP3026"}
};
#endif
diff --git a/xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c b/xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c
index 664ee5273..5e26ff098 100644
--- a/xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c
+++ b/xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c,v 1.5 1999/10/13 22:33:08 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86Cursor.c,v 1.7 2000/04/24 23:40:27 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -101,12 +101,14 @@ xf86InitCursor(
PointPriv->spriteFuncs = &xf86CursorSpriteFuncs;
ScreenPriv->SwitchMode = pScrn->SwitchMode;
- pScrn->SwitchMode = xf86CursorSwitchMode;
ScreenPriv->EnterVT = pScrn->EnterVT;
- pScrn->EnterVT = xf86CursorEnterVT;
ScreenPriv->LeaveVT = pScrn->LeaveVT;
- pScrn->LeaveVT = xf86CursorLeaveVT;
ScreenPriv->SetDGAMode = pScrn->SetDGAMode;
+
+ if(pScrn->SwitchMode)
+ pScrn->SwitchMode = xf86CursorSwitchMode;
+ pScrn->EnterVT = xf86CursorEnterVT;
+ pScrn->LeaveVT = xf86CursorLeaveVT;
pScrn->SetDGAMode = xf86SetDGAMode;
return TRUE;
@@ -261,7 +263,7 @@ xf86SetDGAMode(int index, int num, DGADevicePtr devRet)
ret = (*ScreenPriv->SetDGAMode)(index, num, devRet);
- if(!num && ScreenPriv->CurrentCursor) {
+ if(ScreenPriv->CurrentCursor && (!num || (ret != Success))) {
xf86CursorSetCursor(pScreen, ScreenPriv->CurrentCursor,
ScreenPriv->x, ScreenPriv->y);
}
diff --git a/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h b/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h
index f417cec18..626a8b2b9 100644
--- a/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h
+++ b/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h
@@ -1,8 +1,9 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h,v 1.10 1999/06/14 07:32:09 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDac.h,v 1.11 2000/03/21 21:15:28 alanh Exp $ */
#ifndef _XF86RAMDAC_H
#define _XF86RAMDAC_H 1
+#include "colormapst.h"
#include "xf86Cursor.h"
/* Define unique vendor codes for RAMDAC's */
@@ -29,6 +30,14 @@ typedef struct _RamDacHWRegRec {
typedef struct _RamDacRec {
CARD32 RamDacType;
+ void (*LoadPalette)(
+ ScrnInfoPtr pScrn,
+ int numColors,
+ int *indices,
+ LOCO *colors,
+ VisualPtr pVisual
+ );
+
unsigned char (*ReadDAC)(
ScrnInfoPtr pScrn,
CARD32
diff --git a/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c b/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c
index 097cf57b2..0f94bf9b7 100644
--- a/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c
+++ b/xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c
@@ -23,7 +23,7 @@
*
* Generic RAMDAC access to colormaps.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c,v 1.5 1999/07/18 03:27:01 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/ramdac/xf86RamDacCmap.c,v 1.6 2000/03/21 21:15:28 alanh Exp $ */
#include "X.h"
#include "Xproto.h"
@@ -60,6 +60,13 @@ Bool
RamDacHandleColormaps(ScreenPtr pScreen, int maxColors, int sigRGBbits,
unsigned int flags)
{
- return xf86HandleColormaps(pScreen, maxColors, sigRGBbits,
+ 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/xc/programs/Xserver/hw/xfree86/scanpci/Imakefile b/xc/programs/Xserver/hw/xfree86/scanpci/Imakefile
index 947e02735..04d784b38 100644
--- a/xc/programs/Xserver/hw/xfree86/scanpci/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/scanpci/Imakefile
@@ -1,7 +1,11 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/Imakefile,v 1.6 1999/08/14 10:50:08 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/Imakefile,v 1.8 2000/04/06 15:27:26 dawes Exp $
+
+#if DoLoadableServer
+#define IHaveSubdirs
+SUBDIRS = module
+#endif
-#define IHaveModules
#include <Server.tmpl>
MODPATHDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\"
@@ -14,17 +18,15 @@ MODPATHDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\"
SRCS = xf86ScanPci.c xf86PciData.c
-ModuleObjectRule()
-
-LibraryModuleTarget(scanpci,xf86ScanPci.o)
+NormalLibraryObjectRule()
-InstallLibraryModule(scanpci,$(MODULEDIR),.)
+NormalLibraryTarget(scanpci,xf86ScanPci.o)
-LibraryModuleTarget(pcidata,xf86PciData.o)
+NormalLibraryTarget(pcidata,xf86PciData.o)
-InstallLibraryModule(pcidata,$(MODULEDIR),.)
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
DependTarget()
-
-InstallDriverSDKLibraryModule(scanpci,$(DRIVERSDKMODULEDIR),.)
-InstallDriverSDKLibraryModule(pcidata,$(DRIVERSDKMODULEDIR),.)
diff --git a/xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile b/xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile
new file mode 100644
index 000000000..49f5eaf20
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile
@@ -0,0 +1,33 @@
+
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/module/Imakefile,v 1.1 2000/04/06 15:35:05 dawes Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+MODPATHDEFINES = -DDEFAULT_MODULE_PATH=\"$(MODULEDIR)\"
+ INCLUDES = -I$(XF86SRC)/common -I$(XF86OSSRC) -I$(XF86OSSRC)/bus \
+ -I$(SERVERSRC)/include -I$(SERVERSRC)/os \
+ -I$(XINCLUDESRC) -I$(SERVERSRC)/Xext -I$(EXTINCSRC) \
+ -I$(SERVERSRC)/Xi \
+ -I$(FONTLIBSRC)/include -I$(XF86PARSERSRC) \
+ -I$(XF86SRC)/loader $(VGAINCLUDES) -I$(XF86SRC)/rac -I..
+
+SRCS = xf86ScanPci.c xf86PciData.c
+
+LinkSourceFile(xf86ScanPci.c,..)
+LinkSourceFile(xf86PciData.c,..)
+
+ModuleObjectRule()
+
+LibraryModuleTarget(scanpci,xf86ScanPci.o)
+
+InstallLibraryModule(scanpci,$(MODULEDIR),.)
+
+LibraryModuleTarget(pcidata,xf86PciData.o)
+
+InstallLibraryModule(pcidata,$(MODULEDIR),.)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(scanpci,$(DRIVERSDKMODULEDIR),.)
+InstallDriverSDKLibraryModule(pcidata,$(DRIVERSDKMODULEDIR),.)
diff --git a/xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c b/xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c
index 8e50830b2..e17125d2e 100644
--- a/xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c
+++ b/xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c,v 1.4 2000/02/21 18:05:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/xf86PciData.c,v 1.5 2000/04/05 18:13:58 dawes Exp $ */
/*
* the PCI data structures
*
@@ -11,14 +11,19 @@
/* XXX This is including a lot of stuff that modules should not include! */
-#include <ctype.h>
-#include <stdlib.h>
#include "X.h"
#include "os.h"
#include "xf86.h"
#include "xf86Priv.h"
#include "xf86Pci.h"
+#ifndef IN_MODULE
+#include <ctype.h>
+#include <stdlib.h>
+#else
+#include <xf86_ansic.h>
+#endif
+
#define INIT_PCI_CARD_INFO TRUE
#define DECLARE_CARD_DATASTRUCTURES TRUE
#define INIT_PCI_VENDOR_INFO TRUE
diff --git a/xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c b/xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c
index 97208f116..029bd36ce 100644
--- a/xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c
+++ b/xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c,v 1.10 2000/02/21 18:05:49 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/scanpci/xf86ScanPci.c,v 1.11 2000/04/05 18:13:58 dawes Exp $ */
/*
* Display the Subsystem Vendor Id and Subsystem Id in order to identify
* the cards installed in this computer
@@ -11,8 +11,6 @@
/* XXX This is including a lot of stuff that modules should not include! */
-#include <ctype.h>
-#include <stdlib.h>
#include "X.h"
#include "os.h"
#include "xf86.h"
@@ -20,6 +18,13 @@
#include "xf86Pci.h"
#include "xf86_OSproc.h"
+#ifndef IN_MODULE
+#include <ctype.h>
+#include <stdlib.h>
+#else
+#include <xf86_ansic.h>
+#endif
+
#define INIT_PCI_CARD_INFO TRUE
#define DECLARE_CARD_DATASTRUCTURES TRUE
#define INIT_PCI_VENDOR_INFO TRUE
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/Imakefile b/xc/programs/Xserver/hw/xfree86/xaa/Imakefile
index 0bc86210e..2ce1c9efa 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/xaa/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile,v 3.40 1999/11/04 21:32:55 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile,v 3.41 2000/06/20 05:08:49 dawes Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -16,7 +16,7 @@ GENSRCS = xaaInit.c xaaGC.c xaaInitAccel.c xaaFallback.c xaaBitBlt.c \
xaaImage.c xaaPaintWin.c xaaRect.c xaaLineMisc.c xaaBitOrder.c \
xaaFillPoly.c xaaWideLine.c xaaTables.c xaaFillArc.c xaaLine.c \
xaaSeg.c xaaDashLine.c xaaDashSeg.c xaaOverlay.c xaaOffscreen.c \
- xaaOverlayDF.c
+ xaaOverlayDF.c xaaStateChange.c
GENOBJS = xaaInit.o xaaGC.o xaaInitAccel.o xaaFallback.o xaaBitBlt.o \
xaaCpyArea.o xaaGCmisc.o xaaCpyWin.o xaaCpyPlane.o xaaFillRect.o \
@@ -24,7 +24,7 @@ GENOBJS = xaaInit.o xaaGC.o xaaInitAccel.o xaaFallback.o xaaBitBlt.o \
xaaImage.o xaaPaintWin.o xaaRect.o xaaLineMisc.o xaaBitOrder.o \
xaaFillPoly.o xaaWideLine.o xaaTables.o xaaFillArc.o xaaLine.o \
xaaSeg.o xaaDashLine.o xaaDashSeg.o xaaOverlay.o xaaOffscreen.o \
- xaaOverlayDF.o
+ xaaOverlayDF.o xaaStateChange.o
SRCS = $(GENSRCS)
OBJS = $(GENOBJS)
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP b/xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP
index a7ed03306..d6387f369 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP
+++ b/xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP,v 1.5 1999/07/10 07:24:53 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xaa/Imakefile.EXP,v 1.6 2000/05/03 00:44:21 tsi Exp $
#define IHaveModules
#include <Server.tmpl>
@@ -9,8 +9,8 @@ INCLUDES = -I.. -I$(XF86COMSRC) -I$(XF86OSSRC) -I$(XF86HWSRC) \
DEFINES = EXPDEFINES
-GENSRCS = xaaBitmap.c xaaTEGlyph.c xaaBitmap3.c xaaStipple.c
-GENOBJS = xaaBitmap.o xaaTEGlyph.o xaaBitmap3.o xaaStipple.o
+GENSRCS = xaaBitmap.c xaaBitmap3.c xaaStipple.c xaaStipple3.c xaaTEGlyph.c
+GENOBJS = xaaBitmap.o xaaBitmap3.o xaaStipple.o xaaStipple3.o xaaTEGlyph.o
#if defined(i386Architecture) && defined(UseAssembler) && !MakeDllModules
SRCS = $(GENSRCS) xaaTEGlyphBlt.S
@@ -36,5 +36,6 @@ LinkSourceFile(xaaTEGlyphBlt.S, LinkDirectory)
#endif
ObjectFromSpecialSource(xaaBitmap3, xaaBitmap, -DTRIPLE_BITS)
+ObjectFromSpecialSource(xaaStipple3, xaaStipple, -DTRIPLE_BITS)
DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO b/xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO
index e70bbf260..4101886a1 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO
+++ b/xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO
@@ -24,8 +24,7 @@ document as well.
2.8 Image Writes
2.8.1 The Direct Method
2.8.2 The Indirect Method
- 2.9 Image Reads
- 2.10 Clipping
+ 2.9 Clipping
3) The Pixmap Cache
4) Offscreen Pixmaps
@@ -651,8 +650,7 @@ void SubsequentDashedBresenhamLine(ScrnInfoPtr pScrn,
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. When definining this
- flag, also define RGB_EQUAL.
+ bits when writing the monochrome data.
2.5.1 The Direct Method
@@ -1331,12 +1329,7 @@ void SubsequentImageWriteScanline(ScrnInfoPtr pScrn, int bufno)
manipulate these buffers and then send the data to the accelerator.
-2.9 Image Reads
-
- /* More to come */
-
-
-2.10 Clipping
+2.9 Clipping
XAA supports hardware clipping rectangles. To use clipping
in this way it is expected that the graphics accelerator can
@@ -1435,4 +1428,4 @@ void DisableClipping (ScrnInfoPtr pScrn)
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.10 1999/03/07 11:40:45 dawes Exp $
+$XFree86: xc/programs/Xserver/hw/xfree86/xaa/XAA.HOWTO,v 1.12 2000/04/12 14:44:42 tsi Exp $
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaa.h b/xc/programs/Xserver/hw/xfree86/xaa/xaa.h
index e57a55b52..fd8affa81 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaa.h
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaa.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaa.h,v 1.28 2000/02/18 12:20:08 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaa.h,v 1.30 2000/06/20 05:08:49 dawes Exp $ */
#ifndef _XAA_H
#define _XAA_H
@@ -239,6 +239,17 @@ typedef struct _XAAInfoRec {
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 *****************/
@@ -498,7 +509,7 @@ typedef struct _XAAInfoRec {
int NumScanlineImageWriteBuffers;
unsigned char **ScanlineImageWriteBuffers;
- /* Image Reads */
+ /* Image Reads - OBSOLETE AND NOT USED */
void (*SetupForImageRead) (
ScrnInfoPtr pScrn,
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c
index 2a42e3aec..2904a7548 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c,v 1.5 1998/09/05 06:37:03 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitOrder.c,v 1.6 2000/06/13 02:51:24 mvojkovi Exp $ */
#include "xf86.h"
#include "xf86_ansic.h"
@@ -10,56 +10,11 @@
#endif
-#if defined(__GNUC__) && defined(__i386__) && !defined(DLOPEN_HACK)
CARD32
-XAAReverseBitOrder(CARD32 data)
+XAAReverseBitOrder(CARD32 v)
{
-#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__) || defined(__GNU__)
- __asm__(
- "movl $0,%%ecx\n"
- "movb %%al,%%cl\n"
- "movb byte_reversed(%%ecx),%%al\n"
- "movb %%ah,%%cl\n"
- "movb byte_reversed(%%ecx),%%ah\n"
- "roll $16,%%eax\n"
- "movb %%al,%%cl\n"
- "movb byte_reversed(%%ecx),%%al\n"
- "movb %%ah,%%cl\n"
- "movb byte_reversed(%%ecx),%%ah\n"
- "roll $16,%%eax\n"
- : "=a" (data) : "0" (data)
- : "cx"
- );
-#else
- __asm__(
- "movl $0,%%ecx\n"
- "movb %%al,%%cl\n"
- "movb _byte_reversed(%%ecx),%%al\n"
- "movb %%ah,%%cl\n"
- "movb _byte_reversed(%%ecx),%%ah\n"
- "roll $16,%%eax\n"
- "movb %%al,%%cl\n"
- "movb _byte_reversed(%%ecx),%%al\n"
- "movb %%ah,%%cl\n"
- "movb _byte_reversed(%%ecx),%%ah\n"
- "roll $16,%%eax\n"
- : "=a" (data) : "0" (data)
- : "cx"
- );
-#endif
- return data;
-}
-#else
-CARD32
-XAAReverseBitOrder(CARD32 data)
-{
- unsigned char* kludge = (unsigned char*)&data;
-
- kludge[0] = byte_reversed[kludge[0]];
- kludge[1] = byte_reversed[kludge[1]];
- kludge[2] = byte_reversed[kludge[2]];
- kludge[3] = byte_reversed[kludge[3]];
-
- return data;
+ 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));
}
-#endif
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c
index 3f8dea6f3..8797d53f2 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c,v 1.6 2000/03/03 18:49:55 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaBitmap.c,v 1.9 2000/06/29 10:55:41 alanh Exp $ */
#include "xaa.h"
@@ -21,7 +21,7 @@
#endif
#ifdef MSBFIRST
-# define SOURCE(i) XAAReverseBitOrder(src[i])
+# define SOURCE(i) SWAP_BITS_IN_BYTES(src[i])
#else
# define SOURCE(i) src[i]
#endif
@@ -35,15 +35,20 @@ BitmapScanline(
CARD32 *src, CARD32 *base,
int count, int skipleft )
{
+ CARD32 bits;
+
while(count >= 3) {
- WRITE_BITS3(*src);
+ bits = *src;
+ WRITE_BITS3(bits);
src++;
count -= 3;
}
if (count == 2) {
- WRITE_BITS2(*src);
+ bits = *src;
+ WRITE_BITS2(bits);
} else if (count == 1) {
- WRITE_BITS1(*src);
+ bits = *src;
+ WRITE_BITS1(bits);
}
return base;
@@ -54,15 +59,20 @@ BitmapScanline_Inverted(
CARD32 *src, CARD32 *base,
int count, int skipleft )
{
+ CARD32 bits;
+
while(count >= 3) {
- WRITE_BITS3(~(*src));
+ bits = ~(*src);
+ WRITE_BITS3(bits);
src++;
count -= 3;
}
if (count == 2) {
- WRITE_BITS2(~(*src));
+ bits = ~(*src);
+ WRITE_BITS2(bits);
} else if (count == 1) {
- WRITE_BITS1(~(*src));
+ bits = ~(*src);
+ WRITE_BITS1(bits);
}
return base;
@@ -71,21 +81,23 @@ BitmapScanline_Inverted(
static CARD32*
BitmapScanline_Shifted(
- CARD32 *bits, CARD32 *base,
+ CARD32 *src, CARD32 *base,
int count, int skipleft )
{
+ CARD32 bits;
+
while(count >= 3) {
- WRITE_BITS3((SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft))));
- bits++;
+ bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
+ WRITE_BITS3(bits);
+ src++;
count -= 3;
}
if (count == 2) {
- WRITE_BITS2((SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft))));
+ bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
+ WRITE_BITS2(bits);
} else if (count == 1) {
- WRITE_BITS1((SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft))));
+ bits = SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft));
+ WRITE_BITS1(bits);
}
return base;
@@ -93,21 +105,23 @@ BitmapScanline_Shifted(
static CARD32*
BitmapScanline_Shifted_Inverted(
- CARD32 *bits, CARD32 *base,
+ CARD32 *src, CARD32 *base,
int count, int skipleft )
{
+ CARD32 bits;
+
while(count >= 3) {
- WRITE_BITS3(~(SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft))));
- bits++;
+ bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
+ WRITE_BITS3(bits);
+ src++;
count -= 3;
}
if (count == 2) {
- WRITE_BITS2(~(SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft))));
+ bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
+ WRITE_BITS2(bits);
} else if (count == 1) {
- WRITE_BITS1(~(SHIFT_R(*bits,skipleft) |
- SHIFT_L(*(bits + 1),(32 - skipleft))));
+ bits = ~(SHIFT_R(*src,skipleft) | SHIFT_L(*(src + 1),(32 - skipleft)));
+ WRITE_BITS1(bits);
}
return base;
@@ -241,7 +255,7 @@ EXPNAME(XAAWriteBitmapColorExpand3)(
EXPNAME(XAAWriteBitmapColorExpand)(
#endif
ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
+ int x, int y, int w, int H,
unsigned char *src,
int srcwidth,
int skipleft,
@@ -258,6 +272,7 @@ EXPNAME(XAAWriteBitmapColorExpand)(
BitmapScanlineProcPtr firstFunc;
BitmapScanlineProcPtr secondFunc;
int flag;
+ int h = H;
#ifdef TRIPLE_BITS
if((bg != -1) &&
@@ -268,7 +283,7 @@ EXPNAME(XAAWriteBitmapColorExpand)(
if((bg != -1) &&
(infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
#endif
- if(rop == GXcopy) {
+ if((rop == GXcopy) && infoRec->SetupForSolidFill) {
(*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
(*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
} else SecondPassColor = bg;
@@ -336,6 +351,7 @@ SECOND_PASS:
}
if(SecondPassColor != -1) {
+ h = H; /* Reset height */
fg = SecondPassColor;
SecondPassColor = -1;
firstFunc = secondFunc;
@@ -383,7 +399,7 @@ EXPNAME(XAAWriteBitmapScanlineColorExpand)(
if((bg != -1) &&
(infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)){
#endif
- if(rop == GXcopy) {
+ if((rop == GXcopy) && infoRec->SetupForSolidFill) {
(*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
(*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
} else SecondPassColor = bg;
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c
index 2ea9a148e..37218b238 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c,v 1.10 1999/04/04 08:46:24 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyArea.c,v 1.11 2000/04/01 22:42:04 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -65,6 +65,16 @@ XAACopyArea(
pGC, srcx, srcy, width, height, dstx, dsty,
XAADoBitBlt, 0L));
}
+ } else if((pSrcDrawable->type == DRAWABLE_WINDOW) ||
+ IS_OFFSCREEN_PIXMAP(pSrcDrawable)) {
+ if(infoRec->ReadPixmap && (pGC->alu == GXcopy) &&
+ (pSrcDrawable->bitsPerPixel == pDstDrawable->bitsPerPixel) &&
+ ((pGC->planemask & infoRec->FullPlanemask) == infoRec->FullPlanemask))
+ {
+ return (XAABitBlt( pSrcDrawable, pDstDrawable,
+ pGC, srcx, srcy, width, height, dstx, dsty,
+ XAADoImageRead, 0L));
+ }
}
return (XAAFallbackOps.CopyArea(pSrcDrawable, pDstDrawable, pGC,
@@ -219,6 +229,36 @@ XAADoImageWrite(
}
}
+
+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;
+
+ pdstBase = (unsigned char *)((PixmapPtr)pDst)->devPrivate.ptr;
+ dstwidth = (int)((PixmapPtr)pSrc)->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,
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c
index 320fab72e..ec6c87aa4 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c,v 1.9 1999/08/14 10:50:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaCpyPlane.c,v 1.10 2000/06/13 02:51:24 mvojkovi Exp $ */
/*
A CopyPlane function that handles bitmap->screen copies and
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c
index d8add9ea0..b38126bc6 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c,v 1.11 1999/05/30 03:03:31 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaFillPoly.c,v 1.13 2000/05/03 00:44:22 tsi Exp $ */
/*
* Copyright 1996 The XFree86 Project
@@ -723,8 +723,7 @@ XAAFillPolygonStippled(
yorg = (pDraw->y + pGC->patOrg.y);
- if((fg == bg) && (bg != -1) &&
- infoRec->SubsequentSolidFillRect && infoRec->SetupForSolidFill) {
+ if((fg == bg) && (bg != -1) && infoRec->SetupForSolidFill) {
(*infoRec->SetupForSolidFill)(infoRec->pScrn, fg,
pGC->alu, pGC->planemask);
@@ -923,7 +922,7 @@ XAAFillPolygonTiled(
case DO_CACHE_BLT:
pCache = (*infoRec->CacheTile)(infoRec->pScrn, pGC->tile.pixmap);
(*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, pCache->trans_color);
+ pGC->alu, pGC->planemask, -1);
RectFunc = CacheBltRectHelper;
break;
@@ -937,7 +936,7 @@ XAAFillPolygonTiled(
pPriv->offscreenArea->box.y2 - pCache->y;
(*infoRec->SetupForScreenToScreenCopy)(infoRec->pScrn, 1, 1,
- pGC->alu, pGC->planemask, pCache->trans_color);
+ pGC->alu, pGC->planemask, -1);
RectFunc = CacheBltRectHelper;
break;
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c
index b7cc22867..899e6d777 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c,v 1.12 1999/09/25 14:38:13 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaFillRect.c,v 1.13 2000/03/28 01:21:04 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -343,6 +343,7 @@ XAARenderPixmapCopyRects(
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,
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c
index 3d9aa2651..f6e932a5e 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c,v 1.13 1999/09/25 14:38:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaGCmisc.c,v 1.14 2000/05/03 00:44:23 tsi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -265,7 +265,7 @@ XAAValidateImageGlyphBlt(
if(infoRec->ImageGlyphBltNonTE &&
CHECK_PLANEMASK(pGC,infoRec->ImageGlyphBltNonTEFlags) &&
CHECK_FG(pGC,infoRec->ImageGlyphBltNonTEFlags) &&
- infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
+ infoRec->SetupForSolidFill &&
CHECK_PLANEMASK(pGC,infoRec->SolidFillFlags) &&
CHECK_BG(pGC,infoRec->SolidFillFlags))
{
@@ -283,7 +283,7 @@ XAAValidateImageGlyphBlt(
pGC->ops->ImageGlyphBlt = infoRec->ImageGlyphBltTE;
} else {
if(CHECK_FG(pGC,infoRec->ImageGlyphBltTEFlags) &&
- infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
+ infoRec->SetupForSolidFill &&
CHECK_PLANEMASK(pGC,infoRec->SolidFillFlags) &&
CHECK_BG(pGC,infoRec->SolidFillFlags))
{
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c
index 7ff9dfdf7..b0bb33ff3 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c,v 1.18 2000/02/10 23:21:38 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaImage.c,v 1.19 2000/04/01 22:42:04 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -515,88 +515,3 @@ XAAPutImage(
XAAFallbackOps.PutImage(pDraw, pGC, depth, x, y, w, h, leftPad,
format, pImage);
}
-
-
-void
-XAAReadPixmap (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *dst,
- int dstwidth, /* bytes */
- int bpp, int depth
-){
- XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
- int ReadDwords, WriteBytes, Surplus, Bpp = bpp >> 3;
- unsigned char *tmp;
- Bool PlusOne = FALSE;
- union {
- CARD32 IntData;
- unsigned char CharData[4];
- } extra;
-
- WriteBytes = w * Bpp;
- ReadDwords = (WriteBytes + 3) >> 2;
-
- if((infoRec->ImageReadFlags & CPU_TRANSFER_PAD_QWORD) &&
- ((ReadDwords * h) & 0x01)) {
- PlusOne = TRUE;
- }
-
-
- (*infoRec->SetupForImageRead)(pScrn, bpp, depth);
- (*infoRec->SubsequentImageReadRect)(pScrn, x, y, w, h);
-
- if(ReadDwords > infoRec->ImageWriteRange) {
- if((Surplus = (ReadDwords << 2) - WriteBytes)) {
- ReadDwords--;
- while(h--) {
- if(ReadDwords)
- XAAMoveDWORDS_FixedSrc((CARD32*)dst,
- (CARD32*)infoRec->ImageReadBase, ReadDwords);
- extra.IntData = *((CARD32*)infoRec->ImageReadBase);
- tmp = dst + (ReadDwords << 2);
- switch(Surplus) {
- case 3: tmp[2] = extra.CharData[2];
- case 2: tmp[1] = extra.CharData[1];
- case 1: tmp[0] = extra.CharData[0];
- }
- dst += dstwidth;
- }
- } else {
- while(h--) {
- XAAMoveDWORDS_FixedSrc((CARD32*)dst,
- (CARD32*)infoRec->ImageReadBase, ReadDwords);
- dst += dstwidth;
- }
- }
- } else {
- if((Surplus = (ReadDwords << 2) - WriteBytes)) {
- ReadDwords--;
- while(h--) {
- if(ReadDwords)
- XAAMoveDWORDS((CARD32*)dst,
- (CARD32*)infoRec->ImageReadBase, ReadDwords);
- extra.IntData =
- *((CARD32*)(infoRec->ImageReadBase) + ReadDwords);
- tmp = dst + (ReadDwords << 2);
- switch(Surplus) {
- case 3: tmp[2] = extra.CharData[2];
- case 2: tmp[1] = extra.CharData[1];
- case 1: tmp[0] = extra.CharData[0];
- }
- dst += dstwidth;
- }
- } else {
- while(h--) {
- XAAMoveDWORDS((CARD32*)dst,
- (CARD32*)infoRec->ImageReadBase, ReadDwords);
- dst += dstwidth;
- }
- }
- }
-
- if(PlusOne)
- extra.IntData = *((CARD32*)infoRec->ImageReadBase);
-
- SET_SYNC_FLAG(infoRec);
-}
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c
index 0f7f03406..1312eccb3 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.25 2000/02/11 06:35:17 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInit.c,v 1.28 2000/04/22 21:47:08 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -256,11 +256,27 @@ XAAGetImage (
)
{
ScreenPtr pScreen = pDraw->pScreen;
- XAA_SCREEN_PROLOGUE (pScreen, GetImage);
- if(xf86Screens[pScreen->myNum]->vtSema &&
- ((pDraw->type == DRAWABLE_WINDOW) || IS_OFFSCREEN_PIXMAP(pDraw))) {
+ 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->FullPlanemask) == infoRec->FullPlanemask) &&
+ (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);
}
@@ -624,6 +640,7 @@ XAASetDGAMode(int index, int num, DGADevicePtr devRet)
}
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);
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c
index ecbc7106d..8df9e6fe8 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c,v 1.19 1999/07/10 12:17:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaInitAccel.c,v 1.24 2000/06/20 05:08:49 dawes Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -35,7 +35,6 @@ typedef enum {
XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL,
XAAOPT_IMAGE_WRITE_RECT,
XAAOPT_SCANLINE_IMAGE_WRITE_RECT,
- XAAOPT_IMAGE_READ_RECT,
XAAOPT_PIXMAP_CACHE,
XAAOPT_OFFSCREEN_PIXMAPS
} XAAOpts;
@@ -75,8 +74,6 @@ static OptionInfoRec XAAOptions[] = {
OPTV_BOOLEAN, {0}, FALSE },
{XAAOPT_SCANLINE_IMAGE_WRITE_RECT, "XaaNoScanlineImageWriteRect",
OPTV_BOOLEAN, {0}, FALSE },
- {XAAOPT_IMAGE_READ_RECT, "XaaNoImageReadRect",
- OPTV_BOOLEAN, {0}, FALSE },
{XAAOPT_PIXMAP_CACHE, "XaaNoPixmapCache",
OPTV_BOOLEAN, {0}, FALSE },
{XAAOPT_OFFSCREEN_PIXMAPS, "XaaNoOffscreenPixmaps",
@@ -85,6 +82,8 @@ static OptionInfoRec XAAOptions[] = {
OPTV_NONE, {0}, FALSE }
};
+#define nXAAOptions (sizeof(XAAOptions) / sizeof(XAAOptions[0]))
+
Bool
XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
{
@@ -107,16 +106,31 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
Bool HaveImageWriteRect = FALSE;
Bool HaveScanlineImageWriteRect = FALSE;
Bool HaveScreenToScreenColorExpandFill = FALSE;
- Bool HaveImageReadRect = FALSE;
+ OptionInfoRec options[nXAAOptions];
+ int is_shared = 0;
+ int i;
- xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, 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(!infoRec->FullPlanemask)
infoRec->FullPlanemask = (1 << pScrn->depth) - 1;
@@ -127,33 +141,49 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
/************** Low Level *************/
- if(!infoRec->SetClippingRectangle || !infoRec->DisableClipping)
+ if(!infoRec->SetClippingRectangle || !infoRec->DisableClipping) {
infoRec->ClippingFlags = 0;
+ infoRec->SetClippingRectangle = NULL;
+ infoRec->DisableClipping = NULL;
+ }
/**** CopyArea ****/
if(infoRec->SetupForScreenToScreenCopy &&
infoRec->SubsequentScreenToScreenCopy &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SCREEN_TO_SCREEN_COPY))
+ !xf86IsOptionSet(options, XAAOPT_SCREEN_TO_SCREEN_COPY)) {
HaveScreenToScreenCopy = TRUE;
+ } else {
+ infoRec->ScreenToScreenCopyFlags = 0;
+ infoRec->SetupForScreenToScreenCopy = NULL;
+ infoRec->SubsequentScreenToScreenCopy = NULL;
+ }
/**** Solid Filled Rects ****/
if(infoRec->SetupForSolidFill && infoRec->SubsequentSolidFillRect &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SOLID_FILL_RECT)) {
+ !xf86IsOptionSet(options, XAAOPT_SOLID_FILL_RECT)) {
HaveSolidFillRect = TRUE;
if(infoRec->SubsequentSolidFillTrap &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SOLID_FILL_TRAP))
+ !xf86IsOptionSet(options, XAAOPT_SOLID_FILL_TRAP))
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 &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SOLID_TWO_POINT_LINE))
+ !xf86IsOptionSet(options, XAAOPT_SOLID_TWO_POINT_LINE))
HaveSolidTwoPointLine = TRUE;
if(infoRec->SubsequentSolidBresenhamLine &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SOLID_BRESENHAM_LINE)) {
+ !xf86IsOptionSet(options, XAAOPT_SOLID_BRESENHAM_LINE)) {
HaveSolidBresenhamLine = TRUE;
if(infoRec->SolidBresenhamLineErrorTermBits)
@@ -162,7 +192,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
if(infoRec->SubsequentSolidHorVertLine &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SOLID_HORVERT_LINE))
+ !xf86IsOptionSet(options, XAAOPT_SOLID_HORVERT_LINE))
HaveSolidHorVertLine = TRUE;
else if(HaveSolidTwoPointLine) {
infoRec->SubsequentSolidHorVertLine =
@@ -173,24 +203,42 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
XAASolidHorVertLineAsBresenham;
HaveSolidHorVertLine = TRUE;
}
- } else if(HaveSolidFillRect) {
+ }
+
+ /* 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 &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_MONO_8x8_PATTERN_FILL_RECT)) {
+ !xf86IsOptionSet(options, XAAOPT_MONO_8x8_PATTERN_FILL_RECT)) {
HaveMono8x8PatternFillRect = TRUE;
if(infoRec->SubsequentMono8x8PatternFillTrap &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_MONO_8x8_PATTERN_FILL_TRAP))
+ !xf86IsOptionSet(options, XAAOPT_MONO_8x8_PATTERN_FILL_TRAP))
HaveMono8x8PatternFillTrap = TRUE;
if(infoRec->Mono8x8PatternFillFlags &
@@ -230,17 +278,20 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
}
+ } else {
+ infoRec->Mono8x8PatternFillFlags = 0;
+ infoRec->SetupForMono8x8PatternFill = NULL;
+ infoRec->SubsequentMono8x8PatternFillRect = NULL;
}
-
/**** Dashed lines ****/
if(infoRec->SetupForDashedLine && infoRec->DashPatternMaxLength) {
if(infoRec->SubsequentDashedTwoPointLine &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_DASHED_TWO_POINT_LINE))
+ !xf86IsOptionSet(options, XAAOPT_DASHED_TWO_POINT_LINE))
HaveDashedTwoPointLine = TRUE;
if(infoRec->SubsequentDashedBresenhamLine &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_DASHED_BRESENHAM_LINE)) {
+ !xf86IsOptionSet(options, XAAOPT_DASHED_BRESENHAM_LINE)) {
HaveDashedBresenhamLine = TRUE;
if(infoRec->DashedBresenhamLineErrorTermBits)
@@ -249,15 +300,28 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
+ 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 &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_COL_8x8_PATTERN_FILL_RECT)) {
+ !xf86IsOptionSet(options, XAAOPT_COL_8x8_PATTERN_FILL_RECT)) {
HaveColor8x8PatternFillRect = TRUE;
if(infoRec->SubsequentColor8x8PatternFillTrap &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_COL_8x8_PATTERN_FILL_TRAP))
+ !xf86IsOptionSet(options, XAAOPT_COL_8x8_PATTERN_FILL_TRAP))
HaveColor8x8PatternFillTrap = TRUE;
+ else
+ infoRec->SubsequentColor8x8PatternFillTrap = NULL;
infoRec->PixmapCacheFlags |= CACHE_COLOR_8x8;
@@ -275,15 +339,19 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
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 &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL)) {
+ !xf86IsOptionSet(options, XAAOPT_CPU_TO_SCREEN_COL_EXP_FILL)) {
int dwordsNeeded = pScrn->virtualX;
infoRec->ColorExpandRange >>= 2; /* convert to DWORDS */
@@ -295,6 +363,10 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
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 ****/
@@ -304,30 +376,43 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->SubsequentColorExpandScanline &&
infoRec->ScanlineColorExpandBuffers &&
(infoRec->NumScanlineColorExpandBuffers > 0) &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL))
+ !xf86IsOptionSet(options, XAAOPT_SCANLINE_CPU_TO_SCREEN_COL_EXP_FILL)) {
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 &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL)) {
+ !xf86IsOptionSet(options, XAAOPT_SCREEN_TO_SCREEN_COL_EXP_FILL)) {
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 &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_IMAGE_WRITE_RECT)) {
+ !xf86IsOptionSet(options, XAAOPT_IMAGE_WRITE_RECT)) {
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 ****/
@@ -337,20 +422,15 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->SubsequentImageWriteScanline &&
infoRec->ScanlineImageWriteBuffers &&
(infoRec->NumScanlineImageWriteBuffers > 0) &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_SCANLINE_IMAGE_WRITE_RECT))
+ !xf86IsOptionSet(options, XAAOPT_SCANLINE_IMAGE_WRITE_RECT)) {
HaveScanlineImageWriteRect = TRUE;
+ } else {
+ infoRec->ScanlineImageWriteFlags = 0;
+ infoRec->SetupForScanlineImageWrite = NULL;
+ infoRec->SubsequentScanlineImageWriteRect = NULL;
+ infoRec->SubsequentImageWriteScanline = NULL;
+ }
- /**** Image Reads ****/
-
- if(infoRec->SetupForImageRead && infoRec->ImageReadBase &&
- infoRec->SubsequentImageReadRect &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_IMAGE_READ_RECT)) {
-
- infoRec->ImageReadRange >>= 2; /* convert to DWORDS */
- if(infoRec->ImageReadFlags & CPU_TRANSFER_BASE_FIXED)
- infoRec->ImageReadRange = 0;
- HaveImageReadRect = TRUE;
- }
if (serverGeneration == 1) {
if(HaveScreenToScreenCopy)
@@ -389,14 +469,12 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
else if(HaveScanlineImageWriteRect)
xf86ErrorF("\tScanline Image Writes\n");
- if(HaveImageReadRect)
- xf86ErrorF("\tImage Reads\n");
}
#define XAAMSG(s) do { if (serverGeneration == 1) xf86ErrorF(s); } while (0)
if((infoRec->Flags & OFFSCREEN_PIXMAPS) && HaveScreenToScreenCopy &&
- !xf86IsOptionSet(XAAOptions, XAAOPT_OFFSCREEN_PIXMAPS)) {
+ !xf86IsOptionSet(options, XAAOPT_OFFSCREEN_PIXMAPS)) {
XAAMSG("\tOffscreen Pixmaps\n");
} else {
infoRec->Flags &= ~OFFSCREEN_PIXMAPS;
@@ -423,7 +501,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillSolidRectsFlags = infoRec->SolidFillFlags;
}
-
/**** FillSolidSpans ****/
if(infoRec->FillSolidSpans) {
@@ -433,7 +510,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillSolidSpansFlags = infoRec->SolidFillFlags;
}
-
/**** FillMono8x8PatternRects ****/
if(infoRec->FillMono8x8PatternRects) {
@@ -490,7 +566,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->Color8x8PatternFillFlags;
}
-
/**** FillCacheBltRects ****/
if(infoRec->FillCacheBltRects) {
@@ -509,7 +584,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillCacheBltSpansFlags = infoRec->ScreenToScreenCopyFlags;
}
-
/**** FillCacheExpandRects ****/
if(infoRec->FillCacheExpandRects) {
@@ -530,13 +604,11 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->ScreenToScreenColorExpandFillFlags;
}
-
/**** FillColorExpandRects ****/
if(infoRec->FillColorExpandRects) {
XAAMSG("\tDriver provided FillColorExpandRects replacement\n");
} else if(HaveColorExpansion) {
-#if 0
if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
if(infoRec->CPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST) {
@@ -556,9 +628,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillColorExpandRects =
XAAFillColorExpandRects3LSBFirst;
}
- } else
-#endif
- {
+ } else {
if(infoRec->CPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST) {
if(infoRec->CPUToScreenColorExpandFillFlags &
@@ -579,21 +649,18 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
infoRec->FillColorExpandRectsFlags =
- infoRec->CPUToScreenColorExpandFillFlags & ~TRANSPARENCY_ONLY;
+ infoRec->CPUToScreenColorExpandFillFlags;
} else if(HaveScanlineColorExpansion) {
-#if 0
if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
TRIPLE_BITS_24BPP) {
if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST)
infoRec->FillColorExpandRects =
- XAAFillColorExpandRects3MSBFirst;
+ XAAFillScanlineColorExpandRects3MSBFirst;
else
infoRec->FillColorExpandRects =
- XAAFillColorExpandRects3LSBFirst;
- } else
-#endif
- {
+ XAAFillScanlineColorExpandRects3LSBFirst;
+ } else {
if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST)
infoRec->FillColorExpandRects =
@@ -602,8 +669,8 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillColorExpandRects =
XAAFillScanlineColorExpandRectsLSBFirst;
}
- infoRec->FillColorExpandRectsFlags = ~TRANSPARENCY_ONLY &
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
+ infoRec->FillColorExpandRectsFlags =
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags;
}
/**** FillColorExpandSpans ****/
@@ -611,7 +678,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
if(infoRec->FillColorExpandSpans) {
XAAMSG("\tDriver provided FillColorExpandSpans replacement\n");
} else if(HaveColorExpansion) {
-#if 0
if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
if(infoRec->CPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST) {
@@ -631,9 +697,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillColorExpandSpans =
XAAFillColorExpandSpans3LSBFirst;
}
- } else
-#endif
- {
+ } else {
if(infoRec->CPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST) {
if(infoRec->CPUToScreenColorExpandFillFlags &
@@ -654,21 +718,18 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
infoRec->FillColorExpandSpansFlags =
- infoRec->CPUToScreenColorExpandFillFlags & ~TRANSPARENCY_ONLY;
+ infoRec->CPUToScreenColorExpandFillFlags;
} else if(HaveScanlineColorExpansion) {
-#if 0
if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
TRIPLE_BITS_24BPP) {
if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST)
infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpans3MSBFirst;
+ XAAFillScanlineColorExpandSpans3MSBFirst;
else
infoRec->FillColorExpandSpans =
- XAAFillColorExpandSpans3LSBFirst;
- } else
-#endif
- {
+ XAAFillScanlineColorExpandSpans3LSBFirst;
+ } else {
if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST)
infoRec->FillColorExpandSpans =
@@ -677,11 +738,10 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->FillColorExpandSpans =
XAAFillScanlineColorExpandSpansLSBFirst;
}
- infoRec->FillColorExpandSpansFlags = ~TRANSPARENCY_ONLY &
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
+ infoRec->FillColorExpandSpansFlags =
+ infoRec->ScanlineCPUToScreenColorExpandFillFlags;
}
-
/**** FillImageWriteRects ****/
if(infoRec->FillImageWriteRects) {
@@ -733,10 +793,10 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->WriteBitmap = XAAWriteBitmapColorExpandLSBFirst;
}
}
- infoRec->WriteBitmapFlags =
- infoRec->CPUToScreenColorExpandFillFlags & ~TRANSPARENCY_ONLY;
+ infoRec->WriteBitmapFlags = infoRec->CPUToScreenColorExpandFillFlags;
} else if(HaveScanlineColorExpansion) {
- if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
+ if (infoRec->ScanlineCPUToScreenColorExpandFillFlags &
+ TRIPLE_BITS_24BPP) {
if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
BIT_ORDER_IN_BYTE_MSBFIRST)
infoRec->WriteBitmap =
@@ -753,85 +813,93 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->WriteBitmap =
XAAWriteBitmapScanlineColorExpandLSBFirst;
}
- infoRec->WriteBitmapFlags = ~TRANSPARENCY_ONLY &
+ infoRec->WriteBitmapFlags =
infoRec->ScanlineCPUToScreenColorExpandFillFlags;
}
-
-
/**** TE Glyphs ****/
- if(infoRec->TEGlyphRenderer) {
+ if (infoRec->TEGlyphRenderer) {
XAAMSG("\tDriver provided TEGlyphRenderer 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->TEGlyphRenderer =
+ } 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->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
+ 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->CPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST) {
- if(infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
+ 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->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_BASE_FIXED)
- infoRec->TEGlyphRenderer =
+ if (infoRec->TEGlyphRendererFlags & CPU_TRANSFER_BASE_FIXED)
+ infoRec->TEGlyphRenderer =
XAATEGlyphRendererLSBFirstFixedBase;
else
infoRec->TEGlyphRenderer = XAATEGlyphRendererLSBFirst;
}
}
- infoRec->TEGlyphRendererFlags =
- infoRec->CPUToScreenColorExpandFillFlags;
- if(HaveSolidFillRect)
- infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
+ if (!HaveSolidFillRect &&
+ (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
+ infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
+ XAAMSG("WARNING: TEGlyphRenderer cannot support TRANPARENCY_ONLY"
+ " without solid fills\n");
+ }
- } else if(HaveScanlineColorExpansion) {
- if (infoRec->CPUToScreenColorExpandFillFlags & TRIPLE_BITS_24BPP) {
- if(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->TEGlyphRenderer =
- XAATEGlyphRendererScanline3MSBFirst;
+ } 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;
+ 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->ScanlineCPUToScreenColorExpandFillFlags &
- BIT_ORDER_IN_BYTE_MSBFIRST)
- infoRec->TEGlyphRenderer =
- XAATEGlyphRendererScanlineMSBFirst;
+ if (infoRec->TEGlyphRendererFlags & BIT_ORDER_IN_BYTE_MSBFIRST)
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineMSBFirst;
else
- infoRec->TEGlyphRenderer =
- XAATEGlyphRendererScanlineLSBFirst;
+ infoRec->TEGlyphRenderer = XAATEGlyphRendererScanlineLSBFirst;
}
- infoRec->TEGlyphRendererFlags =
- infoRec->ScanlineCPUToScreenColorExpandFillFlags;
-
- if(HaveSolidFillRect)
- infoRec->TEGlyphRendererFlags &= ~TRANSPARENCY_ONLY;
+ 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) {
@@ -841,7 +909,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->NonTEGlyphRenderer = XAANonTEGlyphRenderer;
infoRec->NonTEGlyphRendererFlags = infoRec->WriteBitmapFlags;
}
-
/**** WritePixmap ****/
@@ -856,16 +923,13 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->WritePixmapFlags = infoRec->ScanlineImageWriteFlags;
}
-
/**** ReadPixmap ****/
if(infoRec->ReadPixmap) {
XAAMSG("\tDriver provided ReadPixmap replacement\n");
- } else if(HaveImageReadRect) {
- infoRec->ReadPixmap = XAAReadPixmap;
- infoRec->ReadPixmapFlags = infoRec->ImageReadFlags;
}
+
/************** GC Level *************/
/**** CopyArea ****/
@@ -917,7 +981,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
-
if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
infoRec->FillCacheBltRects || infoRec->FillColorExpandRects ||
infoRec->FillCacheExpandRects) {
@@ -927,6 +990,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->PolyFillRectStippledFlags = 0;
}
}
+
if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
infoRec->FillCacheExpandSpans) {
@@ -946,6 +1010,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->PolyFillRectOpaqueStippledFlags = 0;
}
}
+
if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
infoRec->FillCacheBltSpans || infoRec->FillColorExpandSpans ||
infoRec->FillCacheExpandSpans) {
@@ -956,7 +1021,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
-
if(infoRec->FillMono8x8PatternRects || infoRec->FillColor8x8PatternRects ||
infoRec->FillCacheBltRects || infoRec->FillImageWriteRects) {
if(!infoRec->PolyFillRectTiled) {
@@ -965,6 +1029,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->PolyFillRectTiledFlags = 0;
}
}
+
if(infoRec->FillMono8x8PatternSpans || infoRec->FillColor8x8PatternSpans ||
infoRec->FillCacheBltSpans) {
if(!infoRec->FillSpansTiled) {
@@ -974,7 +1039,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
-
if(infoRec->TEGlyphRenderer &&
!(infoRec->TEGlyphRendererFlags & NO_TRANSPARENCY)) {
@@ -1029,7 +1093,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
}
-
if(infoRec->NonTEGlyphRenderer && HaveSolidFillRect) {
if(!infoRec->ImageText8NonTE) {
infoRec->ImageText8NonTE = XAAImageText8NonTEColorExpansion;
@@ -1127,6 +1190,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
infoRec->ComputeDash = XAAComputeDash;
}
+
/************ Validation Functions **************/
if(!infoRec->ValidateCopyArea && infoRec->CopyArea) {
@@ -1270,7 +1334,7 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
}
-
+ /**** Fill choosers ****/
if(!infoRec->StippledFillChooser)
infoRec->StippledFillChooser = XAAStippledFillChooser;
@@ -1284,7 +1348,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
/**** Setup the pixmap cache ****/
-
if(infoRec->WriteBitmapToCache) {}
else if(infoRec->WriteBitmap &&
!(infoRec->WriteBitmapFlags & TRANSPARENCY_ONLY))
@@ -1294,7 +1357,6 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
else
infoRec->PixmapCacheFlags |= DO_NOT_BLIT_STIPPLES;
-
if(infoRec->WritePixmapToCache) {}
else if(infoRec->WritePixmap && !(infoRec->WritePixmapFlags & NO_GXCOPY))
infoRec->WritePixmapToCache = XAAWritePixmapToCache;
@@ -1303,10 +1365,9 @@ XAAInitAccel(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
else
infoRec->Flags &= ~PIXMAP_CACHE;
- if (xf86IsOptionSet(XAAOptions, XAAOPT_PIXMAP_CACHE))
+ if (xf86IsOptionSet(options, XAAOPT_PIXMAP_CACHE))
infoRec->Flags &= ~PIXMAP_CACHE;
-
if(infoRec->WriteMono8x8PatternToCache) {}
else if(infoRec->PixmapCacheFlags & CACHE_MONO_8x8) {
if(infoRec->WritePixmapToCache)
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c
index 0f159f3eb..914631b58 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c,v 1.11 1999/09/25 14:38:14 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaNonTEText.c,v 1.12 2000/04/07 19:11:10 mvojkovi Exp $ */
/********************************************************************
@@ -266,7 +266,7 @@ PolyGlyphBltAsSingleBitmap (
){
XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCRNINFOPTR(pScrn);
CARD32 *block, *pntr, *bits;
- int pitch, topLine, botLine, top, bot;
+ int pitch, topLine, botLine, top, bot, height;
int Left, Right, Top, Bottom;
int LeftEdge, RightEdge;
int bitPitch, shift, size, i, skippix;
@@ -332,10 +332,12 @@ PolyGlyphBltAsSingleBitmap (
if(RightEdge > LeftEdge) {
skippix = LeftEdge - Left;
topLine = max(Top, pbox->y1);
- botLine = min(Bottom, pbox->y2);
+ botLine = min(Bottom, pbox->y2);
+ height = botLine - topLine;
- (*infoRec->WriteBitmap)(pScrn, LeftEdge, topLine,
- RightEdge - LeftEdge, 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);
@@ -403,9 +405,10 @@ ImageGlyphBltNonTEColorExpansion(
nbox = REGION_NUM_RECTS(cclip);
pbox = REGION_RECTS(cclip);
- if((nglyph > 1) && ((FONTMAXBOUNDS(font, rightSideBearing) -
- FONTMINBOUNDS(font, leftSideBearing)) <= 32)) {
-
+ if(infoRec->WriteBitmap && (nglyph > 1) &&
+ ((FONTMAXBOUNDS(font, rightSideBearing) -
+ FONTMINBOUNDS(font, leftSideBearing)) <= 32))
+ {
PolyGlyphBltAsSingleBitmap(pScrn, nglyph, font,
xInit, yInit, nbox, pbox,
fg, GXcopy, planemask);
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c
index c321a4ed4..4e2f9127d 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.10 2000/02/11 06:35:17 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaOverlay.c,v 1.11 2000/03/28 01:21:04 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -187,6 +187,7 @@ XAAPaintWindow8_32(
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, GXcopy, pm,
nBox, pBox, xorg, yorg, pCache);
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c
index 82c541177..de26e7a52 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c,v 1.28 2000/02/27 21:50:20 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPCache.c,v 1.29 2000/06/13 02:51:24 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -1176,8 +1176,8 @@ XAACheckStippleReducibility(PixmapPtr pPixmap)
}
if(infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
- pPriv->pattern0 = XAAReverseBitOrder(pPriv->pattern0);
- pPriv->pattern1 = XAAReverseBitOrder(pPriv->pattern1);
+ pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0);
+ pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1);
}
@@ -1381,8 +1381,8 @@ XAACheckTileReducibility(PixmapPtr pPixmap, Bool checkMono)
pPriv->flags |= REDUCIBLE_TO_2_COLOR;
if(infoRec->Mono8x8PatternFillFlags & BIT_ORDER_IN_BYTE_MSBFIRST) {
- pPriv->pattern0 = XAAReverseBitOrder(pPriv->pattern0);
- pPriv->pattern1 = XAAReverseBitOrder(pPriv->pattern1);
+ pPriv->pattern0 = SWAP_BITS_IN_BYTES(pPriv->pattern0);
+ pPriv->pattern1 = SWAP_BITS_IN_BYTES(pPriv->pattern1);
}
}
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c
index 20d2e9e99..6e2939552 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c,v 1.8 1999/08/28 09:01:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaPaintWin.c,v 1.9 2000/03/28 01:21:05 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -112,6 +112,7 @@ XAAPaintWindow(
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, GXcopy, ~0,
nBox, pBox, xorg, yorg, pCache);
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c
index 1023c0cd6..1e2a2957b 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c,v 1.13 1999/10/31 23:52:57 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaSpans.c,v 1.14 2000/03/28 01:21:05 mvojkovi Exp $ */
#include "misc.h"
#include "xf86.h"
@@ -365,6 +365,7 @@ XAARenderPixmapCopySpans(
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,
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaStateChange.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaStateChange.c
new file mode 100644
index 000000000..5885061e3
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaStateChange.c
@@ -0,0 +1,1628 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaStateChange.c,v 3.1 2000/06/20 05:08:49 dawes Exp $ */
+
+#include "misc.h"
+#include "xf86.h"
+#include "xf86_ansic.h"
+#include "xf86_OSproc.h"
+
+#include "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;
+ PaintWindowBackgroundProcPtr PaintWindowBackground;
+ PaintWindowBorderProcPtr PaintWindowBorder;
+ CopyWindowProcPtr CopyWindow;
+ BackingStoreSaveAreasProcPtr SaveAreas;
+ BackingStoreRestoreAreasProcPtr RestoreAreas;
+} XAAStateWrapRec, *XAAStateWrapPtr;
+
+static int XAAStateIndex = -1;
+static unsigned long XAAStateGeneration = 0;
+
+/* Wrap functions start here */
+#define GET_STATEPRIV_GC(pGC) XAAStateWrapPtr pStatePriv =\
+(XAAStateWrapPtr)(pGC->pScreen->devPrivates[XAAStateIndex].ptr)
+
+#define GET_STATEPRIV_SCREEN(pScreen) XAAStateWrapPtr pStatePriv =\
+(XAAStateWrapPtr)(pScreen->devPrivates[XAAStateIndex].ptr)
+
+#define GET_STATEPRIV_PSCRN(pScrn) XAAStateWrapPtr pStatePriv =\
+(XAAStateWrapPtr)(pScrn->pScreen->devPrivates[XAAStateIndex].ptr)
+
+#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 XAAStateWrapPaintWindowBackground(WindowPtr pWindow, RegionPtr pRegion,
+ int what)
+{
+ GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PaintWindowBackground)(pWindow, pRegion,
+ what);
+}
+
+static void XAAStateWrapPaintWindowBorder(WindowPtr pWindow, RegionPtr pRegion,
+ int what)
+{
+ GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->PaintWindowBorder)(pWindow, pRegion,
+ what);
+}
+
+static void XAAStateWrapCopyWindow(WindowPtr pWindow, DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc)
+{
+ GET_STATEPRIV_SCREEN(pWindow->drawable.pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->CopyWindow)(pWindow, ptOldOrg,
+ prgnSrc);
+}
+
+static void XAAStateWrapSaveAreas(PixmapPtr pBackingPixmap, RegionPtr pObscured, int x,
+ int y, WindowPtr pWin)
+{
+ GET_STATEPRIV_SCREEN(pBackingPixmap->drawable.pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->SaveAreas)(pBackingPixmap, pObscured, x,
+ y, pWin);
+}
+
+static void XAAStateWrapRestoreAreas(PixmapPtr pBackingPixmap, RegionPtr pExposed,
+ int x, int y, WindowPtr pWin)
+{
+ GET_STATEPRIV_SCREEN(pBackingPixmap->drawable.pScreen);
+ STATE_CHECK_SP(pStatePriv);
+
+ (*pStatePriv->RestoreAreas)(pBackingPixmap, pExposed,
+ x, y, pWin);
+}
+
+/* Setup Function */
+Bool
+XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ XAAStateWrapPtr pStatePriv;
+ int i = 0;
+
+ if (XAAStateGeneration != serverGeneration) {
+ if((XAAStateIndex = AllocateScreenPrivateIndex()) < 0) return FALSE;
+ XAAStateGeneration = serverGeneration;
+ }
+ if(!(pStatePriv = xalloc(sizeof(XAAStateWrapRec)))) return FALSE;
+ pScreen->devPrivates[XAAStateIndex].ptr = (pointer)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(PaintWindowBackground);
+ XAA_STATE_WRAP(PaintWindowBorder);
+ XAA_STATE_WRAP(CopyWindow);
+ XAA_STATE_WRAP(SaveAreas);
+ XAA_STATE_WRAP(RestoreAreas);
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c
index 5807cb6e6..a3e1ac0d6 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c,v 1.7 2000/02/29 17:38:32 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaStipple.c,v 1.9 2000/06/13 02:51:25 mvojkovi Exp $ */
#include "xaa.h"
#include "xaalocal.h"
@@ -13,7 +13,11 @@ 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)
+#else
#define stipple_scanline_func EXPNAME(XAAStippleScanlineFunc)
+#endif
StippleScanlineProcPtr stipple_scanline_func[6] = {
StipplePowerOfTwo,
@@ -34,7 +38,43 @@ StippleScanlineProcPtr stipple_scanline_func[6] = {
#endif
-#if defined(FIXEDBASE) && defined(MSBFIRST)
+/* 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) */
@@ -59,7 +99,11 @@ unsigned int XAAShiftMasks[32] = {
#endif
void
+#ifdef TRIPLE_BITS
+EXPNAME(XAAFillColorExpandRects3)(
+#else
EXPNAME(XAAFillColorExpandRects)(
+#endif
ScrnInfoPtr pScrn,
int fg, int bg, int rop,
unsigned int planemask,
@@ -88,8 +132,15 @@ EXPNAME(XAAFillColorExpandRects)(
}
StippleFunc = stipple_scanline_func[funcNo];
+#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 */
@@ -107,7 +158,11 @@ EXPNAME(XAAFillColorExpandRects)(
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) {
@@ -180,7 +235,11 @@ SECOND_PASS:
void
+#ifdef TRIPLE_BITS
+EXPNAME(XAAFillColorExpandSpans3)(
+#else
EXPNAME(XAAFillColorExpandSpans)(
+#endif
ScrnInfoPtr pScrn,
int fg, int bg, int rop,
unsigned int planemask,
@@ -208,8 +267,15 @@ EXPNAME(XAAFillColorExpandSpans)(
}
StippleFunc = stipple_scanline_func[funcNo];
+#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 */
@@ -228,7 +294,11 @@ EXPNAME(XAAFillColorExpandSpans)(
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;
@@ -276,7 +346,11 @@ SECOND_PASS:
#ifndef FIXEDBASE
void
+#ifdef TRIPLE_BITS
+EXPNAME(XAAFillScanlineColorExpandRects3)(
+#else
EXPNAME(XAAFillScanlineColorExpandRects)(
+#endif
ScrnInfoPtr pScrn,
int fg, int bg, int rop,
unsigned int planemask,
@@ -304,8 +378,15 @@ EXPNAME(XAAFillScanlineColorExpandRects)(
}
StippleFunc = stipple_scanline_func[funcNo];
+#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 */
@@ -323,7 +404,12 @@ EXPNAME(XAAFillScanlineColorExpandRects)(
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,
@@ -373,7 +459,11 @@ SECOND_PASS:
}
void
+#ifdef TRIPLE_BITS
+EXPNAME(XAAFillScanlineColorExpandSpans3)(
+#else
EXPNAME(XAAFillScanlineColorExpandSpans)(
+#endif
ScrnInfoPtr pScrn,
int fg, int bg, int rop,
unsigned int planemask,
@@ -401,8 +491,15 @@ EXPNAME(XAAFillScanlineColorExpandSpans)(
}
StippleFunc = stipple_scanline_func[funcNo];
+#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 */
@@ -422,7 +519,11 @@ EXPNAME(XAAFillScanlineColorExpandSpans)(
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;
@@ -479,9 +580,26 @@ StipplePowerOfTwo(
pat = SHIFT_R(pat,shift) | SHIFT_L(pat,32 - shift);
#ifdef MSBFIRST
- pat = XAAReverseBitOrder(pat);
+ 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;
@@ -500,6 +618,7 @@ StipplePowerOfTwo(
if(dwords == 2) RETURN(2);
DEST(2) = pat;
RETURN(3);
+#endif /* TRIPLE_BITS */
}
static CARD32 *
@@ -520,11 +639,28 @@ StipplePowerOfTwo_Inverted(
pat = SHIFT_R(pat,shift) | SHIFT_L(pat,32 - shift);
#ifdef MSBFIRST
- pat = XAAReverseBitOrder(pat);
+ 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;
@@ -543,6 +679,7 @@ StipplePowerOfTwo_Inverted(
if(dwords == 2) RETURN(2);
DEST(2) = pat;
RETURN(3);
+#endif /* TRIPLE_BITS */
}
@@ -551,7 +688,6 @@ StippleUpTo32(
CARD32* base, CARD32* src,
int shift, int width, int dwords
){
- int offset = shift;
CARD32 pat = *src & XAAShiftMasks[width];
while(width <= 15) {
@@ -561,9 +697,24 @@ StippleUpTo32(
pat |= SHIFT_L(pat,width);
while(dwords--) {
- WRITE_BITS(SHIFT_R(pat,offset) | SHIFT_L(pat,width-offset));
- offset += 32;
- while(offset >= width) offset -= width;
+#ifdef TRIPLE_BITS
+ CARD32 bits = SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift);
+
+ if(dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ } else if(dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
+ } else {
+ WRITE_BITS1(bits);
+ }
+#else
+ WRITE_BITS(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift));
+#endif
+
+ shift += 32;
+ shift %= width;
}
return base;
}
@@ -583,9 +734,24 @@ StippleUpTo32_Inverted(
pat |= SHIFT_L(pat,width);
while(dwords--) {
+#ifdef TRIPLE_BITS
+ CARD32 bits = ~(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift));
+
+ if(dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ } else if(dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
+ } else {
+ WRITE_BITS1(bits);
+ }
+#else
WRITE_BITS(~(SHIFT_R(pat,shift) | SHIFT_L(pat,width-shift)));
+#endif
+
shift += 32;
- while(shift >= width) shift -= width;
+ shift %= width;
}
return base;
}
@@ -597,25 +763,38 @@ StippleOver32(
int offset, int width, int dwords
){
CARD32* srcp;
+ CARD32 bits;
int bitsleft, shift;
while(dwords--) {
bitsleft = width - offset;
- srcp = (CARD32*)(src + (offset >> 5));
+ srcp = src + (offset >> 5);
shift = offset & 31;
- if(bitsleft >= 32) {
- if(shift)
- WRITE_BITS(SHIFT_R(*srcp,shift) |
- SHIFT_L(srcp[1],32-shift));
- else
- WRITE_BITS(*srcp);
+ if(bitsleft < 32)
+ bits = SHIFT_L(*src,bitsleft) |
+ (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]);
+ else if(shift)
+ bits = SHIFT_R(*srcp,shift) | SHIFT_L(srcp[1],32-shift);
+ else
+ bits = *srcp;
+
+#ifdef TRIPLE_BITS
+ if(dwords >= 2) {
+ WRITE_BITS3(bits);
+ dwords -= 2;
+ } else if(dwords > 0) {
+ WRITE_BITS2(bits);
+ dwords--;
} else {
- WRITE_BITS(SHIFT_L(*src,bitsleft) |
- (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]));
+ WRITE_BITS1(bits);
}
+#else
+ WRITE_BITS(bits);
+#endif
+
offset += 32;
- while(offset >= width) offset -= width;
+ offset %= width;
}
return base;
}
@@ -627,25 +806,40 @@ StippleOver32_Inverted(
int offset, int width, int dwords
){
CARD32* srcp;
+ CARD32 bits;
int bitsleft, shift;
while(dwords--) {
bitsleft = width - offset;
- srcp = (CARD32*)(src + (offset >> 5));
+ srcp = src + (offset >> 5);
shift = offset & 31;
- if(bitsleft >= 32) {
- if(shift)
- WRITE_BITS(~(SHIFT_R(*srcp,shift) |
- SHIFT_L(srcp[1],32-shift)));
- else
- WRITE_BITS(~(*srcp));
+ if(bitsleft < 32)
+ bits = SHIFT_L(*src,bitsleft) |
+ (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft]);
+ else if(shift)
+ bits = SHIFT_R(*srcp,shift) | SHIFT_L(srcp[1],32-shift);
+ 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_BITS(~(SHIFT_L(*src,bitsleft) |
- (SHIFT_R(*srcp,shift) & XAAShiftMasks[bitsleft])));
+ WRITE_BITS1(bits);
}
+#else
+ WRITE_BITS(bits);
+#endif
+
offset += 32;
- while(offset >= width) offset -= width;
+ offset %= width;
}
return base;
}
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c b/xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c
index 60bcc6892..31c416632 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c,v 1.7 1999/11/06 23:14:46 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaaTEGlyph.c,v 1.8 2000/05/03 00:44:24 tsi Exp $ */
#include "xaa.h"
@@ -151,8 +151,7 @@ EXPNAME(XAATEGlyphRenderer)(
GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1];
int dwords = 0;
- if((bg != -1) &&
- (infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
(*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
(*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
bg = -1;
@@ -162,9 +161,8 @@ EXPNAME(XAATEGlyphRenderer)(
pScrn, fg, bg, rop, planemask);
if(skipleft &&
- (!(infoRec->CPUToScreenColorExpandFillFlags & LEFT_EDGE_CLIPPING) ||
- (!(infoRec->CPUToScreenColorExpandFillFlags &
- LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) ||
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
(skipleft > x)))) {
/* draw the first character only */
@@ -183,8 +181,7 @@ EXPNAME(XAATEGlyphRenderer)(
}
w -= width;
- if((infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_PAD_QWORD) &&
+ if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
((((width + 31) >> 5) * h) & 1)) {
base = (CARD32*)infoRec->ColorExpandBase;
base[0] = 0x00000000;
@@ -215,7 +212,7 @@ EXPNAME(XAATEGlyphRenderer)(
(*GlyphFunc)(base, glyphs, startline++, w, glyphWidth);
}
- if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) &&
+ if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
(dwords & 1)) {
base = (CARD32*)infoRec->ColorExpandBase;
base[0] = 0x00000000;
@@ -223,7 +220,7 @@ EXPNAME(XAATEGlyphRenderer)(
THE_END:
- if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
+ if(infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND)
(*infoRec->Sync)(pScrn);
else SET_SYNC_FLAG(infoRec);
}
@@ -250,8 +247,8 @@ EXPNAME(XAATEGlyphRenderer3)(
int dwords = 0;
if((bg != -1) &&
- ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
- ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
+ ((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);
@@ -286,8 +283,7 @@ EXPNAME(XAATEGlyphRenderer3)(
}
w -= width;
- if((infoRec->CPUToScreenColorExpandFillFlags &
- CPU_TRANSFER_PAD_QWORD) &&
+ if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
((((3 * width + 31) >> 5) * h) & 1)) {
base = (CARD32*)infoRec->ColorExpandBase;
base[0] = 0x00000000;
@@ -321,7 +317,7 @@ EXPNAME(XAATEGlyphRenderer3)(
DEALLOCATE_LOCAL(mem);
- if((infoRec->CPUToScreenColorExpandFillFlags & CPU_TRANSFER_PAD_QWORD) &&
+ if((infoRec->TEGlyphRendererFlags & CPU_TRANSFER_PAD_QWORD) &&
(dwords & 1)) {
base = (CARD32*)infoRec->ColorExpandBase;
base[0] = 0x00000000;
@@ -329,7 +325,7 @@ EXPNAME(XAATEGlyphRenderer3)(
THE_END:
- if(infoRec->CPUToScreenColorExpandFillFlags & SYNC_AFTER_COLOR_EXPAND)
+ if(infoRec->TEGlyphRendererFlags & SYNC_AFTER_COLOR_EXPAND)
(*infoRec->Sync)(pScrn);
else SET_SYNC_FLAG(infoRec);
}
@@ -351,8 +347,7 @@ EXPNAME(XAATEGlyphRendererScanline)(
CARD32* base;
GlyphScanlineFuncPtr GlyphFunc = glyph_scanline_func[glyphWidth - 1];
- if((bg != -1) &&
- (infoRec->ScanlineCPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY)) {
+ if((bg != -1) && (infoRec->TEGlyphRendererFlags & TRANSPARENCY_ONLY)) {
(*infoRec->SetupForSolidFill)(pScrn, bg, rop, planemask);
(*infoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
bg = -1;
@@ -362,10 +357,9 @@ EXPNAME(XAATEGlyphRendererScanline)(
pScrn, fg, bg, rop, planemask);
if(skipleft &&
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- LEFT_EDGE_CLIPPING) ||
- (!(infoRec->ScanlineCPUToScreenColorExpandFillFlags &
- LEFT_EDGE_CLIPPING_NEGATIVE_X) && (skipleft > x)))) {
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING) ||
+ (!(infoRec->TEGlyphRendererFlags & LEFT_EDGE_CLIPPING_NEGATIVE_X) &&
+ (skipleft > x)))) {
/* draw the first character only */
int count = h, line = startline;
@@ -428,8 +422,8 @@ EXPNAME(XAATEGlyphRendererScanline3)(
GlyphScanlineFuncPtr GlyphFunc = XAAGlyphScanlineFuncLSBFirst[glyphWidth - 1];
if((bg != -1) &&
- ((infoRec->CPUToScreenColorExpandFillFlags & TRANSPARENCY_ONLY) ||
- ((infoRec->CPUToScreenColorExpandFillFlags & RGB_EQUAL) &&
+ ((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);
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h b/xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h
index b52b9921b..276f01672 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h,v 1.4 2000/01/22 19:51:46 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaacexp.h,v 1.5 2000/06/13 02:51:25 mvojkovi Exp $ */
#include "Xarch.h"
@@ -25,15 +25,15 @@
# endif
#else
# ifdef FIXEDBASE
-# define WRITE_IN_BITORDER(dest, offset, data) *(dest) = XAAReverseBitOrder(data);
+# define WRITE_IN_BITORDER(dest, offset, data) *(dest) = SWAP_BITS_IN_BYTES(data);
# else
-# define WRITE_IN_BITORDER(dest, offset, data) *(dest + offset) = XAAReverseBitOrder(data)
+# 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 = XAAReverseBitOrder(b)
+# 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; }
@@ -69,7 +69,7 @@
# endif
#else
# ifdef MSBFIRST
-# define WRITE_BITS(b) *(base++) = XAAReverseBitOrder(b)
+# 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; }
diff --git a/xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h b/xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h
index 5043be85f..14f65eb71 100644
--- a/xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h
+++ b/xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h,v 1.22 2000/02/11 06:35:17 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xaa/xaalocal.h,v 1.26 2000/06/20 05:08:49 dawes Exp $ */
#ifndef _XAALOCAL_H
#define _XAALOCAL_H
@@ -149,6 +149,15 @@ XAADoImageWrite(
DDXPointPtr pptSrc
);
+void
+XAADoImageRead(
+ DrawablePtr pSrc,
+ DrawablePtr pDst,
+ GC *pGC,
+ RegionPtr prgnDst,
+ DDXPointPtr pptSrc
+);
+
void
XAACopyWindow(
WindowPtr pWin,
@@ -722,6 +731,17 @@ XAAFillColorExpandRectsLSBFirst(
);
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,
@@ -732,6 +752,16 @@ XAAFillColorExpandRectsLSBFirstFixedBase(
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(
@@ -744,6 +774,16 @@ XAAFillColorExpandRectsMSBFirst(
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(
@@ -756,7 +796,16 @@ XAAFillColorExpandRectsMSBFirstFixedBase(
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(
@@ -769,6 +818,16 @@ XAAFillScanlineColorExpandRectsLSBFirst(
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(
@@ -781,6 +840,16 @@ XAAFillScanlineColorExpandRectsMSBFirst(
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(
@@ -796,6 +865,19 @@ XAAFillColorExpandSpansLSBFirst(
);
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,
@@ -808,6 +890,18 @@ XAAFillColorExpandSpansLSBFirstFixedBase(
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(
@@ -822,6 +916,18 @@ XAAFillColorExpandSpansMSBFirst(
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(
@@ -836,6 +942,18 @@ XAAFillColorExpandSpansMSBFirstFixedBase(
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(
@@ -851,6 +969,19 @@ XAAFillScanlineColorExpandSpansLSBFirst(
);
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,
@@ -877,6 +1008,19 @@ XAAFillScanlineColorExpandSpansMSBFirst(
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
@@ -1259,15 +1403,6 @@ XAAFillPolygonHelper(
XAACacheInfoPtr pCache
);
-void
-XAAReadPixmap (
- ScrnInfoPtr pScrn,
- int x, int y, int w, int h,
- unsigned char *dst,
- int dstwidth,
- int bpp, int depth
-);
-
void
XAAPolySegment(
DrawablePtr pDrawable,
@@ -1383,6 +1518,7 @@ void XAAMoveInOffscreenPixmaps(ScreenPtr pScreen);
void XAAMoveOutOffscreenPixmaps(ScreenPtr pScreen);
void XAARemoveAreaCallback(FBAreaPtr area);
void XAAMoveOutOffscreenPixmap(PixmapPtr pPix);
+Bool XAAInitStateWrap(ScreenPtr pScreen, XAAInfoRecPtr infoRec);
extern GCOps XAAFallbackOps;
extern GCFuncs XAAGCFuncs;
@@ -1475,6 +1611,11 @@ CARD32 XAAReverseBitOrder(CARD32 data);
}}
+#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
diff --git a/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h b/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h
index 5b634ab89..5386ba5ea 100644
--- a/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h
+++ b/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h,v 1.4 2000/01/26 22:05:58 tsi Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfb24_32.h,v 1.5 2000/04/01 00:17:19 mvojkovi Exp $ */
#ifndef _CFB24_32_H
#define _CFB24_32_H
@@ -20,6 +20,7 @@ extern int cfb24_32PixmapIndex;
typedef struct {
PixmapPtr pix;
Bool freePrivate;
+ Bool isRefPix;
} cfb24_32PixmapRec, *cfb24_32PixmapPtr;
RegionPtr
diff --git a/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c b/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c
index 6e566c253..8250c8c5b 100644
--- a/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c
+++ b/xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c,v 1.2 1999/01/31 12:22:15 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf24_32bpp/cfbpixmap.c,v 1.3 2000/04/01 00:17:19 mvojkovi Exp $ */
#include "Xmd.h"
#include "servermd.h"
@@ -56,6 +56,7 @@ cfb24_32CreatePixmap (
pPixPriv = CFB24_32_GET_PIXMAP_PRIVATE(pPix);
pPixPriv->pix = NULL; /* no clone yet */
pPixPriv->freePrivate = FALSE;
+ pPixPriv->isRefPix = FALSE;
return pPix;
}
@@ -119,6 +120,7 @@ cfb24_32RefreshPixmap(PixmapPtr pPix)
newPixPriv = CFB24_32_GET_PIXMAP_PRIVATE(newPix);
newPixPriv->pix = pPix;
newPixPriv->freePrivate = TRUE;
+ pixPriv->isRefPix = TRUE;
}
} else { /* bitsPerPixel == 32 */
if(!pixPriv->pix) { /* need to make a 32bpp clone */
@@ -128,17 +130,21 @@ cfb24_32RefreshPixmap(PixmapPtr pPix)
pixPriv->pix->refcnt = pPix->refcnt;
newPixPriv = CFB24_32_GET_PIXMAP_PRIVATE(pixPriv->pix);
newPixPriv->pix = pPix;
+ pixPriv->isRefPix = TRUE;
}
}
if(pPix->refcnt != pixPriv->pix->refcnt)
ErrorF("Pixmap refcnt mismatch in RefreshPixmap()\n");
- pGC = GetScratchGC(24, pScreen);
- ValidateGC((DrawablePtr)pixPriv->pix, pGC);
- (*pGC->ops->CopyArea)((DrawablePtr)pPix, (DrawablePtr)pixPriv->pix,
+ /* make sure copies only go from the real to the clone */
+ if(pixPriv->isRefPix) {
+ pGC = GetScratchGC(24, pScreen);
+ ValidateGC((DrawablePtr)pixPriv->pix, pGC);
+ (*pGC->ops->CopyArea)((DrawablePtr)pPix, (DrawablePtr)pixPriv->pix,
pGC, 0, 0, width, height, 0, 0);
- FreeScratchGC(pGC);
+ FreeScratchGC(pGC);
+ }
return pixPriv->pix;
}
diff --git a/xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c b/xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c
index da51784dd..2317fbdfa 100644
--- a/xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c
+++ b/xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c,v 1.4 1999/06/06 08:49:00 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf4bpp/ppcPixmap.c,v 1.5 2000/04/27 16:26:49 eich Exp $ */
/*
* Copyright IBM Corporation 1987,1988,1989
*
@@ -75,6 +75,7 @@ SOFTWARE.
#include "servermd.h"
#include "OScompiler.h"
#include "ibmTrace.h"
+#include "scrnintstr.h"
PixmapPtr
xf4bppCreatePixmap( pScreen, width, height, depth )
@@ -85,14 +86,15 @@ xf4bppCreatePixmap( pScreen, width, height, depth )
{
register PixmapPtr pPixmap = (PixmapPtr)NULL;
int size ;
-
+
TRACE(("xf4bppCreatePixmap(pScreen=0x%x, width=%d, height=%d, depth=%d)\n", pScreen, width, height, depth)) ;
if ( depth > 8 )
return (PixmapPtr) NULL ;
size = PixmapBytePad(width, depth);
- pPixmap = xalloc( sizeof (PixmapRec) + (height * size) ) ;
+ pPixmap = AllocatePixmap (pScreen, (height * size));
+
if ( !pPixmap )
return (PixmapPtr) NULL ;
pPixmap->drawable.type = DRAWABLE_PIXMAP ;
@@ -109,8 +111,12 @@ xf4bppCreatePixmap( pScreen, width, height, depth )
pPixmap->devKind = size;
pPixmap->refcnt = 1 ;
size = height * pPixmap->devKind ;
-
+#ifdef PIXPRIV
+ pPixmap->devPrivate.ptr = (pointer) (((CARD8*)pPixmap)
+ + pScreen->totalPixmapSize);
+#else
pPixmap->devPrivate.ptr = (pointer) (pPixmap + 1);
+#endif
bzero( (char *) pPixmap->devPrivate.ptr, size ) ;
return pPixmap ;
}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86Version.h b/xc/programs/Xserver/hw/xfree86/xf86Version.h
index 57e9ede9d..c3b6288c1 100644
--- a/xc/programs/Xserver/hw/xfree86/xf86Version.h
+++ b/xc/programs/Xserver/hw/xfree86/xf86Version.h
@@ -1,11 +1,11 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.428 2000/03/08 15:14:43 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.441 2000/07/02 02:35:26 dawes Exp $ */
-#define XF86_VERSION " 4.0 "
+#define XF86_VERSION " 4.0.1 "
/* The finer points in versions... */
#define XF86_VERSION_MAJOR 4
#define XF86_VERSION_MINOR 0
-#define XF86_VERSION_SUBMINOR 0
+#define XF86_VERSION_SUBMINOR 1
#define XF86_VERSION_BETA 0 /* 0="", 1="A", 2="B", etc... */
#define XF86_VERSION_ALPHA 0 /* 0="", 1="a", 2="b", etc... */
@@ -18,6 +18,6 @@
XF86_VERSION_BETA, \
XF86_VERSION_ALPHA)
-#define XF86_DATE "8 March 2000"
+#define XF86_DATE "1 July 2000"
/* $XConsortium: xf86Version.h /main/78 1996/10/28 05:42:10 kaleb $ */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile b/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile
new file mode 100644
index 000000000..702961eb8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile
@@ -0,0 +1,76 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/Imakefile,v 1.6 2000/06/13 23:15:51 dawes Exp $
+
+XCOMM CDEBUGFLAGS=-g -Wall -ansi -pedantic
+
+SRCS =\
+ accessx.c\
+ card-cfg.c\
+ cards.c\
+ config.c\
+ help.c\
+ interface.c\
+ keyboard-cfg.c\
+ monitor-cfg.c\
+ mouse-cfg.c\
+ options.c\
+ screen-cfg.c\
+ screen.c\
+ startx.c\
+ vidmode.c\
+ xf86config.c
+
+OBJS =\
+ accessx.o\
+ cards.o\
+ config.o\
+ card-cfg.o\
+ help.o\
+ interface.o\
+ keyboard-cfg.o\
+ monitor-cfg.o\
+ mouse-cfg.o\
+ options.o\
+ screen-cfg.o\
+ screen.o\
+ startx.o\
+ vidmode.o\
+ xf86config.o
+
+PROG = xf86cfg
+
+XBMPICS =\
+ card.xbm\
+ keyboard.xbm\
+ monitor.xbm\
+ mouse.xbm\
+ left.xbm\
+ right.xbm\
+ up.xbm\
+ down.xbm\
+ wider.xbm\
+ narrower.xbm\
+ shorter.xbm\
+ taller.xbm
+
+XPMPICS =\
+ card.xpm\
+ computer.xpm\
+ keyboard.xpm\
+ monitor.xpm\
+ mouse.xpm
+
+AllTarget(ProgramTargetName($(PROG)))
+
+LOCAL_LIBRARIES = $(XKBUILIB) $(XKBFILELIB) -lxf86config $(XXF86MISCLIB) \
+ $(XXF86VMLIB) $(XAWLIB) $(XMULIB) $(XTOOLLIB) \
+ $(XPMLIB) $(XLIB) -lm
+
+NormalProgramTarget($(PROG),$(OBJS),,$(LOCAL_LIBRARIES),)
+InstallProgramWithFlags($(PROG),$(BINDIR),NullParameter)
+InstallMultipleFlags($(XBMPICS),$(INCDIR)/X11/bitmaps,$(INSTINCFLAGS))
+InstallMultipleFlags($(XPMPICS),$(INCDIR)/X11/pixmaps,$(INSTINCFLAGS))
+InstallAppDefaults(XF86Cfg)
+InstallManPage(xf86cfg,$(MANDIR))
+
+NormalLibraryObjectRule()
+DependTarget()
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad b/xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad
new file mode 100644
index 000000000..91c4872e5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/XF86Cfg.ad
@@ -0,0 +1,1291 @@
+!!
+!! 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.3 2000/06/13 23:15:51 dawes 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
+
+.xf86cfg.geometry: 320x400
+.xf86cfg.minWidth: 320
+.xf86cfg.minHeight: 400
+.xf86cfg.maxWidth: 320
+.xf86cfg.maxHeight: 400
+
+.xf86cfg.config.geometry: 320x369
+.xf86cfg.config.minWidth: 320
+.xf86cfg.config.maxWidth: 320
+.xf86cfg.config.minHeight: 369
+.xf86cfg.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.background: black
+*commands.borderWidth: 0
+*commands.defaultDistance: 2
+*commands.?.bottom: chainTop
+*commands.height: 50
+
+*commands.keyboard.fromHoriz: mouse
+*card.fromHoriz: keyboard
+*monitor.fromHoriz: card
+
+*commands.mouse.tip: Add mouse
+*commands.keyboard.tip: Add keyboard
+*commands.card.tip: Add video card
+*commands.monitor.tip: Add monitor
+
+*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
+
+*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 XFree86 4.0 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.labelL.vertDistance: 16
+*keyboardML.layout.vertDistance: 16
+*keyboardML.keyboard.vertDistance: 16
+*keyboardML.Label.borderWidth: 0
+*keyboardML.Label.width: 115
+*keyboardML.Label.internalWidth: 0
+*keyboardML.Label.justify: right
+*keyboardML.model.width: 185
+*keyboardML.model.left: chainRight
+*keyboardML.model.right: chainRight
+*keyboardML.model.justify: left
+*keyboardML.model.fromHoriz: labelM
+*keyboardML.labelM.label: Keyboard model:
+*keyboardML.layout.width: 185
+*keyboardML.layout.left: chainRight
+*keyboardML.layout.right: chainRight
+*keyboardML.layout.justify: left
+*keyboardML.layout.fromVert: model
+*keyboardML.labelL.fromVert: model
+*keyboardML.layout.fromHoriz: labelL
+*keyboardML.labelL.label: Keyboard layout:
+*keyboardML.keyboard.fromVert: labelL
+*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: 244
+*cardModel.busidL.label: BusID
+*cardModel.busidL.fromVert: viewport
+*cardModel.busid.fromVert: viewport
+*cardModel.busid.fromHoriz: busidL
+*cardModel.busid.width: 255
+*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
+
+.xf86cfg.pane.work.Simple.borderWidth: 1
+.xf86cfg.pane.work.Simple.translations:\
+<Btn1Down>: select-device()\n\
+<Btn1Motion>: move-device()\n\
+<Btn1Up>: unselect-device()\n\
+<Btn3Down>: device-popup()\n\
+<Btn3Up>: device-popdown()
+
+.xf86cfg.pane.work.screen.translations:\
+<Btn1Down>: select-device()\n\
+<Btn1Motion>: move-device()\n\
+<Btn1Up>: unselect-device()\n\
+<Btn3Down>: device-popup()\n\
+<Btn3Up>: device-popdown()
+
+XF86Cfg.translations: #override \
+<Message>WM_PROTOCOLS: quit()
+.xf86cfg.config.translations: #override \
+<Message>WM_PROTOCOLS: config-cancel()
+.xf86cfg.options.translations: #override \
+<Message>WM_PROTOCOLS: options-cancel()
+.xf86cfg.quit.translations: #override \
+<Message>WM_PROTOCOLS: quit-cancel()
+.xf86cfg.error.translations: #override \
+<Message>WM_PROTOCOLS: error-cancel()
+.xf86cfg.force.translations: #override \
+<Message>WM_PROTOCOLS: addmode-cancel()
+.xf86cfg.accessx.translations: #override \
+<Message>WM_PROTOCOLS: accessx-close()
+.xf86cfg.test.translations: #override \
+<Message>WM_PROTOCOLS: testmode-cancel()
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! Options
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+.xf86cfg.options.geometry: 400x176
+.xf86cfg.options.minWidth: 400
+.xf86cfg.options.maxWidth: 400
+.xf86cfg.options.minHeight: 176
+.xf86cfg.options.maxHeight: 176
+
+*options*commands.remove.fromHoriz: add
+*options*commands.update.fromHoriz: remove
+*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*Label.internalWidth: 0
+*options*Label.height: 21
+*options*Text.height: 19
+*options*Label.top: chainTop
+*options*Text.top: chainTop
+*options*Label.bottom: chainTop
+*options*Text.bottom: chainTop
+*options*Label.horizDistance: 0
+*options*Text.horizDistance: 0
+*options*Label.vertDistance: 8
+*options*Text.vertDistance: 8
+*options*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
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! 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
+.xf86cfg.force.geometry: 268x58
+.xf86cfg.force.minWidth: 268
+.xf86cfg.force.maxWidth: 268
+.xf86cfg.force.minHeight: 58
+.xf86cfg.force.maxHeight: 58
+.xf86cfg.force.?.label: There is already a modeline with the\n\
+specified identifier. Add anyway?
+.xf86cfg.test.?.label: \ Testing modeline...\n\n\
+Press ESC or stop button to quit.
+.xf86cfg.test.geometry: 250x72
+.xf86cfg.test.minWidth: 250
+.xf86cfg.test.maxWidth: 250
+.xf86cfg.test.minHeight: 72
+.xf86cfg.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*viewR.fromHoriz: select
+*screenD*viewR.fromVert: modeL
+*screenD*select.label: ->
+*screenD*unselect.label: <-
+*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
+.xf86cfg.quit.geometry: 230x92
+.xf86cfg.quit.minWidth: 230
+.xf86cfg.quit.maxWidth: 230
+.xf86cfg.quit.minHeight: 92
+.xf86cfg.quit.maxHeight: 92
+
+*error.notice.label: Failed to write configuration file.
+.xf86cfg.error.geometry: 280x50
+.xf86cfg.error.minWidth: 260
+.xf86cfg.error.maxWidth: 260
+.xf86cfg.error.minHeight: 50
+.xf86cfg.error.maxHeight: 50
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+!! accessx
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+*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/7/7
+*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: gray70
+*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.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.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"
+
+*help*text.properties:\
+default?family=Times&weight=Medium&slant=R&pixelsize=12&registry=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*close.min: 18
+*help*close.max: 18
+*help*close.showGrip: False
+*help*wrap: word
+.xf86cfg.help.geometry: 320x369
+.xf86cfg.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>
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c
new file mode 100644
index 000000000..fc2f41c16
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/accessx.c
@@ -0,0 +1,687 @@
+/*
+ * 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/accessx.c,v 1.4 2000/06/20 05:08:50 dawes Exp $
+ */
+
+#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);
+
+/*
+ * Implementation
+ */
+void
+startaccessx(void)
+{
+ InitializeKeyboard();
+ 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);
+ UpdateKeyboard(True);
+ CreateAccessXHelpDialog();
+}
+
+void
+CreateAccessXHelpDialog()
+{
+ Widget form;
+
+ shell = XtVaCreatePopupShell("accessx", transientShellWidgetClass, toplevel,
+ XtNx, toplevel->core.x + toplevel->core.width,
+ XtNy, toplevel->core.y, NULL, 0);
+ 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;
+
+ 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 |
+ XkbMouseKeysMask | XkbMouseKeysAccelMask |
+ XkbRepeatKeysMask | XkbSlowKeysMask |
+ XkbBounceKeysMask)) != 0, NULL, 0);
+
+ apply = XtCreateManagedWidget("apply", commandWidgetClass, accessx, NULL, 0);
+ XtAddCallback(apply, XtNcallback, ApplyCallback, NULL);
+
+ form = XtCreateManagedWidget("Accessx", formWidgetClass, accessx, NULL, 0);
+ XtAddCallback(enable, XtNcallback, EnableCallback, (XtPointer)form);
+ timeoutToggle = XtVaCreateManagedWidget("timeoutToggle", toggleWidgetClass,
+ form, XtNstate,
+ xkb_info->xkb->ctrls->ax_timeout > 60
+ && xkb_info->xkb->ctrls->ax_timeout
+ < 30000, NULL, 0);
+ 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, 0);
+ 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, 0);
+ stickyBeep = XtVaCreateManagedWidget("beep", toggleWidgetClass, stickyForm,
+ XtNstate,
+ (xkb_info->xkb->ctrls->ax_options &
+ XkbAX_StickyKeysFBMask) != 0, NULL, 0);
+
+ mouse = XtVaCreateManagedWidget("mouseKeys", toggleWidgetClass, form,
+ XtNstate,
+ (xkb_info->xkb->ctrls->enabled_ctrls &
+ (XkbMouseKeysMask | XkbMouseKeysAccelMask))
+ != 0, NULL, 0);
+ 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, 0);
+ 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, 0);
+ 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, 0);
+ slowAccepted = XtVaCreateManagedWidget("accepted", toggleWidgetClass,
+ slowForm, XtNstate,
+ (xkb_info->xkb->ctrls->ax_options &
+ XkbAX_SKAcceptFBMask) != 0,
+ NULL, 0);
+ 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, 0);
+ 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)(int)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)(int)state);
+
+ XtSetArg(args[0], XtNstate, &state);
+ XtGetValues(mouse, args, 1);
+ EnableCallback(mouse, (XtPointer)mouseForm, (XtPointer)(int)state);
+ if (xkb_info->xkb->ctrls->mk_interval > 10)
+ val = (float)(xkb_info->xkb->ctrls->mk_interval - 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_time_to_max > 10)
+ val = (float)(xkb_info->xkb->ctrls->mk_time_to_max - 10) /
+ (float)(MAX_MOUSE_TIME * 100);
+ else
+ val = 10.0 / (float)(MAX_MOUSE_TIME * 100);
+ ScaleJumpCallback(mouseTime->scroller, (XtPointer)mouseTime,
+ (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)(int)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)(int)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)(int)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);
+ EnableCallback(enable, (XtPointer)form, (XtPointer)(int)state);
+}
+
+void
+AccessXConfigureStart(void)
+{
+ AccessXInitialize();
+
+ XtMapWidget(accessx);
+}
+
+void
+AccessXConfigureEnd(void)
+{
+ XtUnmapWidget(accessx);
+}
+
+/*ARGSUSED*/
+static void
+EnableCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ XtSetSensitive((XtPointer)user_data, (int)call_data);
+}
+
+/*ARGSUSED*/
+static void
+ScaleEnableCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ Scale *scale = (Scale*)user_data;
+
+ XtSetSensitive(scale->label, (int)call_data);
+ XtSetSensitive(scale->number, (int)call_data);
+ XtSetSensitive(scale->scroller, (int)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->xkb->ctrls->enabled_ctrls |= XkbAccessXKeysMask;
+ xkb_info->config.initial_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 |= XkbMouseKeysMask |
+ 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 = mouseSpeed->value;
+ xkb_info->config.mk_time_to_max =
+ xkb_info->xkb->ctrls->mk_time_to_max = mouseTime->value * 100;
+/* xkb_info->xkb->ctrls->mk_max_speed = 500;
+ 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;
+ }
+ }
+ else {
+ xkb_info->config.initial_ctrls &=
+ ~(XkbAccessXKeysMask | XkbStickyKeysMask | XkbMouseKeysMask |
+ XkbMouseKeysAccelMask | XkbRepeatKeysMask | XkbSlowKeysMask |
+ XkbBounceKeysMask);
+ xkb_info->config.initial_opts &=
+ ~(XkbAX_TwoKeysMask | XkbAX_LatchToLockMask | XkbAX_StickyKeysFBMask |
+ XkbAX_SKPressFBMask | XkbAX_SKAcceptFBMask);
+
+ xkb_info->xkb->ctrls->enabled_ctrls &=
+ ~(XkbAccessXKeysMask | XkbStickyKeysMask | XkbMouseKeysMask |
+ XkbMouseKeysAccelMask | XkbRepeatKeysMask | XkbSlowKeysMask |
+ XkbBounceKeysMask);
+ xkb_info->xkb->ctrls->ax_options &=
+ ~(XkbAX_TwoKeysMask | XkbAX_LatchToLockMask | XkbAX_StickyKeysFBMask |
+ XkbAX_SKPressFBMask | XkbAX_SKAcceptFBMask);
+ }
+
+ XkbSetControls(DPY, XkbAllControlsMask, xkb_info->xkb);
+ XSync(DPY, False);
+ UpdateKeyboard(True);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c
new file mode 100644
index 000000000..8513a9089
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.c
@@ -0,0 +1,316 @@
+/*
+ * 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/card-cfg.c,v 1.2 2000/06/13 23:15:51 dawes Exp $
+ */
+
+#include "xf86config.h"
+#include "mouse-cfg.h"
+#include "cards.h"
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/Form.h>
+#include <X11/Xaw/Label.h>
+#include <X11/Xaw/List.h>
+#include <X11/Xaw/Viewport.h>
+
+/*
+ * Prototypes
+ */
+static Bool CardConfigCheck(void);
+static void CardModelCallback(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+static CardsEntry *card_entry;
+static XF86ConfDevicePtr current_device;
+static Widget filter, list, busid;
+static char **cards = NULL;
+static int ncards;
+
+
+/*
+ * Implementation
+ */
+/*ARGSUSED*/
+XtPointer
+CardConfig(XtPointer config)
+{
+ XF86ConfDevicePtr card = (XF86ConfDevicePtr)config;
+/* XF86OptionPtr option;*/
+ char card_name[32];
+ Arg args[1];
+ char *bus;
+
+ 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);
+ }
+ else {
+ XF86ConfDevicePtr device = XF86Config->conf_device_lst;
+ int ndevices = 0;
+
+ while (device != NULL) {
+ ++ndevices;
+ device = (XF86ConfDevicePtr)(device->list.next);
+ }
+ do {
+ ++ndevices;
+ XmuSnprintf(card_name, sizeof(card_name), "Card%d", 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);
+ }
+
+ 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);
+ 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 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);
+
+ return ((XtPointer)card);
+ }
+
+ return (NULL);
+}
+
+static Bool
+CardConfigCheck(void)
+{
+ XF86ConfDevicePtr device = XF86Config->conf_device_lst;
+
+ if (ident_string == NULL || strlen(ident_string) == 0 ||
+ (current_device == NULL && card_entry == NULL))
+ 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], *str;
+ int len;
+ static int first = 1;
+
+ XtSetArg(args[0], XtNstring, info->string);
+ XtSetValues(filter, args, 1);
+ card_entry = LookupCard(info->string);
+
+ 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)
+ 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);
+
+ /* the first tip memory, if any, cannot be released */
+ if (!first) {
+ XtSetArg(args[0], XtNtip, &str);
+ XtGetValues(filter, args, 1);
+ XtFree(str);
+ }
+ else
+ first = 0;
+
+ str = XtNewString(tip);
+ XtSetArg(args[0], XtNtip, str);
+ 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);
+}
+
+void
+CardModel(XF86SetupInfo *info)
+{
+ static int first = 1;
+ static Widget model;
+
+ if (first) {
+ Widget label, viewport;
+
+ first = 0;
+
+ cards = GetCardNames(&ncards);
+
+ model = XtCreateWidget("cardModel", formWidgetClass,
+ configp, NULL, 0);
+ label = XtCreateManagedWidget("label", labelWidgetClass,
+ model, NULL, 0);
+ filter = XtVaCreateManagedWidget("filter", asciiTextWidgetClass,
+ model,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+ viewport = XtCreateManagedWidget("viewport", viewportWidgetClass,
+ model, NULL, 0);
+ list = XtVaCreateManagedWidget("list", listWidgetClass,
+ viewport,
+ XtNlist, cards,
+ XtNnumberStrings, ncards,
+ NULL, 0);
+ XtAddCallback(list, XtNcallback, CardModelCallback,
+ (XtPointer)info);
+ XtCreateManagedWidget("busidL", labelWidgetClass, model, NULL, 0);
+ busid = XtVaCreateManagedWidget("busid", asciiTextWidgetClass,
+ model,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+
+ XtRealizeWidget(model);
+ }
+ XtChangeManagedSet(&current, 1, NULL, NULL, &model, 1);
+ current = model;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.h
new file mode 100644
index 000000000..14411440d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/card-cfg.h
@@ -0,0 +1,44 @@
+/*
+ * 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/card-cfg.h,v 1.1 2000/04/04 22:36:57 dawes Exp $
+ */
+
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/card.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/card.xbm
new file mode 100644
index 000000000..b3cbba322
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/card.xbm,v 1.1 2000/04/04 22:36:57 dawes Exp $
+ */
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/card.xpm b/xc/programs/Xserver/hw/xfree86/xf86cfg/card.xpm
new file mode 100644
index 000000000..d68257469
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/card.xpm,v 1.1 2000/04/04 22:36:57 dawes Exp $
+ */
+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/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c
new file mode 100644
index 000000000..8696dc96a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.c
@@ -0,0 +1,462 @@
+/*
+ * 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/cards.c,v 1.1 2000/04/04 22:36:57 dawes Exp $
+ */
+
+#include "cards.h"
+
+/* 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);
+
+/*
+ * Initialization
+ */
+static int linenum = 0;
+static char *Cards = "lib/X11/Cards";
+CardsEntry **CardsDB;
+int NumCardsEntry;
+
+/*
+ * Implementation
+ */
+void
+ReadCardsDatabase(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);
+ }
+ else
+ entry->chipset = strdup(buffer);
+ 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;
+
+ 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)
+{
+ 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 strcmp((*(CardsEntry**)left)->name, (*(CardsEntry**)right)->name);
+}
+
+static int
+BCompareCards(_Xconst void *name, _Xconst void *card)
+{
+ return (strcmp((char*)name, (*(CardsEntry**)card)->name));
+}
+
+#ifdef TEST_CARDS
+int
+main(int argc, char *argv[])
+{
+ int i;
+
+ chdir("/usr/X11R6");
+ ReadCardsDatabase();
+
+ for (i = 0; i < NumCardsEntry; i++) {
+ CardsEntry *entry = CardsDB[i];
+
+ printf("name: %s\n", entry->name);
+ if (entry->chipset)
+ printf("chipset: %s\n", entry->chipset);
+ if (entry->server)
+ printf("server: %s\n", entry->server);
+ if (entry->driver)
+ printf("driver: %s\n", entry->driver);
+ if (entry->ramdac)
+ printf("%s\n", entry->ramdac);
+ if (entry->clockchip)
+ printf("%s\n", entry->clockchip);
+ if (entry->dacspeed)
+ printf("%s\n", entry->dacspeed);
+ if (entry->flags & F_NOCLOCKPROBE)
+ printf("NOCLOCKPROBE\n");
+ if (entry->flags & F_UNSUPPORTED)
+ printf("UNSUPPORTED\n");
+ if (entry->lines)
+ printf("%s\n", entry->lines);
+ printf("\n");
+ }
+
+ return (0);
+}
+#endif /* TEST_CARDS */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.h
new file mode 100644
index 000000000..51b5fb7b1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/cards.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>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/cards.h,v 1.1 2000/04/04 22:36:57 dawes Exp $
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <X11/Xfuncproto.h>
+
+#ifndef _xf86cfg_cards_h
+#define _xf86cfg_cards_h
+
+/* 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*);
+
+#endif /* _xf86cfg_cards_h */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/computer.xpm b/xc/programs/Xserver/hw/xfree86/xf86cfg/computer.xpm
new file mode 100644
index 000000000..75fc85b26
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/computer.xpm,v 1.1 2000/04/04 22:36:58 dawes Exp $
+ */
+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/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c
new file mode 100644
index 000000000..284a72d3f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.c
@@ -0,0 +1,291 @@
+/*
+ * 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/config.c,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#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>
+
+#define CONFPATH "%A,%R,/etc/X11/%R,%P/etc/X11/%R,%E,%F,/etc/X11/%F," \
+ "%P/etc/X11/%F,%D/%X,/etc/X11/%X,/etc/%X,%P/etc/X11/%X.%H," \
+ "%P/etc/X11/%X,%P/lib/X11/%X.%H,%P/lib/X11/%X"
+
+/*
+ * 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, label, bottom, cancel;
+ const char *filename;
+
+ if (!first)
+ return;
+ first = 0;
+
+ /* Read initial configuration */
+ if ((filename = xf86OpenConfigFile(CONFPATH, XF86Config_path, NULL)) == NULL) {
+ fprintf(stderr, "Cannot to open config file.\n");
+ exit(1);
+ }
+ 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);
+ label = XtCreateManagedWidget("label", labelWidgetClass,
+ top, NULL, 0);
+ ident_widget = XtVaCreateManagedWidget("identifier", asciiTextWidgetClass,
+ top,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+ 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 label, command;
+
+ errcurrent = XtCreateWidget("error", formWidgetClass,
+ configp, NULL, 0);
+ label = XtCreateManagedWidget("label", labelWidgetClass,
+ errcurrent, NULL, 0);
+ command = XtCreateManagedWidget("command", commandWidgetClass,
+ errcurrent, NULL, 0);
+ XtAddCallback(command, XtNcallback, ErrorCallback, NULL);
+
+ XtRealizeWidget(errcurrent);
+ }
+
+ oldcurrent = current;
+ XtChangeManagedSet(&current, 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/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h
new file mode 100644
index 000000000..4bf9ac2ae
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/config.h
@@ -0,0 +1,195 @@
+/*
+ * 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/config.h,v 1.4 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/SysUtil.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <dirent.h>
+#include <string.h>
+#include <unistd.h>
+
+#if NeedVarargsPrototypes
+#include <stdarg.h>
+#define Va_start(a,b) va_start(a,b)
+#else
+#include <varargs.h>
+#define Va_start(a,b) va_start(a)
+#endif
+
+#ifdef __EMX__
+#define strcasecmp stricmp
+#define setenv putenv
+#define PATH_MAX 260
+#endif
+
+/* 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
+
+/*
+ * 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)();
+
+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*);
+
+/*
+ * 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 *XFree86Dir;
+extern xf86cfgComputer computer;
+extern Atom wm_delete_window;
+extern Display *DPY;
+
+#endif /* _xf86cfg_config_h */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/down.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/down.xbm
new file mode 100644
index 000000000..742adf202
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/help.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/help.c
new file mode 100644
index 000000000..a970b1006
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/help.c,v 1.1 2000/06/13 23:15:51 dawes Exp $
+ */
+
+#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/Paned.h>
+
+#include <X11/Xaw/Text.h>
+#include <X11/Xaw/TextSinkP.h>
+#include <X11/Xaw/TextSrcP.h>
+#include <X11/Xmu/Xmu.h>
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h> /* for bsearch() */
+#endif
+#include <ctype.h>
+
+/*
+ * Prototypes
+ */
+static void CloseCallback(Widget, XtPointer, XtPointer);
+static void StartHelp(void);
+void Html_ModeStart(Widget);
+
+/*
+ * Initialization
+ */
+static Widget shell, text;
+extern Widget toplevel;
+extern Display *DPY;
+extern Atom wm_delete_window;
+static Bool popped_up = False;
+
+/*
+ * Implementation
+ */
+Bool
+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, 0);
+ 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, 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, 0);
+ close = XtCreateManagedWidget("close", commandWidgetClass,
+ pane, 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, 0);
+ }
+}
+
+/*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;
+ int entity : 1; /* it changes the type of the text */
+ int nest : 1; /* does not close tags automatically */
+ int end : 1; /* need a close markup */
+ int adnl : 1; /* add newline before/after tag contents */
+ 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_ModeStart(Widget);
+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 char *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, 0);
+
+ 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, 0);
+
+ 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, 0);
+ XawTextSourceReplace(src, 0, info->last, &info->block);
+ XtVaSetValues(src, XtNeditType, XawtextRead, NULL, 0);
+
+ 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)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 <= sizeof(buf) + 1)
+ 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 <= sizeof(buf) + 1)
+ 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 = 'á'; break; case 'e': idx = 'é'; break;
+ case 'i': idx = 'í'; break; case 'o': idx = 'ó'; break;
+ case 'u': idx = 'ú'; break; case 'A': idx = 'Á'; break;
+ case 'E': idx = 'É'; break; case 'I': idx = 'Í'; break;
+ case 'O': idx = 'Ó'; break; case 'U': idx = 'Ú'; break;
+ case 'y': idx = 'ý'; break; case 'Y': idx = 'Ý'; break;
+ }
+ }
+ else if (strcmp(buf + 1, "grave") == 0) {
+ switch (*buf) {
+ case 'a': idx = 'à'; break; case 'e': idx = 'è'; break;
+ case 'i': idx = 'ì'; break; case 'o': idx = 'ò'; break;
+ case 'u': idx = 'ù'; break; case 'A': idx = 'À'; break;
+ case 'E': idx = 'È'; break; case 'I': idx = 'Ì'; break;
+ case 'O': idx = 'Ò'; break; case 'U': idx = 'Ù'; break;
+ }
+ }
+ else if (strcmp(buf + 1, "tilde") == 0) {
+ switch (*buf) {
+ case 'a': idx = 'ã'; break; case 'o': idx = 'õ'; break;
+ case 'n': idx = 'ñ'; break; case 'A': idx = 'Ã'; break;
+ case 'O': idx = 'Õ'; break; case 'N': idx = 'Ñ'; break;
+ }
+ }
+ else if (strcmp(buf + 1, "circ") == 0) {
+ switch (*buf) {
+ case 'a': idx = 'â'; break; case 'e': idx = 'ê'; break;
+ case 'i': idx = 'î'; break; case 'o': idx = 'ô'; break;
+ case 'u': idx = 'û'; break; case 'A': idx = 'Â'; break;
+ case 'E': idx = 'Ê'; break; case 'I': idx = 'Î'; break;
+ case 'O': idx = 'Ô'; break; case 'U': idx = 'Û'; 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 = 'ü'; break; case 'A': idx = 0xc4;break;
+ case 'E': idx = 0xcb;break; case 'I': idx = 0xfc;break;
+ case 'O': idx = 0xd6;break; case 'U': idx = 'Ü'; break;
+ case 'y': idx = 0xff;break;
+ }
+ }
+ else if (strcmp(buf + 1, "cedil") == 0) {
+ switch (*buf) {
+ case 'c': idx = 'ç'; break; case 'C': idx = 'Ç'; 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 = 'ª';
+ 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 = '°';
+ else if (strcasecmp(buf, "plusmn") == 0)
+ idx = 0xb1;
+ else if (strcasecmp(buf, "sup2") == 0)
+ idx = '²';
+ else if (strcasecmp(buf, "sup3") == 0)
+ idx = '³';
+ 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 = '¹';
+ else if (strcasecmp(buf, "ordm") == 0)
+ idx = 'º';
+ 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 char *
+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, sz = 0;
+ char buf[32];
+ Html_TagInfo *info;
+
+ 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 <= sizeof(buf) + 1)
+ 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 <= sizeof(buf) + 1)
+ 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;
+
+ 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/xc/programs/Xserver/hw/xfree86/xf86cfg/help.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/help.h
new file mode 100644
index 000000000..f03e01b14
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/help.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>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/help.h,v 1.1 2000/06/13 23:15:51 dawes Exp $
+ */
+
+/* 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/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c
new file mode 100644
index 000000000..19ed96443
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/interface.c
@@ -0,0 +1,1861 @@
+/*
+ * 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/interface.c,v 1.4 2000/06/14 21:57:57 dawes Exp $
+ */
+
+#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"
+
+#define randomize() srand((unsigned)time((time_t*)NULL))
+#define DefaultXFree86Dir "/usr/X11R6"
+
+/*
+ * 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 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*);
+static void ErrorCancelAction(Widget, XEvent*, String*, Cardinal*);
+static void QuitCancelAction(Widget, XEvent*, String*, Cardinal*);
+static void HelpCallback(Widget, XtPointer, XtPointer);
+
+extern void AccessXConfigureStart(void);
+extern void AccessXConfigureEnd(void);
+extern void CloseAccessXAction(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+Widget toplevel, work, config, layout, layoutsme, layoutp;
+XtAppContext appcon;
+
+char *XF86Config_path = NULL;
+char *XFree86Dir;
+Bool xf86config_set = False;
+
+xf86cfgComputer computer;
+xf86cfgDevice cpu_device;
+Cursor no_cursor;
+static Widget device, menu, 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;
+
+#define CONFIG_LAYOUT 0
+#define CONFIG_SCREEN 1
+#define CONFIG_MODELINE 2
+#define CONFIG_ACCESSX 3
+static 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", CancelForceAddModeAction},
+ {"accessx-close", CloseAccessXAction},
+ {"testmode-cancel", CancelTestModeAction},
+ {"help-close", HelpCancelAction},
+};
+
+static char *device_names[] = {
+/* MOUSE */
+ "mouse",
+/* KEYBOARD */
+ "keyboard",
+/* CARD */
+ "card",
+/* MONITOR */
+ "monitor",
+/* SCREEN */
+ "screen",
+};
+
+/*
+static XtResource appResources[] = {
+ {"xf86config", "XF86Config", XtRString, sizeof(char*),
+ 0, XtRString, "/etc/X11/XF86Config"},
+};
+
+static XrmOptionDescRec optionDescList[] = {
+ {"-xf86config", "*xf86config", XrmoptionSepArg, (XtPointer)"/etc/X11/XF86Config"},
+};
+*/
+
+/*
+ * Implementation
+ */
+int
+main(int argc, char *argv[])
+{
+ Widget pane, popup, mouse, keyboard, card, monitor;
+ Widget bottom, sme, smemodeline, help, quit, layopt;
+ XColor color, tmp;
+ Pixmap pixmap;
+ XGCValues values;
+ XF86ConfLayoutPtr lay;
+ int i, startedx;
+
+ if ((XFree86Dir = getenv("XWINHOME")) == NULL)
+ XFree86Dir = DefaultXFree86Dir;
+
+ chdir(XFree86Dir);
+
+ for (i = 1; i < argc; i++)
+ if (strcmp(argv[i], "-xf86config") == 0) {
+ if (i + 1 < argc)
+ XF86Config_path = argv[i + 1];
+ break;
+ }
+
+ startedx = startx();
+ if (XF86Config_path == NULL)
+ XF86Config_path = "/etc/X11/XF86Config";
+ toplevel = XtAppInitialize(&appcon, "XF86Cfg",
+/* optionDescList, XtNumber(optionDescList),*/
+ NULL, 0,
+ &argc, argv,
+ NULL, NULL, 0);
+ if (DPY == NULL)
+ DPY = XtDisplay(toplevel);
+
+/*
+ XtGetApplicationResources(toplevel, (XtPointer)&XF86Config_path,
+ appResources, XtNumber(appResources), NULL, 0);
+*/
+
+ XtAppAddActions(appcon, actions, XtNumber(actions));
+
+ XawSimpleMenuAddGlobalActions(appcon);
+ XtRegisterGrabAction(DevicePopupMenu, True,
+ ButtonPressMask | ButtonReleaseMask,
+ GrabModeAsync, GrabModeAsync);
+
+ pane = XtCreateManagedWidget("pane", panedWidgetClass,
+ toplevel, NULL, 0);
+ menu = XtCreateManagedWidget("topM", menuButtonWidgetClass,
+ pane, NULL, 0);
+ popup = XtCreatePopupShell("menu", simpleMenuWidgetClass,
+ menu, 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 = XtCreateManagedWidget("mouse", commandWidgetClass,
+ commands, NULL, 0);
+ XtAddCallback(mouse, XtNcallback, AddDeviceCallback, (XtPointer)MOUSE);
+ keyboard = XtCreateManagedWidget("keyboard", commandWidgetClass,
+ commands, NULL, 0);
+ XtAddCallback(keyboard, XtNcallback, AddDeviceCallback, (XtPointer)KEYBOARD);
+ card = XtCreateManagedWidget("card", commandWidgetClass,
+ commands, NULL, 0);
+ XtAddCallback(card, XtNcallback, AddDeviceCallback, (XtPointer)CARD);
+ monitor = XtCreateManagedWidget("monitor", commandWidgetClass,
+ commands, NULL, 0);
+ XtAddCallback(monitor, XtNcallback, AddDeviceCallback, (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, 0);
+ 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);
+
+ layopt = XtCreatePopupShell("options", 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);
+
+ XtRealizeWidget(toplevel);
+ XtRealizeWidget(menu);
+
+ 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();
+ XtSetSensitive(smemodeline, VideoModeInitialize());
+ ReadCardsDatabase();
+
+ lay = XF86Config->conf_layout_lst;
+ while (lay != NULL) {
+ sme = XtVaCreateManagedWidget("sme", smeBSBObjectClass,
+ layoutp,
+ XtNlabel, lay->lay_identifier,
+ XtNmenuName, "options",
+ NULL, 0);
+ XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay);
+ if (layoutsme == NULL)
+ layoutsme = sme;
+ lay = (XF86ConfLayoutPtr)(lay->list.next);
+ }
+ SelectLayoutCallback(layoutsme,
+ XF86Config->conf_layout_lst, NULL);
+
+ if (startedx) {
+ startaccessx();
+ switch (fork()) {
+ case 0: {
+ char path[PATH_MAX];
+
+ XmuSnprintf(path, sizeof(path), "%s/bin/twm", XFree86Dir);
+ execl(path, "twm", NULL);
+ exit(-127);
+ } break;
+ case -1:
+ fprintf(stderr, "Cannot fork.\n");
+ exit(1);
+ break;
+ default:
+ break;
+ }
+ }
+
+ 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 = (int)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;
+
+ shell_cf = XtCreatePopupShell("quit", transientShellWidgetClass,
+ toplevel, NULL, 0);
+ dialog = XtVaCreateManagedWidget("ask", dialogWidgetClass, shell_cf,
+ XtNvalue, XF86Config_path, NULL, 0);
+ 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(strlen(l) + 12);
+ strcpy(label, "XF86Config\n");
+ 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, *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, XkbConfigDir XkbConfigFile);
+ ++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)
+ XF86Config_path = XawDialogGetValueString(dialog);
+
+ 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(XkbConfigDir XkbConfigFile,
+ &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, 0);
+ 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 (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 (strcasecmp(input->inp_driver, "keyboard") == 0) {
+ 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, 0);
+ 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);
+ }
+
+ 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;
+ Arg args[1];
+ char *str;
+
+ if (lay == 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 {
+ ++num_layouts;
+ XmuSnprintf(name, sizeof(name), "Layout%d", 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, "options",
+ NULL, 0);
+ XtAddCallback(layoutsme, XtNcallback,
+ SelectLayoutCallback, (XtPointer)l);
+ 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 sme = (Widget)(((SimpleMenuWidget)(w->core.parent->core.parent))
+ ->simple_menu.entry_set);
+ int i;
+ char *str;
+ Arg args[1];
+ XF86ConfLayoutPtr prev, tmp, lay;
+
+ XtSetArg(args[0], XtNlabel, &str);
+ XtGetValues(sme, args, 1);
+
+ 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]);
+
+ 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, "options",
+ NULL, 0);
+ XtAddCallback(sme, XtNcallback, SelectLayoutCallback, (XtPointer)lay);
+ if (layoutsme == NULL)
+ layoutsme = sme;
+ 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 = (Widget)(((SimpleMenuWidget)(w->core.parent->core.parent))
+ ->simple_menu.entry_set);
+ char *str;
+ Arg args[1];
+
+ XtSetArg(args[0], XtNlabel, &str);
+ XtGetValues(sme, args, 1);
+ 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 {
+ int i;
+
+ 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();
+ }
+
+ xf86RemoveLayout(XF86Config, rem);
+ XtDestroyWidget(sme);
+}
+
+void
+SetTip(xf86cfgDevice *device)
+{
+ XF86OptionPtr option;
+ char *tip, buffer[4096];
+ Arg args[1];
+ int len;
+
+ XtSetArg(args[0], XtNtip, &tip);
+ XtGetValues(device->widget, args, 1);
+ if (tip)
+ XtFree((XtPointer)tip);
+
+ 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;
+ len = XmuSnprintf(buffer, sizeof(buffer),
+ "Identifier \"%s\"\n"
+ "Vendor \"%s\"\n",
+ monitor->mon_identifier,
+ monitor->mon_vendor);
+ 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 = XtNewString(buffer);
+ XtSetArg(args[0], XtNtip, tip);
+ XtSetValues(device->widget, args, 1);
+}
+
+/*ARGSUSED*/
+void
+AddDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ AddDevice((int)user_data, NULL, 6, 6);
+}
+
+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;
+ }
+ 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;
+
+ 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);
+ break;
+ case CARD:
+ options = (XF86OptionPtr*)&(((XF86ConfDevicePtr)
+ (computer.devices[i]->config))->dev_option_lst);
+ break;
+ case MONITOR:
+ options = (XF86OptionPtr*)&(((XF86ConfMonitorPtr)
+ (computer.devices[i]->config))->mon_option_lst);
+ break;
+ }
+ }
+ }
+
+ OptionsPopup(options);
+ if (config_mode == CONFIG_SCREEN) {
+ XF86OptionPtr option, options;
+ int rotate;
+
+ 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 (strcasecmp(nex->iref_inputdev->inp_driver,
+ "keyboard") == 0)
+ ++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)
+ addListItem((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;
+ }
+}
+
+void
+RemoveDeviceCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ int i, j;
+
+ if (config_mode == CONFIG_SCREEN) {
+ for (i = 0; i < computer.num_screens; i++)
+ if (computer.screens[i]->widget == config) {
+ xf86cfgDevice *mon, *dev;
+
+ RemoveScreen(mon = computer.screens[i]->monitor,
+ dev = computer.screens[i]->card);
+
+/*
+ for (j = 0; j < computer.num_devices; j++) {
+ if (computer.devices[j] == mon ||
+ computer.devices[j] == dev) {
+ if (--computer.devices[j]->refcount <= 0) {
+ XtDestroyWidget(computer.devices[j]->widget);
+ XtFree((XtPointer)computer.devices[j]);
+ if (--computer.num_devices > j)
+ memmove(&computer.devices[j],
+ &computer.devices[j + 1],
+ (computer.num_devices - j) *
+ sizeof(xf86cfgDevice*));
+ --j;
+ }
+ }
+ }
+*/
+
+ 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) {
+ 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();
+ }
+
+ break;
+ }
+ }
+}
+
+/*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 = (int)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(menu, 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/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c
new file mode 100644
index 000000000..d589e392b
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.c
@@ -0,0 +1,814 @@
+/*
+ * 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/keyboard-cfg.c,v 1.5 2000/06/20 05:08:50 dawes Exp $
+ */
+
+#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>
+
+/*
+ * Prototypes
+ */
+static void KeyboardModelCallback(Widget, XtPointer, XtPointer);
+static void KeyboardLayoutCallback(Widget, XtPointer, XtPointer);
+static void KeyboardApplyCallback(Widget, XtPointer, XtPointer);
+static Bool KeyboardConfigCheck(void);
+static void XkbUIEventHandler(Widget, XtPointer, XEvent*, Boolean*);
+
+/*
+ * Initialization
+ */
+static XF86XkbDescInfo xkb_model;
+static XF86XkbDescInfo xkb_layout;
+static XF86XkbDescInfo xkb_variant;
+static XF86XkbDescInfo xkb_option;
+static char *XkbRulesFile = "lib/X11/xkb/rules/xfree86";
+static XF86ConfInputPtr current_input;
+
+static char *model, *layout;
+static Widget kbd, modelb, layoutb;
+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 *XkbModel = "XkbModel", *XkbLayout = "XkbLayout";
+
+ InitializeKeyboard();
+
+ 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;
+ while (timeout > 0) {
+ xkb_info->xkb =
+ XkbGetKeyboard(XtDisplay(configp),
+ XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+ if (xkb_info->xkb == NULL || xkb_info->xkb->geom == NULL)
+ sleep(timeout -= 1);
+ else
+ break;
+ }
+ if (timeout <= 0) {
+ fprintf(stderr, "Couldn't get keyboard\n");
+ exit(1);
+ }
+ if (xkb_info->xkb->names->geometry == 0)
+ xkb_info->xkb->names->geometry = xkb_info->xkb->geom->name;
+
+ bzero((char*)&(xkb_info->defs), sizeof(XkbRF_VarDefsRec));
+ }
+
+ /* check for removed devices */
+ for (i = 0; i < num_xkb_infos; i++) {
+ XF86ConfInputPtr key = XF86Config->conf_input_lst;
+
+ while (key != NULL) {
+ if (strcasecmp(key->inp_driver, "keyboard") == 0 &&
+ 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, XkbModel)) != NULL)
+ xkb_info->defs.model = model = option->opt_val;
+ else
+ xkb_info->defs.model = model = xkb_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_layout.name[0];
+
+ XtSetArg(args[0], XtNstring, keyboard->inp_identifier);
+ XtSetValues(ident_widget, args, 1);
+
+ UpdateKeyboard(False);
+ }
+ else {
+ XF86ConfInputPtr input = XF86Config->conf_input_lst;
+ char keyboard_name[48];
+ int nkeyboards = 0;
+
+ while (input != NULL) {
+ if (strcasecmp(input->inp_driver, "keyboard") == 0)
+ ++nkeyboards;
+ input = (XF86ConfInputPtr)(input->list.next);
+ }
+ do {
+ ++nkeyboards;
+ XmuSnprintf(keyboard_name, sizeof(keyboard_name),
+ "Keyboard%d", nkeyboards);
+ } while (xf86FindInput(keyboard_name,
+ XF86Config->conf_input_lst));
+
+ model = xkb_model.name[0];
+ layout = xkb_layout.name[0];
+ XtSetArg(args[0], XtNstring, keyboard_name);
+ XtSetValues(ident_widget, args, 1);
+ }
+
+ 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("keyboard");
+ keyboard->inp_option_lst = xf86NewOption(XtNewString(XkbModel),
+ XtNewString(model));
+ xf86addNewOption(keyboard->inp_option_lst,
+ XtNewString(XkbLayout), XtNewString(layout));
+ keyboard->inp_comment = NULL;
+ }
+ else {
+ int i;
+ char *str;
+
+ XtSetArg(args[0], XtNlabel, &str);
+ XtGetValues(modelb, args, 1);
+ for (i = 0; i < xkb_model.nelem; i++)
+ if (strcmp(xkb_model.desc[i], str) == 0) {
+ model = xkb_model.name[i];
+ break;
+ }
+
+ XtSetArg(args[0], XtNlabel, &str);
+ XtGetValues(layoutb, args, 1);
+ for (i = 0; i < xkb_layout.nelem; i++)
+ if (strcmp(xkb_layout.desc[i], str) == 0) {
+ layout = xkb_layout.name[i];
+ break;
+ }
+
+ if ((option = xf86FindOption(keyboard->inp_option_lst, XkbModel))
+ != NULL) {
+ XtFree(option->opt_val);
+ option->opt_val = XtNewString(model);
+ XtFree(option->opt_comment);
+ }
+/* else {
+ if (keyboard->inp_option_lst == NULL)
+ keyboard->inp_option_lst = xf86NewOption(XtNewString(XkbModel),
+ XtNewString(model));
+ else
+ 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);
+ XtFree(option->opt_comment);
+ }
+ /*else
+ xf86addNewOption(keyboard->inp_option_lst,
+ XtNewString(XkbLayout), XtNewString(layout));*/
+ XtFree(xkb_info->config.layout);
+ xkb_info->config.layout = XtNewString(layout);
+ }
+ if (strcasecmp(keyboard->inp_identifier, ident_string))
+ xf86RenameInput(XF86Config, keyboard, ident_string);
+
+ xkb_info->conf = keyboard;
+ return ((XtPointer)keyboard);
+ }
+
+ 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;
+ XkbRF_RulesPtr list;
+ int i, 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 = XtNew(XkbInfo);
+ xkb_info->conf = NULL;
+ xkb_infos = (XkbInfo**)XtCalloc(1, sizeof(XkbInfo*));
+ num_xkb_infos = 1;
+ xkb_infos[0] = xkb_info;
+
+ while (timeout > 0) {
+ xkb_info->xkb =
+ XkbGetKeyboard(DPY, XkbGBN_AllComponentsMask, XkbUseCoreKbd);
+ if (xkb_info->xkb == NULL || xkb_info->xkb->geom == NULL) {
+ timeout -= 1;
+ sleep(1);
+ }
+ else
+ break;
+ }
+ if (timeout <= 0) {
+ fprintf(stderr, "Couldn't get keyboard\n");
+ exit(1);
+ }
+ if (xkb_info->xkb->names->geometry == 0)
+ xkb_info->xkb->names->geometry = xkb_info->xkb->geom->name;
+
+ bzero((char*)&(xkb_info->defs), sizeof(XkbRF_VarDefsRec));
+
+ if ((list = XkbRF_Create(0, 0)) == NULL ||
+ !XkbRF_LoadDescriptionsByName(XkbRulesFile, NULL, list)) {
+ fprintf(stderr, "Can't create rules structure\n");
+ exit(1);
+ }
+
+ for (i = 0; i < list->models.num_desc; i++) {
+ if (i % 16 == 0) {
+ xkb_model.name = (char**)XtRealloc((XtPointer)xkb_model.name,
+ (i + 16) * sizeof(char*));
+ xkb_model.desc = (char**)XtRealloc((XtPointer)xkb_model.desc,
+ (i + 16) * sizeof(char*));
+ }
+ xkb_model.name[i] = XtNewString(list->models.desc[i].name);
+ xkb_model.desc[i] = XtNewString(list->models.desc[i].desc);
+ }
+ xkb_model.nelem = i;
+
+ for (i = 0; i < list->layouts.num_desc; i++) {
+ if (i % 16 == 0) {
+ xkb_layout.name = (char**)XtRealloc((XtPointer)xkb_layout.name,
+ (i + 16) * sizeof(char*));
+ xkb_layout.desc = (char**)XtRealloc((XtPointer)xkb_layout.desc,
+ (i + 16) * sizeof(char*));
+ }
+ xkb_layout.name[i] = XtNewString(list->layouts.desc[i].name);
+ xkb_layout.desc[i] = XtNewString(list->layouts.desc[i].desc);
+ }
+ xkb_layout.nelem = i;
+
+ for (i = 0; i < list->variants.num_desc; i++) {
+ if (i % 16 == 0) {
+ xkb_variant.name = (char**)XtRealloc((XtPointer)xkb_variant.name,
+ (i + 16) * sizeof(char*));
+ xkb_variant.desc = (char**)XtRealloc((XtPointer)xkb_variant.desc,
+ (i + 16) * sizeof(char*));
+ }
+ xkb_variant.name[i] = XtNewString(list->variants.desc[i].name);
+ xkb_variant.desc[i] = XtNewString(list->variants.desc[i].desc);
+ }
+ xkb_variant.nelem = i;
+
+ for (i = 0; i < list->options.num_desc; i++) {
+ if (i % 16 == 0) {
+ xkb_option.name = (char**)XtRealloc((XtPointer)xkb_option.name,
+ (i + 16) * sizeof(char*));
+ xkb_option.desc = (char**)XtRealloc((XtPointer)xkb_option.desc,
+ (i + 16) * sizeof(char*));
+ }
+ xkb_option.name[i] = XtNewString(list->options.desc[i].name);
+ xkb_option.desc[i] = XtNewString(list->options.desc[i].desc);
+ }
+ xkb_option.nelem = i;
+
+ XkbRF_Free(list, True);
+
+ /* Load configuration */
+ XmuSnprintf(name, sizeof(name), "%s%s", XkbConfigDir, XkbConfigFile);
+ file = fopen(name, "r");
+/* if ((file = fopen(name, "r")) == NULL) {
+ strcpy(name, 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);
+ }
+
+ /* XXX Assumes the first keyboard is the core keyboard */
+ while (keyboard != NULL) {
+ if (strcasecmp(keyboard->inp_driver, "keyboard") == 0)
+ break;
+ keyboard = (XF86ConfInputPtr)(keyboard->list.next);
+ }
+ if (keyboard == NULL)
+ return;
+
+ 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_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_layout.name[0];
+}
+
+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);
+ fprintf(fp, "MouseKeysCurve = %d\n", conf->mk_curve);
+
+ 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);
+}
+
+void
+UpdateKeyboard(Bool load)
+{
+ static XkbRF_RulesPtr rules;
+ XkbComponentNamesRec comps;
+ XkbDescPtr xkb;
+
+ if (rules == NULL) {
+ FILE *fp;
+
+ if ((fp = fopen(XkbRulesFile, "r")) == NULL) {
+ fprintf(stderr, "Can't open rules file\n");
+ exit(1);
+ }
+
+ if ((rules = XkbRF_Create(0, 0)) == NULL) {
+ fclose(fp);
+ fprintf(stderr, "Can't create rules structure\n");
+ exit(1);
+ }
+
+ if (!XkbRF_LoadRules(fp, rules)) {
+ fclose(fp);
+ XkbRF_Free(rules, True);
+ fprintf(stderr, "Can't load rules\n");
+ exit(1);
+ }
+ fclose(fp);
+ }
+
+ bzero((char*)&comps, sizeof(XkbComponentNamesRec));
+ XkbRF_GetComponents(rules, &(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");
+ exit(1);
+ }
+ if (xkb->names->geometry == 0)
+ xkb->names->geometry = 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);
+}
+
+static void
+KeyboardModelCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ Arg args[1];
+ int i;
+
+ for (i = 0; i < xkb_model.nelem; i++)
+ if (strcmp(XtName(w), xkb_model.name[i]) == 0)
+ break;
+ XtSetArg(args[0], XtNlabel, xkb_model.desc[i]);
+ XtSetValues(modelb, args, 1);
+ model = xkb_info->defs.model = xkb_model.name[i];
+ UpdateKeyboard(False);
+}
+
+static void
+KeyboardLayoutCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ Arg args[1];
+ int i;
+
+ for (i = 0; i < xkb_layout.nelem; i++)
+ if (strcmp(XtName(w), xkb_layout.name[i]) == 0)
+ break;
+ XtSetArg(args[0], XtNlabel, xkb_layout.desc[i]);
+ XtSetValues(layoutb, args, 1);
+ layout = xkb_info->defs.layout = xkb_layout.name[i];
+}
+
+/*ARGSUSED*/
+static void
+KeyboardApplyCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ UpdateKeyboard(True);
+}
+
+void
+KeyboardModelAndLayout(XF86SetupInfo *info)
+{
+ static int first = 1;
+ static Widget kbdml;
+ Arg args[1];
+ int i;
+
+ if (first) {
+ Widget label, popup, sme;
+
+ first = 0;
+
+ kbdml = XtCreateWidget("keyboardML", formWidgetClass,
+ configp, NULL, 0);
+
+ /* MODEL */
+ label = XtCreateManagedWidget("labelM", labelWidgetClass,
+ kbdml, NULL, 0);
+ modelb = XtVaCreateManagedWidget("model", menuButtonWidgetClass, kbdml,
+ XtNmenuName, "modelP",
+ NULL, 0);
+ popup = XtCreatePopupShell("modelP", simpleMenuWidgetClass,
+ modelb, NULL, 0);
+ for (i = 0; i < xkb_model.nelem; i++) {
+ sme = XtVaCreateManagedWidget(xkb_model.name[i], smeBSBObjectClass,
+ popup,
+ XtNlabel, xkb_model.desc[i],
+ NULL, 0);
+ XtAddCallback(sme, XtNcallback, KeyboardModelCallback, NULL);
+ }
+
+ /* LAYOUT */
+ label = XtCreateManagedWidget("labelL", labelWidgetClass,
+ kbdml, NULL, 0);
+ layoutb = XtVaCreateManagedWidget("layout", menuButtonWidgetClass, kbdml,
+ XtNmenuName, "layoutP",
+ XtNlabel, xkb_layout.desc[0],
+ NULL, 0);
+ popup = XtCreatePopupShell("layoutP", simpleMenuWidgetClass,
+ layoutb, NULL, 0);
+ for (i = 0; i < xkb_layout.nelem; i++) {
+ sme = XtVaCreateManagedWidget(xkb_layout.name[i], smeBSBObjectClass,
+ popup,
+ XtNlabel, xkb_layout.desc[i],
+ NULL, 0);
+ XtAddCallback(sme, XtNcallback, KeyboardLayoutCallback, NULL);
+ }
+
+ 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);
+ }
+
+ for (i = 0; i < xkb_model.nelem; i++)
+ if (strcmp(model, xkb_model.name[i]) == 0) {
+ XtSetArg(args[0], XtNlabel, xkb_model.desc[i]);
+ XtSetValues(modelb, args, 1);
+ break;
+ }
+
+ for (i = 0; i < xkb_layout.nelem; i++)
+ if (strcmp(layout, xkb_layout.name[i]) == 0) {
+ XtSetArg(args[0], XtNlabel, xkb_layout.desc[i]);
+ XtSetValues(layoutb, args, 1);
+ break;
+ }
+
+ XtChangeManagedSet(&current, 1, NULL, NULL, &kbdml, 1);
+ current = kbdml;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.h
new file mode 100644
index 000000000..b8f461c78
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard-cfg.h
@@ -0,0 +1,74 @@
+/*
+ * 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/keyboard-cfg.h,v 1.2 2000/06/13 23:15:51 dawes Exp $
+ */
+
+#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 "lib/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);
+void UpdateKeyboard(Bool);
+Bool WriteXKBConfiguration(char*, XkbConfigRtrnPtr);
+
+/*
+ * Initialization
+ */
+extern XkbInfo *xkb_info;
+
+#endif /* _xf86cfg_keyboard_h */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xbm
new file mode 100644
index 000000000..69d4aac42
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xbm,v 1.1 2000/04/04 22:36:59 dawes Exp $
+ */
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xpm b/xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xpm
new file mode 100644
index 000000000..5ef7b605d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/keyboard.xpm,v 1.1 2000/04/04 22:36:59 dawes Exp $
+ */
+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/xc/programs/Xserver/hw/xfree86/xf86cfg/left.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/left.xbm
new file mode 100644
index 000000000..bfb8f3ba8
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c
new file mode 100644
index 000000000..44a03ae68
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.c
@@ -0,0 +1,448 @@
+/*
+ * 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/monitor-cfg.c,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#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);
+static int string_to_parser_range(char*, parser_range*, int);
+#define PARSER_RANGE_SIZE 256
+/* string must have at least 256 bytes */
+static int parser_range_to_string(char*, parser_range*, int);
+
+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",
+};
+
+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",
+};
+
+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 {
+ ++nmonitors;
+ XmuSnprintf(monitor_name, sizeof(monitor_name),
+ "Monitor%d", 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);
+}
+
+static 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;
+ 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;
+ }
+ 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);
+}
+
+static 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, 0);
+ viewport = XtCreateManagedWidget("hviewport", viewportWidgetClass,
+ layout, NULL, 0);
+ hlist = XtVaCreateManagedWidget("hlist", listWidgetClass, viewport,
+ XtNlist, hmodes,
+ XtNnumberStrings, sizeof(hmodes) /
+ sizeof(hmodes[0]), NULL, 0);
+ XtAddCallback(hlist, XtNcallback, MonitorHsyncCallback, NULL);
+
+ XtCreateManagedWidget("vlabel", labelWidgetClass, layout, NULL, 0);
+ vsync = XtVaCreateManagedWidget("vsync", asciiTextWidgetClass, layout,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+ viewport = XtCreateManagedWidget("vviewport", viewportWidgetClass,
+ layout, NULL, 0);
+ vlist = XtVaCreateManagedWidget("vlist", listWidgetClass, viewport,
+ XtNlist, vmodes,
+ XtNnumberStrings, sizeof(vmodes) /
+ sizeof(vmodes[0]), NULL, 0);
+ 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, 0);
+ 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(&current, 1, NULL, NULL, &layout, 1);
+ current = layout;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h
new file mode 100644
index 000000000..8265e4340
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor-cfg.h
@@ -0,0 +1,44 @@
+/*
+ * 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/monitor-cfg.h,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#include "config.h"
+
+#ifndef _xf86cfg_monitor_h
+#define _xf86cfg_monitor_h
+
+/*
+ * Prototypes
+ */
+XtPointer MonitorConfig(XtPointer);
+void MonitorLayout(XF86SetupInfo*);
+void MonitorVidtune(XF86SetupInfo*);
+
+#endif /* _xf86cfg_monitor_h */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xbm
new file mode 100644
index 000000000..c4b01eb74
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xbm,v 1.1 2000/04/04 22:37:00 dawes Exp $
+ */
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xpm b/xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xpm
new file mode 100644
index 000000000..c694edf2e
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/monitor.xpm,v 1.1 2000/04/04 22:37:00 dawes Exp $
+ */
+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/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c
new file mode 100644
index 000000000..db4435596
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.c
@@ -0,0 +1,431 @@
+/*
+ * 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/mouse-cfg.c,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#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>
+
+/*
+ * Prootypes
+ */
+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 char *protocols[] = {
+ "Auto",
+ "BusMouse",
+ "GlidePoint",
+ "IntelliMouse",
+ "Logitech",
+ "Microsoft",
+ "MMHitTab",
+ "MMSeries",
+ "MouseMan",
+ "MouseSystems",
+ "PS/2",
+ "SysMouse",
+ "ThinkingMouse",
+};
+
+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 {
+ ++nmouses;
+ XmuSnprintf(mouse_name, sizeof(mouse_name), "Mouse%d", 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)call_data;
+}
+
+/* This function does not yet work in 4.0 */
+static void
+MouseApplyCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ XF86MiscMouseSettings mouse;
+
+ XF86MiscGetMouseSettings(XtDisplay(w), &mouse);
+ XtFree(mouse.device);
+
+ if (strcmp(protocol, "BusMouse") == 0)
+ mouse.type = MTYPE_BUSMOUSE;
+ else if (strcmp(protocol, "GlidePoint") == 0)
+ mouse.type = MTYPE_GLIDEPOINT;
+ else if (strcmp(protocol, "IntelliMouse") == 0)
+ mouse.type = MTYPE_IMSERIAL;
+ else if (strcmp(protocol, "Logitech") == 0)
+ mouse.type = MTYPE_LOGITECH;
+ else if (strcmp(protocol, "Microsoft") == 0)
+ mouse.type = MTYPE_MICROSOFT;
+ else if (strcmp(protocol, "MMHitTab") == 0)
+ mouse.type = MTYPE_MMHIT;
+ else if (strcmp(protocol, "MMSeries") == 0)
+ mouse.type = MTYPE_MMSERIES;
+ else if (strcmp(protocol, "MouseMan") == 0)
+ mouse.type = MTYPE_LOGIMAN;
+ else if (strcmp(protocol, "MouseSystems") == 0)
+ mouse.type = MTYPE_MOUSESYS;
+ else if (strcmp(protocol, "PS/2") == 0)
+ mouse.type = MTYPE_PS_2;
+ else if (strcmp(protocol, "SysMouse") == 0)
+ mouse.type = MTYPE_SYSMOUSE;
+ else if (strcmp(protocol, "ThinkingMouse") == 0)
+ mouse.type = MTYPE_THINKING;
+ else
+ mouse.type = MTYPE_AUTOMOUSE;
+
+ mouse.emulate3buttons = emulate;
+ mouse.flags |= MF_REOPEN;
+
+ /* This was not working in 3.3 */
+ 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 *patterns[] = {
+ "cua",
+ "mouse",
+ "ps",
+ "sysmouse",
+ "ttyS",
+ };
+ Arg args[2];
+ int i;
+
+ if (first) {
+ Widget label, viewport;
+ struct dirent *ent;
+ DIR *dir;
+
+ first = 0;
+
+ mouse_dp = XtCreateWidget("mouseDP", formWidgetClass,
+ configp, NULL, 0);
+
+ /* DEVICE */
+ if ((dir = opendir("/dev")) != NULL) {
+ int i, len;
+
+ (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) + 6;
+
+ devices = (char**)XtRealloc((XtPointer)devices,
+ sizeof(char*) * ++ndevices);
+ devices[ndevices - 1] = XtMalloc(len);
+ XmuSnprintf(devices[ndevices - 1], len, "/dev/%s",
+ ent->d_name);
+ }
+ }
+ }
+ closedir(dir);
+ }
+
+ label = XtCreateManagedWidget("labelD", labelWidgetClass,
+ mouse_dp, NULL, 0);
+ text = XtVaCreateManagedWidget("device", asciiTextWidgetClass,
+ mouse_dp,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+ viewport = XtCreateManagedWidget("viewportD", viewportWidgetClass,
+ mouse_dp, NULL, 0);
+
+ listD = XtVaCreateManagedWidget("listD", listWidgetClass,
+ viewport,
+ XtNlist, devices,
+ XtNnumberStrings, ndevices,
+ NULL, 0);
+ XtAddCallback(listD, XtNcallback, MouseDeviceCallback, (XtPointer)text);
+
+ /* PROTOCOL */
+ label = XtCreateManagedWidget("labelP", labelWidgetClass,
+ mouse_dp, NULL, 0);
+ viewport = XtCreateManagedWidget("viewportP", viewportWidgetClass,
+ mouse_dp, NULL, 0);
+
+ listP = XtVaCreateManagedWidget("listP", listWidgetClass,
+ viewport,
+ XtNlist, protocols,
+ XtNnumberStrings,
+ sizeof(protocols) / sizeof(protocols[0]),
+ NULL, 0);
+ XtAddCallback(listP, XtNcallback, MouseProtocolCallback, NULL);
+
+ emul3 = XtCreateManagedWidget("emulate3", toggleWidgetClass,
+ mouse_dp, NULL, 0);
+ 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]) == 0) {
+ protocol = protocols[i];
+ XawListHighlight(listP, i);
+ break;
+ }
+ }
+ else {
+ /* "Auto" is the default */
+ protocol = protocols[0];
+ XawListHighlight(listP, 0);
+ }
+
+ XtSetArg(args[0], XtNstate, emulate);
+ XtSetValues(emul3, args, 1);
+
+ XtChangeManagedSet(&current, 1, NULL, NULL, &mouse_dp, 1);
+ current = mouse_dp;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.h
new file mode 100644
index 000000000..249f50840
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse-cfg.h
@@ -0,0 +1,44 @@
+/*
+ * 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/mouse-cfg.h,v 1.1 2000/04/04 22:37:00 dawes Exp $
+ */
+
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xbm
new file mode 100644
index 000000000..8577137e6
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xbm,v 1.1 2000/04/04 22:37:01 dawes Exp $
+ */
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xpm b/xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xpm
new file mode 100644
index 000000000..7ad21fb8f
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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: xc/programs/Xserver/hw/xfree86/xf86cfg/mouse.xpm,v 1.1 2000/04/04 22:37:01 dawes Exp $
+ */
+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/xc/programs/Xserver/hw/xfree86/xf86cfg/narrower.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/narrower.xbm
new file mode 100644
index 000000000..0649ef8b4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/options.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/options.c
new file mode 100644
index 000000000..2381fb623
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/options.c
@@ -0,0 +1,284 @@
+/*
+ * 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/options.c,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#include "options.h"
+#include "xf86config.h"
+#include <X11/Shell.h>
+#include <X11/Xaw/AsciiText.h>
+#include <X11/Xaw/List.h>
+#include <X11/Xaw/Command.h>
+#include <X11/Xaw/Paned.h>
+#include <X11/Xaw/Viewport.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);
+
+/*
+ * Initialization
+ */
+static XF86OptionPtr *options;
+static Widget shell, add, remov, update, list, name, value;
+static char *option_str;
+static int option_index, popped = False;
+
+/*
+ * Implementation
+ */
+void
+OptionsPopup(XF86OptionPtr *opts)
+{
+ static int first = 1;
+
+ option_str = NULL;
+ options = opts;
+ if (first) {
+ Widget pane, form, viewport, bottom, popdown;
+
+ first = 0;
+
+ shell = XtCreatePopupShell("options", transientShellWidgetClass,
+ toplevel, NULL, 0);
+ pane = XtCreateManagedWidget("pane", panedWidgetClass,
+ shell, 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);
+ form = XtCreateManagedWidget("form", formWidgetClass,
+ pane, NULL, 0);
+ XtVaCreateManagedWidget("label1", labelWidgetClass, form,
+ XtNlabel, " Option \"",
+ NULL, 0);
+ name = XtVaCreateManagedWidget("name", asciiTextWidgetClass, form,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+ XtVaCreateManagedWidget("label2", labelWidgetClass,
+ form,
+ XtNlabel, "\" \"",
+ NULL, 0);
+ value = XtVaCreateManagedWidget("value", asciiTextWidgetClass, form,
+ XtNeditType, XawtextEdit,
+ NULL, 0);
+ XtVaCreateManagedWidget("label3", labelWidgetClass, form,
+ XtNlabel, "\" ",
+ NULL, 0);
+ 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);
+ popdown = XtCreateManagedWidget("popdown", commandWidgetClass,
+ bottom, NULL, 0);
+ XtAddCallback(popdown, XtNcallback, PopdownCallback, NULL);
+ XtRealizeWidget(shell);
+ XSetWMProtocols(DPY, XtWindow(shell), &wm_delete_window, 1);
+ }
+
+ UpdateOptionList();
+ popped = True;
+ XtPopup(shell, XtGrabExclusive);
+
+ while (popped)
+ XtAppProcessEvent(XtWidgetToApplicationContext(shell), 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(shell);
+ 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();
+}
+
+/*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);
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/options.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/options.h
new file mode 100644
index 000000000..0ab081f79
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/options.h
@@ -0,0 +1,38 @@
+/*
+ * 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/options.h,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#include "config.h"
+
+/*
+ * Prototypes
+ */
+void OptionsPopup(XF86OptionPtr*);
+void OptionsCancelAction(Widget, XEvent*, String*, Cardinal*);
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/right.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/right.xbm
new file mode 100644
index 000000000..a2f2ce2d1
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c
new file mode 100644
index 000000000..8a6c514be
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.c
@@ -0,0 +1,439 @@
+/*
+ * 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/screen-cfg.c,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#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>
+
+#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 RotateCallback(Widget, XtPointer, XtPointer);
+
+/*
+ * Initialization
+ */
+static char *standard_modes[] = {
+ "640x400",
+ "640x480",
+ "800x600",
+ "1024x768",
+ "1280x1024",
+ "320x200",
+ "320x240",
+ "400x300",
+ "1152x864",
+ "1600x1200",
+ "1800x1400",
+ "512x384",
+};
+
+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)
+ 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, 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)
+ addListItem((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) {
+ XF86OptionPtr option;
+ 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 = (int)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);
+ unsel_index = -1;
+}
+
+/*ARGSUSED*/
+static void
+UnselectCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ Arg args[2];
+
+ if (unsel_index < 0 || unsel_index >= ndefmodes)
+ return;
+
+ 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);
+ unsel_index = -1;
+}
+
+/*ARGSUSED*/
+void
+RotateCallback(Widget w, XtPointer user_data, XtPointer call_data)
+{
+ if (call_data != NULL)
+ rotate = (int)user_data;
+ else
+ rotate = 0;
+}
+
+void
+ScreenDialog(XF86SetupInfo *info)
+{
+ static Widget dialog, d1, d4, d8, d16, d24, cw, ccw;
+ Arg args[2];
+ XF86ConfMonitorPtr mon = screen->scrn_monitor;
+ XF86ConfModeLinePtr mline = mon != NULL ? mon->mon_modeline_lst : NULL;
+ int i;
+
+ 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, 0);
+ XtAddCallback(d4, XtNcallback, DepthCallback, (XtPointer)4);
+ d8 = XtVaCreateManagedWidget("8", toggleWidgetClass, dialog,
+ XtNradioGroup, d4, NULL, 0);
+ XtAddCallback(d8, XtNcallback, DepthCallback, (XtPointer)8);
+ d16 = XtVaCreateManagedWidget("16", toggleWidgetClass, dialog,
+ XtNradioGroup, d8, NULL, 0);
+ XtAddCallback(d16, XtNcallback, DepthCallback, (XtPointer)16);
+ d24 = XtVaCreateManagedWidget("24", toggleWidgetClass, dialog,
+ XtNradioGroup, d16, NULL, 0);
+ 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);
+ viewport = XtCreateManagedWidget("viewR", viewportWidgetClass, dialog,
+ NULL, 0);
+ listR = XtCreateManagedWidget("listRight", listWidgetClass, viewport,
+ NULL, 0);
+ XtAddCallback(listR, XtNcallback, UnselectIndexCallback, NULL);
+
+ 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, 0);
+ XtAddCallback(ccw, XtNcallback, RotateCallback, (XtPointer)CCW);
+
+ XtRealizeWidget(dialog);
+ }
+
+ if (rotate == CW) {
+ XtVaSetValues(cw, XtNstate, True, NULL, 0);
+ XtVaSetValues(ccw, XtNstate, False, NULL, 0);
+ }
+ else if (rotate == CCW) {
+ XtVaSetValues(cw, XtNstate, False, NULL, 0);
+ XtVaSetValues(ccw, XtNstate, True, NULL, 0);
+ }
+ else {
+ XtVaSetValues(cw, XtNstate, False, NULL, 0);
+ XtVaSetValues(ccw, XtNstate, False, NULL, 0);
+ }
+
+ 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(&current, 1, NULL, NULL, &dialog, 1);
+ current = dialog;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.h
new file mode 100644
index 000000000..a152f6188
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen-cfg.h
@@ -0,0 +1,44 @@
+/*
+ * 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/screen-cfg.h,v 1.2 2000/05/18 16:29:59 dawes Exp $
+ */
+
+#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/xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c
new file mode 100644
index 000000000..36b8ce5cb
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen.c
@@ -0,0 +1,978 @@
+/*
+ * 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/screen.c,v 1.3 2000/06/13 23:15:52 dawes Exp $
+ */
+
+#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*);
+
+/*
+ * 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
+CreateScreenWidget(xf86cfgScreen *screen)
+{
+ static char *Rotate = "Rotate", *_CW = "CW", *_CCW = "CCW";
+ int rotate = 0;
+ XF86OptionPtr option, options;
+ Widget w = XtCreateWidget("screen", simpleWidgetClass,
+ XtParent(computer.cpu), NULL, 0);
+
+ /* When this function is called, the monitor and card fields should have
+ * been already set.
+ */
+
+ /* 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;
+
+ 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 {
+ ++nscreens;
+ XmuSnprintf(screen_name, sizeof(screen_name), "Screen%d",
+ 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)
+ addListItem((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, x, y, 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, *topscr, *botscr, *lefscr, *rigscr;
+
+ for (i = 0; i < computer.num_screens; i++)
+ if (computer.screens[i]->screen == adj->adj_screen)
+ break;
+ 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;
+ topscr = computer.screens[i];
+ }
+ else
+ topscr = NULL;
+
+ if (adj->adj_bottom != NULL) {
+ for (i = 0; i < computer.num_screens; i++)
+ if (computer.screens[i]->screen == adj->adj_bottom)
+ break;
+ botscr = computer.screens[i];
+ }
+ else
+ botscr = NULL;
+
+ if (adj->adj_left != NULL) {
+ for (i = 0; i < computer.num_screens; i++)
+ if (computer.screens[i]->screen == adj->adj_left)
+ break;
+ lefscr = computer.screens[i];
+ }
+ else
+ lefscr = NULL;
+
+ if (adj->adj_right != NULL) {
+ for (i = 0; i < computer.num_screens; i++)
+ if (computer.screens[i]->screen == adj->adj_right)
+ break;
+ rigscr = computer.screens[i];
+ }
+ else
+ rigscr = NULL;
+
+ 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;
+ 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;
+
+ 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);
+}
+
+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, 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/xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h
new file mode 100644
index 000000000..c0e30923c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/screen.h,v 1.2 2000/05/18 16:30:00 dawes Exp $
+ */
+
+#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 AdjustScreenUI(void);
+void UpdateScreenUI(void);
+
+#endif /* _xf86cfg_screen_h */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/shorter.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/shorter.xbm
new file mode 100644
index 000000000..878f219d4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c
new file mode 100644
index 000000000..9748fd870
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/startx.c
@@ -0,0 +1,119 @@
+/*
+ * 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/startx.c,v 1.2 2000/05/18 16:30:00 dawes Exp $
+ */
+
+#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];
+
+ if (system("XFree86 :8 -configure") != 0) {
+ fprintf(stderr, "Failed to run \"XFree86 -configure\".\n");
+ exit(1);
+ }
+
+ if ((home = getenv("HOME")) == NULL)
+ home = "/";
+
+ XmuSnprintf(filename, sizeof(filename), "%s/XF86Config.new", home);
+
+ /* 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];
+
+ XmuSnprintf(path, sizeof(path), "%s/bin/XFree86", XFree86Dir);
+ execl(path, "X", ":8", /*"+xinerama",*/ "+accessx","-allowMouseOpenFail",
+ "-xf86config", XF86Config_path, 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/xc/programs/Xserver/hw/xfree86/xf86cfg/taller.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/taller.xbm
new file mode 100644
index 000000000..c779300ea
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/up.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/up.xbm
new file mode 100644
index 000000000..64f8f9ec4
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c
new file mode 100644
index 000000000..a7ddd3e27
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.c
@@ -0,0 +1,1236 @@
+/*
+ * 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/vidmode.c,v 1.1 2000/05/18 16:30:00 dawes Exp $
+ */
+
+/*
+ * Most of the code here is based on the xvidtune code.
+ */
+
+#include "vidmode.h"
+#include <X11/extensions/Xinerama.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);
+
+/*
+ * 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 Bool S3Specials;
+static int invert_vclk, blank1, blank2, early_sc, screenno;
+static int (*XtErrorFunc)(Display*, XErrorEvent*);
+static Widget labels[VSYNC + 1], values[VSYNC + 1], repeater, monitor,
+ monitorb, add, text, vesab, vesap, forceshell, testshell;
+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 {
+ 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;
+ }
+ }
+
+ vtune = XtCreateWidget("vidtune", formWidgetClass,
+ work, NULL, 0);
+
+ vesab = XtVaCreateManagedWidget("vesaB", menuButtonWidgetClass, vtune,
+ XtNmenuName, "vesaP", NULL, 0);
+ 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);
+ menu = XtCreatePopupShell("menu", simpleMenuWidgetClass, 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)i);
+ if (i == 0) {
+ screenb = XtVaCreateManagedWidget("screenB", menuButtonWidgetClass,
+ vtune,
+ XtNmenuName, "screenP",
+ XtNlabel, name,
+ NULL, 0);
+ }
+ }
+ XtRealizeWidget(screenp);
+ monitor = XtCreatePopupShell("monitorP", simpleMenuWidgetClass,
+ vtune, NULL, 0);
+
+ 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++) {
+ labels[i] = 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 = XtVaCreateManagedWidget("ident", menuButtonWidgetClass, vtune,
+ XtNmenuName, "monitorP", NULL, 0);
+ XtCreateManagedWidget("as", labelWidgetClass, vtune, NULL, 0);
+ text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, vtune,
+ XtNeditType, XawtextEdit, NULL, 0);
+
+ XtRealizeWidget(vtune);
+
+ return (True);
+}
+
+void
+VideoModeConfigureStart(void)
+{
+ vidtune = computer.vidmodes[screenno];
+
+ XtSetSensitive(vtune, vidtune != NULL);
+ if (!XtIsManaged(vtune))
+ XtManageChild(vtune);
+ else
+ XtMapWidget(vtune);
+ if (vidtune != NULL) {
+ int i;
+ Arg args[1];
+ Boolean state;
+ XF86ConfMonitorPtr mon;
+
+ 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;
+
+ for (i = 0; i < ((CompositeWidget)monitor)->composite.num_children; i++)
+ XtDestroyWidget(((CompositeWidget)monitor)->composite.children[i]);
+ 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);
+
+ XmuSnprintf(string, sizeof(string), "%dx%d@%d",
+ modeline.hdisplay, modeline.vdisplay,
+ (int)((double)dot_clock / (double)modeline.htotal * 1000.0 /
+ (double)modeline.vtotal));
+ 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)
+{
+ 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 ((int)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);
+ if (modeline.privsize != 0 && modeline.private != NULL) {
+ S3Specials = True;
+ invert_vclk = modeline.private[1];
+ blank1 = modeline.private[2] & 7;
+ blank2 = (modeline.private[2] >> 4) & 7;
+ early_sc = modeline.private[3];
+ }
+ else
+ S3Specials = 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)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 = (int)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);
+
+ XmuSnprintf(label, sizeof(label), "%dx%d @ %d Hz",
+ modeline.hdisplay, modeline.vdisplay,
+ (int)((double)dot_clock / (double)modeline.htotal * 1000.0 /
+ (double)modeline.vtotal));
+ 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 = (int)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;
+
+ memcpy(&mode, &vesa->info, sizeof(XF86VidModeModeInfo));
+ if (XF86VidModeAddModeLine(XtDisplay(toplevel), vidtune->screen,
+ &vesa->info, &mode)) {
+ XSync(XtDisplay(toplevel), False);
+ GetModes();
+ }
+ else
+ XBell(XtDisplay(w), 80);
+}
+
+static void
+GetModes(void)
+{
+ int i;
+ char label[32];
+ Arg args[1];
+
+ XFree(vidtune->infos);
+ XF86VidModeGetAllModeLines(XtDisplay(toplevel), vidtune->screen,
+ &vidtune->num_infos, &vidtune->infos);
+
+ for (i = 0; i < ((CompositeWidget)menu)->composite.num_children; i++)
+ XtDestroyWidget(((CompositeWidget)menu)->composite.children[i]);
+ for (i = 0; i < vidtune->num_infos; i++) {
+ Widget sme;
+
+ 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));
+ sme = XtCreateManagedWidget(label, smeBSBObjectClass, menu, NULL, 0);
+ XtAddCallback(sme, XtNcallback, SelectCallback,
+ (XtPointer)vidtune->infos[i]);
+ }
+
+ XmuSnprintf(label, sizeof(label), "%dx%d @ %d Hz",
+ modeline.hdisplay, modeline.vdisplay,
+ (int)((double)dot_clock / (double)modeline.htotal * 1000.0 /
+ (double)modeline.vtotal));
+ 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 = (int)user_data;
+}
+
+void
+CancelForceAddModeAction(Widget w, XEvent *event,
+ String *params, Cardinal *num_params)
+{
+ PopdownForce(w, (XtPointer)False, NULL);
+}
+
+static int
+ForceAddMode(void)
+{
+ if (forceshell == NULL) {
+ Widget dialog;
+
+ forceshell = XtCreatePopupShell("force", transientShellWidgetClass,
+ toplevel, NULL, 0);
+ dialog = XtVaCreateManagedWidget("dialog", dialogWidgetClass,
+ forceshell, XtNvalue, NULL, NULL, 0);
+ 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);
+}
+
+/*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, 0);
+ 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/xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.h
new file mode 100644
index 000000000..325e62f2d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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>
+ *
+ * $XFree86: xc/programs/Xserver/hw/xfree86/xf86cfg/vidmode.h,v 1.1 2000/05/18 16:30:00 dawes Exp $
+ */
+
+#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 CancelForceAddModeAction(Widget, XEvent*, String*, Cardinal*);
+void CancelTestModeAction(Widget, XEvent*, String*, Cardinal*);
+
+/*
+ * Initialization
+ */
+extern Widget vtune;
+
+#endif /* _xf86cfg_vidmode_h */
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/wider.xbm b/xc/programs/Xserver/hw/xfree86/xf86cfg/wider.xbm
new file mode 100644
index 000000000..5cf87f25a
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/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/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man b/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man
new file mode 100644
index 000000000..6563a02bd
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86cfg.man
@@ -0,0 +1,121 @@
+.\"
+.\" 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.1 2000/06/13 23:15:52 dawes Exp $
+.\"
+.TH xf86cfg 1 "Version 4.0" "XFree86"
+.SH NAME
+xf86cfg - Graphical configuration tool for XFree86 4.0
+.SH SYNOPSIS
+.B xf86cfg
+[-xf86config \fIXF86Config\fP] [-toolkitoption ...]
+.SH DESCRITPION
+.I Xf86cfg
+is a tool to configure \fIXFree86 4.0\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, xf86cfg will run
+the command \fIXFree86 -configure\fP to allow the xserver detect the
+hardware in the computer, and write an initial \fIXF86Config\fP file
+in the user's home directory. Then, it will start XFree86 and allow
+customizations.
+.br
+If the \fBDISPLAY\fP environment variable is set, xf86cfg will read the
+default \fIXF86Config\fP, that may not be the same being used by the current
+server, and allow customizations.
+.PP
+Unless there is an \fBApply\fP button in the current xf86cfg dialog, the
+changes made will take place the next time \fIXFree86\fP is started.
+
+.PP
+Xf86cfg 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 xf86cfg's accessx section.
+
+.SH ENVIRONMENT
+.TP 8
+.I DISPLAY
+Default host and display number
+.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/XF86Config
+Server configuration file
+.TP 8
+.I /etc/X11/XF86Config
+Server configuration file
+.TP 8
+.I /usr/X11R6/etc/XF86Config
+Server configuration file
+.TP 8
+.I <XRoot>/lib/X11/XF86Config.\fIhostname\fP
+Server configuration file
+.TP 8
+.I <XRoot>/lib/X11/XF86Config
+Server configuration file
+.TP 8
+.I <XRoot>/lib/X11/app-default/XF86Cfg
+Specifies xf86cfg resources
+.TP 8
+.I <Xroot>/lib/X11/xkb/X0-config.keyboard
+Keyboard specific configuration
+
+.SH "SEE ALSO"
+.IR XFree86 (1)
+.IR XF86Config (5x)
+
+.SH RESTRICTIONS
+Not all customizable options are available.
+.br
+A protocol for external modules is in the plans.
+
+.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ésar Pereira de Andrade \fI<pcpa@conectiva.com.br>\fP
+The XFree86 Project
+
+.SH BUGS
+Probably.
diff --git a/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c b/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c
new file mode 100644
index 000000000..33c32019c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.c
@@ -0,0 +1,595 @@
+/*
+ * 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/xf86config.c,v 1.2 2000/05/18 16:30:01 dawes Exp $
+ */
+
+#include "xf86config.h"
+
+/*
+ * Implementation
+ */
+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);
+}
+
+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 = 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 = 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);
+ }
+
+
+ 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);
+ }
+
+ XtFree(screen->scrn_identifier);
+ XtFree(screen->scrn_obso_driver);
+ 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
+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/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h b/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h
new file mode 100644
index 000000000..ee8747246
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86cfg/xf86config.h
@@ -0,0 +1,69 @@
+/*
+ * 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/xf86config.h,v 1.2 2000/05/18 16:30:01 dawes Exp $
+ */
+
+#include "config.h"
+
+#define xf86OptionListFree OptionListFree
+#define xf86AddInput(head, ptr) \
+ (XF86ConfInputPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86AddInputref(head, ptr) \
+ (XF86ConfInputrefPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86AddDevice(head, ptr) \
+ (XF86ConfDevicePtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86AddMonitor(head, ptr) \
+ (XF86ConfMonitorPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86AddScreen(head, ptr) \
+ (XF86ConfScreenPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86AddLayout(head, ptr) \
+ (XF86ConfLayoutPtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86AddModeLine(head, ptr) \
+ (XF86ConfModeLinePtr)addListItem((GenericListPtr)(head), (GenericListPtr)(ptr))
+#define xf86NewOption NewOption
+#define xf86addNewOption addNewOption
+#define xf86FindOption FindOption
+
+int ErrorF(const char*, ...);
+int VErrorF(const char*, va_list);
+int xf86RemoveOption(XF86OptionPtr*, char*);
+int xf86RemoveInput(XF86ConfigPtr, XF86ConfInputPtr);
+int xf86RemoveInputRef(XF86ConfLayoutPtr, XF86ConfInputPtr);
+int xf86RemoveDevice(XF86ConfigPtr, XF86ConfDevicePtr);
+int xf86RemoveMonitor(XF86ConfigPtr, XF86ConfMonitorPtr);
+int xf86RemoveScreen(XF86ConfigPtr, XF86ConfScreenPtr);
+int xf86RemoveAdjacency(XF86ConfLayoutPtr, XF86ConfAdjacencyPtr);
+int xf86RemoveInactive(XF86ConfLayoutPtr, XF86ConfInactivePtr);
+int xf86RemoveLayout(XF86ConfigPtr, XF86ConfLayoutPtr);
+
+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*);
diff --git a/xc/programs/Xserver/hw/xfree86/xf86config/Cards b/xc/programs/Xserver/hw/xfree86/xf86config/Cards
index 64583135a..940fe2cd7 100644
--- a/xc/programs/Xserver/hw/xfree86/xf86config/Cards
+++ b/xc/programs/Xserver/hw/xfree86/xf86config/Cards
@@ -18,7 +18,7 @@
# 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.67 2000/02/12 02:54:45 dawes Exp $
+# $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Cards,v 3.69 2000/03/31 20:13:40 dawes Exp $
# VGA
@@ -1648,335 +1648,129 @@ UNSUPPORTED
NAME ATI Graphics Ultra
CHIPSET ATI-Mach8
SERVER Mach8
-DRIVER vga
-UNSUPPORTED
-LINE #Probable clocks:
-LINE #Clocks 43 49 80 36 50 56 0 45 30 32 110 79 40 45 75 65
-LINE #Clocks 22 25 46 18 25 28 0 22 15 16 55 40 20 22 38 32
+DRIVER ati
NAME ATI Graphics Ultra Pro
CHIPSET ATI-Mach32
SERVER Mach32
-DRIVER vga
-UNSUPPORTED
-LINE #Probable clocks:
-LINE #Clocks 100 126 92 36 51 57 0 44 135 32 110 80 39
-LINE #Clocks 45 75 65 50 63 46 18 25 28 0 22 67 16 55 40 19 23 37 33
-LINE #Option "dac_8_bit"
+DRIVER ati
NAME ATI Wonder SVGA
CHIPSET ATI vgawonder
SERVER SVGA
-DRIVER vga
-UNSUPPORTED
-LINE #probable clocks:
-LINE #Clocks 30 32 11 80 42 48 92 36 40 45 75 65 50 56 0 0
-LINE #Clocks 15 16 55 0 21 24 46 18 20 22 37 32 25 28 0 0
+DRIVER ati
NAME ATI Ultra Plus
CHIPSET ATI-Mach32
SERVER Mach32
-DRIVER vga
-UNSUPPORTED
+DRIVER ati
NAME ATI Mach32
CHIPSET ATI-Mach32
SERVER Mach32
-DRIVER vga
-UNSUPPORTED
+DRIVER ati
NAME ATI Mach64
CHIPSET ATI-Mach64
SERVER Mach64
-DRIVER vga
-UNSUPPORTED
+DRIVER ati
NOCLOCKPROBE
-NAME ATI Mach64 with ATI68860 RAMDAC
-LINE #Ramdac "ati68860"
-SEE ATI Mach64
-
-NAME ATI Mach64 with ATI68860B RAMDAC
-LINE #Ramdac "ati68860b"
-SEE ATI Mach64
-
-NAME ATI Mach64 with ATI68860C RAMDAC
-LINE #Ramdac "ati68860c"
-SEE ATI Mach64
-
-NAME ATI Mach64 with ATI68875 RAMDAC
-LINE #Ramdac "ati68875"
-SEE ATI Mach64
-
-NAME ATI Mach64 with AT&T 20C408 RAMDAC
-LINE #Ramdac "att20c408"
-SEE ATI Mach64
-
-NAME ATI Mach64 with CH8398 RAMDAC
-LINE #Ramdac "ch8398"
-SEE ATI Mach64
-
-NAME ATI Mach64 with IBM RGB514 RAMDAC
-LINE #Ramdac "ibm_rgb514"
-SEE ATI Mach64
-
-NAME ATI Mach64 with STG1702 RAMDAC
-LINE #Ramdac "stg1702"
-SEE ATI Mach64
-
-NAME ATI Mach64 with STG1703 RAMDAC
-LINE #Ramdac "stg1703"
-SEE ATI Mach64
-
-NAME ATI Mach64 with TLC34075 RAMDAC
-LINE #Ramdac "tlc34075"
-SEE ATI Mach64
-
-NAME ATI Mach64 with Internal RAMDAC
-SEE ATI Mach64
-
NAME ATI Mach64 CT (264CT)
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Mach64 VT (264VT)
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Mach64 GT (264GT), aka 3D RAGE
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Mach64 3D RAGE II
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Mach64 3D RAGE II+DVD
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Mach64 3D Rage IIC
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Mach64 3D Rage Pro
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI 3D Pro Turbo
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI 3D Pro Turbo PC2TV
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI 3D Xpression
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI 3D Xpression+
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI 3D Xpression+ PC2TV
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI All-in-Wonder
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI All-in-Wonder Pro
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Graphics Pro Turbo
SEE ATI Mach64
-NAME ATI Graphics Pro Turbo with ATI68860 RAMDAC
-SEE ATI Mach64 with ATI68860 RAMDAC
-
-NAME ATI Graphics Pro Turbo with ATI68860B RAMDAC
-SEE ATI Mach64 with ATI68860B RAMDAC
-
-NAME ATI Graphics Pro Turbo with ATI68860C RAMDAC
-SEE ATI Mach64 with ATI68860C RAMDAC
-
-NAME ATI Graphics Pro Turbo with ATI68875 RAMDAC
-SEE ATI Mach64 with ATI68875 RAMDAC
-
-NAME ATI Graphics Pro Turbo with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
-
-NAME ATI Graphics Pro Turbo with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
-
-NAME ATI Graphics Pro Turbo with STG1702 RAMDAC
-SEE ATI Mach64 with STG1702 RAMDAC
-
-NAME ATI Graphics Pro Turbo with STG1703 RAMDAC
-SEE ATI Mach64 with STG1703 RAMDAC
-
-NAME ATI Graphics Pro Turbo with TLC34075 RAMDAC
-SEE ATI Mach64 with TLC34075 RAMDAC
-
NAME ATI Graphics Pro Turbo 1600
-SEE ATI Mach64 with IBM RGB514 RAMDAC
+SEE ATI Mach64
NAME ATI Graphics Xpression
SEE ATI Mach64
-NAME ATI Graphics Xpression with ATI68860 RAMDAC
-SEE ATI Mach64 with ATI68860 RAMDAC
-
-NAME ATI Graphics Xpression with ATI68860B RAMDAC
-SEE ATI Mach64 with ATI68860B RAMDAC
-
-NAME ATI Graphics Xpression with ATI68860C RAMDAC
-SEE ATI Mach64 with ATI68860C RAMDAC
-
-NAME ATI Graphics Xpression with ATI68875 RAMDAC
-SEE ATI Mach64 with ATI68875 RAMDAC
-
-NAME ATI Graphics Xpression with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
-
-NAME ATI Graphics Xpression with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
-
-NAME ATI Graphics Xpression with STG1702 RAMDAC
-SEE ATI Mach64 with STG1702 RAMDAC
-
-NAME ATI Graphics Xpression with STG1703 RAMDAC
-SEE ATI Mach64 with STG1703 RAMDAC
-
-NAME ATI Graphics Xpression with TLC34075 RAMDAC
-SEE ATI Mach64 with TLC34075 RAMDAC
-
-NAME ATI Graphics Xpression with Mach64 CT (264CT)
-SEE ATI Mach64 with Internal RAMDAC
-
NAME ATI Video Boost
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Video Charger
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Video Xpression
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Video Xpression+
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI WinBoost
SEE ATI Mach64
-NAME ATI WinBoost with ATI68860 RAMDAC
-SEE ATI Mach64 with ATI68860 RAMDAC
-
-NAME ATI WinBoost with ATI68860B RAMDAC
-SEE ATI Mach64 with ATI68860B RAMDAC
-
-NAME ATI WinBoost with ATI68860C RAMDAC
-SEE ATI Mach64 with ATI68860C RAMDAC
-
-NAME ATI WinBoost with ATI68875 RAMDAC
-SEE ATI Mach64 with ATI68875 RAMDAC
-
-NAME ATI WinBoost with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
-
-NAME ATI WinBoost with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
-
-NAME ATI WinBoost with STG1702 RAMDAC
-SEE ATI Mach64 with STG1702 RAMDAC
-
-NAME ATI WinBoost with STG1703 RAMDAC
-SEE ATI Mach64 with STG1703 RAMDAC
-
-NAME ATI WinBoost with TLC34075 RAMDAC
-SEE ATI Mach64 with TLC34075 RAMDAC
-
-NAME ATI WinBoost with Mach64 CT (264CT)
-SEE ATI Mach64 with Internal RAMDAC
-
NAME ATI WinCharger
SEE ATI Mach64
-NAME ATI WinCharger with ATI68860 RAMDAC
-SEE ATI Mach64 with ATI68860 RAMDAC
-
-NAME ATI WinCharger with ATI68860B RAMDAC
-SEE ATI Mach64 with ATI68860B RAMDAC
-
-NAME ATI WinCharger with ATI68860C RAMDAC
-SEE ATI Mach64 with ATI68860C RAMDAC
-
-NAME ATI WinCharger with ATI68875 RAMDAC
-SEE ATI Mach64 with ATI68875 RAMDAC
-
-NAME ATI WinCharger with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
-
-NAME ATI WinCharger with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
-
-NAME ATI WinCharger with STG1702 RAMDAC
-SEE ATI Mach64 with STG1702 RAMDAC
-
-NAME ATI WinCharger with STG1703 RAMDAC
-SEE ATI Mach64 with STG1703 RAMDAC
-
-NAME ATI WinCharger with TLC34075 RAMDAC
-SEE ATI Mach64 with TLC34075 RAMDAC
-
-NAME ATI WinCharger with Mach64 CT (264CT)
-SEE ATI Mach64 with Internal RAMDAC
-
NAME ATI WinTurbo
SEE ATI Mach64
-NAME ATI WinTurbo with ATI68860 RAMDAC
-SEE ATI Mach64 with ATI68860 RAMDAC
-
-NAME ATI WinTurbo with ATI68860B RAMDAC
-SEE ATI Mach64 with ATI68860B RAMDAC
-
-NAME ATI WinTurbo with ATI68860C RAMDAC
-SEE ATI Mach64 with ATI68860C RAMDAC
-
-NAME ATI WinTurbo with ATI68875 RAMDAC
-SEE ATI Mach64 with ATI68875 RAMDAC
-
-NAME ATI WinTurbo with AT&T 20C408 RAMDAC
-SEE ATI Mach64 with AT&T 20C408 RAMDAC
-
-NAME ATI WinTurbo with CH8398 RAMDAC
-SEE ATI Mach64 with CH8398 RAMDAC
-
-NAME ATI WinTurbo with STG1702 RAMDAC
-SEE ATI Mach64 with STG1702 RAMDAC
-
-NAME ATI WinTurbo with STG1703 RAMDAC
-SEE ATI Mach64 with STG1703 RAMDAC
-
-NAME ATI WinTurbo with TLC34075 RAMDAC
-SEE ATI Mach64 with TLC34075 RAMDAC
-
-NAME ATI WinTurbo with Mach64 CT (264CT)
-SEE ATI Mach64 with Internal RAMDAC
-
NAME ATI Xpert 98
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Xpert XL
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Xpert@Play
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Xpert@Play 98
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI Xpert@Work
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ATI integrated on Intel Maui MU440EX motherboard
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ASUS PCI-V264CT
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
NAME ASUS PCI-AV264CT
-SEE ATI Mach64 with Internal RAMDAC
+SEE ATI Mach64
# AGX
@@ -2797,6 +2591,12 @@ SERVER SVGA
DRIVER nv
NOCLOCKPROBE
+NAME NVIDIA GeForce
+CHIPSET GeForce
+SERVER SVGA
+DRIVER nv
+NOCLOCKPROBE
+
NAME ELSA VICTORY ERAZOR
SEE RIVA128
diff --git a/xc/programs/Xserver/hw/xfree86/xf86config/Imakefile b/xc/programs/Xserver/hw/xfree86/xf86config/Imakefile
index c2d16b3ac..01982ae13 100644
--- a/xc/programs/Xserver/hw/xfree86/xf86config/Imakefile
+++ b/xc/programs/Xserver/hw/xfree86/xf86config/Imakefile
@@ -1,4 +1,4 @@
-XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Imakefile,v 3.6 1996/12/23 07:04:41 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/Imakefile,v 3.7 2000/04/05 18:14:00 dawes Exp $
@@ -13,10 +13,16 @@ XCOMM $XConsortium: Imakefile /main/5 1996/02/21 18:12:46 kaleb $
CARDDBFILE = $(LIBDIR)/Cards
DEFINES = -DCARD_DATABASE_FILE='"$(CARDDBFILE)"'
+#if !defined(OS2Architecture)
AllTarget(ProgramTargetName(xf86config))
NormalProgramTarget(xf86config,$(OBJS),$(DEPLIBS),$(LOCAL_LIBRARIES),NullParameter)
InstallProgram(xf86config,$(BINDIR))
+#else
+all::
+
+InstallNamedProg(xf86config.cmd,xf86config.cmd,$(BINDIR))
+#endif
DependTarget()
InstallNonExecFile(Cards,$(LIBDIR))
diff --git a/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c b/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c
index 3023be71c..7b7617e39 100644
--- a/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c
+++ b/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c,v 3.51 2000/01/23 05:24:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.c,v 3.53 2000/06/14 00:16:13 dawes Exp $ */
/*
* This is a configuration program that will create a base XF86Config
@@ -180,6 +180,7 @@ int config_xkbdisable = 0;
char *config_xkbrules;
char *config_xkbmodel;
char *config_xkblayout;
+char *config_xkbcompat;
char *config_depth;
char *temp_dir = "";
@@ -546,31 +547,33 @@ static char *xkblayouttext =
static struct xkb_layout_str {
char *layout;
char *desc;
+ char *compat;
} xkb_layout_list[] = {
- { "us", "U.S. English" },
- { "en_US", "U.S. English w/ISO9995-3" },
- { "be", "Belgian" },
- { "bg", "Bulgarian" },
- { "ca", "Canadian" },
- { "cs", "Czechoslovakian" },
- { "de", "German" },
- { "de_CH", "Swiss German" },
- { "dk", "Danish" },
- { "es", "Spanish" },
- { "fi", "Finnish" },
- { "fr", "French" },
- { "fr_CH", "Swiss French" },
- { "gb", "United Kingdom" },
- { "hu", "Hungarian" },
- { "it", "Italian" },
- { "jp", "Japanese" },
- { "no", "Norwegian" },
- { "pl", "Polish" },
- { "pt", "Portugese" },
- { "ru", "Russian" },
- { "se", "Swedish" },
- { "th", "Thai" },
- { "nec/jp", "PC-98xx Series" },
+ { "us", "U.S. English", ""},
+ { "en_US", "U.S. English w/ISO9995-3", "" },
+ { "be", "Belgian", "" },
+ { "bg", "Bulgarian", "" },
+ { "ca", "Canadian", "" },
+ { "czsk(cz_us_qwertz)", "Czech", "group_led" },
+ { "de", "German", "" },
+ { "de_CH", "Swiss German", "" },
+ { "dk", "Danish", "" },
+ { "es", "Spanish", "" },
+ { "fi", "Finnish", "" },
+ { "fr", "French", "" },
+ { "fr_CH", "Swiss French", "" },
+ { "gb", "United Kingdom", "" },
+ { "hu", "Hungarian", "" },
+ { "it", "Italian", "" },
+ { "jp", "Japanese", "" },
+ { "no", "Norwegian", "" },
+ { "pl", "Polish", "" },
+ { "pt", "Portugese", "" },
+ { "ru", "Russian", "" },
+ { "czsk(sk_us_qwertz)", "Slovak", "group_led" },
+ { "se", "Swedish", "" },
+ { "th", "Thai", "" },
+ { "nec/jp", "PC-98xx Series", "" },
};
static int nlayouts = sizeof(xkb_layout_list)/sizeof(struct xkb_layout_str);
@@ -640,6 +643,9 @@ keyboard_configuration(void)
config_xkblayout = Malloc(strlen(xkb_layout_list[xkblayout].layout)+1);
sprintf(config_xkblayout,"%s", xkb_layout_list[xkblayout].layout);
+ config_xkbcompat = Malloc(strlen(xkb_layout_list[xkblayout].compat)+1);
+ sprintf(config_xkbcompat,"%s", xkb_layout_list[xkblayout].compat);
+
return;
}
@@ -1123,7 +1129,7 @@ static char *modestring[NU_MODESTRINGS] = {
#ifdef __EMX__
/* yet another instance of this code, sigh! */
-static char *
+char *
__XOS2RedirRoot(char *path, char sep)
{
static char pn[300];
@@ -2295,6 +2301,8 @@ write_XF86Config(char *filename)
config_xkbmodel);
fprintf(f, " Option \"XkbLayout\" \"%s\"\n",
config_xkblayout);
+ fprintf(f, " Option \"XkbCompat\" \"%s\"\n",
+ config_xkbcompat);
fprintf(f, "%s",keyboardlastchunk_text);
diff --git a/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cmd b/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cmd
new file mode 100644
index 000000000..e8e95e010
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cmd
@@ -0,0 +1,99 @@
+/* OS/2 REXX */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86config/xf86config.cmd,v 1.1 2000/04/05 18:14:01 dawes Exp $ */
+
+call RxFuncAdd 'SysCls','RexxUtil','SysCls'
+
+env = 'OS2ENVIRONMENT'
+home= VALUE('HOME',,env)
+bootdrv= LEFT(VALUE('SYSTEM_INI',,env),2)
+x11root= TRANSLATE(VALUE('X11ROOT',,env),'\','/')
+editor= VALUE('EDITOR',,env)
+if editor = '' then
+ editor = 'epm'
+
+call SysCls
+if \(exists(home'\XF86Config.new')) then
+do
+ say "This script will create a default XF86Config file. This is"
+ say "done by running the XFree86-4.0 server's configuration feature."
+ say " "
+
+ call configx86
+end
+
+do until cmd=7
+ call SysCls
+ say "XFree86 created a default config file at "home"\XF86Config.new."
+ say " "
+ say "You may now either:"
+ say " 1. View the logfile"
+ say " 2. Start the graphical configuration tool (alpha version)"
+ say " 3. Start the X server with the default file"
+ say " 4. Edit the config file manually, using the "editor" editor"
+ say " 5. Copy the config file to the standard location"
+ say " 6. Re-run X Server for configuration"
+ say " 7. Exit this program."
+ parse pull cmd
+ select
+ when cmd=1 then do
+ call show_file
+ end
+ when cmd=2 then do
+ "xinit xf86cfg -xf86config "home"\XF86Config.new -- :0"
+ end
+ when cmd=3 then do
+ "xfree86 -xf86config "home"\XF86Config.new"
+ end
+ when cmd=4 then do
+ editor" "home"\XF86Config.new"
+ end
+ when cmd=5 then do
+ say "Copying file to "x11root"\lib\X11\XF86Config"
+ "copy "home"\XF86Config.new "x11root"\XFree86\lib\X11\XF86Config"
+ end
+ when cmd=6 then do
+ call configx86
+ end
+ when cmd=7 then do
+ say "Exiting from xf86config"
+ exit
+ end
+ otherwise
+ say "***ERROR*** Please enter a number from 1..7!"
+ say " "
+ end
+end
+exit
+
+configx86:
+ say "ATTENTION! If in the following the screen becomes blank or does not"
+ say "change for a minute (be patient), something went wrong -"
+ say "please reboot then (CTRL-ALT-DEL)"
+ say ""
+ say "Press RETURN to start the configuration process"
+ pull input
+ 'xfree86 -configure'
+ return
+
+show_file:
+ file=bootdrv"\xf86log.os2"
+ i=0
+ call SysCls
+ do until stream(file,s)="NOTREADY"
+ say linein(file)
+ i = i+1
+ if i = 20 then do
+ say " "
+ say "Press Return for next page"
+ pull input
+ i = 0
+ call SysCls
+ end
+ end
+ return
+
+/* returns 1, if file exists */
+exists:
+ 'DIR "'arg(1)'" >nul 2>&1'
+ IF rc = 0 THEN return 1
+ RETURN 0
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c b/xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c
index 2e152addc..956470bdc 100644
--- a/xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c,v 1.6 1999/09/25 14:38:19 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32bpp/xf86overlay.c,v 1.8 2000/03/25 20:14:43 mvojkovi Exp $ */
/*
Copyright (C) 1998. The XFree86 Project Inc.
@@ -22,6 +22,9 @@
#include "colormapst.h"
#include "cfb8_32.h"
+#define IS_DIRTY 1
+#define IS_SHARED 2
+
/** Screen Functions **/
static Bool OverlayCloseScreen (int, ScreenPtr);
@@ -177,7 +180,7 @@ typedef struct {
typedef struct {
PixmapPtr pix32;
- Bool dirty;
+ CARD32 dirty;
} OverlayPixmapRec, *OverlayPixmapPtr;
@@ -251,7 +254,7 @@ static unsigned long OverlayGeneration = 0;
pGCPriv->wrapOps = pGC->ops;\
pGC->funcs = &OverlayGCFuncs;\
pGC->ops = &PixmapGCOps;\
- pPixPriv->dirty = TRUE
+ pPixPriv->dirty |= IS_DIRTY
Bool
@@ -359,7 +362,9 @@ OverlayCreatePixmap(ScreenPtr pScreen, int w, int h, int depth)
if(pPix) {
OverlayPixmapPtr pPriv = OVERLAY_GET_PIXMAP_PRIVATE(pPix);
pPriv->pix32 = NULL;
- pPriv->dirty = TRUE;
+ pPriv->dirty = IS_DIRTY;
+ if(!w || !h)
+ pPriv->dirty |= IS_SHARED;
}
return pPix;
@@ -455,6 +460,11 @@ OverlayPaintWindow(
if(pWin->backgroundState == BackgroundPixmap) {
oldPix = pWin->background.pixmap;
pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
+ /* have to do this here because alot of applications
+ incorrectly assume changes to a pixmap that is
+ a window background go into effect immediatedly */
+ if(pixPriv->dirty & IS_DIRTY)
+ OverlayRefreshPixmap(pWin->background.pixmap);
pWin->background.pixmap = pixPriv->pix32;
}
}
@@ -469,6 +479,8 @@ OverlayPaintWindow(
if((pWin->drawable.depth == 8) && !pWin->borderIsPixel) {
oldPix = pWin->border.pixmap;
pixPriv = OVERLAY_GET_PIXMAP_PRIVATE(oldPix);
+ if(pixPriv->dirty & IS_DIRTY)
+ OverlayRefreshPixmap(pWin->border.pixmap);
pWin->border.pixmap = pixPriv->pix32;
}
@@ -498,7 +510,6 @@ OverlayRefreshPixmap(PixmapPtr pix8)
pix8->drawable.height, 24);
newPix->drawable.depth = 8; /* Bad Mark! Bad Mark! */
pixPriv->pix32 = newPix;
- pixPriv->dirty = TRUE;
}
if(pixPriv->dirty) {
@@ -515,7 +526,7 @@ OverlayRefreshPixmap(PixmapPtr pix8)
pScreenPriv->LockPrivate--;
FreeScratchGC(pGC);
- pixPriv->dirty = FALSE;
+ pixPriv->dirty &= ~IS_DIRTY;
pixPriv->pix32->drawable.serialNumber = NEXT_SERIAL_NUMBER;
}
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32wid/Imakefile b/xc/programs/Xserver/hw/xfree86/xf8_32wid/Imakefile
new file mode 100644
index 000000000..68c965cbd
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32wid/Imakefile
@@ -0,0 +1,33 @@
+XCOMM $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/Imakefile,v 1.1 2000/05/21 01:02:42 mvojkovi Exp $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+
+#if DoLoadableServer
+XFMODSRC = cfb8_32widmodule.c
+XFMODOBJ = cfb8_32widmodule.o
+#endif
+
+SRCS = cfbscrinit.c cfbwindow.c cfbwid.c $(XFMODSRC)
+
+OBJS = cfbscrinit.o cfbwindow.o cfbwid.o $(XFMODOBJ)
+
+INCLUDES = -I. -I$(XF86SRC)/xf1bpp -I$(SERVERSRC)/mfb \
+ -I$(SERVERSRC)/cfb -I$(SERVERSRC)/mi -I$(SERVERSRC)/include \
+ -I$(XF86OSSRC) -I$(XF86COMSRC) \
+ -I$(FONTINCSRC) -I$(XINCLUDESRC)
+
+
+ModuleObjectRule()
+LibraryModuleTarget(xf8_32wid,$(OBJS))
+LintLibraryTarget(xf8_32wid,$(SRCS))
+NormalLintTarget($(LINTDEFS) $(SRCS))
+
+InstallLibraryModule(xf8_32wid,$(MODULEDIR),.)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(xf8_32wid,$(DRIVERSDKMODULEDIR),.)
+
+InstallDriverSDKNonExecFile(cfb8_32wid.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32wid.h b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32wid.h
new file mode 100644
index 000000000..9913c2a6c
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32wid.h
@@ -0,0 +1,93 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32wid.h,v 1.1 2000/05/21 01:02:43 mvojkovi Exp $ */
+
+#ifndef _CFB8_32WID_H
+#define _CFB8_32WID_H
+
+#include "regionstr.h"
+#include "windowstr.h"
+
+typedef struct {
+ unsigned int (*WidGet)(WindowPtr);
+ Bool (*WidAlloc)(WindowPtr);
+ void (*WidFree)(WindowPtr);
+ void (*WidFillBox)(DrawablePtr, DrawablePtr, int, BoxPtr);
+ void (*WidCopyArea)(DrawablePtr, RegionPtr, DDXPointPtr);
+} cfb8_32WidOps;
+
+typedef struct {
+ pointer pix8;
+ int width8;
+ pointer pix32;
+ int width32;
+
+ /* WID information */
+ pointer pixWid;
+ int widthWid;
+ int bitsPerWid;
+ cfb8_32WidOps *WIDOps;
+} cfb8_32WidScreenRec, *cfb8_32WidScreenPtr;
+
+extern int cfb8_32WidScreenPrivateIndex;
+
+Bool
+cfb8_32WidScreenInit (
+ ScreenPtr pScreen,
+ pointer pbits32,
+ pointer pbits8,
+ pointer pbitsWid,
+ int xsize, int ysize,
+ int dpix, int dpiy,
+ int width32,
+ int width8,
+ int widthWid,
+ int bitsPerWid,
+ cfb8_32WidOps *WIDOps
+);
+
+/* cfbwindow.c */
+
+void
+cfb8_32WidPaintWindow (
+ WindowPtr pWin,
+ RegionPtr pRegion,
+ int what
+);
+
+Bool cfb8_32WidCreateWindow(WindowPtr pWin);
+Bool cfb8_32WidDestroyWindow(WindowPtr pWin);
+
+Bool
+cfb8_32WidPositionWindow(
+ WindowPtr pWin,
+ int x, int y
+);
+
+void
+cfb8_32WidCopyWindow(
+ WindowPtr pWin,
+ DDXPointRec ptOldOrg,
+ RegionPtr prgnSrc
+);
+
+Bool
+cfb8_32WidChangeWindowAttributes(
+ WindowPtr pWin,
+ unsigned long mask
+);
+
+void
+cfb8_32WidWindowExposures(
+ WindowPtr pWin,
+ RegionPtr pReg,
+ RegionPtr pOtherReg
+);
+
+/* cfbwid.c */
+
+Bool
+cfb8_32WidGenericOpsInit(cfb8_32WidScreenPtr pScreenPriv);
+
+#define CFB8_32WID_GET_SCREEN_PRIVATE(pScreen)\
+ (cfb8_32WidScreenPtr)((pScreen)->devPrivates[cfb8_32WidScreenPrivateIndex].ptr)
+
+#endif /* _CFB8_32WID_H */
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32widmodule.c b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32widmodule.c
new file mode 100644
index 000000000..5a47b9ff5
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32widmodule.c
@@ -0,0 +1,46 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfb8_32widmodule.c,v 1.1 2000/05/21 01:02:43 mvojkovi Exp $ */
+
+#ifdef XFree86LOADER
+
+#include "xf86Module.h"
+
+static MODULESETUPPROTO(xf8_32widSetup);
+
+static XF86ModuleVersionInfo VersRec =
+{
+ "xf8_32wid",
+ MODULEVENDORSTRING,
+ MODINFOSTRING1,
+ MODINFOSTRING2,
+ XF86_VERSION_CURRENT,
+ 1, 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 */
+};
+
+XF86ModuleData xf8_32widModuleData = { &VersRec, xf8_32widSetup, NULL };
+
+static pointer
+xf8_32widSetup(pointer module, pointer opts, int *errmaj, int *errmin)
+{
+ if (!LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin))
+ return NULL;
+ if (!LoadSubModule(module, "cfb", NULL, NULL, NULL, NULL,
+ errmaj, errmin))
+ return NULL;
+ if (!LoadSubModule(module, "cfb16", NULL, NULL, NULL, NULL,
+ errmaj, errmin))
+ return NULL;
+ if (!LoadSubModule(module, "cfb24", 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 */
+}
+
+#endif
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbscrinit.c b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbscrinit.c
new file mode 100644
index 000000000..93c15371d
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbscrinit.c
@@ -0,0 +1,382 @@
+/*
+ Copyright (C) 1999. The XFree86 Project Inc.
+
+ Written by David S. Miller (davem@redhat.com)
+
+ Based largely upon the xf8_16bpp module which is
+ Mark Vojkovich's work.
+*/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbscrinit.c,v 1.1 2000/05/21 01:02:43 mvojkovi Exp $ */
+
+#include "X.h"
+#include "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_32wid.h"
+#include "mi.h"
+#include "micmap.h"
+#include "mistruct.h"
+#include "gcstruct.h"
+#include "dix.h"
+#include "mibstore.h"
+#include "xf86str.h"
+#include "xf86.h"
+
+/* CAUTION: We require that cfb8 and cfb32 were NOT
+ compiled with CFB_NEED_SCREEN_PRIVATE */
+
+int cfb8_32WidScreenPrivateIndex;
+
+static unsigned long cfb8_32WidGeneration = 0;
+extern WindowPtr *WindowTable;
+
+static PixmapPtr cfb8_32WidGetWindowPixmap(WindowPtr pWin);
+
+static void
+cfb8_32WidSaveAreas(
+ PixmapPtr pPixmap,
+ RegionPtr prgnSave,
+ int xorg,
+ int yorg,
+ WindowPtr pWin
+);
+
+static void
+cfb8_32WidRestoreAreas(
+ PixmapPtr pPixmap,
+ RegionPtr prgnRestore,
+ int xorg,
+ int yorg,
+ WindowPtr pWin
+);
+
+static BSFuncRec cfb8_32WidBSFuncRec = {
+ cfb8_32WidSaveAreas,
+ cfb8_32WidRestoreAreas,
+ (BackingStoreSetClipmaskRgnProcPtr) 0,
+ (BackingStoreGetImagePixmapProcPtr) 0,
+ (BackingStoreGetSpansPixmapProcPtr) 0,
+};
+
+static void
+cfb8_32WidGetSpans(
+ DrawablePtr pDraw,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart
+);
+
+static void
+cfb8_32WidGetImage (
+ DrawablePtr pDraw,
+ int sx, int sy, int w, int h,
+ unsigned int format,
+ unsigned long planeMask,
+ char *pdstLine
+);
+
+static Bool cfb8_32WidCreateGC(GCPtr pGC);
+static void cfb8_32WidEnableDisableFBAccess(int index, Bool enable);
+
+
+static Bool
+cfb8_32WidAllocatePrivates(ScreenPtr pScreen)
+{
+ cfb8_32WidScreenPtr pScreenPriv;
+
+ if (cfb8_32WidGeneration != serverGeneration) {
+ if ((cfb8_32WidScreenPrivateIndex = AllocateScreenPrivateIndex()) < 0)
+ return FALSE;
+ cfb8_32WidGeneration = serverGeneration;
+ }
+
+ if (!(pScreenPriv = xalloc(sizeof(cfb8_32WidScreenRec))))
+ return FALSE;
+
+ pScreen->devPrivates[cfb8_32WidScreenPrivateIndex].ptr = (pointer)pScreenPriv;
+
+ /* All cfb will have the same GC and Window private indicies */
+ if (!mfbAllocatePrivates(pScreen, &cfbWindowPrivateIndex, &cfbGCPrivateIndex))
+ return FALSE;
+
+ /* The cfb indicies are the mfb indicies. Reallocating them resizes them */
+ if (!AllocateWindowPrivate(pScreen, cfbWindowPrivateIndex, sizeof(cfbPrivWin)))
+ return FALSE;
+
+ if (!AllocateGCPrivate(pScreen, cfbGCPrivateIndex, sizeof(cfbPrivGC)))
+ return FALSE;
+
+ return TRUE;
+}
+
+static Bool
+cfb8_32WidSetupScreen(
+ ScreenPtr pScreen,
+ int xsize, int ysize, /* in pixels */
+ int dpix, int dpiy
+){
+ if (!cfb8_32WidAllocatePrivates(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_32WidGetImage;
+ pScreen->GetSpans = cfb8_32WidGetSpans;
+ pScreen->CreateWindow = cfb8_32WidCreateWindow;
+ pScreen->DestroyWindow = cfb8_32WidDestroyWindow;
+ pScreen->PositionWindow = cfb8_32WidPositionWindow;
+ pScreen->ChangeWindowAttributes = cfb8_32WidChangeWindowAttributes;
+ pScreen->RealizeWindow = cfb32MapWindow; /* OK */
+ pScreen->UnrealizeWindow = cfb32UnmapWindow; /* OK */
+ pScreen->PaintWindowBackground = cfb8_32WidPaintWindow;
+ pScreen->PaintWindowBorder = cfb8_32WidPaintWindow;
+ pScreen->CopyWindow = cfb8_32WidCopyWindow;
+ pScreen->CreatePixmap = cfb32CreatePixmap; /* OK */
+ pScreen->DestroyPixmap = cfb32DestroyPixmap; /* OK */
+ pScreen->RealizeFont = mfbRealizeFont;
+ pScreen->UnrealizeFont = mfbUnrealizeFont;
+ pScreen->CreateGC = cfb8_32WidCreateGC;
+ pScreen->CreateColormap = miInitializeColormap;
+ pScreen->DestroyColormap = (void (*)())NoopDDA;
+ pScreen->InstallColormap = miInstallColormap;
+ pScreen->UninstallColormap = miUninstallColormap;
+ pScreen->ListInstalledColormaps = miListInstalledColormaps;
+ pScreen->StoreColors = (void (*)())NoopDDA;
+ pScreen->ResolveColor = miResolveColor;
+ pScreen->BitmapToRegion = mfbPixmapToRegion;
+
+ mfbRegisterCopyPlaneProc (pScreen, cfbCopyPlane);
+ return TRUE;
+}
+
+static Bool
+cfb8_32WidCreateScreenResources(ScreenPtr pScreen)
+{
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ PixmapPtr pix8, pix32, pixWid;
+
+ xfree(pScreen->devPrivate); /* freeing miScreenInitParmsRec */
+
+ pix8 = (*pScreen->CreatePixmap)(pScreen, 0, 0, 8);
+ pix32 = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScrn->depth);
+ pixWid = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreenPriv->bitsPerWid);
+ if (!pix32 || !pix8 || !pixWid)
+ return FALSE;
+
+ pix8->drawable.width = pScreen->width;
+ pix8->drawable.height = pScreen->height;
+ pix8->devKind = pScreenPriv->width8;
+ pix8->devPrivate.ptr = pScreenPriv->pix8;
+
+ pix32->drawable.width = pScreen->width;
+ pix32->drawable.height = pScreen->height;
+ pix32->devKind = pScreenPriv->width32 * 4;
+ pix32->devPrivate.ptr = pScreenPriv->pix32;
+
+ pixWid->drawable.width = pScreen->width;
+ pixWid->drawable.height = pScreen->height;
+ pixWid->devKind = (pScreenPriv->widthWid * pScreenPriv->bitsPerWid) / 8;
+ pixWid->devPrivate.ptr = pScreenPriv->pixWid;
+
+ pScreenPriv->pix8 = (pointer) pix8;
+ pScreenPriv->pix32 = (pointer) pix32;
+ pScreenPriv->pixWid = (pointer) pixWid;
+
+ pScreen->devPrivate = (pointer) pix32;
+
+ return TRUE;
+}
+
+
+static Bool
+cfb8_32WidCloseScreen (int i, ScreenPtr pScreen)
+{
+ cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+
+ xfree((pointer) pScreenPriv);
+
+ return cfb32CloseScreen(i, pScreen);
+}
+
+static Bool
+cfb8_32WidFinishScreenInit(
+ ScreenPtr pScreen,
+ int xsize, int ysize, /* in pixels */
+ int dpix, int dpiy /* dots per inch */
+){
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ 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, NULL, xsize, ysize, dpix, dpiy, 0,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+
+ pScreen->BackingStoreFuncs = cfb8_32WidBSFuncRec;
+ pScreen->CreateScreenResources = cfb8_32WidCreateScreenResources;
+ pScreen->CloseScreen = cfb8_32WidCloseScreen;
+ pScreen->GetWindowPixmap = cfb8_32WidGetWindowPixmap;
+ pScreen->WindowExposures = cfb8_32WidWindowExposures;
+
+ pScrn->EnableDisableFBAccess = cfb8_32WidEnableDisableFBAccess;
+
+ return TRUE;
+}
+
+Bool
+cfb8_32WidScreenInit(
+ ScreenPtr pScreen,
+ pointer pbits32, /* pointer to screen bitmap */
+ pointer pbits8,
+ pointer pbitsWid, /* pointer to WID bitmap */
+ int xsize, int ysize, /* in pixels */
+ int dpix, int dpiy, /* dots per inch */
+ int width32, /* pixel width of frame buffer */
+ int width8,
+ int widthWid,
+ int bitsPerWid,
+ cfb8_32WidOps *WIDOps
+){
+ cfb8_32WidScreenPtr pScreenPriv;
+
+ if (!WIDOps || !WIDOps->WidGet || !WIDOps->WidAlloc || !WIDOps->WidFree)
+ return FALSE;
+
+ if (!cfb8_32WidSetupScreen(pScreen, xsize, ysize, dpix, dpiy))
+ return FALSE;
+
+ pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ pScreenPriv->pix8 = pbits8;
+ pScreenPriv->pix32 = pbits32;
+ pScreenPriv->pixWid = pbitsWid;
+ pScreenPriv->width8 = width8;
+ pScreenPriv->width32 = width32;
+ pScreenPriv->widthWid = widthWid;
+ pScreenPriv->bitsPerWid = bitsPerWid;
+
+ pScreenPriv->WIDOps = xalloc(sizeof(cfb8_32WidOps));
+ if (!pScreenPriv->WIDOps)
+ return FALSE;
+
+ *(pScreenPriv->WIDOps) = *WIDOps;
+
+ if (!WIDOps->WidFillBox || !WIDOps->WidCopyArea)
+ cfb8_32WidGenericOpsInit(pScreenPriv);
+
+ return cfb8_32WidFinishScreenInit(pScreen, xsize, ysize, dpix, dpiy);
+}
+
+static PixmapPtr
+cfb8_32WidGetWindowPixmap(WindowPtr pWin)
+{
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
+
+ return ((pWin->drawable.bitsPerPixel == 8) ?
+ (PixmapPtr) pScreenPriv->pix8 : (PixmapPtr) pScreenPriv->pix32);
+}
+
+static void
+cfb8_32WidGetImage (DrawablePtr pDraw, int sx, int sy, int w, int h,
+ unsigned int format, unsigned long planemask, char *pdstLine)
+{
+ if (!w || !h)
+ return;
+
+ if (pDraw->bitsPerPixel == 8)
+ cfbGetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine);
+ else
+ cfb32GetImage(pDraw, sx, sy, w, h, format, planemask, pdstLine);
+}
+
+static void
+cfb8_32WidGetSpans(DrawablePtr pDraw, int wMax, DDXPointPtr ppt, int *pwidth, int nspans, char *pDst)
+{
+ if (pDraw->bitsPerPixel == 8)
+ cfbGetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst);
+ else
+ cfb32GetSpans(pDraw, wMax, ppt, pwidth, nspans, pDst);
+}
+
+static void
+cfb8_32WidSaveAreas(PixmapPtr pPixmap, RegionPtr prgnSave, int xorg, int yorg, WindowPtr pWin)
+{
+ if (pWin->drawable.bitsPerPixel == 8)
+ cfbSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin);
+ else
+ cfb32SaveAreas(pPixmap, prgnSave, xorg, yorg, pWin);
+}
+
+static void
+cfb8_32WidRestoreAreas(PixmapPtr pPixmap, RegionPtr prgnRestore, int xorg, int yorg, WindowPtr pWin)
+{
+ if (pWin->drawable.bitsPerPixel == 8)
+ cfbRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin);
+ else
+ cfb32RestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin);
+}
+
+
+static Bool
+cfb8_32WidCreateGC(GCPtr pGC)
+{
+ if (pGC->depth == 8)
+ return cfbCreateGC(pGC);
+ else
+ return cfb32CreateGC(pGC);
+}
+
+static void
+cfb8_32WidEnableDisableFBAccess(int index, Bool enable)
+{
+ ScreenPtr pScreen = xf86Screens[index]->pScreen;
+ cfb8_32WidScreenPtr pScreenPriv = CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ static DevUnion devPrivates8[MAXSCREENS];
+ static DevUnion devPrivates32[MAXSCREENS];
+ PixmapPtr pix8, pix32;
+
+ pix8 = (PixmapPtr) pScreenPriv->pix8;
+ pix32 = (PixmapPtr) pScreenPriv->pix32;
+
+ if (enable) {
+ pix8->devPrivate = devPrivates8[index];
+ pix32->devPrivate = devPrivates32[index];
+ }
+
+ xf86EnableDisableFBAccess (index, enable);
+
+ if (!enable) {
+ devPrivates8[index] = pix8->devPrivate;
+ pix8->devPrivate.ptr = 0;
+ devPrivates32[index] = pix32->devPrivate;
+ pix32->devPrivate.ptr = 0;
+ }
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwid.c b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwid.c
new file mode 100644
index 000000000..0aa894176
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwid.c
@@ -0,0 +1,147 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwid.c,v 1.1 2000/05/21 01:02:44 mvojkovi Exp $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "misc.h"
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "pixmapstr.h"
+#include "resource.h"
+#include "colormap.h"
+#include "colormapst.h"
+
+#include "mfb.h"
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb16.h"
+#include "cfb24.h"
+#include "cfb32.h"
+
+#include "cfb8_32wid.h"
+
+static void
+WidFillBox1(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox)
+{
+ WindowPtr pWin = (WindowPtr) pWinDraw;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
+ unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin);
+
+ if (wid & 1)
+ mfbSolidWhiteArea((DrawablePtr)pWin, nbox, pBox, GXset, NullPixmap);
+ else
+ mfbSolidBlackArea((DrawablePtr)pWin, nbox, pBox, GXset, NullPixmap);
+}
+
+static void
+WidCopyArea1(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc)
+{
+ mfbDoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc);
+}
+
+static void
+WidFillBox8(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox)
+{
+ WindowPtr pWin = (WindowPtr) pWinDraw;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
+ unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin);
+
+ cfbFillBoxSolid(pixWid, nbox, pBox, wid);
+}
+
+static void
+WidCopyArea8(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc)
+{
+ cfbDoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L);
+}
+
+static void
+WidFillBox16(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox)
+{
+ WindowPtr pWin = (WindowPtr) pWinDraw;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
+ unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin);
+
+ cfb16FillBoxSolid(pixWid, nbox, pBox, wid);
+}
+
+static void
+WidCopyArea16(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc)
+{
+ cfb16DoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L);
+}
+
+static void
+WidFillBox24(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox)
+{
+ WindowPtr pWin = (WindowPtr) pWinDraw;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
+ unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin);
+
+ cfb24FillBoxSolid(pixWid, nbox, pBox, wid);
+}
+
+static void
+WidCopyArea24(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc)
+{
+ cfb24DoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L);
+}
+
+static void
+WidFillBox32(DrawablePtr pixWid, DrawablePtr pWinDraw, int nbox, BoxPtr pBox)
+{
+ WindowPtr pWin = (WindowPtr) pWinDraw;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pWin->drawable.pScreen);
+ unsigned int wid = pScreenPriv->WIDOps->WidGet(pWin);
+
+ cfb32FillBoxSolid(pixWid, nbox, pBox, wid);
+}
+
+static void
+WidCopyArea32(DrawablePtr pixWid, RegionPtr pRgn, DDXPointPtr pptSrc)
+{
+ cfb32DoBitbltCopy(pixWid, pixWid, GXcopy, pRgn, pptSrc, ~0L);
+}
+
+Bool
+cfb8_32WidGenericOpsInit(cfb8_32WidScreenPtr pScreenPriv)
+{
+ cfb8_32WidOps *WIDOps = pScreenPriv->WIDOps;
+
+ switch (pScreenPriv->bitsPerWid) {
+ case 1:
+ WIDOps->WidFillBox = WidFillBox1;
+ WIDOps->WidCopyArea = WidCopyArea1;
+ break;
+
+ case 8:
+ WIDOps->WidFillBox = WidFillBox8;
+ WIDOps->WidCopyArea = WidCopyArea8;
+ break;
+
+ case 16:
+ WIDOps->WidFillBox = WidFillBox16;
+ WIDOps->WidCopyArea = WidCopyArea16;
+ break;
+
+ case 24:
+ WIDOps->WidFillBox = WidFillBox24;
+ WIDOps->WidCopyArea = WidCopyArea24;
+ break;
+
+ case 32:
+ WIDOps->WidFillBox = WidFillBox32;
+ WIDOps->WidCopyArea = WidCopyArea32;
+ break;
+
+ default:
+ return FALSE;
+ };
+
+ return TRUE;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwindow.c b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwindow.c
new file mode 100644
index 000000000..57130a6d0
--- /dev/null
+++ b/xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwindow.c
@@ -0,0 +1,285 @@
+/*
+ Copyright (C) 1999. The XFree86 Project Inc.
+
+ Written by David S. Miller (davem@redhat.com)
+
+ Based largely upon the xf8_16bpp module which is
+ Mark Vojkovich's work.
+*/
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf8_32wid/cfbwindow.c,v 1.1 2000/05/21 01:02:44 mvojkovi Exp $ */
+
+#include "X.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#define PSZ 8
+#include "cfb.h"
+#undef PSZ
+#include "cfb32.h"
+#include "cfb8_32wid.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+#include "xf86.h"
+
+/* We don't bother with cfb's fastBackground/Border so we don't
+ need to use the Window privates */
+
+Bool
+cfb8_32WidCreateWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ cfbPrivWin *pPrivWin = cfbGetWindowPrivate(pWin);
+
+ pPrivWin->fastBackground = FALSE;
+ pPrivWin->fastBorder = FALSE;
+
+ if (!pScreenPriv->WIDOps->WidAlloc(pWin))
+ return FALSE;
+
+ return TRUE;
+}
+
+
+Bool
+cfb8_32WidDestroyWindow(WindowPtr pWin)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+
+ pScreenPriv->WIDOps->WidFree(pWin);
+ return TRUE;
+}
+
+Bool
+cfb8_32WidPositionWindow(WindowPtr pWin, int x, int y)
+{
+ return TRUE;
+}
+
+static void
+SegregateChildrenBpp(WindowPtr pWin, RegionPtr pReg, int subtract, int bpp, int other_bpp)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ WindowPtr pChild;
+
+ for (pChild = pWin->firstChild; pChild; pChild = pChild->nextSib) {
+ if (pChild->drawable.bitsPerPixel == bpp) {
+ if (subtract) {
+ REGION_SUBTRACT(pScreen, pReg,
+ pReg, &pChild->borderClip);
+ } else {
+ REGION_UNION(pScreen, pReg,
+ pReg, &pChild->borderClip);
+ }
+ if (pChild->firstChild)
+ SegregateChildrenBpp(pChild, pReg,
+ !subtract, other_bpp, bpp);
+ } else {
+ if (pChild->firstChild)
+ SegregateChildrenBpp(pChild, pReg,
+ subtract, bpp, other_bpp);
+ }
+ }
+}
+
+void
+cfb8_32WidCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
+{
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+ ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
+ PixmapPtr pPixChildren;
+ DDXPointPtr ppt, pptSrc;
+ RegionRec rgnDst, rgnOther, rgnPixmap;
+ BoxPtr pbox;
+ int i, nbox, dx, dy, other_bpp;
+
+ REGION_INIT(pScreen, &rgnDst, NullBox, 0);
+
+ 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);
+
+ if ((nbox = REGION_NUM_RECTS(&rgnDst)) == 0) {
+ /* Nothing to render. */
+ REGION_UNINIT(pScreen, &rgnDst);
+ return;
+ }
+
+ /* First, copy the WID plane for the whole area. */
+ pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec));
+ if(pptSrc) {
+ pbox = REGION_RECTS(&rgnDst);
+ for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ pScreenPriv->WIDOps->WidCopyArea((DrawablePtr)pScreenPriv->pixWid,
+ &rgnDst, pptSrc);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ /* Next, we copy children which have a different
+ * bpp than pWin into a temporary pixmap. We will
+ * toss this pixmap back onto the framebuffer before
+ * we return.
+ */
+ if (pWin->drawable.bitsPerPixel == 8)
+ other_bpp = pScrn->bitsPerPixel;
+ else
+ other_bpp = 8;
+
+ REGION_INIT(pScreen, &rgnOther, NullBox, 0);
+ SegregateChildrenBpp(pWin, &rgnOther, 0,
+ other_bpp, pWin->drawable.bitsPerPixel);
+ pPixChildren = NULL;
+ if (REGION_NOTEMPTY(pScreen, &rgnOther)) {
+ REGION_INTERSECT(pScreen, &rgnOther, &rgnOther, prgnSrc);
+ nbox = REGION_NUM_RECTS(&rgnOther);
+ if (nbox) {
+ int width = rgnOther.extents.x2 - rgnOther.extents.x1;
+ int height = rgnOther.extents.y2 - rgnOther.extents.y1;
+ int depth = (other_bpp == 8) ? 8 : pScrn->depth;
+
+ if (other_bpp == 8)
+ pPixChildren = cfbCreatePixmap(pScreen, width, height, depth);
+ else
+ pPixChildren = cfb32CreatePixmap(pScreen, width, height, depth);
+ }
+ if (nbox &&
+ pPixChildren &&
+ (pptSrc = (DDXPointPtr) ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec)))) {
+ pbox = REGION_RECTS(&rgnOther);
+ for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
+ ppt->x = pbox->x1 + dx;
+ ppt->y = pbox->y1 + dy;
+ }
+
+ REGION_INIT(pScreen, &rgnPixmap, NullBox, 0);
+ REGION_COPY(pScreen, &rgnPixmap, &rgnOther);
+ REGION_TRANSLATE(pScreen, &rgnPixmap, -(rgnOther.extents.x1), -(rgnOther.extents.y1));
+
+ if (other_bpp == 8)
+ cfbDoBitbltCopy((DrawablePtr)pScreenPriv->pix8,
+ (DrawablePtr)pPixChildren,
+ GXcopy, &rgnPixmap, pptSrc, ~0L);
+ else
+ cfb32DoBitbltCopy((DrawablePtr)pScreenPriv->pix32,
+ (DrawablePtr)pPixChildren,
+ GXcopy, &rgnPixmap, pptSrc, ~0L);
+
+ REGION_UNINIT(pScreen, &rgnPixmap);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ REGION_SUBTRACT(pScreen, &rgnDst, &rgnDst, &rgnOther);
+ }
+
+ /* Now copy the parent along with all child windows using the same depth. */
+ nbox = REGION_NUM_RECTS(&rgnDst);
+ if(nbox &&
+ (pptSrc = (DDXPointPtr )ALLOCATE_LOCAL(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;
+ }
+
+ if (pWin->drawable.bitsPerPixel == 8)
+ cfbDoBitbltCopy((DrawablePtr)pScreenPriv->pix8,
+ (DrawablePtr)pScreenPriv->pix8,
+ GXcopy, &rgnDst, pptSrc, ~0L);
+ else
+ cfb32DoBitbltCopy((DrawablePtr)pScreenPriv->pix32,
+ (DrawablePtr)pScreenPriv->pix32,
+ GXcopy, &rgnDst, pptSrc, ~0L);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ REGION_UNINIT(pScreen, &rgnDst);
+
+ if (pPixChildren) {
+ nbox = REGION_NUM_RECTS(&rgnOther);
+ pptSrc = (DDXPointPtr) ALLOCATE_LOCAL(nbox * sizeof(DDXPointRec));
+ if (pptSrc) {
+ pbox = REGION_RECTS(&rgnOther);
+ for (i = nbox, ppt = pptSrc; i--; ppt++, pbox++) {
+ ppt->x = pbox->x1 - rgnOther.extents.x1;
+ ppt->y = pbox->y1 - rgnOther.extents.y1;
+ }
+
+ if (other_bpp == 8)
+ cfbDoBitbltCopy((DrawablePtr)pPixChildren,
+ (DrawablePtr)pScreenPriv->pix8,
+ GXcopy, &rgnOther, pptSrc, ~0L);
+ else
+ cfb32DoBitbltCopy((DrawablePtr)pPixChildren,
+ (DrawablePtr)pScreenPriv->pix32,
+ GXcopy, &rgnOther, pptSrc, ~0L);
+
+ DEALLOCATE_LOCAL(pptSrc);
+ }
+
+ if (other_bpp == 8)
+ cfbDestroyPixmap(pPixChildren);
+ else
+ cfb32DestroyPixmap(pPixChildren);
+ }
+ REGION_UNINIT(pScreen, &rgnOther);
+}
+
+Bool
+cfb8_32WidChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
+{
+ return TRUE;
+}
+
+void
+cfb8_32WidWindowExposures(WindowPtr pWin, RegionPtr pReg, RegionPtr pOtherReg)
+{
+ /* Fill in the WID channel before rendering of
+ * the exposed window area.
+ */
+ if (REGION_NUM_RECTS(pReg)) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+
+ pScreenPriv->WIDOps->WidFillBox((DrawablePtr)pScreenPriv->pixWid,
+ (DrawablePtr)pWin,
+ REGION_NUM_RECTS(pReg), REGION_RECTS(pReg));
+ }
+
+ miWindowExposures(pWin, pReg, pOtherReg);
+}
+
+void
+cfb8_32WidPaintWindow(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+ if (what == PW_BORDER) {
+ ScreenPtr pScreen = pWin->drawable.pScreen;
+ cfb8_32WidScreenPtr pScreenPriv =
+ CFB8_32WID_GET_SCREEN_PRIVATE(pScreen);
+
+ pScreenPriv->WIDOps->WidFillBox((DrawablePtr)pScreenPriv->pixWid,
+ (DrawablePtr)pWin,
+ REGION_NUM_RECTS(pRegion),
+ REGION_RECTS(pRegion));
+ }
+
+ if (pWin->drawable.bitsPerPixel == 8)
+ cfbPaintWindow(pWin, pRegion, what);
+ else
+ cfb32PaintWindow(pWin, pRegion, what);
+}
+
diff --git a/xc/programs/Xserver/hw/xnest/Display.h b/xc/programs/Xserver/hw/xnest/Display.h
index c0d554fe4..6f5c15d7d 100644
--- a/xc/programs/Xserver/hw/xnest/Display.h
+++ b/xc/programs/Xserver/hw/xnest/Display.h
@@ -12,7 +12,7 @@ the suitability of this software for any purpose. It is provided "as
is" without express or implied warranty.
*/
-/* $XFree86: xc/programs/Xserver/hw/xnest/Display.h,v 1.3 1998/12/20 22:18:57 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/xnest/Display.h,v 1.4 2000/06/17 00:27:33 dawes Exp $ */
#ifndef XNESTCOMMON_H
#define XNESTCOMMON_H
@@ -20,7 +20,7 @@ is" without express or implied warranty.
#define UNDEFINED -1
#define MAXDEPTH 32
-#define MAXVISUALSPERDEPTH 32
+#define MAXVISUALSPERDEPTH 64
extern Display *xnestDisplay;
extern XVisualInfo *xnestVisuals;
diff --git a/xc/programs/Xserver/hw/xnest/Imakefile b/xc/programs/Xserver/hw/xnest/Imakefile
index 9725d5e1d..0e308bd3d 100644
--- a/xc/programs/Xserver/hw/xnest/Imakefile
+++ b/xc/programs/Xserver/hw/xnest/Imakefile
@@ -1,5 +1,5 @@
XCOMM $TOG: Imakefile /main/12 1997/11/03 14:13:20 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/hw/xnest/Imakefile,v 3.15 2000/01/25 18:37:48 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/hw/xnest/Imakefile,v 3.18 2000/06/28 19:06:18 tsi Exp $
#include <Server.tmpl>
#ifdef OS2Architecture
@@ -53,15 +53,15 @@ OBJS = Args.o \
INCLUDES = -I. -I$(XBUILDINCDIR) -I$(FONTINCSRC) \
-I../../mi -I../../include -I../../os \
-I$(EXTINCSRC) -I$(XINCLUDESRC)
+DEFINES = $(OS_DEFINES) -UXINPUT -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UMITSHM -UXF86DRI -UXFree86LOADER
all:: $(OBJS)
LinkSourceFile(stubs.c,$(SERVERSRC)/Xi)
SpecialCObjectRule(Init,$(ICONFIGFILES),$(EXT_DEFINES))
LinkSourceFile(miinitext.c,$(SERVERSRC)/mi)
-SpecialCObjectRule(miinitext,$(ICONFIGFILES),$(OS_DEFINES) -UXINPUT \
- -UXF86VIDMODE -UXFreeXDGA -UXF86MISC -UMITSHM -UDPMSExtension \
- -UXF86DRI -UXFree86LOADER)
+SpecialCObjectRule(miinitext,$(ICONFIGFILES),-UDPMSExtension)
NormalLibraryObjectRule()
NormalLibraryTarget(xnest,$(OBJS))
diff --git a/xc/programs/Xserver/include/dix.h b/xc/programs/Xserver/include/dix.h
index 09b8063ab..b0be9acaa 100644
--- a/xc/programs/Xserver/include/dix.h
+++ b/xc/programs/Xserver/include/dix.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/dix.h,v 3.12 1999/10/14 02:45:28 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/dix.h,v 3.13 2000/05/18 23:46:23 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -400,6 +400,36 @@ extern int GetGeometry(
#endif
);
+extern int SendConnSetup(
+#if NeedFunctionPrototypes
+ ClientPtr /*client*/,
+ char* /*reason*/
+#endif
+);
+
+extern int
+DoGetImage(
+#if NeedFunctionPrototypes
+ ClientPtr /*client*/,
+ int /*format*/,
+ Drawable /*drawable*/,
+ int /*x*/,
+ int /*y*/,
+ int /*width*/,
+ int /*height*/,
+ Mask /*planemask*/,
+ xGetImageReply **/*im_return*/
+#endif
+);
+
+#ifdef LBX
+extern void IncrementClientCount(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+#endif /* LBX */
+
/* dixutils.c */
extern void CopyISOLatin1Lowered(
diff --git a/xc/programs/Xserver/include/dixstruct.h b/xc/programs/Xserver/include/dixstruct.h
index 72fa45407..4756a0e45 100644
--- a/xc/programs/Xserver/include/dixstruct.h
+++ b/xc/programs/Xserver/include/dixstruct.h
@@ -21,7 +21,7 @@ SOFTWARE.
******************************************************************/
/* $XConsortium: dixstruct.h /main/43 1996/12/15 21:25:06 rws $ */
-/* $XFree86: xc/programs/Xserver/include/dixstruct.h,v 3.10 1999/11/19 13:55:03 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/include/dixstruct.h,v 3.11 2000/05/05 17:53:52 keithp Exp $ */
#ifndef DIXSTRUCT_H
#define DIXSTRUCT_H
@@ -150,6 +150,7 @@ typedef struct _Client {
int smart_priority;
long smart_start_tick;
long smart_stop_tick;
+ long smart_check_tick;
#endif
} ClientRec;
@@ -159,7 +160,11 @@ typedef struct _Client {
*/
extern long SmartScheduleTime;
extern long SmartScheduleInterval;
+extern long SmartScheduleSlice;
+extern long SmartScheduleMaxSlice;
extern Bool SmartScheduleDisable;
+#define SMART_MAX_PRIORITY 20
+#define SMART_MIN_PRIORITY -20
#endif
/* This prototype is used pervasively in Xext, dix */
diff --git a/xc/programs/Xserver/include/globals.h b/xc/programs/Xserver/include/globals.h
index e7c414261..3b1b6ba0b 100644
--- a/xc/programs/Xserver/include/globals.h
+++ b/xc/programs/Xserver/include/globals.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/globals.h,v 1.3 1999/09/25 14:38:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/globals.h,v 1.4 2000/06/28 18:21:22 tsi Exp $ */
#ifndef _XSERV_GLOBAL_H_
#define _XSERV_GLOBAL_H_
@@ -25,7 +25,7 @@ extern Bool noTestExtensions;
extern DDXPointRec dixScreenOrigins[MAXSCREENS];
-#if DPMSExtension
+#ifdef DPMSExtension
extern CARD32 defaultDPMSStandbyTime;
extern CARD32 defaultDPMSSuspendTime;
extern CARD32 defaultDPMSOffTime;
diff --git a/xc/programs/Xserver/include/os.h b/xc/programs/Xserver/include/os.h
index 31fbcb411..f5829e96d 100644
--- a/xc/programs/Xserver/include/os.h
+++ b/xc/programs/Xserver/include/os.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/os.h,v 3.30 1999/10/13 04:21:38 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/include/os.h,v 3.34 2000/06/16 01:50:21 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -50,8 +50,10 @@ SOFTWARE.
#define ALLOCATE_LOCAL_FALLBACK(_size) Xalloc((unsigned long)(_size))
#define DEALLOCATE_LOCAL_FALLBACK(_ptr) Xfree((pointer)(_ptr))
#include "Xalloca.h"
-#if NeedVarargsPrototypes
+#ifndef IN_MODULE
#include <stdarg.h>
+#else
+#include "xf86_ansic.h"
#endif
#define NullFID ((FID) 0)
@@ -123,6 +125,12 @@ extern int StandardReadRequestFromClient(
ClientPtr /*client*/
#endif
);
+
+extern int ClientConnectionNumber(
+#if NeedFunctionPrototypes
+ ClientPtr /*client*/
+#endif
+);
#else
extern int ReadRequestFromClient(
#if NeedFunctionPrototypes
@@ -273,6 +281,20 @@ extern int MakeClientGrabPervious(
#endif
);
+#ifdef LBX
+extern void CloseDownFileDescriptor(
+#if NeedFunctionPrototypes
+ ClientPtr /* client */
+#endif
+);
+#endif
+
+extern void AvailableClientInput(
+#if NeedFunctionPrototypes
+ ClientPtr /* client */
+#endif
+);
+
extern void Error(
#if NeedFunctionPrototypes
char* /*str*/
@@ -532,6 +554,8 @@ extern int Pclose(pointer);
#define Pclose(a) pclose(a)
#endif
+extern void CheckUserParameters(int argc, char **argv, char **envp);
+
extern int AddHost(
#if NeedFunctionPrototypes
ClientPtr /*client*/,
diff --git a/xc/programs/Xserver/include/scrnintstr.h b/xc/programs/Xserver/include/scrnintstr.h
index 7a550b37b..ec8abb308 100644
--- a/xc/programs/Xserver/include/scrnintstr.h
+++ b/xc/programs/Xserver/include/scrnintstr.h
@@ -41,7 +41,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
-/* $XFree86: xc/programs/Xserver/include/scrnintstr.h,v 1.7 2000/02/11 06:27:25 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/include/scrnintstr.h,v 1.8 2000/04/27 16:26:49 eich Exp $ */
#ifndef SCREENINTSTRUCT_H
#define SCREENINTSTRUCT_H
@@ -942,8 +942,8 @@ typedef struct _Screen {
#ifdef PIXPRIV
int PixmapPrivateLen;
- unsigned *PixmapPrivateSizes;
- unsigned totalPixmapSize;
+ unsigned int *PixmapPrivateSizes;
+ unsigned int totalPixmapSize;
#endif
MarkWindowProcPtr MarkWindow;
diff --git a/xc/programs/Xserver/include/servermd.h b/xc/programs/Xserver/include/servermd.h
index 6d08b6d2c..daeddcc18 100644
--- a/xc/programs/Xserver/include/servermd.h
+++ b/xc/programs/Xserver/include/servermd.h
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.38 2000/02/22 01:04:01 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/include/servermd.h,v 3.39 2000/05/18 16:30:02 dawes Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -170,10 +170,7 @@ SOFTWARE.
#if (defined(sun) && !(defined(i386) && defined(SVR4))) || \
(defined(AMOEBA) && (defined(sparc) || defined(mc68000))) || \
(defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
- (defined(Lynx) && defined(__sparc__)) || \
- (defined(linux) && defined(__sparc__)) || \
- ((defined(__NetBSD__) || defined(__OpenBSD__)) && \
- (defined(__sparc__) || defined(__mc68000__)))
+ defined(__sparc__) || defined(__mc68000__)
#if defined(sun386) || defined(sun5)
# define IMAGE_BYTE_ORDER LSBFirst /* Values for the SUN only */
@@ -363,7 +360,15 @@ SOFTWARE.
#endif /* luna */
-#if (defined(i386) && (defined(SVR4) || defined(SYSV) || (defined(sun) && defined(SVR4))) || defined(__bsdi__) || (defined(__NetBSD__) && defined(__i386__)) || (defined(__OpenBSD__) && defined(__i386__)) || defined(__FreeBSD__) || defined(MACH386) || (defined(linux) && (defined(__i386__) || defined(__alpha__))) || (defined(AMOEBA) && defined(i80386)) || defined(MINIX) || defined(__EMX__) || (defined(Lynx) && defined(__i386__))) || defined(__OS2ELF__) || (defined(__GNU__) && defined(__i386__)) || defined(__QNX__)
+#if (defined(AMOEBA) && defined(i80386)) || \
+ (defined(SVR4) && defined(i386)) || \
+ defined(__alpha__) || \
+ defined(__i386__) || \
+ defined(__EMX__) || \
+ defined(__OS2ELF__) || \
+ defined(__QNX__) || \
+ defined(MACH386) || \
+ defined(MINIX)
#ifndef IMAGE_BYTE_ORDER
#define IMAGE_BYTE_ORDER LSBFirst
diff --git a/xc/programs/Xserver/include/site.h b/xc/programs/Xserver/include/site.h
index d6d9cfd71..891663be5 100644
--- a/xc/programs/Xserver/include/site.h
+++ b/xc/programs/Xserver/include/site.h
@@ -41,6 +41,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
********************************************************/
+/* $XFree86: xc/programs/Xserver/include/site.h,v 1.5 2000/05/18 16:30:02 dawes Exp $ */
#ifndef SITE_H
#define SITE_H
@@ -95,19 +96,12 @@ SOFTWARE.
#else
#define DEFAULT_AUTOREPEAT FALSE
#endif
-#ifdef hpux
#define DEFAULT_AUTOREPEATS {\
0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,\
0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
-#else
-#define DEFAULT_AUTOREPEATS {\
- 0, 0, 0, 0, 0, 0, 0, 0,\
- 0, 0, 0, 0, 0, 0, 0, 0,\
- 0, 0, 0, 0, 0, 0, 0, 0,\
- 0, 0, 0, 0, 0, 0, 0, 0 }
-#endif
+
#define DEFAULT_LEDS 0x0 /* all off */
#define DEFAULT_LEDS_MASK 0xffffffff /* 32 */
#define DEFAULT_INT_RESOLUTION 1000
diff --git a/xc/programs/Xserver/lbx/lbxcmap.c b/xc/programs/Xserver/lbx/lbxcmap.c
index e70890263..babef133b 100644
--- a/xc/programs/Xserver/lbx/lbxcmap.c
+++ b/xc/programs/Xserver/lbx/lbxcmap.c
@@ -21,7 +21,7 @@ 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/lbx/lbxcmap.c,v 1.5 1998/11/15 11:11:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxcmap.c,v 1.6 2000/05/18 23:46:23 dawes Exp $ */
#include <sys/types.h>
#define NEED_REPLIES
@@ -35,6 +35,7 @@ from The Open Group.
#include "resource.h"
#include "scrnintstr.h"
#include "colormapst.h"
+#include "propertyst.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
#include "lbxserve.h"
@@ -67,8 +68,7 @@ typedef struct _LbxColormapPriv { /* lbx colormap private */
#define CMAP_GRABBED 1
#define CMAP_WAITING_FOR_UNGRAB 2
-static int LbxUnstallClient();
-void LbxReleaseCmap();
+static int LbxUnstallClient(pointer data, XID id);
static RESTYPE StalledResType;
@@ -77,8 +77,7 @@ static RESTYPE StalledResType;
*/
static LbxColormapPriv *
-LbxColormapPrivInit (pmap)
- ColormapPtr pmap;
+LbxColormapPrivInit (ColormapPtr pmap)
{
LbxColormapPriv *cmapPriv;
@@ -100,8 +99,7 @@ LbxColormapPrivInit (pmap)
static int
-LbxDefCmapPrivInit (pmap)
- ColormapPtr pmap;
+LbxDefCmapPrivInit (ColormapPtr pmap)
{
#if 0
/* BUG: You can't do that. lbxColormapPrivIndex hasn't
@@ -112,8 +110,7 @@ LbxDefCmapPrivInit (pmap)
}
static Bool
-LbxCreateColormap (pmap)
- ColormapPtr pmap;
+LbxCreateColormap (ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
Bool ret;
@@ -130,8 +127,7 @@ LbxCreateColormap (pmap)
}
static void
-LbxDestroyColormap (pmap)
- ColormapPtr pmap;
+LbxDestroyColormap (ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
@@ -149,7 +145,7 @@ LbxDestroyColormap (pmap)
*/
int
-LbxCmapInit ()
+LbxCmapInit (void)
{
LbxScreenPriv *pScreenPriv;
@@ -197,9 +193,8 @@ LbxCmapInit ()
*/
static int
-NumAllocatedCells (pent, size)
- EntryPtr pent;
- int size;
+NumAllocatedCells (EntryPtr pent,
+ int size)
{
Pixel pixel;
int count = 0;
@@ -230,13 +225,12 @@ NumAllocatedCells (pent, size)
*/
static CARD8 *
-OutputChannel(pmap, chan, size, ptr, flags, channels)
- ColormapPtr pmap;
- EntryPtr chan;
- int size;
- CARD8 *ptr;
- CARD8 flags;
- CARD8 channels;
+OutputChannel(ColormapPtr pmap,
+ EntryPtr chan,
+ int size,
+ CARD8 *ptr,
+ CARD8 flags,
+ CARD8 channels)
{
Bool px2;
Bool rgb2;
@@ -340,11 +334,10 @@ OutputChannel(pmap, chan, size, ptr, flags, channels)
}
static void
-GetAllocatedCells (pmap, flags, buf, bytes)
- ColormapPtr pmap;
- CARD8 *flags;
- CARD8 *buf;
- int *bytes;
+GetAllocatedCells (ColormapPtr pmap,
+ CARD8 *flags,
+ CARD8 *buf,
+ int *bytes)
{
CARD8 *ptr;
@@ -376,9 +369,8 @@ GetAllocatedCells (pmap, flags, buf, bytes)
*/
static void
-SendReleaseCmapEvent (proxy, cmap)
- LbxProxyPtr proxy;
- Colormap cmap;
+SendReleaseCmapEvent (LbxProxyPtr proxy,
+ Colormap cmap)
{
xLbxReleaseCmapEvent ev;
ClientPtr client;
@@ -421,9 +413,8 @@ SendReleaseCmapEvent (proxy, cmap)
*/
static Bool
-WaitForServerCmapControl (client, pmap)
- register ClientPtr client;
- register ColormapPtr pmap;
+WaitForServerCmapControl (ClientPtr client,
+ ColormapPtr pmap)
{
LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
(pmap->devPrivates[lbxColormapPrivIndex].ptr);
@@ -457,10 +448,9 @@ WaitForServerCmapControl (client, pmap)
*/
Bool
-LbxCheckColorRequest (client, pmap, req)
- ClientPtr client;
- ColormapPtr pmap;
- xReq *req;
+LbxCheckColorRequest (ClientPtr client,
+ ColormapPtr pmap,
+ xReq *req)
{
LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
(pmap->devPrivates[lbxColormapPrivIndex].ptr);
@@ -551,9 +541,8 @@ LbxCheckColorRequest (client, pmap, req)
}
static Bool
-LbxGrabbedByClient (client, pmap)
- ClientPtr client;
- ColormapPtr pmap;
+LbxGrabbedByClient (ClientPtr client,
+ ColormapPtr pmap)
{
LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
(pmap->devPrivates[lbxColormapPrivIndex].ptr);
@@ -567,8 +556,7 @@ LbxGrabbedByClient (client, pmap)
*/
int
-LbxCheckCmapGrabbed (pmap)
- ColormapPtr pmap;
+LbxCheckCmapGrabbed (ColormapPtr pmap)
{
LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
(pmap->devPrivates[lbxColormapPrivIndex].ptr);
@@ -582,8 +570,7 @@ LbxCheckCmapGrabbed (pmap)
*/
void
-LbxDisableSmartGrab (pmap)
- ColormapPtr pmap;
+LbxDisableSmartGrab (ColormapPtr pmap)
{
LbxColormapPriv *cmapPriv = (LbxColormapPriv *)
(pmap->devPrivates[lbxColormapPrivIndex].ptr);
@@ -598,11 +585,10 @@ LbxDisableSmartGrab (pmap)
*/
static void
-SendFreeCellsEvent (proxy, cmap, pixel_start, pixel_end)
- LbxProxyPtr proxy;
- Colormap cmap;
- Pixel pixel_start;
- Pixel pixel_end;
+SendFreeCellsEvent (LbxProxyPtr proxy,
+ Colormap cmap,
+ Pixel pixel_start,
+ Pixel pixel_end)
{
xLbxFreeCellsEvent ev;
ClientPtr client;
@@ -651,8 +637,7 @@ static long pixel_end;
/*ARGSUSED*/
void
-LbxBeginFreeCellsEvent (pmap)
- ColormapPtr pmap;
+LbxBeginFreeCellsEvent (ColormapPtr pmap)
{
pixel_start = -1;
pixel_end = -1;
@@ -660,9 +645,8 @@ LbxBeginFreeCellsEvent (pmap)
void
-LbxAddFreeCellToEvent (pmap, pixel)
- ColormapPtr pmap;
- Pixel pixel;
+LbxAddFreeCellToEvent (ColormapPtr pmap,
+ Pixel pixel)
{
/*
* We must notify the proxy that has this colormap
@@ -696,8 +680,7 @@ LbxAddFreeCellToEvent (pmap, pixel)
}
void
-LbxEndFreeCellsEvent (pmap)
- ColormapPtr pmap;
+LbxEndFreeCellsEvent (ColormapPtr pmap)
{
/*
* Check if there is an LbxFreeCellEvent we need to write.
@@ -721,9 +704,8 @@ LbxEndFreeCellsEvent (pmap)
*/
void
-LbxSortPixelList (pixels, count)
- Pixel *pixels;
- int count;
+LbxSortPixelList (Pixel *pixels,
+ int count)
{
int i, j;
@@ -743,8 +725,7 @@ LbxSortPixelList (pixels, count)
*/
int
-ProcLbxGrabCmap(client)
- register ClientPtr client;
+ProcLbxGrabCmap(ClientPtr client)
{
REQUEST(xLbxGrabCmapReq);
xLbxGrabCmapReply *reply;
@@ -936,9 +917,8 @@ ProcLbxGrabCmap(client)
}
static int
-LbxUnstallClient(data, id)
- pointer data;
- XID id;
+LbxUnstallClient(pointer data,
+ XID id)
{
LbxColormapPriv *cmapPriv = (LbxColormapPriv *)data;
LbxStalled **prev;
@@ -954,9 +934,8 @@ LbxUnstallClient(data, id)
}
void
-LbxReleaseCmap(pmap, smart)
- ColormapPtr pmap;
- Bool smart;
+LbxReleaseCmap(ColormapPtr pmap,
+ Bool smart)
{
LbxColormapPriv *cmapPriv;
ColormapPtr *prev;
@@ -988,8 +967,7 @@ LbxReleaseCmap(pmap, smart)
*/
int
-ProcLbxReleaseCmap(client)
- register ClientPtr client;
+ProcLbxReleaseCmap(ClientPtr client)
{
REQUEST(xLbxReleaseCmapReq);
ColormapPtr pmap;
@@ -1022,8 +1000,7 @@ ProcLbxReleaseCmap(client)
*/
int
-ProcLbxAllocColor(client)
- register ClientPtr client;
+ProcLbxAllocColor(ClientPtr client)
{
REQUEST(xLbxAllocColorReq);
ColormapPtr pmap;
@@ -1082,8 +1059,7 @@ ProcLbxAllocColor(client)
*/
int
-ProcLbxIncrementPixel(client)
- register ClientPtr client;
+ProcLbxIncrementPixel(ClientPtr client)
{
REQUEST(xLbxIncrementPixelReq);
ColormapPtr pmap;
diff --git a/xc/programs/Xserver/lbx/lbxdix.c b/xc/programs/Xserver/lbx/lbxdix.c
index 4fde16b19..6b7e9fb04 100644
--- a/xc/programs/Xserver/lbx/lbxdix.c
+++ b/xc/programs/Xserver/lbx/lbxdix.c
@@ -42,7 +42,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $XFree86: xc/programs/Xserver/lbx/lbxdix.c,v 1.3 1999/06/13 16:18:16 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxdix.c,v 1.4 2000/05/18 23:46:24 dawes Exp $ */
/* various bits of DIX-level mangling */
@@ -69,18 +69,19 @@ in this Software without prior written authorization from The Open Group.
#include "lbxtags.h"
#include "lbxdata.h"
#include "Xfuncproto.h"
+#ifdef XAPPGROUP
+#include "Xagsrv.h"
+#endif
-extern void CopySwap32Write();
-extern int (*ProcVector[256]) ();
-extern int (*SwappedProcVector[256]) ();
-extern void (*ReplySwapVector[256]) ();
+extern ReplySwapPtr CopySwap32Write;
+extern int (*ProcVector[256]) (ClientPtr);
+extern int (*SwappedProcVector[256]) (ClientPtr);
-extern void LbxWriteSConnSetupPrefix();
int lbx_font_private = -1;
void
-LbxDixInit()
+LbxDixInit(void)
{
TagInit();
lbx_font_private = AllocateFontPrivateIndex();
@@ -88,9 +89,8 @@ LbxDixInit()
/* ARGSUSED */
void
-LbxAllowMotion(client, num)
- ClientPtr client;
- int num;
+LbxAllowMotion(ClientPtr client,
+ int num)
{
LbxProxyPtr proxy = LbxProxy(client);
proxy->motion_allowed_events += num;
@@ -102,9 +102,8 @@ extern char *ConnectionInfo;
extern int connBlockScreenStart;
int
-LbxSendConnSetup(client, reason)
- ClientPtr client;
- char *reason;
+LbxSendConnSetup(ClientPtr client,
+ char *reason)
{
int dlength;
int i, ndex, lim, wndex;
@@ -192,8 +191,7 @@ extern InputInfo inputInfo;
static XID modifier_map_tag;
int
-LbxGetModifierMapping(client)
- ClientPtr client;
+LbxGetModifierMapping(ClientPtr client)
{
TagData td;
pointer tagdata;
@@ -242,7 +240,7 @@ LbxGetModifierMapping(client)
}
void
-LbxFlushModifierMapTag()
+LbxFlushModifierMapTag(void)
{
if (modifier_map_tag)
@@ -252,8 +250,7 @@ LbxFlushModifierMapTag()
static XID keyboard_map_tag;
int
-LbxGetKeyboardMapping(client)
- ClientPtr client;
+LbxGetKeyboardMapping(ClientPtr client)
{
TagData td;
pointer tagdata;
@@ -325,7 +322,7 @@ LbxGetKeyboardMapping(client)
}
void
-LbxFlushKeyboardMapTag()
+LbxFlushKeyboardMapTag(void)
{
if (keyboard_map_tag)
TagDeleteTag(keyboard_map_tag);
@@ -333,8 +330,7 @@ LbxFlushKeyboardMapTag()
/* counts number of bits needed to hold value */
static int
-_bitsize(val)
- int val;
+_bitsize(int val)
{
int bits = 1; /* always need one for sign bit */
@@ -361,10 +357,9 @@ _bitsize(val)
int _lbx_fi_junklen = sizeof(BYTE) * 2 + sizeof(CARD16) + sizeof(CARD32);
static int
-squish_font_info(qfr, rlen, sqrep)
- xQueryFontReply *qfr;
- int rlen;
- xLbxFontInfo **sqrep;
+squish_font_info(xQueryFontReply *qfr,
+ int rlen,
+ xLbxFontInfo **sqrep)
{
int len,
hlen;
@@ -456,8 +451,7 @@ squish_font_info(qfr, rlen, sqrep)
}
int
-LbxQueryFont(client)
- ClientPtr client;
+LbxQueryFont(ClientPtr client)
{
xQueryFontReply *reply;
xLbxQueryFontReply lbxrep;
@@ -593,8 +587,7 @@ LbxQueryFont(client)
}
void
-LbxFreeFontTag(pfont)
- FontPtr pfont;
+LbxFreeFontTag(FontPtr pfont)
{
FontTagInfoPtr ftip;
@@ -603,19 +596,18 @@ LbxFreeFontTag(pfont)
TagDeleteTag(ftip->tid);
}
-LbxInvalidateTag(client, tag)
- ClientPtr client;
- XID tag;
+int
+LbxInvalidateTag(ClientPtr client,
+ XID tag)
{
TagClearProxy(tag, LbxProxyID(client));
return client->noClientException;
}
void
-LbxSendInvalidateTag(client, tag, tagtype)
- ClientPtr client;
- XID tag;
- int tagtype;
+LbxSendInvalidateTag(ClientPtr client,
+ XID tag,
+ int tagtype)
{
xLbxInvalidateTagEvent ev;
int n;
@@ -638,10 +630,9 @@ LbxSendInvalidateTag(client, tag, tagtype)
}
static void
-LbxSendSendTagData(pid, tag, tagtype)
- int pid;
- XID tag;
- int tagtype;
+LbxSendSendTagData(int pid,
+ XID tag,
+ int tagtype)
{
xLbxSendTagDataEvent ev;
int n;
@@ -690,9 +681,8 @@ static SendTagQPtr queried_tags = NULL;
#define LbxSendTagAlreadySent 1
static Bool
-LbxQueueSendTag(client, tag)
- ClientPtr client;
- XID tag;
+LbxQueueSendTag(ClientPtr client,
+ XID tag)
{
SendTagQPtr stqp, *prev, new;
ClientPtr *newlist;
@@ -732,9 +722,8 @@ LbxQueueSendTag(client, tag)
return LbxSendTagSendIt;
}
-SendTagQPtr
-LbxFindQTag(tag)
- XID tag;
+static SendTagQPtr
+LbxFindQTag(XID tag)
{
SendTagQPtr stqp;
@@ -746,16 +735,14 @@ LbxFindQTag(tag)
}
static void
-LbxFreeQTag(stqp)
- SendTagQPtr stqp;
+LbxFreeQTag(SendTagQPtr stqp)
{
xfree(stqp->stalled_clients);
xfree(stqp);
}
static void
-LbxRemoveQTag(tag)
- XID tag;
+LbxRemoveQTag(XID tag)
{
SendTagQPtr stqp, *prev;
@@ -769,8 +756,7 @@ LbxRemoveQTag(tag)
}
Bool
-LbxFlushQTag(tag)
- XID tag;
+LbxFlushQTag(XID tag)
{
SendTagQPtr stqp;
ClientPtr *cp;
@@ -785,7 +771,7 @@ LbxFlushQTag(tag)
}
void
-ProcessQTagZombies()
+ProcessQTagZombies(void)
{
SendTagQPtr stqp;
ClientPtr *out, *in;
@@ -807,11 +793,10 @@ ProcessQTagZombies()
*/
void
-LbxQueryTagData(client, owner_pid, tag, tagtype)
- ClientPtr client;
- int owner_pid;
- XID tag;
- int tagtype;
+LbxQueryTagData(ClientPtr client,
+ int owner_pid,
+ XID tag,
+ int tagtype)
{
/* save the info and the client being stalled */
if (LbxQueueSendTag(client, tag) == LbxSendTagSendIt)
@@ -822,11 +807,10 @@ LbxQueryTagData(client, owner_pid, tag, tagtype)
* server recieves this
*/
int
-LbxTagData(client, tag, len, data)
- ClientPtr client;
- XID tag;
- unsigned long len;
- pointer data;
+LbxTagData(ClientPtr client,
+ XID tag,
+ unsigned long len,
+ pointer data)
{
TagData td;
PropertyPtr pProp;
@@ -869,7 +853,7 @@ LbxTagData(client, tag, len, data)
/* when server resets, need to reset global tags */
void
-LbxResetTags()
+LbxResetTags(void)
{
SendTagQPtr stqp;
diff --git a/xc/programs/Xserver/lbx/lbxexts.c b/xc/programs/Xserver/lbx/lbxexts.c
index a1333b57f..57f3921e4 100644
--- a/xc/programs/Xserver/lbx/lbxexts.c
+++ b/xc/programs/Xserver/lbx/lbxexts.c
@@ -21,13 +21,17 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxexts.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
#include "X.h"
#include "Xproto.h"
#include "misc.h"
#include "dixstruct.h"
+#include "colormapst.h"
+#include "propertyst.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
+#include "lbxserve.h"
#ifdef XCSECURITY
#define _SECURITY_SERVER
#include "extensions/security.h"
@@ -54,15 +58,14 @@ static int num_exts = 0;
Bool
-LbxAddExtension(name, opcode, ev_base, err_base)
- char *name;
- int opcode;
- int ev_base,
- err_base;
+LbxAddExtension(char *name,
+ int opcode,
+ int ev_base,
+ int err_base)
{
int i;
- register LbxExtensionEntry *ext,
- **newexts;
+ LbxExtensionEntry *ext,
+ **newexts;
ext = (LbxExtensionEntry *) xalloc(sizeof(LbxExtensionEntry));
if (!ext)
@@ -102,9 +105,8 @@ LbxAddExtension(name, opcode, ev_base, err_base)
}
Bool
-LbxAddExtensionAlias(idx, alias)
- int idx;
- char *alias;
+LbxAddExtensionAlias(int idx,
+ char *alias)
{
char *name;
char **aliases;
@@ -125,9 +127,8 @@ LbxAddExtensionAlias(idx, alias)
}
static int
-LbxFindExtension(extname, len)
- char *extname;
- int len;
+LbxFindExtension(char *extname,
+ int len)
{
int i, j;
@@ -145,9 +146,8 @@ LbxFindExtension(extname, len)
}
void
-LbxDeclareExtensionSecurity(extname, secure)
- char *extname;
- Bool secure;
+LbxDeclareExtensionSecurity(char *extname,
+ Bool secure)
{
#ifdef XCSECURITY
int i = LbxFindExtension(extname, strlen(extname));
@@ -157,11 +157,10 @@ LbxDeclareExtensionSecurity(extname, secure)
}
Bool
-LbxRegisterExtensionGenerationMasks(idx, num_reqs, rep_mask, ev_mask)
- int idx;
- int num_reqs;
- char *rep_mask,
- *ev_mask;
+LbxRegisterExtensionGenerationMasks(int idx,
+ int num_reqs,
+ char *rep_mask,
+ char *ev_mask)
{
LbxExtensionEntry *ext = lbx_extensions[idx];
CARD8 *nrm,
@@ -186,10 +185,9 @@ LbxRegisterExtensionGenerationMasks(idx, num_reqs, rep_mask, ev_mask)
}
int
-LbxQueryExtension(client, ename, nlen)
- ClientPtr client;
- char *ename;
- int nlen;
+LbxQueryExtension(ClientPtr client,
+ char *ename,
+ int nlen)
{
xLbxQueryExtensionReply rep;
int i;
@@ -237,7 +235,8 @@ LbxQueryExtension(client, ename, nlen)
return Success;
}
-LbxCloseDownExtensions()
+void
+LbxCloseDownExtensions(void)
{
int i;
@@ -254,10 +253,9 @@ LbxCloseDownExtensions()
}
void
-LbxSetReqMask(mask, req, on)
- CARD8 *mask;
- int req;
- Bool on;
+LbxSetReqMask(CARD8 *mask,
+ int req,
+ Bool on)
{
int mword = req / (8 * sizeof(CARD8));
diff --git a/xc/programs/Xserver/lbx/lbxgfx.c b/xc/programs/Xserver/lbx/lbxgfx.c
index 0dc72ad51..c6dac4b1d 100644
--- a/xc/programs/Xserver/lbx/lbxgfx.c
+++ b/xc/programs/Xserver/lbx/lbxgfx.c
@@ -21,6 +21,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxgfx.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
/* various bits of DIX-level mangling */
@@ -48,21 +49,19 @@
#define DrawableCache(client) (LbxClient(client)->drawableCache)
#define GContextCache(client) (LbxClient(client)->gcontextCache)
-extern int (*ProcVector[256])();
+extern int (*ProcVector[256])(ClientPtr);
static void
-push (cache, xid)
- XID cache[GFX_CACHE_SIZE];
- XID xid;
+push (XID cache[GFX_CACHE_SIZE],
+ XID xid)
{
memmove (cache+1, cache, (GFX_CACHE_SIZE - 1) * sizeof (cache[0]));
cache[0] = xid;
}
static XID
-use (cache, i)
- XID cache[GFX_CACHE_SIZE];
- int i;
+use (XID cache[GFX_CACHE_SIZE],
+ int i)
{
XID tmp;
@@ -77,13 +76,12 @@ use (cache, i)
extern char *ConnectionInfo;
-int
-LbxDecodeGFXCache(client, cacheEnts, after, drawp, gcp)
- ClientPtr client;
- CARD8 cacheEnts;
- char *after;
- Drawable *drawp;
- GContext *gcp;
+static int
+LbxDecodeGFXCache(ClientPtr client,
+ CARD8 cacheEnts,
+ char *after,
+ Drawable *drawp,
+ GContext *gcp)
{
int skip;
int dcache, gcache;
@@ -111,12 +109,11 @@ LbxDecodeGFXCache(client, cacheEnts, after, drawp, gcp)
return skip;
}
-int
-LbxDecodeDrawableCache(client, cacheEnts, after, drawp)
- ClientPtr client;
- CARD8 cacheEnts;
- char *after;
- Drawable *drawp;
+static int
+LbxDecodeDrawableCache(ClientPtr client,
+ CARD8 cacheEnts,
+ char *after,
+ Drawable *drawp)
{
int skip;
int dcache;
@@ -135,12 +132,12 @@ LbxDecodeDrawableCache(client, cacheEnts, after, drawp)
return skip;
}
-int
-LbxDecodeGCCache(client, cacheEnts, after, gcp)
- ClientPtr client;
- CARD8 cacheEnts;
- char *after;
- GContext *gcp;
+#ifdef notyet
+static int
+LbxDecodeGCCache(ClientPtr client,
+ CARD8 cacheEnts,
+ char *after,
+ GContext *gcp)
{
int skip;
int gcache;
@@ -158,6 +155,7 @@ LbxDecodeGCCache(client, cacheEnts, after, gcp)
*gcp = use (GContextCache(client), gcache);
return skip;
}
+#endif
#define GFX_GET_DRAWABLE_AND_GC(type,in,len) {\
int skip; \
@@ -203,10 +201,9 @@ LbxDecodeGCCache(client, cacheEnts, after, gcp)
}
int
-LbxDecodePoly(client, xreqtype, decode_rtn)
- register ClientPtr client;
- CARD8 xreqtype;
- int (*decode_rtn)();
+LbxDecodePoly(ClientPtr client,
+ CARD8 xreqtype,
+ int (*decode_rtn)(char *, char *, short *))
{
REQUEST(xLbxPolyPointReq);
char *in;
@@ -220,7 +217,7 @@ LbxDecodePoly(client, xreqtype, decode_rtn)
if ((xreq = (xPolyPointReq *)
xalloc(sizeof(xPolyPointReq) + (len << 1))) == NULL)
return BadAlloc;
- len = (*decode_rtn)(in, in + len - stuff->padBytes, &xreq[1]);
+ len = (*decode_rtn)(in, in + len - stuff->padBytes, (short *)(&xreq[1]));
xreq->reqType = xreqtype;
xreq->coordMode = 1;
xreq->drawable = drawable;
@@ -234,8 +231,7 @@ LbxDecodePoly(client, xreqtype, decode_rtn)
}
int
-LbxDecodeFillPoly(client)
- register ClientPtr client;
+LbxDecodeFillPoly(ClientPtr client)
{
REQUEST(xLbxFillPolyReq);
char *in;
@@ -314,10 +310,9 @@ LbxDecodeFillPoly(client)
}
int
-LbxDecodePoints(in, inend, out)
- register char *in;
- char *inend;
- register short *out;
+LbxDecodePoints(char *in,
+ char *inend,
+ short *out)
{
char *start_out = (char *)out;
@@ -331,12 +326,11 @@ LbxDecodePoints(in, inend, out)
}
int
-LbxDecodeSegment(in, inend, out)
- register char *in;
- char *inend;
- register short *out;
+LbxDecodeSegment(char *in,
+ char *inend,
+ short *out)
{
- register short diff;
+ short diff;
short last_x = 0;
short last_y = 0;
char *start_out = (char *)out;
@@ -362,12 +356,11 @@ LbxDecodeSegment(in, inend, out)
}
int
-LbxDecodeRectangle(in, inend, out)
- register char *in;
- char *inend;
- register short *out;
+LbxDecodeRectangle(char *in,
+ char *inend,
+ short *out)
{
- register short diff;
+ short diff;
short last_x = 0;
short last_y = 0;
char *start_out = (char *)out;
@@ -391,12 +384,11 @@ LbxDecodeRectangle(in, inend, out)
}
int
-LbxDecodeArc(in, inend, out)
- register char *in;
- char *inend;
- register short *out;
+LbxDecodeArc(char *in,
+ char *inend,
+ short *out)
{
- register short diff;
+ short diff;
short last_x = 0;
short last_y = 0;
char *start_out = (char *)out;
@@ -425,8 +417,7 @@ LbxDecodeArc(in, inend, out)
}
int
-LbxDecodeCopyArea (client)
- ClientPtr client;
+LbxDecodeCopyArea (ClientPtr client)
{
REQUEST(xLbxCopyAreaReq);
char *in;
@@ -452,8 +443,7 @@ LbxDecodeCopyArea (client)
}
int
-LbxDecodeCopyPlane (client)
- ClientPtr client;
+LbxDecodeCopyPlane (ClientPtr client)
{
REQUEST(xLbxCopyPlaneReq);
char *in;
@@ -480,9 +470,8 @@ LbxDecodeCopyPlane (client)
}
static pointer
-get_gfx_buffer(client, len)
- ClientPtr client;
- int len;
+get_gfx_buffer(ClientPtr client,
+ int len)
{
LbxClientPtr lbxClient = LbxClient(client);
pointer tmp;
@@ -499,8 +488,7 @@ get_gfx_buffer(client, len)
}
int
-LbxDecodePolyText (client)
- ClientPtr client;
+LbxDecodePolyText (ClientPtr client)
{
REQUEST(xLbxPolyTextReq);
char *in, *pos;
@@ -527,8 +515,7 @@ LbxDecodePolyText (client)
}
int
-LbxDecodeImageText (client)
- ClientPtr client;
+LbxDecodeImageText (ClientPtr client)
{
REQUEST(xLbxImageTextReq);
char *in, *pos;
@@ -556,8 +543,7 @@ LbxDecodeImageText (client)
}
int
-LbxDecodePutImage (client)
- register ClientPtr client;
+LbxDecodePutImage (ClientPtr client)
{
REQUEST (xLbxPutImageReq);
char *in, *data;
@@ -698,8 +684,7 @@ LbxDecodePutImage (client)
}
int
-LbxDecodeGetImage (client)
- register ClientPtr client;
+LbxDecodeGetImage (ClientPtr client)
{
REQUEST (xLbxGetImageReq);
xLbxGetImageReply *reply = NULL;
diff --git a/xc/programs/Xserver/lbx/lbxmain.c b/xc/programs/Xserver/lbx/lbxmain.c
index e0ac1fee7..5afb35511 100644
--- a/xc/programs/Xserver/lbx/lbxmain.c
+++ b/xc/programs/Xserver/lbx/lbxmain.c
@@ -41,7 +41,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $XFree86: xc/programs/Xserver/lbx/lbxmain.c,v 1.6 1998/10/04 09:39:05 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxmain.c,v 1.8 2000/06/07 22:03:14 tsi Exp $ */
#include <sys/types.h>
#define NEED_REPLIES
@@ -59,12 +59,13 @@ in this Software without prior written authorization from The Open Group.
#include "gcstruct.h"
#include "extnsionst.h"
#include "servermd.h"
-#include "lbxdeltastr.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
+#include "lbxdeltastr.h"
#include "lbxserve.h"
#include "lbximage.h"
#include "lbxsrvopts.h"
+#include "lbxtags.h"
#include "Xfuncproto.h"
#include <errno.h>
#ifdef X_NOT_STDC_ENV
@@ -85,11 +86,12 @@ extern int errno;
#define MAXBYTESDIFF 8
-extern void LbxAllowMotion();
-extern int LbxDecodePoints();
-extern int LbxDecodeSegment();
-extern int LbxDecodeRectangle();
-extern int LbxDecodeArc();
+extern void LbxAllowMotion ( ClientPtr client, int num );
+extern int LbxDecodePoints ( char *in, char *inend, short *out );
+extern int LbxDecodeSegment ( char *in, char *inend, short *out );
+extern int LbxDecodeRectangle ( char *in, char *inend, short *out );
+extern int LbxDecodeArc ( char *in, char *inend, short *out );
+
extern int GrabInProgress;
@@ -99,12 +101,11 @@ int LbxWhoAmI = 1; /*
* proxy = 0
*/
-int ProcLbxDispatch();
-extern int SProcLbxDispatch();
-static void LbxResetProc();
-static int DecodeLbxDelta();
-static void LbxFreeClient ();
-static void LbxShutdownProxy ();
+
+static void LbxResetProc ( ExtensionEntry *extEntry );
+static void LbxFreeClient ( ClientPtr client );
+static void LbxShutdownProxy ( LbxProxyPtr proxy );
+static int DecodeLbxDelta ( ClientPtr client );
static LbxProxyPtr proxyList;
unsigned char LbxReqCode;
@@ -118,7 +119,7 @@ LbxClientPtr lbxClients[MAXCLIENTS];
extern xConnSetupPrefix connSetupPrefix;
extern char *ConnectionInfo;
-extern int (*LbxInitialVector[3])();
+extern int (*LbxInitialVector[3])(ClientPtr);
#ifdef DEBUG
int lbxDebug = 0;
@@ -126,7 +127,7 @@ int lbxDebug = 0;
void
-LbxExtensionInit()
+LbxExtensionInit(void)
{
ExtensionEntry *extEntry;
@@ -149,16 +150,14 @@ LbxExtensionInit()
/*ARGSUSED*/
static void
-LbxResetProc (extEntry)
-ExtensionEntry *extEntry;
+LbxResetProc (ExtensionEntry *extEntry)
{
LbxResetTags();
uid_seed = 0;
}
void
-LbxCloseClient (client)
- ClientPtr client;
+LbxCloseClient (ClientPtr client)
{
xLbxCloseEvent closeEvent;
ClientPtr master;
@@ -205,10 +204,9 @@ LbxCloseClient (client)
}
static int
-LbxReencodeEvent(client, proxy, buf)
- ClientPtr client;
- LbxProxyPtr proxy;
- char *buf;
+LbxReencodeEvent(ClientPtr client,
+ LbxProxyPtr proxy,
+ char *buf)
{
xEvent *ev = (xEvent *)buf;
int n;
@@ -367,27 +365,26 @@ LbxReencodeEvent(client, proxy, buf)
}
static int
-LbxComposeDelta(proxy, reply, len, buf)
- LbxProxyPtr proxy;
- char *reply;
- int len;
- char *buf;
+LbxComposeDelta(LbxProxyPtr proxy,
+ char *reply,
+ int len,
+ char *buf)
{
int diffs;
int cindex;
int n;
xLbxDeltaReq *p = (xLbxDeltaReq *)buf;
- diffs = LBXDeltaMinDiffs(&proxy->outdeltas, reply, len,
+ diffs = LBXDeltaMinDiffs(&proxy->outdeltas, (unsigned char *)reply, len,
min(MAXBYTESDIFF, (len - sz_xLbxDeltaReq) >> 1),
&cindex);
if (diffs < 0) {
- LBXAddDeltaOut(&proxy->outdeltas, reply, len);
+ LBXAddDeltaOut(&proxy->outdeltas, (unsigned char *)reply, len);
return 0;
}
- LBXEncodeDelta(&proxy->outdeltas, reply, diffs, cindex,
- &buf[sz_xLbxDeltaReq]);
- LBXAddDeltaOut(&proxy->outdeltas, reply, len);
+ LBXEncodeDelta(&proxy->outdeltas, (unsigned char *)reply, diffs, cindex,
+ (unsigned char *)(&buf[sz_xLbxDeltaReq]));
+ LBXAddDeltaOut(&proxy->outdeltas, (unsigned char *)reply, len);
p->reqType = LbxEventCode;
p->lbxReqType = LbxDeltaEvent;
p->diffs = diffs;
@@ -401,12 +398,11 @@ LbxComposeDelta(proxy, reply, len, buf)
}
void
-LbxReencodeOutput(client, pbuf, pcount, cbuf, ccount)
- ClientPtr client;
- char *pbuf;
- int *pcount;
- char *cbuf;
- int *ccount;
+LbxReencodeOutput(ClientPtr client,
+ char *pbuf,
+ int *pcount,
+ char *cbuf,
+ int *ccount)
{
LbxClientPtr lbxClient = LbxClient(client);
LbxProxyPtr proxy = lbxClient->proxy;
@@ -498,10 +494,9 @@ LbxReencodeOutput(client, pbuf, pcount, cbuf, ccount)
/*ARGSUSED*/
static void
-LbxReplyCallback(pcbl, nulldata, calldata)
- CallbackListPtr *pcbl;
- pointer nulldata;
- pointer calldata;
+LbxReplyCallback(CallbackListPtr *pcbl,
+ pointer nulldata,
+ pointer calldata)
{
ReplyInfoRec *pri = (ReplyInfoRec *)calldata;
ClientPtr client = pri->client;
@@ -521,9 +516,8 @@ LbxReplyCallback(pcbl, nulldata, calldata)
*/
/* ARGSUSED */
static Bool
-LbxCheckCompressInput (dummy1, dummy2)
- ClientPtr dummy1;
- pointer dummy2;
+LbxCheckCompressInput (ClientPtr dummy1,
+ pointer dummy2)
{
LbxProxyPtr proxy;
@@ -539,8 +533,7 @@ LbxCheckCompressInput (dummy1, dummy2)
}
static Bool
-LbxIsClientBlocked (lbxClient)
- LbxClientPtr lbxClient;
+LbxIsClientBlocked (LbxClientPtr lbxClient)
{
LbxProxyPtr proxy = lbxClient->proxy;
@@ -550,9 +543,8 @@ LbxIsClientBlocked (lbxClient)
}
static void
-LbxSwitchRecv (proxy, lbxClient)
- LbxProxyPtr proxy;
- LbxClientPtr lbxClient;
+LbxSwitchRecv (LbxProxyPtr proxy,
+ LbxClientPtr lbxClient)
{
ClientPtr client;
@@ -573,9 +565,8 @@ LbxSwitchRecv (proxy, lbxClient)
/* ARGSUSED */
static Bool
-LbxWaitForUnblocked (client, closure)
- ClientPtr client;
- pointer closure;
+LbxWaitForUnblocked (ClientPtr client,
+ pointer closure)
{
LbxClientPtr lbxClient;
LbxProxyPtr proxy;
@@ -599,8 +590,7 @@ LbxWaitForUnblocked (client, closure)
}
void
-LbxSetForBlock(lbxClient)
- LbxClientPtr lbxClient;
+LbxSetForBlock(LbxClientPtr lbxClient)
{
lbxClient->reqs_pending++;
if (!lbxClient->input_blocked)
@@ -612,9 +602,8 @@ LbxSetForBlock(lbxClient)
/* ARGSUSED */
static int
-LbxWaitForUngrab (client, closure)
- ClientPtr client;
- pointer closure;
+LbxWaitForUngrab (ClientPtr client,
+ pointer closure)
{
LbxClientPtr lbxClient = LbxClient(client);
LbxProxyPtr proxy;
@@ -638,8 +627,7 @@ LbxWaitForUngrab (client, closure)
}
static void
-LbxServerGrab(proxy)
- LbxProxyPtr proxy;
+LbxServerGrab(LbxProxyPtr proxy)
{
LbxClientPtr grabbingLbxClient;
xLbxListenToOneEvent grabEvent;
@@ -723,8 +711,7 @@ static Bool lbxCacheable[] = {
#define NUM(a) (sizeof (a) / sizeof (a[0]))
static int
-LbxReadRequestFromClient (client)
- ClientPtr client;
+LbxReadRequestFromClient (ClientPtr client)
{
int ret;
LbxClientPtr lbxClient = LbxClient(client);
@@ -802,10 +789,9 @@ LbxReadRequestFromClient (client)
}
static LbxClientPtr
-LbxInitClient (proxy, client, id)
- LbxProxyPtr proxy;
- ClientPtr client;
- CARD32 id;
+LbxInitClient (LbxProxyPtr proxy,
+ ClientPtr client,
+ CARD32 id)
{
LbxClientPtr lbxClient;
int i;
@@ -837,8 +823,7 @@ LbxInitClient (proxy, client, id)
}
static void
-LbxFreeClient (client)
- ClientPtr client;
+LbxFreeClient (ClientPtr client)
{
LbxClientPtr lbxClient = LbxClient(client);
LbxProxyPtr proxy = lbxClient->proxy;
@@ -867,8 +852,7 @@ LbxFreeClient (client)
}
static void
-LbxFreeProxy (proxy)
- LbxProxyPtr proxy;
+LbxFreeProxy (LbxProxyPtr proxy)
{
LbxProxyPtr *p;
@@ -908,8 +892,7 @@ LbxFreeProxy (proxy)
}
LbxProxyPtr
-LbxPidToProxy(pid)
- int pid;
+LbxPidToProxy(int pid)
{
LbxProxyPtr proxy;
@@ -921,8 +904,7 @@ LbxPidToProxy(pid)
}
static void
-LbxShutdownProxy (proxy)
- LbxProxyPtr proxy;
+LbxShutdownProxy (LbxProxyPtr proxy)
{
int i;
ClientPtr client;
@@ -946,8 +928,7 @@ LbxShutdownProxy (proxy)
int
-ProcLbxQueryVersion(client)
- register ClientPtr client;
+ProcLbxQueryVersion (ClientPtr client)
{
REQUEST(xLbxQueryVersionReq);
xLbxQueryVersionReply rep;
@@ -972,7 +953,7 @@ ProcLbxQueryVersion(client)
}
static int
-NextProxyID()
+NextProxyID (void)
{
LbxProxyPtr proxy;
int id;
@@ -987,8 +968,7 @@ NextProxyID()
}
int
-ProcLbxStartProxy(client)
- register ClientPtr client;
+ProcLbxStartProxy (ClientPtr client)
{
REQUEST(xLbxStartProxyReq);
LbxProxyPtr proxy;
@@ -1037,9 +1017,9 @@ ProcLbxStartProxy(client)
LbxOptionInit(&negopt);
replylen = LbxOptionParse(&negopt,
- &stuff[1],
+ (unsigned char *)&stuff[1],
reqlen - sz_xLbxStartProxyReq,
- &replybuf->optDataStart);
+ (unsigned char *)&replybuf->optDataStart);
if (replylen < 0) {
/*
* Didn't understand option format, so we'll just end up
@@ -1137,8 +1117,7 @@ ProcLbxStartProxy(client)
}
int
-ProcLbxStopProxy(client)
- register ClientPtr client;
+ProcLbxStopProxy(ClientPtr client)
{
REQUEST(xLbxStopProxyReq);
LbxProxyPtr proxy;
@@ -1158,8 +1137,7 @@ ProcLbxStopProxy(client)
}
int
-ProcLbxSwitch(client)
- register ClientPtr client;
+ProcLbxSwitch(ClientPtr client)
{
REQUEST(xLbxSwitchReq);
LbxProxyPtr proxy = LbxMaybeProxy(client);
@@ -1181,8 +1159,7 @@ ProcLbxSwitch(client)
}
int
-ProcLbxBeginLargeRequest(client)
- register ClientPtr client;
+ProcLbxBeginLargeRequest(ClientPtr client)
{
REQUEST(xLbxBeginLargeRequestReq);
@@ -1195,8 +1172,7 @@ ProcLbxBeginLargeRequest(client)
int
-ProcLbxLargeRequestData(client)
- register ClientPtr client;
+ProcLbxLargeRequestData(ClientPtr client)
{
REQUEST(xLbxLargeRequestDataReq);
@@ -1210,8 +1186,7 @@ ProcLbxLargeRequestData(client)
int
-ProcLbxEndLargeRequest(client)
- register ClientPtr client;
+ProcLbxEndLargeRequest(ClientPtr client)
{
REQUEST(xReq);
@@ -1222,8 +1197,7 @@ ProcLbxEndLargeRequest(client)
int
-ProcLbxInternAtoms(client)
- register ClientPtr client;
+ProcLbxInternAtoms(ClientPtr client)
{
REQUEST(xLbxInternAtomsReq);
LbxClientPtr lbxClient = LbxClient(client);
@@ -1289,8 +1263,7 @@ ProcLbxInternAtoms(client)
int
-ProcLbxGetWinAttrAndGeom(client)
- register ClientPtr client;
+ProcLbxGetWinAttrAndGeom(ClientPtr client)
{
REQUEST(xLbxGetWinAttrAndGeomReq);
xGetWindowAttributesReply wa;
@@ -1369,8 +1342,7 @@ ProcLbxGetWinAttrAndGeom(client)
}
int
-ProcLbxNewClient(client)
- register ClientPtr client;
+ProcLbxNewClient(ClientPtr client)
{
REQUEST(xLbxNewClientReq);
ClientPtr newClient;
@@ -1418,8 +1390,7 @@ ProcLbxNewClient(client)
}
int
-ProcLbxEstablishConnection(client)
- register ClientPtr client;
+ProcLbxEstablishConnection(ClientPtr client)
{
char *reason = NULL;
char *auth_proto, *auth_string;
@@ -1446,8 +1417,7 @@ ProcLbxEstablishConnection(client)
}
int
-ProcLbxCloseClient (client)
- register ClientPtr client;
+ProcLbxCloseClient (ClientPtr client)
{
REQUEST(xLbxCloseClientReq);
LbxClientPtr lbxClient = LbxClient(client);
@@ -1461,8 +1431,7 @@ ProcLbxCloseClient (client)
}
int
-ProcLbxModifySequence (client)
- register ClientPtr client;
+ProcLbxModifySequence (ClientPtr client)
{
REQUEST(xLbxModifySequenceReq);
@@ -1472,8 +1441,7 @@ ProcLbxModifySequence (client)
}
int
-ProcLbxAllowMotion (client)
- register ClientPtr client;
+ProcLbxAllowMotion (ClientPtr client)
{
REQUEST(xLbxAllowMotionReq);
@@ -1485,17 +1453,17 @@ ProcLbxAllowMotion (client)
static int
-DecodeLbxDelta(client)
- register ClientPtr client;
+DecodeLbxDelta (ClientPtr client)
{
REQUEST(xLbxDeltaReq);
LbxClientPtr lbxClient = LbxClient(client);
LbxProxyPtr proxy = lbxClient->proxy;
int len;
- char *buf;
+ unsigned char *buf;
/* Note that LBXDecodeDelta decodes and adds current msg to the cache */
- len = LBXDecodeDelta(&proxy->indeltas, ((char *)stuff) + sz_xLbxDeltaReq,
+ len = LBXDecodeDelta(&proxy->indeltas,
+ (xLbxDiffItem *)(((char *)stuff) + sz_xLbxDeltaReq),
stuff->diffs, stuff->cindex, &buf);
/*
* Some requests, such as FillPoly, result in the protocol input
@@ -1512,8 +1480,7 @@ DecodeLbxDelta(client)
}
int
-ProcLbxGetModifierMapping(client)
- ClientPtr client;
+ProcLbxGetModifierMapping(ClientPtr client)
{
REQUEST(xLbxGetModifierMappingReq);
@@ -1522,8 +1489,7 @@ ProcLbxGetModifierMapping(client)
}
int
-ProcLbxGetKeyboardMapping(client)
- ClientPtr client;
+ProcLbxGetKeyboardMapping(ClientPtr client)
{
REQUEST(xLbxGetKeyboardMappingReq);
@@ -1532,8 +1498,7 @@ ProcLbxGetKeyboardMapping(client)
}
int
-ProcLbxQueryFont(client)
- ClientPtr client;
+ProcLbxQueryFont(ClientPtr client)
{
REQUEST(xLbxQueryFontReq);
@@ -1542,8 +1507,7 @@ ProcLbxQueryFont(client)
}
int
-ProcLbxChangeProperty(client)
- ClientPtr client;
+ProcLbxChangeProperty(ClientPtr client)
{
REQUEST(xLbxChangePropertyReq);
@@ -1552,8 +1516,7 @@ ProcLbxChangeProperty(client)
}
int
-ProcLbxGetProperty(client)
- ClientPtr client;
+ProcLbxGetProperty(ClientPtr client)
{
REQUEST(xLbxGetPropertyReq);
@@ -1562,8 +1525,7 @@ ProcLbxGetProperty(client)
}
int
-ProcLbxTagData(client)
- ClientPtr client;
+ProcLbxTagData(ClientPtr client)
{
REQUEST(xLbxTagDataReq);
@@ -1575,8 +1537,7 @@ ProcLbxTagData(client)
}
int
-ProcLbxInvalidateTag(client)
- ClientPtr client;
+ProcLbxInvalidateTag(ClientPtr client)
{
REQUEST(xLbxInvalidateTagReq);
@@ -1586,93 +1547,80 @@ ProcLbxInvalidateTag(client)
}
int
-ProcLbxPolyPoint(client)
- register ClientPtr client;
+ProcLbxPolyPoint(ClientPtr client)
{
return LbxDecodePoly(client, X_PolyPoint, LbxDecodePoints);
}
int
-ProcLbxPolyLine(client)
- register ClientPtr client;
+ProcLbxPolyLine(ClientPtr client)
{
return LbxDecodePoly(client, X_PolyLine, LbxDecodePoints);
}
int
-ProcLbxPolySegment(client)
- register ClientPtr client;
+ProcLbxPolySegment(ClientPtr client)
{
return LbxDecodePoly(client, X_PolySegment, LbxDecodeSegment);
}
int
-ProcLbxPolyRectangle(client)
- register ClientPtr client;
+ProcLbxPolyRectangle(ClientPtr client)
{
return LbxDecodePoly(client, X_PolyRectangle, LbxDecodeRectangle);
}
int
-ProcLbxPolyArc(client)
- register ClientPtr client;
+ProcLbxPolyArc(ClientPtr client)
{
return LbxDecodePoly(client, X_PolyArc, LbxDecodeArc);
}
int
-ProcLbxFillPoly(client)
- register ClientPtr client;
+ProcLbxFillPoly(ClientPtr client)
{
return LbxDecodeFillPoly(client);
}
int
-ProcLbxPolyFillRectangle(client)
- register ClientPtr client;
+ProcLbxPolyFillRectangle(ClientPtr client)
{
return LbxDecodePoly(client, X_PolyFillRectangle, LbxDecodeRectangle);
}
int
-ProcLbxPolyFillArc(client)
- register ClientPtr client;
+ProcLbxPolyFillArc(ClientPtr client)
{
return LbxDecodePoly(client, X_PolyFillArc, LbxDecodeArc);
}
int
-ProcLbxCopyArea (client)
- register ClientPtr client;
+ProcLbxCopyArea(ClientPtr client)
{
return LbxDecodeCopyArea(client);
}
int
-ProcLbxCopyPlane (client)
- register ClientPtr client;
+ProcLbxCopyPlane(ClientPtr client)
{
return LbxDecodeCopyPlane(client);
}
int
-ProcLbxPolyText (client)
- register ClientPtr client;
+ProcLbxPolyText(ClientPtr client)
{
return LbxDecodePolyText(client);
}
int
-ProcLbxImageText (client)
- register ClientPtr client;
+ProcLbxImageText(ClientPtr client)
{
return LbxDecodeImageText(client);
}
int
-ProcLbxQueryExtension(client)
- ClientPtr client;
+ProcLbxQueryExtension(ClientPtr client)
{
REQUEST(xLbxQueryExtensionReq);
char *ename;
@@ -1683,23 +1631,20 @@ ProcLbxQueryExtension(client)
}
int
-ProcLbxPutImage(client)
- register ClientPtr client;
+ProcLbxPutImage(ClientPtr client)
{
return LbxDecodePutImage(client);
}
int
-ProcLbxGetImage(client)
- register ClientPtr client;
+ProcLbxGetImage(ClientPtr client)
{
return LbxDecodeGetImage(client);
}
int
-ProcLbxSync(client)
- register ClientPtr client;
+ProcLbxSync(ClientPtr client)
{
xLbxSyncReply reply;
@@ -1728,8 +1673,7 @@ ProcLbxSync(client)
int
-ProcLbxDispatch (client)
- register ClientPtr client;
+ProcLbxDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data)
diff --git a/xc/programs/Xserver/lbx/lbxopts.c b/xc/programs/Xserver/lbx/lbxopts.c
index a03c78847..7ae86ee4f 100644
--- a/xc/programs/Xserver/lbx/lbxopts.c
+++ b/xc/programs/Xserver/lbx/lbxopts.c
@@ -21,7 +21,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
-/* $XFree86: xc/programs/Xserver/lbx/lbxopts.c,v 1.2 1998/12/20 11:57:56 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/lbx/lbxopts.c,v 1.4 2000/06/07 22:03:14 tsi Exp $ */
#ifdef OPTDEBUG
#include <stdio.h>
@@ -29,6 +29,8 @@
#include "X.h"
#include "Xproto.h"
#include "misc.h"
+#include "colormapst.h"
+#include "propertyst.h"
#include "lbxserve.h"
#include "lbxstr.h"
#include "lbximage.h"
@@ -38,22 +40,35 @@
#include "lbxzlib.h"
#endif /* NO_ZLIB */
-static int LbxDeltaOpt();
-static int LbxProxyDeltaOpt();
-static int LbxServerDeltaOpt();
-static int LbxStreamCompOpt();
-static int LbxBitmapCompOpt();
-static int LbxPixmapCompOpt();
-static int LbxMessageCompOpt();
-static int LbxUseTagsOpt();
-static int LbxCmapAllOpt();
+static int LbxProxyDeltaOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxServerDeltaOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxDeltaOpt ( unsigned char *popt, int optlen,
+ unsigned char *preply, short *pn, short *pmaxlen );
+static int LbxStreamCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int ZlibParse ( LbxNegOptsPtr pno, unsigned char *popt, int optlen,
+ unsigned char *preply );
+static int LbxMessageCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxUseTagsOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxBitmapCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int LbxPixmapCompOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+static int MergeDepths ( int *depths, LbxPixmapCompMethod *method );
+static int LbxCmapAllOpt ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
/*
* List of LBX options we recognize and are willing to negotiate
*/
static struct _LbxOptionParser {
CARD8 optcode;
- int (*parser)();
+ int (*parser)(LbxNegOptsPtr, unsigned char *,
+ int, unsigned char *);
} LbxOptions[] = {
{ LBX_OPT_DELTA_PROXY, LbxProxyDeltaOpt },
{ LBX_OPT_DELTA_SERVER, LbxServerDeltaOpt },
@@ -70,8 +85,8 @@ static struct _LbxOptionParser {
/*
* Set option defaults
*/
-LbxOptionInit(pno)
- LbxNegOptsPtr pno;
+void
+LbxOptionInit(LbxNegOptsPtr pno)
{
bzero(pno, sizeof(LbxNegOptsRec));
pno->proxyDeltaN = pno->serverDeltaN = LBX_OPT_DELTA_NCACHE_DFLT;
@@ -86,11 +101,10 @@ LbxOptionInit(pno)
}
int
-LbxOptionParse(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+LbxOptionParse(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
int i;
int nopts = *popt++;
@@ -140,34 +154,31 @@ LbxOptionParse(pno, popt, optlen, preply)
}
static int
-LbxProxyDeltaOpt(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+LbxProxyDeltaOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
return LbxDeltaOpt(popt, optlen, preply,
&pno->proxyDeltaN, &pno->proxyDeltaMaxLen);
}
static int
-LbxServerDeltaOpt(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+LbxServerDeltaOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
return LbxDeltaOpt(popt, optlen, preply,
&pno->serverDeltaN, &pno->serverDeltaMaxLen);
}
static int
-LbxDeltaOpt(popt, optlen, preply, pn, pmaxlen)
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
- short *pn;
- short *pmaxlen;
+LbxDeltaOpt(unsigned char *popt,
+ int optlen,
+ unsigned char *preply,
+ short *pn,
+ short *pmaxlen)
{
short n;
short maxlen;
@@ -212,12 +223,12 @@ LbxDeltaOpt(popt, optlen, preply, pn, pmaxlen)
return LBX_OPT_DELTA_REPLYLEN;
}
-static int ZlibParse();
static struct _LbxStreamCompParser {
int typelen;
char *type;
- int (*parser)();
+ int (*parser)(LbxNegOptsPtr, unsigned char *,
+ int, unsigned char *);
} LbxStreamComp[] = {
#ifndef NO_ZLIB
{ ZLIB_STRCOMP_OPT_LEN, ZLIB_STRCOMP_OPT, ZlibParse },
@@ -228,11 +239,10 @@ static struct _LbxStreamCompParser {
(sizeof(LbxStreamComp) / sizeof(struct _LbxStreamCompParser))
static int
-LbxStreamCompOpt(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+LbxStreamCompOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
int i;
int typelen;
@@ -278,18 +288,11 @@ LbxStreamCompOpt(pno, popt, optlen, preply)
}
-extern LbxStreamCompHandle ZlibInit();
-extern int ZlibStuffInput(), ZlibInputAvail(), ZlibFlush(),
- ZlibRead(), ZlibWriteV();
-extern void ZlibCompressOn(), ZlibCompressOff(), ZlibFree();
-
-
static int
-ZlibParse(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+ZlibParse(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
int level; /* compression level */
@@ -300,7 +303,8 @@ ZlibParse(pno, popt, optlen, preply)
if (level < 1 || level > 9)
return (-1);
- pno->streamOpts.streamCompInit = ZlibInit;
+ pno->streamOpts.streamCompInit =
+ (LbxStreamCompHandle (*)(int, pointer))ZlibInit;
pno->streamOpts.streamCompArg = (pointer)(long)level;
pno->streamOpts.streamCompStuffInput = ZlibStuffInput;
pno->streamOpts.streamCompInputAvail = ZlibInputAvail;
@@ -309,17 +313,17 @@ ZlibParse(pno, popt, optlen, preply)
pno->streamOpts.streamCompWriteV = ZlibWriteV;
pno->streamOpts.streamCompOn = ZlibCompressOn;
pno->streamOpts.streamCompOff = ZlibCompressOff;
- pno->streamOpts.streamCompFreeHandle = ZlibFree;
+ pno->streamOpts.streamCompFreeHandle =
+ (void (*)(LbxStreamCompHandle))ZlibFree;
return (0);
}
static int
-LbxMessageCompOpt(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+LbxMessageCompOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
if (optlen == 0) {
@@ -335,11 +339,10 @@ LbxMessageCompOpt(pno, popt, optlen, preply)
static int
-LbxUseTagsOpt(pno, popt, optlen, preply)
- LbxNegOptsPtr pno;
- unsigned char *popt;
- int optlen;
- unsigned char *preply;
+LbxUseTagsOpt(LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
if (optlen == 0) {
@@ -405,22 +408,18 @@ LbxPixmapCompMethods [] = {
(sizeof (LbxPixmapCompMethods) / sizeof (LbxPixmapCompMethod))
#endif
-static int MergeDepths ();
-
static int
-LbxImageCompOpt (pixmap, pno, popt, optlen, preply)
-
-Bool pixmap;
-LbxNegOptsPtr pno;
-unsigned char *popt;
-int optlen;
-unsigned char *preply;
+LbxImageCompOpt (Bool pixmap,
+ LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
unsigned char *preplyStart = preply;
int numMethods = *popt++;
- char *myIndices, *hisIndices;
+ unsigned char *myIndices, *hisIndices;
unsigned *retFormats;
int **retDepths;
int replyCount = 0;
@@ -437,8 +436,8 @@ unsigned char *preply;
return (1);
}
- myIndices = (char *) xalloc (numMethods);
- hisIndices = (char *) xalloc (numMethods);
+ myIndices = (unsigned char *) xalloc (numMethods);
+ hisIndices = (unsigned char *) xalloc (numMethods);
if (!myIndices || !hisIndices)
{
@@ -635,12 +634,10 @@ unsigned char *preply;
static int
-LbxBitmapCompOpt (pno, popt, optlen, preply)
-
-LbxNegOptsPtr pno;
-unsigned char *popt;
-int optlen;
-unsigned char *preply;
+LbxBitmapCompOpt (LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
return (LbxImageCompOpt (0 /* bitmap */, pno, popt, optlen, preply));
@@ -648,12 +645,10 @@ unsigned char *preply;
static int
-LbxPixmapCompOpt (pno, popt, optlen, preply)
-
-LbxNegOptsPtr pno;
-unsigned char *popt;
-int optlen;
-unsigned char *preply;
+LbxPixmapCompOpt (LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
return (LbxImageCompOpt (1 /* Pixmap */, pno, popt, optlen, preply));
@@ -661,10 +656,8 @@ unsigned char *preply;
LbxBitmapCompMethod *
-LbxSrvrLookupBitmapCompMethod (proxy, methodOpCode)
-
-LbxProxyPtr proxy;
-int methodOpCode;
+LbxSrvrLookupBitmapCompMethod (LbxProxyPtr proxy,
+ int methodOpCode)
{
int i;
@@ -684,10 +677,8 @@ int methodOpCode;
LbxPixmapCompMethod *
-LbxSrvrLookupPixmapCompMethod (proxy, methodOpCode)
-
-LbxProxyPtr proxy;
-int methodOpCode;
+LbxSrvrLookupPixmapCompMethod (LbxProxyPtr proxy,
+ int methodOpCode)
{
int i;
@@ -707,9 +698,7 @@ int methodOpCode;
LbxBitmapCompMethod *
-LbxSrvrFindPreferredBitmapCompMethod (proxy)
-
-LbxProxyPtr proxy;
+LbxSrvrFindPreferredBitmapCompMethod (LbxProxyPtr proxy)
{
if (proxy->numBitmapCompMethods == 0)
@@ -721,11 +710,9 @@ LbxProxyPtr proxy;
LbxPixmapCompMethod *
-LbxSrvrFindPreferredPixmapCompMethod (proxy, format, depth)
-
-LbxProxyPtr proxy;
-int format;
-int depth;
+LbxSrvrFindPreferredPixmapCompMethod (LbxProxyPtr proxy,
+ int format,
+ int depth)
{
if (proxy->numPixmapCompMethods == 0)
@@ -758,10 +745,9 @@ int depth;
}
-static int MergeDepths (depths, method)
-
-int *depths;
-LbxPixmapCompMethod *method;
+static int
+MergeDepths (int *depths,
+ LbxPixmapCompMethod *method)
{
int i, j, count;
@@ -789,12 +775,10 @@ LbxPixmapCompMethod *method;
#define LbxCmapAllMethod "XC-CMAP"
static int
-LbxCmapAllOpt (pno, popt, optlen, preply)
-
-LbxNegOptsPtr pno;
-unsigned char *popt;
-int optlen;
-unsigned char *preply;
+LbxCmapAllOpt (LbxNegOptsPtr pno,
+ unsigned char *popt,
+ int optlen,
+ unsigned char *preply)
{
int numMethods = *popt++;
diff --git a/xc/programs/Xserver/lbx/lbxprop.c b/xc/programs/Xserver/lbx/lbxprop.c
index e79d18e5d..6c286e731 100644
--- a/xc/programs/Xserver/lbx/lbxprop.c
+++ b/xc/programs/Xserver/lbx/lbxprop.c
@@ -42,6 +42,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxprop.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
/* various bits of DIX-level mangling */
@@ -57,6 +58,7 @@ in this Software without prior written authorization from The Open Group.
#include "resource.h"
#include "servermd.h"
#include "propertyst.h"
+#include "colormapst.h"
#include "windowstr.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
@@ -68,14 +70,11 @@ in this Software without prior written authorization from The Open Group.
#include "extensions/security.h"
#endif
-extern int (*ProcVector[256]) ();
-extern void (*ReplySwapVector[256]) ();
-extern void CopySwap16Write(), CopySwap32Write(), Swap32Write();
+extern ReplySwapPtr CopySwap16Write, CopySwap32Write, Swap32Write;
void
-LbxStallPropRequest(client, pProp)
- ClientPtr client;
- PropertyPtr pProp;
+LbxStallPropRequest(ClientPtr client,
+ PropertyPtr pProp)
{
xReq *req = (xReq *) client->requestBuffer;
register char n;
@@ -135,19 +134,17 @@ LbxStallPropRequest(client, pProp)
}
int
-LbxChangeWindowProperty(client, pWin, property, type, format, mode, len,
- have_data, value, sendevent, tag)
- ClientPtr client;
- WindowPtr pWin;
- Atom property,
- type;
- int format,
- mode;
- unsigned long len;
- Bool have_data;
- pointer value;
- Bool sendevent;
- XID *tag;
+LbxChangeWindowProperty(ClientPtr client,
+ WindowPtr pWin,
+ Atom property,
+ Atom type,
+ int format,
+ int mode,
+ unsigned long len,
+ Bool have_data,
+ pointer value,
+ Bool sendevent,
+ XID *tag)
{
PropertyPtr pProp;
xEvent event;
@@ -284,8 +281,7 @@ LbxChangeWindowProperty(client, pWin, property, type, format, mode, len,
}
int
-LbxChangeProperty(client)
- ClientPtr client;
+LbxChangeProperty(ClientPtr client)
{
WindowPtr pWin;
char format,
@@ -366,9 +362,8 @@ LbxChangeProperty(client)
}
static void
-LbxWriteGetpropReply(client, rep)
- ClientPtr client;
- xLbxGetPropertyReply *rep;
+LbxWriteGetpropReply(ClientPtr client,
+ xLbxGetPropertyReply *rep)
{
int n;
@@ -384,8 +379,7 @@ LbxWriteGetpropReply(client, rep)
}
int
-LbxGetProperty(client)
- ClientPtr client;
+LbxGetProperty(ClientPtr client)
{
PropertyPtr pProp,
prevProp;
@@ -527,7 +521,7 @@ LbxGetProperty(client)
client->pSwapReplyFunc = CopySwap16Write;
break;
default:
- client->pSwapReplyFunc = (void (*) ()) WriteToClient;
+ client->pSwapReplyFunc = (ReplySwapPtr) WriteToClient;
break;
}
WriteSwappedDataToClient(client, len,
diff --git a/xc/programs/Xserver/lbx/lbxserve.h b/xc/programs/Xserver/lbx/lbxserve.h
index c5b3049a1..a436fc599 100644
--- a/xc/programs/Xserver/lbx/lbxserve.h
+++ b/xc/programs/Xserver/lbx/lbxserve.h
@@ -41,12 +41,13 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxserve.h,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
#ifndef _LBXSERVE_H_
#define _LBXSERVE_H_
-#include "lbxdeltastr.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
+#include "lbxdeltastr.h"
#include "lbxopts.h"
#define MAX_LBX_CLIENTS MAXCLIENTS
@@ -100,9 +101,9 @@ typedef struct _LbxProxy {
LbxStreamOpts streamOpts;
int numBitmapCompMethods;
- char *bitmapCompMethods; /* array of indices */
+ unsigned char *bitmapCompMethods; /* array of indices */
int numPixmapCompMethods;
- char *pixmapCompMethods; /* array of indices */
+ unsigned char *pixmapCompMethods; /* array of indices */
int **pixmapCompDepths; /* depths supported from each method */
struct _ColormapRec *grabbedCmaps; /* chained via lbx private */
@@ -122,48 +123,154 @@ extern LbxClientPtr lbxClients[MAXCLIENTS];
extern int LbxEventCode;
-extern void LbxDixInit(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-extern LbxProxyPtr LbxPidToProxy(
-#if NeedFunctionPrototypes
- int /* pid */
-#endif
-);
-
-extern void LbxReencodeOutput(
-#if NeedFunctionPrototypes
- ClientPtr /*client*/,
- char* /*pbuf*/,
- int* /*pcount*/,
- char* /*cbuf*/,
- int* /*ccount*/
-#endif
-);
-
-extern int UncompressedWriteToClient(
-#if NeedFunctionPrototypes
- ClientPtr /*who*/,
- int /*count*/,
- char* /*buf*/
-#endif
-);
-
-extern ClientPtr AllocLbxClientConnection(
-#if NeedFunctionPrototypes
- ClientPtr /* client */,
- LbxProxyPtr /* proxy */
-#endif
-);
-
-extern void LbxProxyConnection(
-#if NeedFunctionPrototypes
- ClientPtr /* client */,
- LbxProxyPtr /* proxy */
-#endif
-);
+
+/* os/connection.c */
+extern ClientPtr AllocLbxClientConnection ( ClientPtr client,
+ LbxProxyPtr proxy );
+extern void LbxProxyConnection ( ClientPtr client, LbxProxyPtr proxy );
+
+/* os/libxio.c */
+extern int UncompressedWriteToClient ( ClientPtr who, int count, char *buf );
+extern void LbxForceOutput ( LbxProxyPtr proxy );
+extern void SwitchClientInput ( ClientPtr client, Bool pending );
+extern int PrepareLargeReqBuffer ( ClientPtr client );
+extern Bool AppendFakeRequest ( ClientPtr client, char *data, int count );
+extern int LbxFreeOsBuffers ( LbxProxyPtr proxy );
+extern Bool AllocateLargeReqBuffer ( ClientPtr client, int size );
+extern Bool AddToLargeReqBuffer ( ClientPtr client, char *data, int size );
+
+/* lbxcmap.c */
+extern int LbxCmapInit ( void );
+extern Bool LbxCheckColorRequest ( ClientPtr client, ColormapPtr pmap,
+ xReq *req );
+extern int LbxCheckCmapGrabbed ( ColormapPtr pmap );
+extern void LbxDisableSmartGrab ( ColormapPtr pmap );
+extern void LbxBeginFreeCellsEvent ( ColormapPtr pmap );
+extern void LbxAddFreeCellToEvent ( ColormapPtr pmap, Pixel pixel );
+extern void LbxEndFreeCellsEvent ( ColormapPtr pmap );
+extern void LbxSortPixelList ( Pixel *pixels, int count );
+extern int ProcLbxGrabCmap ( ClientPtr client );
+extern void LbxReleaseCmap ( ColormapPtr pmap, Bool smart );
+extern int ProcLbxReleaseCmap ( ClientPtr client );
+extern int ProcLbxAllocColor ( ClientPtr client );
+extern int ProcLbxIncrementPixel ( ClientPtr client );
+
+/* lbxdix.h */
+extern void LbxDixInit ( void );
+extern void LbxResetTags ( void );
+extern int LbxSendConnSetup ( ClientPtr client, char *reason );
+extern int LbxGetModifierMapping ( ClientPtr client );
+extern int LbxGetKeyboardMapping ( ClientPtr client );
+extern int LbxQueryFont ( ClientPtr client );
+extern int LbxTagData ( ClientPtr client, XID tag, unsigned long len,
+ pointer data );
+extern int LbxInvalidateTag ( ClientPtr client, XID tag );
+extern void LbxAllowMotion ( ClientPtr client, int num );
+extern void LbxFlushModifierMapTag ( void );
+extern void LbxFlushKeyboardMapTag ( void );
+extern void LbxFreeFontTag ( FontPtr pfont );
+extern void LbxSendInvalidateTag ( ClientPtr client, XID tag, int tagtype );
+extern Bool LbxFlushQTag ( XID tag );
+extern void ProcessQTagZombies ( void );
+extern void LbxQueryTagData ( ClientPtr client, int owner_pid, XID tag,
+ int tagtype );
+
+/* lbxexts.c */
+extern Bool LbxAddExtension ( char *name, int opcode, int ev_base,
+ int err_base );
+extern Bool LbxAddExtensionAlias ( int idx, char *alias );
+extern void LbxDeclareExtensionSecurity ( char *extname, Bool secure );
+extern Bool LbxRegisterExtensionGenerationMasks ( int idx, int num_reqs,
+ char *rep_mask,
+ char *ev_mask );
+extern int LbxQueryExtension ( ClientPtr client, char *ename, int nlen );
+extern void LbxCloseDownExtensions ( void );
+extern void LbxSetReqMask ( CARD8 *mask, int req, Bool on );
+
+/* lbxgfx.c */
+extern int LbxDecodePoly( ClientPtr client, CARD8 xreqtype,
+ int (*decode_rtn)(char *, char *, short *) );
+extern int LbxDecodeFillPoly ( ClientPtr client );
+extern int LbxDecodeCopyArea ( ClientPtr client );
+extern int LbxDecodeCopyPlane ( ClientPtr client );
+extern int LbxDecodePolyText ( ClientPtr client );
+extern int LbxDecodeImageText ( ClientPtr client );
+extern int LbxDecodePutImage ( ClientPtr client );
+extern int LbxDecodeGetImage ( ClientPtr client );
+extern int LbxDecodePoints ( char *in, char *inend, short *out );
+extern int LbxDecodeSegment ( char *in, char *inend, short *out );
+extern int LbxDecodeRectangle ( char *in, char *inend, short *out );
+extern int LbxDecodeArc ( char *in, char *inend, short *out );
+
+/* lbxmain.c */
+extern LbxProxyPtr LbxPidToProxy ( int pid );
+extern void LbxReencodeOutput ( ClientPtr client, char *pbuf, int *pcount,
+ char *cbuf, int *ccount );
+extern void LbxExtensionInit ( void );
+extern void LbxCloseClient ( ClientPtr client );
+extern void LbxSetForBlock ( LbxClientPtr lbxClient );
+extern int ProcLbxDispatch ( ClientPtr client );
+extern int ProcLbxSwitch ( ClientPtr client );
+extern int ProcLbxQueryVersion ( ClientPtr client );
+extern int ProcLbxStartProxy ( ClientPtr client );
+extern int ProcLbxStopProxy ( ClientPtr client );
+extern int ProcLbxBeginLargeRequest ( ClientPtr client );
+extern int ProcLbxLargeRequestData ( ClientPtr client );
+extern int ProcLbxEndLargeRequest ( ClientPtr client );
+extern int ProcLbxInternAtoms ( ClientPtr client );
+extern int ProcLbxGetWinAttrAndGeom ( ClientPtr client );
+extern int ProcLbxNewClient ( ClientPtr client );
+extern int ProcLbxEstablishConnection ( ClientPtr client );
+extern int ProcLbxCloseClient ( ClientPtr client );
+extern int ProcLbxModifySequence ( ClientPtr client );
+extern int ProcLbxAllowMotion ( ClientPtr client );
+extern int ProcLbxGetModifierMapping ( ClientPtr client );
+extern int ProcLbxGetKeyboardMapping ( ClientPtr client );
+extern int ProcLbxQueryFont ( ClientPtr client );
+extern int ProcLbxChangeProperty ( ClientPtr client );
+extern int ProcLbxGetProperty ( ClientPtr client );
+extern int ProcLbxTagData ( ClientPtr client );
+extern int ProcLbxInvalidateTag ( ClientPtr client );
+extern int ProcLbxPolyPoint ( ClientPtr client );
+extern int ProcLbxPolyLine ( ClientPtr client );
+extern int ProcLbxPolySegment ( ClientPtr client );
+extern int ProcLbxPolyRectangle ( ClientPtr client );
+extern int ProcLbxPolyArc ( ClientPtr client );
+extern int ProcLbxFillPoly ( ClientPtr client );
+extern int ProcLbxPolyFillRectangle ( ClientPtr client );
+extern int ProcLbxPolyFillArc ( ClientPtr client );
+extern int ProcLbxCopyArea ( ClientPtr client );
+extern int ProcLbxCopyPlane ( ClientPtr client );
+extern int ProcLbxPolyText ( ClientPtr client );
+extern int ProcLbxImageText ( ClientPtr client );
+extern int ProcLbxQueryExtension ( ClientPtr client );
+extern int ProcLbxPutImage ( ClientPtr client );
+extern int ProcLbxGetImage ( ClientPtr client );
+extern int ProcLbxSync ( ClientPtr client );
+
+/* lbxprop.c */
+extern int LbxChangeProperty ( ClientPtr client );
+extern int LbxGetProperty ( ClientPtr client );
+extern void LbxStallPropRequest ( ClientPtr client, PropertyPtr pProp );
+extern int LbxChangeWindowProperty ( ClientPtr client, WindowPtr pWin,
+ Atom property, Atom type, int format,
+ int mode, unsigned long len,
+ Bool have_data, pointer value,
+ Bool sendevent, XID *tag );
+/* lbxsquish.c */
+extern int LbxSquishEvent ( char *buf );
+
+/* lbwswap.c */
+extern int SProcLbxDispatch( ClientPtr client );
+extern int SProcLbxSwitch ( ClientPtr client );
+extern int SProcLbxBeginLargeRequest ( ClientPtr client );
+extern int SProcLbxLargeRequestData ( ClientPtr client );
+extern int SProcLbxEndLargeRequest ( ClientPtr client );
+extern void LbxWriteSConnSetupPrefix ( ClientPtr pClient,
+ xLbxConnSetupPrefix *pcsp );
+extern void LbxSwapFontInfo ( xLbxFontInfo *pr, Bool compressed );
+
+/* lbxzerorep.c */
+extern void ZeroReplyPadBytes ( char *buf, int reqType );
#endif /* _LBXSERVE_H_ */
diff --git a/xc/programs/Xserver/lbx/lbxsquish.c b/xc/programs/Xserver/lbx/lbxsquish.c
index c8018cee0..54c195c26 100644
--- a/xc/programs/Xserver/lbx/lbxsquish.c
+++ b/xc/programs/Xserver/lbx/lbxsquish.c
@@ -42,12 +42,15 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxsquish.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
#define NEED_REPLIES
#define NEED_EVENTS
#include "X.h"
#include "Xproto.h"
#include "Xos.h"
#include "misc.h"
+#include "colormapst.h"
+#include "propertyst.h"
#include "lbxserve.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
@@ -131,8 +134,7 @@ static char lbxevpad[] = {
};
int
-LbxSquishEvent(buf)
- char *buf;
+LbxSquishEvent(char *buf)
{
int delta = lbxevdelta[((xEvent *)buf)->u.u.type];
int pad = lbxevpad[((xEvent *)buf)->u.u.type];
diff --git a/xc/programs/Xserver/lbx/lbxsrvopts.h b/xc/programs/Xserver/lbx/lbxsrvopts.h
index b41e3c764..997316175 100644
--- a/xc/programs/Xserver/lbx/lbxsrvopts.h
+++ b/xc/programs/Xserver/lbx/lbxsrvopts.h
@@ -21,6 +21,7 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxsrvopts.h,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
#ifndef _LBX_SRVOPTS_H_
#define _LBX_SRVOPTS_H_
@@ -35,9 +36,9 @@ typedef struct _LbxNegOpts {
short serverDeltaMaxLen;
LbxStreamOpts streamOpts;
int numBitmapCompMethods;
- char *bitmapCompMethods; /* array of indices */
+ unsigned char *bitmapCompMethods; /* array of indices */
int numPixmapCompMethods;
- char *pixmapCompMethods; /* array of indices */
+ unsigned char *pixmapCompMethods; /* array of indices */
int **pixmapCompDepths; /* depths supported from each method */
Bool squish;
Bool useTags;
@@ -46,33 +47,17 @@ typedef struct _LbxNegOpts {
typedef LbxNegOptsRec *LbxNegOptsPtr;
-extern LbxBitmapCompMethod *LbxSrvrLookupBitmapCompMethod (
-#if NeedFunctionPrototypes
- LbxProxyPtr, /* proxy */
- int /* methodOpCode */
-#endif
-);
-
-extern LbxPixmapCompMethod *LbxSrvrLookupPixmapCompMethod (
-#if NeedFunctionPrototypes
- LbxProxyPtr, /* proxy */
- int /* methodOpCode */
-#endif
-);
-
-extern LbxBitmapCompMethod *LbxSrvrFindPreferredBitmapCompMethod (
-#if NeedFunctionPrototypes
- LbxProxyPtr /* proxy */
-#endif
-);
-
-extern LbxPixmapCompMethod *LbxSrvrFindPreferredPixmapCompMethod (
-#if NeedFunctionPrototypes
- LbxProxyPtr, /* proxy */
- int, /* format */
- int /* depth */
-#endif
-);
+extern void LbxOptionInit ( LbxNegOptsPtr pno );
+extern int LbxOptionParse ( LbxNegOptsPtr pno, unsigned char *popt,
+ int optlen, unsigned char *preply );
+extern LbxBitmapCompMethod *
+LbxSrvrLookupBitmapCompMethod ( LbxProxyPtr proxy, int methodOpCode );
+extern LbxPixmapCompMethod *
+LbxSrvrLookupPixmapCompMethod ( LbxProxyPtr proxy, int methodOpCode );
+extern LbxBitmapCompMethod *
+LbxSrvrFindPreferredBitmapCompMethod ( LbxProxyPtr proxy );
+extern LbxPixmapCompMethod *
+LbxSrvrFindPreferredPixmapCompMethod ( LbxProxyPtr proxy, int format, int depth );
#endif /* _LBX_SRVOPTS_H_ */
diff --git a/xc/programs/Xserver/lbx/lbxswap.c b/xc/programs/Xserver/lbx/lbxswap.c
index d8447f19c..737bcb700 100644
--- a/xc/programs/Xserver/lbx/lbxswap.c
+++ b/xc/programs/Xserver/lbx/lbxswap.c
@@ -41,6 +41,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxswap.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
#include <sys/types.h>
#define NEED_REPLIES
@@ -54,6 +55,8 @@ in this Software without prior written authorization from The Open Group.
#include "pixmapstr.h"
#include "scrnintstr.h"
#include "servermd.h"
+#include "swaprep.h"
+#include "propertyst.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
#include "lbxserve.h"
@@ -62,8 +65,7 @@ in this Software without prior written authorization from The Open Group.
#include <stdio.h>
static int
-SProcLbxQueryVersion(client)
- register ClientPtr client;
+SProcLbxQueryVersion(ClientPtr client)
{
register int n;
@@ -74,8 +76,7 @@ SProcLbxQueryVersion(client)
}
static int
-SProcLbxStartProxy(client)
- register ClientPtr client;
+SProcLbxStartProxy(ClientPtr client)
{
register int n;
@@ -86,8 +87,7 @@ SProcLbxStartProxy(client)
}
static int
-SProcLbxStopProxy(client)
- register ClientPtr client;
+SProcLbxStopProxy(ClientPtr client)
{
register int n;
@@ -98,8 +98,7 @@ SProcLbxStopProxy(client)
}
int
-SProcLbxSwitch(client)
- register ClientPtr client;
+SProcLbxSwitch(ClientPtr client)
{
register int n;
@@ -111,8 +110,7 @@ SProcLbxSwitch(client)
}
int
-SProcLbxBeginLargeRequest (client)
- register ClientPtr client;
+SProcLbxBeginLargeRequest (ClientPtr client)
{
register int n;
@@ -124,8 +122,7 @@ SProcLbxBeginLargeRequest (client)
}
int
-SProcLbxLargeRequestData (client)
- register ClientPtr client;
+SProcLbxLargeRequestData (ClientPtr client)
{
register int n;
@@ -136,8 +133,7 @@ SProcLbxLargeRequestData (client)
}
int
-SProcLbxEndLargeRequest (client)
- register ClientPtr client;
+SProcLbxEndLargeRequest (ClientPtr client)
{
register int n;
@@ -148,8 +144,7 @@ SProcLbxEndLargeRequest (client)
}
static int
-SProcLbxNewClient(client)
- register ClientPtr client;
+SProcLbxNewClient(ClientPtr client)
{
register int n;
@@ -161,8 +156,7 @@ SProcLbxNewClient(client)
}
static int
-SProcLbxCloseClient(client)
- register ClientPtr client;
+SProcLbxCloseClient(ClientPtr client)
{
register int n;
@@ -174,8 +168,7 @@ SProcLbxCloseClient(client)
}
static int
-SProcLbxModifySequence(client)
- register ClientPtr client;
+SProcLbxModifySequence(ClientPtr client)
{
register int n;
@@ -187,8 +180,7 @@ SProcLbxModifySequence(client)
}
static int
-SProcLbxAllowMotion(client)
- register ClientPtr client;
+SProcLbxAllowMotion(ClientPtr client)
{
register int n;
@@ -200,8 +192,7 @@ SProcLbxAllowMotion(client)
}
static int
-SProcLbxIncrementPixel(client)
- register ClientPtr client;
+SProcLbxIncrementPixel(ClientPtr client)
{
register int n;
@@ -214,8 +205,7 @@ SProcLbxIncrementPixel(client)
}
static int
-SProcLbxGrabCmap(client)
- register ClientPtr client;
+SProcLbxGrabCmap(ClientPtr client)
{
register int n;
@@ -228,8 +218,7 @@ SProcLbxGrabCmap(client)
}
static int
-SProcLbxReleaseCmap(client)
- register ClientPtr client;
+SProcLbxReleaseCmap(ClientPtr client)
{
register int n;
@@ -242,8 +231,7 @@ SProcLbxReleaseCmap(client)
}
static int
-SProcLbxAllocColor(client)
- register ClientPtr client;
+SProcLbxAllocColor(ClientPtr client)
{
register int n;
@@ -260,8 +248,7 @@ SProcLbxAllocColor(client)
}
static int
-SProcLbxGetModifierMapping(client)
- register ClientPtr client;
+SProcLbxGetModifierMapping(ClientPtr client)
{
register int n;
@@ -272,8 +259,7 @@ SProcLbxGetModifierMapping(client)
}
static int
-SProcLbxGetKeyboardMapping(client)
- register ClientPtr client;
+SProcLbxGetKeyboardMapping(ClientPtr client)
{
register int n;
@@ -284,8 +270,7 @@ SProcLbxGetKeyboardMapping(client)
}
static int
-SProcLbxQueryFont(client)
- register ClientPtr client;
+SProcLbxQueryFont(ClientPtr client)
{
register int n;
@@ -297,8 +282,7 @@ SProcLbxQueryFont(client)
}
static int
-SProcLbxChangeProperty(client)
- register ClientPtr client;
+SProcLbxChangeProperty(ClientPtr client)
{
register int n;
@@ -324,8 +308,7 @@ SProcLbxChangeProperty(client)
}
static int
-SProcLbxGetProperty(client)
- register ClientPtr client;
+SProcLbxGetProperty(ClientPtr client)
{
register int n;
@@ -341,8 +324,7 @@ SProcLbxGetProperty(client)
}
static int
-SProcLbxTagData(client)
- register ClientPtr client;
+SProcLbxTagData(ClientPtr client)
{
register int n;
@@ -355,8 +337,7 @@ SProcLbxTagData(client)
}
static int
-SProcLbxInvalidateTag(client)
- register ClientPtr client;
+SProcLbxInvalidateTag(ClientPtr client)
{
register int n;
@@ -368,8 +349,7 @@ SProcLbxInvalidateTag(client)
}
static int
-SProcLbxPoly(client)
- register ClientPtr client;
+SProcLbxPoly(ClientPtr client)
{
register int n;
@@ -389,8 +369,7 @@ SProcLbxPoly(client)
}
static int
-SProcLbxFillPoly(client)
- register ClientPtr client;
+SProcLbxFillPoly(ClientPtr client)
{
register int n;
@@ -410,10 +389,9 @@ SProcLbxFillPoly(client)
}
static int
-SProcLbxCopyArea (client)
- register ClientPtr client;
+SProcLbxCopyArea(ClientPtr client)
{
- register int n;
+ int n;
REQUEST(xLbxCopyAreaReq);
char *after;
@@ -436,10 +414,9 @@ SProcLbxCopyArea (client)
}
static int
-SProcLbxCopyPlane (client)
- register ClientPtr client;
+SProcLbxCopyPlane(ClientPtr client)
{
- register int n;
+ int n;
REQUEST(xLbxCopyPlaneReq);
char *after;
@@ -463,8 +440,7 @@ SProcLbxCopyPlane (client)
}
static int
-SProcLbxPolyText(client)
- register ClientPtr client;
+SProcLbxPolyText(ClientPtr client)
{
register int n;
@@ -484,8 +460,7 @@ SProcLbxPolyText(client)
}
static int
-SProcLbxImageText(client)
- register ClientPtr client;
+SProcLbxImageText(ClientPtr client)
{
register int n;
@@ -506,8 +481,7 @@ SProcLbxImageText(client)
static int
-SProcLbxPutImage(client)
- register ClientPtr client;
+SProcLbxPutImage(ClientPtr client)
{
register int n;
@@ -518,8 +492,7 @@ SProcLbxPutImage(client)
}
static int
-SProcLbxGetImage(client)
- register ClientPtr client;
+SProcLbxGetImage(ClientPtr client)
{
register int n;
@@ -536,8 +509,7 @@ SProcLbxGetImage(client)
}
static int
-SProcLbxInternAtoms(client)
- register ClientPtr client;
+SProcLbxInternAtoms(ClientPtr client)
{
register int n;
char *ptr;
@@ -565,8 +537,7 @@ SProcLbxInternAtoms(client)
static int
-SProcLbxGetWinAttrAndGeom(client)
- ClientPtr client;
+SProcLbxGetWinAttrAndGeom(ClientPtr client)
{
int n;
@@ -581,8 +552,7 @@ SProcLbxGetWinAttrAndGeom(client)
static int
-SProcLbxQueryExtension(client)
- ClientPtr client;
+SProcLbxQueryExtension(ClientPtr client)
{
int n;
@@ -594,8 +564,7 @@ SProcLbxQueryExtension(client)
}
int
-SProcLbxDispatch(client)
- register ClientPtr client;
+SProcLbxDispatch(ClientPtr client)
{
REQUEST(xReq);
switch (stuff->data) {
@@ -678,10 +647,9 @@ SProcLbxDispatch(client)
#ifdef notyet
void
-LbxWriteSConnectionInfo(pClient, size, pInfo)
- ClientPtr pClient;
- unsigned long size;
- char *pInfo;
+LbxWriteSConnectionInfo(ClientPtr pClient,
+ unsigned long size,
+ char *pInfo)
{
int i, j, k;
ScreenPtr pScreen;
@@ -737,8 +705,8 @@ LbxWriteSConnectionInfo(pClient, size, pInfo)
}
void
-SwapConnSetup(pConnSetup, pConnSetupT)
- xConnSetup *pConnSetup, *pConnSetupT;
+SwapConnSetup(xConnSetup *pConnSetup,
+ xConnSetup *pConnSetupT)
{
cpswapl(pConnSetup->release, pConnSetupT->release);
cpswapl(pConnSetup->ridBase, pConnSetupT->ridBase);
@@ -757,8 +725,8 @@ SwapConnSetup(pConnSetup, pConnSetupT)
}
void
-SwapWinRoot(pRoot, pRootT)
- xWindowRoot *pRoot, *pRootT;
+SwapWinRoot(xWindowRoot *pRoot,
+ xWindowRoot *pRootT)
{
cpswapl(pRoot->windowId, pRootT->windowId);
cpswapl(pRoot->defaultColormap, pRootT->defaultColormap);
@@ -779,8 +747,8 @@ SwapWinRoot(pRoot, pRootT)
}
void
-SwapVisual(pVis, pVisT)
- xVisualType *pVis, *pVisT;
+SwapVisual(xVisualType *pVis,
+ xVisualType *pVisT;
{
cpswapl(pVis->visualID, pVisT->visualID);
pVisT->class = pVis->class;
@@ -793,9 +761,8 @@ SwapVisual(pVis, pVisT)
#endif
void
-LbxWriteSConnSetupPrefix(pClient, pcsp)
- ClientPtr pClient;
- xLbxConnSetupPrefix *pcsp;
+LbxWriteSConnSetupPrefix(ClientPtr pClient,
+ xLbxConnSetupPrefix *pcsp)
{
xLbxConnSetupPrefix cspT;
@@ -810,9 +777,8 @@ LbxWriteSConnSetupPrefix(pClient, pcsp)
}
void
-LbxSwapFontInfo(pr, compressed)
- xLbxFontInfo *pr;
- Bool compressed;
+LbxSwapFontInfo(xLbxFontInfo *pr,
+ Bool compressed)
{
unsigned i;
xCharInfo *pxci;
diff --git a/xc/programs/Xserver/lbx/lbxtables.c b/xc/programs/Xserver/lbx/lbxtables.c
index 590857eca..138c9bf34 100644
--- a/xc/programs/Xserver/lbx/lbxtables.c
+++ b/xc/programs/Xserver/lbx/lbxtables.c
@@ -21,11 +21,13 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxtables.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
+#include "dix.h"
-extern int ProcInitialConnection();
-extern int ProcLbxEstablishConnection();
+extern int ProcInitialConnection(ClientPtr client);
+extern int ProcLbxEstablishConnection(ClientPtr client);
-int (* LbxInitialVector[3]) () =
+int (* LbxInitialVector[3]) (ClientPtr) =
{
0,
ProcInitialConnection,
diff --git a/xc/programs/Xserver/lbx/lbxtags.c b/xc/programs/Xserver/lbx/lbxtags.c
index dc7a890c8..259f29181 100644
--- a/xc/programs/Xserver/lbx/lbxtags.c
+++ b/xc/programs/Xserver/lbx/lbxtags.c
@@ -42,30 +42,31 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxtags.c,v 1.2 2000/05/18 23:46:24 dawes Exp $ */
#include "X.h"
#include "misc.h"
#include "lbxdata.h"
#include "resource.h"
+#include "colormapst.h"
+#include "propertyst.h"
#include "lbxtags.h"
#define _XLBX_SERVER_
#include "lbxstr.h"
#include "propertyst.h"
-static int tag_free();
-
static RESTYPE TagResType;
+extern int _lbx_fi_junklen;
+
/* ARGSUSED */
static int
-tag_free(data, id)
- pointer data;
- XID id;
+tag_free(pointer data,
+ XID id)
{
TagData td = (TagData) data;
FontTagInfoPtr ftip;
char *t;
- extern int _lbx_fi_junklen;
if (td->global)
*(td->global) = 0;
@@ -84,21 +85,21 @@ tag_free(data, id)
return 0;
}
-TagInit()
+void
+TagInit(void)
{
TagResType = CreateNewResourceType(tag_free);
}
XID
-TagNewTag()
+TagNewTag(void)
{
return FakeClientID(0);
}
void
-TagClearProxy(tid, pid)
- XID tid;
- int pid;
+TagClearProxy(XID tid,
+ int pid)
{
TagData td;
@@ -108,9 +109,8 @@ TagClearProxy(tid, pid)
}
void
-TagMarkProxy(tid, pid)
- XID tid;
- int pid;
+TagMarkProxy(XID tid,
+ int pid)
{
TagData td;
@@ -119,9 +119,8 @@ TagMarkProxy(tid, pid)
}
Bool
-TagProxyMarked(tid, pid)
- XID tid;
- int pid;
+TagProxyMarked(XID tid,
+ int pid)
{
TagData td;
@@ -130,11 +129,10 @@ TagProxyMarked(tid, pid)
}
XID
-TagSaveTag(dtype, size, data, global)
- int dtype;
- int size;
- pointer data;
- XID *global;
+TagSaveTag(int dtype,
+ int size,
+ pointer data,
+ XID *global)
{
TagData td;
@@ -158,8 +156,7 @@ TagSaveTag(dtype, size, data, global)
}
void
-TagDeleteTag(tid)
- XID tid;
+TagDeleteTag(XID tid)
{
int pid;
TagData td;
@@ -188,8 +185,7 @@ TagDeleteTag(tid)
}
TagData
-TagGetTag(tid)
- XID tid;
+TagGetTag(XID tid)
{
TagData td;
@@ -198,10 +194,9 @@ TagGetTag(tid)
}
static void
-LbxFlushTag(value, tid, cdata)
- pointer value;
- XID tid;
- pointer cdata;
+LbxFlushTag(pointer value,
+ XID tid,
+ pointer cdata)
{
TagData td = (TagData)value;
LbxProxyPtr proxy = (LbxProxyPtr)cdata;
@@ -227,8 +222,8 @@ LbxFlushTag(value, tid, cdata)
/*
* clear out markers for proxies
*/
-LbxFlushTags(proxy)
- LbxProxyPtr proxy;
+void
+LbxFlushTags(LbxProxyPtr proxy)
{
FindClientResourcesByType(NULL, TagResType, LbxFlushTag, (pointer)proxy);
}
diff --git a/xc/programs/Xserver/lbx/lbxtags.h b/xc/programs/Xserver/lbx/lbxtags.h
index b76e9a646..156a49812 100644
--- a/xc/programs/Xserver/lbx/lbxtags.h
+++ b/xc/programs/Xserver/lbx/lbxtags.h
@@ -42,6 +42,7 @@ in this Software without prior written authorization from The Open Group.
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxtags.h,v 1.2 2000/05/18 23:46:25 dawes Exp $ */
#ifndef _LBXTAGS_H_
#define _LBXTAGS_H_
@@ -64,52 +65,14 @@ typedef struct _tagdata {
typedef struct _tagdata *TagData;
-extern TagData TagGetTag(
-#if NeedFunctionPrototypes
- XID /*tid*/
-#endif
-);
-
-extern XID TagNewTag(
-#if NeedFunctionPrototypes
- void
-#endif
-);
-
-extern void TagClearProxy(
-#if NeedFunctionPrototypes
- XID /*tid*/,
- int /*pid*/
-#endif
-);
-
-extern void TagMarkProxy(
-#if NeedFunctionPrototypes
- XID /*tid*/,
- int /*pid*/
-#endif
-);
-
-extern Bool TagProxyMarked(
-#if NeedFunctionPrototypes
- XID /*tid*/,
- int /*pid*/
-#endif
-);
-
-extern void TagDeleteTag(
-#if NeedFunctionPrototypes
- XID /*tid*/
-#endif
-);
-
-extern XID TagSaveTag(
-#if NeedFunctionPrototypes
- int /*dtype*/,
- int /*size*/,
- pointer /*data*/,
- XID* /*global*/
-#endif
-);
+extern void TagInit ( void );
+extern XID TagNewTag ( void );
+extern void TagClearProxy ( XID tid, int pid );
+extern void TagMarkProxy ( XID tid, int pid );
+extern Bool TagProxyMarked ( XID tid, int pid );
+extern XID TagSaveTag ( int dtype, int size, pointer data, XID *global );
+extern void TagDeleteTag ( XID tid );
+extern TagData TagGetTag ( XID tid );
+extern void LbxFlushTags ( LbxProxyPtr proxy );
#endif /* _LBXTAGS_H_ */
diff --git a/xc/programs/Xserver/lbx/lbxzerorep.c b/xc/programs/Xserver/lbx/lbxzerorep.c
index 335d4e575..994f6a242 100644
--- a/xc/programs/Xserver/lbx/lbxzerorep.c
+++ b/xc/programs/Xserver/lbx/lbxzerorep.c
@@ -23,6 +23,7 @@ other dealings in this Software without prior written authorization
from The Open Group.
*/
+/* $XFree86: xc/programs/Xserver/lbx/lbxzerorep.c,v 1.2 2000/05/18 23:46:25 dawes Exp $ */
/*
* This module handles zeroing out unused pad bytes in core X replies.
@@ -34,10 +35,9 @@ from The Open Group.
#include "X.h"
#include <X11/Xproto.h>
-
-ZeroReplyPadBytes (buf, reqType)
- char *buf;
- int reqType;
+void
+ZeroReplyPadBytes (char *buf,
+ int reqType)
{
switch (reqType) {
case X_GetWindowAttributes:
diff --git a/xc/programs/Xserver/mi/Imakefile b/xc/programs/Xserver/mi/Imakefile
index b93fc1a7d..c6519b718 100644
--- a/xc/programs/Xserver/mi/Imakefile
+++ b/xc/programs/Xserver/mi/Imakefile
@@ -1,5 +1,5 @@
XCOMM $XConsortium: Imakefile /main/44 1996/12/02 10:22:16 lehors $
-XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.29 2000/02/11 06:31:48 mvojkovi Exp $
+XCOMM $XFree86: xc/programs/Xserver/mi/Imakefile,v 3.30 2000/03/31 22:55:54 dawes Exp $
#include <Server.tmpl>
#if ! HasCbrt
@@ -74,6 +74,7 @@ InstallDriverSDKNonExecFile(mi.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(mibank.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(mibstore.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(micmap.h,$(DRIVERSDKINCLUDEDIR))
+InstallDriverSDKNonExecFile(migc.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(miline.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(mipointer.h,$(DRIVERSDKINCLUDEDIR))
InstallDriverSDKNonExecFile(mipointrst.h,$(DRIVERSDKINCLUDEDIR))
diff --git a/xc/programs/Xserver/mi/miinitext.c b/xc/programs/Xserver/mi/miinitext.c
index 79ec1a1ab..f877a73bd 100644
--- a/xc/programs/Xserver/mi/miinitext.c
+++ b/xc/programs/Xserver/mi/miinitext.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.49 2000/02/13 06:15:41 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/miinitext.c,v 3.50 2000/04/17 16:30:14 eich Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -228,9 +228,9 @@ InitExtensions(argc, argv)
char *argv[];
{
#ifdef PANORAMIX
-#if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX)
+# if !defined(PRINT_ONLY_SERVER) && !defined(NO_PANORAMIX)
if (!noPanoramiXExtension) PanoramiXExtensionInit();
-#endif
+# endif
#endif
#ifdef BEZIER
BezierExtensionInit();
diff --git a/xc/programs/Xserver/mi/mioverlay.c b/xc/programs/Xserver/mi/mioverlay.c
index 19589e594..d651d6102 100644
--- a/xc/programs/Xserver/mi/mioverlay.c
+++ b/xc/programs/Xserver/mi/mioverlay.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/mi/mioverlay.c,v 3.4 2000/02/29 00:16:03 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/mi/mioverlay.c,v 3.8 2000/06/07 22:03:15 tsi Exp $ */
#include "X.h"
#include "scrnintstr.h"
@@ -391,7 +391,9 @@ miOverlayMarkOverlappedWindows(
}
if(overMarked)
MARK_OVERLAY(pWin->parent);
- } else if(doUnderlay) {
+ }
+
+ if(doUnderlay && !pTree) {
if(!(pTree = MIOVERLAY_GET_WINDOW_TREE(pWin))) {
pChild = pWin->lastChild;
while(1) {
@@ -718,8 +720,10 @@ miOverlayMarkUnrealizedWindow(
(* pChild->drawable.pScreen->ClipNotify)(pChild, 0, 0);
REGION_EMPTY(pChild->drawable.pScreen, &pChild->borderClip);
if((pTree = MIOVERLAY_GET_WINDOW_TREE(pChild))) {
- REGION_EMPTY(pChild->drawable.pScreen, &pTree->clipList);
- REGION_EMPTY(pChild->drawable.pScreen, &pTree->borderClip);
+ if(pTree->valdata != (miOverlayValDataPtr)UnmapValData) {
+ REGION_EMPTY(pChild->drawable.pScreen, &pTree->clipList);
+ REGION_EMPTY(pChild->drawable.pScreen, &pTree->borderClip);
+ }
}
}
}
@@ -1208,7 +1212,7 @@ miOverlayResizeWindow(
REGION_UNION(pScreen, gravitate2[g],
gravitate2[g], &tChild->borderClip);
} else
- CollectUnderlayChildrenRegions(pChild, gravitate[g]);
+ CollectUnderlayChildrenRegions(pChild, gravitate2[g]);
}
} else {
UnmapWindow(pChild, TRUE);
diff --git a/xc/programs/Xserver/os/Imakefile b/xc/programs/Xserver/os/Imakefile
index 01a70b323..68c0e3f5c 100644
--- a/xc/programs/Xserver/os/Imakefile
+++ b/xc/programs/Xserver/os/Imakefile
@@ -1,5 +1,5 @@
XCOMM $TOG: Imakefile /main/85 1997/12/07 18:26:23 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.26 1999/11/19 13:55:09 hohndel Exp $
+XCOMM $XFree86: xc/programs/Xserver/os/Imakefile,v 3.27 2000/05/05 17:47:29 keithp Exp $
#include <Server.tmpl>
/*
@@ -73,15 +73,20 @@ COLOR_SRCS=oscolor.c
COLOR_OBJS=oscolor.o
#endif
+#if UseInternalMalloc
+MALLOC_SRCS=xalloc.c
+MALLOC_OBJS=xalloc.o
+#endif
+
BOOTSTRAPCFLAGS =
SRCS = WaitFor.c access.c connection.c io.c $(COLOR_SRCS) \
osinit.c utils.c auth.c mitauth.c secauth.c $(XDMAUTHSRCS) \
$(RPCSRCS) $(KRB5SRCS) xdmcp.c decompress.c OtherSources \
- transport.c xalloc.c $(LBX_SRCS)
+ transport.c $(MALLOC_SRCS) $(LBX_SRCS)
OBJS = WaitFor.o access.o connection.o io.o $(COLOR_OBJS) \
osinit.o utils.o auth.o mitauth.o secauth.o $(XDMAUTHOBJS) \
$(RPCOBJS) $(KRB5OBJS) xdmcp.o decompress.o OtherObjects \
- transport.o xalloc.o $(LBX_OBJS)
+ transport.o $(MALLOC_OBJS) $(LBX_OBJS)
#if SpecialMalloc
MEM_DEFINES = -DSPECIAL_MALLOC
diff --git a/xc/programs/Xserver/os/WaitFor.c b/xc/programs/Xserver/os/WaitFor.c
index 631bea0f6..49361d50b 100644
--- a/xc/programs/Xserver/os/WaitFor.c
+++ b/xc/programs/Xserver/os/WaitFor.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.23 1999/11/19 13:55:10 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/os/WaitFor.c,v 3.24 2000/05/05 17:53:50 keithp Exp $ */
/***********************************************************
Copyright 1987, 1998 The Open Group
@@ -157,6 +157,7 @@ WaitForSomething(pClientsReady)
CARD32 now;
#ifdef SMART_SCHEDULE
Bool someReady = FALSE;
+ extern Bool SmartScheduleIdle;
#endif
FD_ZERO(&clientsReadable);
@@ -329,6 +330,7 @@ WaitForSomething(pClientsReady)
XFD_COPYSET(&AllSockets, &LastSelectMask);
#ifdef SMART_SCHEDULE
}
+ SmartScheduleIdle = TRUE;
#endif
BlockHandler((pointer)&wt, (pointer)&LastSelectMask);
if (NewOutputPending)
@@ -358,27 +360,24 @@ WaitForSomething(pClientsReady)
}
#endif /* XTESTEXT1 */
#ifdef SMART_SCHEDULE
- if (someReady)
+ if (i >= 0)
{
- /*
- * If no-one else is home, bail quickly
- */
- if (i == 0)
- {
- XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
- XFD_COPYSET(&ClientsWithInput, &clientsReadable);
- break;
- }
- XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
+ extern unsigned long SmartScheduleIdleCount;
+ extern Bool SmartScheduleTimerStopped;
+ extern Bool SmartScheduleStartTimer(void);
+
+ SmartScheduleIdle = FALSE;
+ SmartScheduleIdleCount = 0;
+ if (SmartScheduleTimerStopped)
+ (void) SmartScheduleStartTimer ();
}
#endif
if (i <= 0) /* An error or timeout occurred */
{
-
if (dispatchException)
return 0;
- FD_ZERO(&clientsWritable);
if (i < 0)
+ {
if (selecterr == EBADF) /* Some client disconnected */
{
CheckConnections ();
@@ -395,6 +394,18 @@ WaitForSomething(pClientsReady)
ErrorF("WaitForSomething(): select: errno=%d\n",
selecterr);
}
+ }
+#ifdef SMART_SCHEDULE
+ else if (someReady)
+ {
+ /*
+ * If no-one else is home, bail quickly
+ */
+ XFD_COPYSET(&ClientsWithInput, &LastSelectMask);
+ XFD_COPYSET(&ClientsWithInput, &clientsReadable);
+ break;
+ }
+#endif
if (timers)
{
now = GetTimeInMillis();
@@ -407,6 +418,10 @@ WaitForSomething(pClientsReady)
else
{
fd_set tmp_set;
+#ifdef SMART_SCHEDULE
+ if (someReady)
+ XFD_ORSET(&LastSelectMask, &ClientsWithInput, &LastSelectMask);
+#endif
if (AnyClientsWriteBlocked && XFD_ANYSET (&clientsWritable))
{
NewOutputPending = TRUE;
diff --git a/xc/programs/Xserver/os/connection.c b/xc/programs/Xserver/os/connection.c
index ae38a7925..e74412498 100644
--- a/xc/programs/Xserver/os/connection.c
+++ b/xc/programs/Xserver/os/connection.c
@@ -41,7 +41,7 @@ ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE.
******************************************************************/
-/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.38 1999/05/15 12:10:35 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/connection.c,v 3.40 2000/06/26 23:00:32 dawes Exp $ */
/*****************************************************************
* Stuff to create connections --- OS dependent
*
@@ -160,6 +160,8 @@ extern __const__ int _nfiles;
#include "extensions/security.h"
#endif
#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
#include "lbxserve.h"
#endif
@@ -639,24 +641,7 @@ ClientAuthorized(client, proto_n, auth_proto, string_n, auth_string)
string_n, auth_string, client, &reason);
#ifdef LBX
- if (restore_trans_conn) {
- /*
- * Restore client's trans_conn state
- */
- priv = (OsCommPtr)client->osPrivate;
- priv->trans_conn = NULL;
-
- trans_conn = NULL;
- }
-
-#endif
-
-#ifdef LBX
- if (!trans_conn) {
- /*
- * Use the proxy's trans_conn
- */
- trans_conn = ((OsCommPtr)lbxpc->osPrivate)->trans_conn;
+ if (! priv->trans_conn) {
if (auth_id == (XID) ~0L && !GetAccessControl())
auth_id = ((OsCommPtr)lbxpc->osPrivate)->auth_id;
#ifdef XCSECURITY
@@ -686,7 +671,7 @@ ClientAuthorized(client, proto_n, auth_proto, string_n, auth_string)
#endif
if (
#ifdef LBX
- !priv->trans_conn ||
+ !trans_conn ||
#endif
InvalidHost ((struct sockaddr *) from, fromlen))
AuthAudit(client, FALSE, (struct sockaddr *) from,
@@ -703,11 +688,20 @@ ClientAuthorized(client, proto_n, auth_proto, string_n, auth_string)
xfree ((char *) from);
}
- if (auth_id == (XID) ~0L)
+ if (auth_id == (XID) ~0L) {
+#ifdef LBX
+ /*
+ * Restore client's trans_conn state
+ */
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
if (reason)
return reason;
else
return "Client is not authorized to connect to Server";
+ }
}
else if (auditTrailLevel > 1)
{
@@ -737,6 +731,11 @@ ClientAuthorized(client, proto_n, auth_proto, string_n, auth_string)
* true purpose of the selfhosts list is to see who may change the
* access control list.
*/
+#ifdef LBX
+ if (restore_trans_conn) {
+ priv->trans_conn = NULL;
+ }
+#endif
return((char *)NULL);
}
diff --git a/xc/programs/Xserver/os/io.c b/xc/programs/Xserver/os/io.c
index ea0af5139..77bb79752 100644
--- a/xc/programs/Xserver/os/io.c
+++ b/xc/programs/Xserver/os/io.c
@@ -48,7 +48,7 @@ SOFTWARE.
* InsertFakeRequest, ResetCurrentRequest
*
*****************************************************************/
-/* $XFree86: xc/programs/Xserver/os/io.c,v 3.21 1999/11/19 13:55:10 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/os/io.c,v 3.22 2000/05/18 23:46:26 dawes Exp $ */
#ifdef WIN32
#include <X11/Xwinsock.h>
@@ -77,6 +77,8 @@ extern int errno;
#include "dixstruct.h"
#include "misc.h"
#ifdef LBX
+#include "colormapst.h"
+#include "propertyst.h"
#include "lbxserve.h"
#endif
diff --git a/xc/programs/Xserver/os/lbxio.c b/xc/programs/Xserver/os/lbxio.c
index cccd00823..ee565bd97 100644
--- a/xc/programs/Xserver/os/lbxio.c
+++ b/xc/programs/Xserver/os/lbxio.c
@@ -1,4 +1,4 @@
-/* $XFree86: xc/programs/Xserver/os/lbxio.c,v 3.10 1998/10/04 09:39:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/lbxio.c,v 3.11 2000/05/18 23:46:26 dawes Exp $ */
/*
Copyright 1996, 1998 The Open Group
@@ -68,6 +68,8 @@ extern int errno;
#include "opaque.h"
#include "dixstruct.h"
#include "misc.h"
+#include "colormapst.h"
+#include "propertyst.h"
#include "lbxserve.h"
/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
diff --git a/xc/programs/Xserver/os/secauth.c b/xc/programs/Xserver/os/secauth.c
index 678423a56..a0b41c9ea 100644
--- a/xc/programs/Xserver/os/secauth.c
+++ b/xc/programs/Xserver/os/secauth.c
@@ -20,7 +20,7 @@ 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/os/secauth.c,v 1.5 1998/10/11 11:23:44 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/secauth.c,v 1.8 2000/06/15 22:10:41 dawes Exp $ */
#include "X.h"
#include "os.h"
@@ -42,7 +42,7 @@ AuthCheckSitePolicy(
ClientPtr client,
char **reason)
{
- char *policy = *dataP;
+ CARD8 *policy = *(CARD8 **)dataP;
int length;
Bool permit;
int nPolicies;
@@ -56,7 +56,7 @@ AuthCheckSitePolicy(
}
permit = (*policy++ == 0);
- nPolicies = *policy++;
+ nPolicies = (CARD8) *policy++;
length -= 2;
@@ -70,7 +70,7 @@ AuthCheckSitePolicy(
return FALSE;
}
- strLen = *policy++;
+ strLen = (CARD8) *policy++;
if (--length < strLen) {
*reason = InvalidPolicyReason;
return FALSE;
@@ -82,7 +82,7 @@ AuthCheckSitePolicy(
{
char *testPolicy = sitePolicies[sitePolicy];
if ((strLen == strlen(testPolicy)) &&
- (strncmp(policy, testPolicy, strLen) == 0))
+ (strncmp((char *)policy, testPolicy, strLen) == 0))
{
found = TRUE; /* need to continue parsing the policy... */
break;
@@ -102,7 +102,7 @@ AuthCheckSitePolicy(
}
*data_lengthP = length;
- *dataP = policy;
+ *dataP = (char *)policy;
return TRUE;
}
diff --git a/xc/programs/Xserver/os/utils.c b/xc/programs/Xserver/os/utils.c
index 35da9a210..337cfb6cd 100644
--- a/xc/programs/Xserver/os/utils.c
+++ b/xc/programs/Xserver/os/utils.c
@@ -45,7 +45,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
OR PERFORMANCE OF THIS SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.56 2000/02/23 20:30:18 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/os/utils.c,v 3.59 2000/06/17 00:27:34 dawes Exp $ */
#ifdef WIN32
#include <X11/Xwinsock.h>
@@ -993,6 +993,25 @@ char *argv[];
{
SmartScheduleDisable = TRUE;
}
+ else if ( strcmp( argv[i], "-schedInterval") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleInterval = atoi(argv[i]);
+ SmartScheduleSlice = SmartScheduleInterval;
+ }
+ else
+ UseMsg();
+ }
+ else if ( strcmp( argv[i], "-schedMax") == 0)
+ {
+ if (++i < argc)
+ {
+ SmartScheduleMaxSlice = atoi(argv[i]);
+ }
+ else
+ UseMsg();
+ }
#endif
else
{
@@ -1542,17 +1561,59 @@ ErrorF(
#ifdef SMART_SCHEDULE
+unsigned long SmartScheduleIdleCount;
+Bool SmartScheduleIdle;
+Bool SmartScheduleTimerStopped;
+
#ifdef SIGVTALRM
#define SMART_SCHEDULE_POSSIBLE
#endif
#ifdef SMART_SCHEDULE_POSSIBLE
-#define SMART_SCHEDULE_SIGNAL SIGVTALRM
+#define SMART_SCHEDULE_SIGNAL SIGALRM
+#define SMART_SCHEDULE_TIMER ITIMER_REAL
+#endif
void
+SmartScheduleStopTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = 0;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = 0;
+ (void) setitimer (ITIMER_REAL, &timer, 0);
+ SmartScheduleTimerStopped = TRUE;
+#endif
+}
+
+Bool
+SmartScheduleStartTimer (void)
+{
+#ifdef SMART_SCHEDULE_POSSIBLE
+ struct itimerval timer;
+
+ SmartScheduleTimerStopped = FALSE;
+ timer.it_interval.tv_sec = 0;
+ timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
+ timer.it_value.tv_sec = 0;
+ timer.it_value.tv_usec = SmartScheduleInterval * 1000;
+ return setitimer (ITIMER_REAL, &timer, 0) >= 0;
+#endif
+ return FALSE;
+}
+
+#ifdef SMART_SCHEDULE_POSSIBLE
+void
SmartScheduleTimer (int sig)
{
SmartScheduleTime += SmartScheduleInterval;
+ if (SmartScheduleIdle)
+ {
+ SmartScheduleStopTimer ();
+ }
}
#endif
@@ -1578,11 +1639,7 @@ SmartScheduleInit (void)
return FALSE;
}
/* Set up the virtual timer */
- timer.it_interval.tv_sec = 0;
- timer.it_interval.tv_usec = SmartScheduleInterval * 1000;
- timer.it_value.tv_sec = 0;
- timer.it_value.tv_usec = SmartScheduleInterval * 1000;
- if (setitimer (ITIMER_VIRTUAL, &timer, 0) < 0)
+ if (!SmartScheduleStartTimer ())
{
perror ("scheduling timer");
return FALSE;
@@ -1607,7 +1664,9 @@ System(command)
char *command;
{
int pid, p;
- void (*csig)();
+#ifdef SIGCHLD
+ void (*csig)(int);
+#endif
int status;
if (!command)
@@ -1617,7 +1676,9 @@ System(command)
csig = signal(SIGCHLD, SIG_DFL);
#endif
+#ifdef DEBUG
ErrorF("System: `%s'\n", command);
+#endif
switch (pid = fork()) {
case -1: /* error */
@@ -1655,7 +1716,6 @@ Popen(command, type)
struct pid *cur;
FILE *iop;
int pdes[2], pid;
- void (*csig)();
if (command == NULL || type == NULL)
return NULL;
@@ -1713,7 +1773,7 @@ Popen(command, type)
cur->next = pidlist;
pidlist = cur;
-#if 0
+#ifdef DEBUG
ErrorF("Popen: `%s', fp = %p\n", command, iop);
#endif
@@ -1725,11 +1785,10 @@ Pclose(iop)
pointer iop;
{
struct pid *cur, *last;
- int omask;
int pstat;
int pid;
-#if 0
+#ifdef DEBUG
ErrorF("Pclose: fp = %p\n", iop);
#endif
@@ -1754,3 +1813,190 @@ Pclose(iop)
return pid == -1 ? -1 : pstat;
}
#endif /* !WIN32 && !__EMX__ */
+
+
+/*
+ * CheckUserParameters: check for long command line arguments and long
+ * environment variables. By default, these checks are only done when
+ * the server's euid != ruid. In 3.3.x, these checks were done in an
+ * external wrapper utility.
+ */
+
+/* Consider LD* variables insecure? */
+#ifndef REMOVE_ENV_LD
+#define REMOVE_ENV_LD 1
+#endif
+
+/* Remove long environment variables? */
+#ifndef REMOVE_LONG_ENV
+#define REMOVE_LONG_ENV 1
+#endif
+
+/* Check args and env only if running setuid (euid == 0 && euid != uid) ? */
+#ifndef CHECK_EUID
+#define CHECK_EUID 1
+#endif
+
+/*
+ * Maybe the locale can be faked to make isprint(3) report that everything
+ * is printable? Avoid it by default.
+ */
+#ifndef USE_ISPRINT
+#define USE_ISPRINT 0
+#endif
+
+#define MAX_ARG_LENGTH 128
+#define MAX_ENV_LENGTH 256
+#define MAX_ENV_PATH_LENGTH 2048 /* Limit for *PATH and TERMCAP */
+
+#if USE_ISPRINT
+#include <ctype.h>
+#define checkPrintable(c) isprint(c)
+#else
+#define checkPrintable(c) (((c) & 0x7f) >= 0x20 && ((c) & 0x7f) != 0x7f)
+#endif
+
+enum BadCode {
+ NotBad = 0,
+ UnsafeArg,
+ ArgTooLong,
+ UnprintableArg,
+ EnvTooLong,
+ InternalError
+};
+
+#define ARGMSG \
+ "\nIf the arguments used are valid, and have been rejected incorrectly\n" \
+ "please send details of the arguments and why they are valid to\n" \
+ "XFree86@XFree86.org. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+#define ENVMSG \
+ "\nIf the environment is valid, and have been rejected incorrectly\n" \
+ "please send details of the environment and why it is valid to\n" \
+ "XFree86@XFree86.org. In the meantime, you can start the Xserver as\n" \
+ "the \"super user\" (root).\n"
+
+void
+CheckUserParameters(int argc, char **argv, char **envp)
+{
+ enum BadCode bad = NotBad;
+ int i = 0, j;
+ char *a, *e = NULL;
+#if defined(__QNX__) && !defined(__QNXNTO__)
+ char cmd_name[64];
+#endif
+
+#if CHECK_EUID
+ if (geteuid() == 0 && getuid() != geteuid())
+#endif
+ {
+ /* Check each argv[] */
+ for (i = 1; i < argc; i++) {
+ if (strlen(argv[i]) > MAX_ARG_LENGTH) {
+ bad = ArgTooLong;
+ break;
+ }
+ a = argv[i];
+ while (*a) {
+ if (checkPrintable(*a) == 0) {
+ bad = UnprintableArg;
+ break;
+ }
+ a++;
+ }
+ if (bad)
+ break;
+ }
+ if (!bad) {
+ /* Check each envp[] */
+ for (i = 0; envp[i]; i++) {
+
+ /* Check for bad environment variables and values */
+#if REMOVE_ENV_LD
+ while (envp[i] && (strncmp(envp[i], "LD", 2) == 0)) {
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ }
+#endif
+ if (envp[i] && (strlen(envp[i]) > MAX_ENV_LENGTH)) {
+#if REMOVE_LONG_ENV
+#ifdef ENVDEBUG
+ ErrorF("CheckUserParameters: removing %s from the "
+ "environment\n", strtok(envp[i], "="));
+#endif
+ for (j = i; envp[j]; j++) {
+ envp[j] = envp[j+1];
+ }
+ i--;
+#else
+ char *eq;
+ int len;
+
+ eq = strchr(envp[i], '=');
+ if (!eq)
+ continue;
+ len = eq - envp[i];
+ e = malloc(len + 1);
+ if (!e) {
+ bad = InternalError;
+ break;
+ }
+ strncpy(e, envp[i], len);
+ e[len] = 0;
+ if (len >= 4 &&
+ (strcmp(e + len - 4, "PATH") == 0 ||
+ strcmp(e, "TERMCAP") == 0)) {
+ if (strlen(envp[i]) > MAX_ENV_PATH_LENGTH) {
+ bad = EnvTooLong;
+ break;
+ } else {
+ free(e);
+ }
+ } else {
+ bad = EnvTooLong;
+ break;
+ }
+#endif
+ }
+ }
+ }
+ }
+ switch (bad) {
+ case NotBad:
+ return;
+ case UnsafeArg:
+ ErrorF("Command line argument number %d is unsafe\n", i);
+ ErrorF(ARGMSG);
+ break;
+ case ArgTooLong:
+ ErrorF("Command line argument number %d is too long\n", i);
+ ErrorF(ARGMSG);
+ break;
+ case UnprintableArg:
+ ErrorF("Command line argument number %d contains unprintable"
+ " characters\n", i);
+ ErrorF(ARGMSG);
+ break;
+ case EnvTooLong:
+ ErrorF("Environment variable `%s' is too long\n", e);
+ ErrorF(ENVMSG);
+ break;
+ case InternalError:
+ ErrorF("Internal Error\n");
+ break;
+ default:
+ ErrorF("Unknown error\n");
+ ErrorF(ARGMSG);
+ ErrorF(ENVMSG);
+ break;
+ }
+ FatalError("X server aborted because of unsafe environment\n");
+}
+
+
diff --git a/xc/programs/Xserver/os/xalloc.c b/xc/programs/Xserver/os/xalloc.c
index 3ae509ce6..3847be7ac 100644
--- a/xc/programs/Xserver/os/xalloc.c
+++ b/xc/programs/Xserver/os/xalloc.c
@@ -25,7 +25,7 @@ dealings in this Software without prior written authorization from
Pascal Haible.
*/
-/* $XFree86: xc/programs/Xserver/os/xalloc.c,v 3.25 2000/02/22 01:03:25 mvojkovi Exp $ */
+/* $XFree86: xc/programs/Xserver/os/xalloc.c,v 3.26 2000/05/18 23:21:42 dawes Exp $ */
/* Only used if INTERNAL_MALLOC is defined
* - otherwise xalloc() in utils.c is used
@@ -413,7 +413,7 @@ Xalloc (unsigned long amount)
ptr[1] = MAGIC;
#endif /* XALLOC_DEBUG */
#ifdef SIZE_TAIL
- ((unsigned long *)((char *)ptr + amount))[-1] = MAGIC2;
+ ((unsigned long *)((char *)ptr + amount - TAIL_SIZE))[0] = MAGIC2;
#endif /* SIZE_TAIL */
ptr = (unsigned long *)((char *)ptr + SIZE_HEADER);
LOG_ALLOC("Xalloc-L", amount, ptr);
diff --git a/xc/programs/Xserver/record/Imakefile b/xc/programs/Xserver/record/Imakefile
index a1952b420..22d9523ae 100644
--- a/xc/programs/Xserver/record/Imakefile
+++ b/xc/programs/Xserver/record/Imakefile
@@ -1,29 +1,31 @@
-XCOMM $XFree86: xc/programs/Xserver/record/Imakefile,v 1.8 1999/08/14 10:50:20 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/record/Imakefile,v 1.10 2000/04/06 15:27:26 dawes Exp $
XCOMM
XCOMM
XCOMM $XConsortium: Imakefile /main/3 1996/09/28 17:15:43 rws $
-#define IHaveModules
+#if DoLoadableServer
+#define IHaveSubdirs
+#endif
+
#include <Server.tmpl>
#if DoLoadableServer
- MSRCS = recordmod.c
- MOBJS = recordmod.o
+ SUBDIRS = module
#endif
-
SRCS = record.c set.c $(MSRCS)
OBJS = record.o set.o $(MOBJS)
INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC)
LINTLIBS = ../dix/llib-ldix.ln
DEFINES = -DNDEBUG
-ModuleObjectRule()
-LibraryModuleTarget(record,$(OBJS))
+NormalLibraryObjectRule()
+NormalLibraryTarget(record,$(OBJS))
LintLibraryTarget(record,$(SRCS))
NormalLintTarget($(SRCS))
-InstallLibraryModule(record,$(MODULEDIR),extensions)
+#if DoLoadableServer
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+#endif
DependTarget()
-
-InstallDriverSDKLibraryModule(record,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/xc/programs/Xserver/record/module/Imakefile b/xc/programs/Xserver/record/module/Imakefile
new file mode 100644
index 000000000..31a28157f
--- /dev/null
+++ b/xc/programs/Xserver/record/module/Imakefile
@@ -0,0 +1,33 @@
+XCOMM $XFree86: xc/programs/Xserver/record/module/Imakefile,v 1.1 2000/04/05 18:14:03 dawes Exp $
+XCOMM
+XCOMM
+XCOMM $XConsortium: Imakefile /main/3 1996/09/28 17:15:43 rws $
+
+#define IHaveModules
+#include <Server.tmpl>
+
+#if DoLoadableServer
+ MSRCS = recordmod.c
+ MOBJS = recordmod.o
+#endif
+
+ SRCS = record.c set.c $(MSRCS)
+ OBJS = record.o set.o $(MOBJS)
+ INCLUDES = -I.. -I../../include -I$(XINCLUDESRC) -I$(EXTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln
+ DEFINES = -DNDEBUG
+
+LinkSourceFile(recordmod.c,..)
+LinkSourceFile(record.c,..)
+LinkSourceFile(set.c,..)
+
+ModuleObjectRule()
+LibraryModuleTarget(record,$(OBJS))
+LintLibraryTarget(record,$(SRCS))
+NormalLintTarget($(SRCS))
+
+InstallLibraryModule(record,$(MODULEDIR),extensions)
+
+DependTarget()
+
+InstallDriverSDKLibraryModule(record,$(DRIVERSDKMODULEDIR),extensions)
diff --git a/xc/programs/Xserver/xkb/Imakefile b/xc/programs/Xserver/xkb/Imakefile
index 58ed69bc7..f8cd9c915 100644
--- a/xc/programs/Xserver/xkb/Imakefile
+++ b/xc/programs/Xserver/xkb/Imakefile
@@ -1,5 +1,5 @@
XCOMM $TOG: Imakefile /main/12 1997/07/16 14:51:50 kaleb $
-XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.12 1999/04/17 09:08:51 dawes Exp $
+XCOMM $XFree86: xc/programs/Xserver/xkb/Imakefile,v 3.13 2000/06/13 23:15:52 dawes Exp $
#define SGIHyperOpt
#include <Server.tmpl>
@@ -40,7 +40,8 @@ XKB_DDXDEFS = XkbServerDefines
xkmread.o xkbtext.o xkbfmisc.o xkberrs.o xkbout.o maprules.o \
XKBMisc.o XKBMAlloc.o XKBAlloc.o XKBGAlloc.o \
$(XKBXI_OBJS) $(DDX_OBJS)
- INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC)
+ INCLUDES = -I../include -I$(XINCLUDESRC) -I$(EXTINCSRC) -I$(SERVERSRC)/Xext \
+ -I$(SERVERSRC)/mi
LINTLIBS = ../dix/llib-ldix.ln ../os/llib-los.ln
DEFINES = -DXKB_IN_SERVER $(EXTRA_ALLOC_DEFINES) $(XKB_DDXDEFS)
diff --git a/xc/programs/Xserver/xkb/ddxFakeMtn.c b/xc/programs/Xserver/xkb/ddxFakeMtn.c
index d864ce2d2..63c73b240 100644
--- a/xc/programs/Xserver/xkb/ddxFakeMtn.c
+++ b/xc/programs/Xserver/xkb/ddxFakeMtn.c
@@ -24,6 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/ddxFakeMtn.c,v 1.3 2000/06/14 18:20:34 dawes Exp $ */
#include <stdio.h>
#define NEED_EVENTS 1
@@ -36,12 +37,28 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include "XKBsrv.h"
#include "XI.h"
+#ifdef PANORAMIX
+#include "panoramiX.h"
+#include "panoramiXsrv.h"
+#endif
+
+#include "mipointer.h"
+#include "mipointrst.h"
+
extern WindowPtr GetSpriteWindow(
#if NeedFunctionPrototypes
void
#endif
);
+extern void NewCurrentScreen(
+#if NeedFunctionPrototypes
+ ScreenPtr /* newScreen */,
+ int /* x */,
+ int /* y */
+#endif
+);
+
void
#if NeedFunctionPrototypes
XkbDDXFakePointerMotion(unsigned flags,int x,int y)
@@ -52,25 +69,70 @@ XkbDDXFakePointerMotion(flags,x,y)
int y;
#endif
{
-ScreenPtr pScreen;
int oldX,oldY;
+ScreenPtr pScreen, oldScreen;
- pScreen= GetSpriteWindow()->drawable.pScreen;
- GetSpritePosition(&oldX,&oldY);
- if (flags&XkbSA_MoveAbsoluteX)
- oldX= x;
- else oldX+= x;
- if (flags&XkbSA_MoveAbsoluteY)
- oldY= y;
- else oldY+= y;
+ GetSpritePosition(&oldX, &oldY);
+ pScreen = oldScreen = GetSpriteWindow()->drawable.pScreen;
- if (oldX<0) oldX= 0;
- else if (oldX>=pScreen->width) oldX= pScreen->width-1;
- if (oldY<0) oldY= 0;
- else if (oldY>=pScreen->height) oldY= pScreen->height-1;
+#ifdef PANORAMIX
+ if (!noPanoramiXExtension) {
+ BoxRec box;
+ int i;
+ if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ oldX, oldY, &box)) {
+ FOR_NSCREENS(i) {
+ if(i == pScreen->myNum)
+ continue;
+ if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
+ oldX, oldY, &box)) {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
+ }
+ oldScreen = pScreen;
+
+ if (flags&XkbSA_MoveAbsoluteX)
+ oldX= x;
+ else oldX+= x;
+ if (flags&XkbSA_MoveAbsoluteY)
+ oldY= y;
+ else oldY+= y;
+
+ if(!POINT_IN_REGION(pScreen, &XineramaScreenRegions[pScreen->myNum],
+ oldX, oldY, &box)) {
+ FOR_NSCREENS(i) {
+ if(i == pScreen->myNum)
+ continue;
+ if(POINT_IN_REGION(pScreen, &XineramaScreenRegions[i],
+ oldX, oldY, &box)) {
+ pScreen = screenInfo.screens[i];
+ break;
+ }
+ }
+ }
+ oldX -= panoramiXdataPtr[pScreen->myNum].x;
+ oldY -= panoramiXdataPtr[pScreen->myNum].y;
+ }
+ else
+#endif
+ {
+ if (flags&XkbSA_MoveAbsoluteX)
+ oldX= x;
+ else oldX+= x;
+ if (flags&XkbSA_MoveAbsoluteY)
+ oldY= y;
+ else oldY+= y;
+
+#define GetScreenPrivate(s) ((miPointerScreenPtr) ((s)->devPrivates[miPointerScreenIndex].ptr))
+ (*(GetScreenPrivate(oldScreen))->screenFuncs->CursorOffScreen)
+ (&pScreen, &oldX, &oldY);
+ }
+
+ if (pScreen != oldScreen)
+ NewCurrentScreen(pScreen, oldX, oldY);
if (pScreen->SetCursorPosition)
(*pScreen->SetCursorPosition)(pScreen, oldX, oldY, TRUE);
- return;
}
-
diff --git a/xc/programs/Xserver/xkb/ddxLoad.c b/xc/programs/Xserver/xkb/ddxLoad.c
index 811944203..b67c64e9a 100644
--- a/xc/programs/Xserver/xkb/ddxLoad.c
+++ b/xc/programs/Xserver/xkb/ddxLoad.c
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.24 1999/01/31 12:22:21 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/ddxLoad.c,v 3.25 2000/06/15 22:04:13 dawes Exp $ */
#include <stdio.h>
#include <ctype.h>
@@ -140,10 +140,8 @@ char cmd[PATH_MAX],file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
+strlen(file)+strlen(xkm_output_dir)
+strlen(outFile)+53 > PATH_MAX)
{
-#ifdef DEBUG
ErrorF("compiler command for keymap (%s) exceeds max length\n",
names->keymap);
-#endif
return False;
}
#ifndef __EMX__
@@ -170,10 +168,8 @@ char cmd[PATH_MAX],file[PATH_MAX],xkm_output_dir[PATH_MAX],*map,*outFile;
+strlen(file)+strlen(xkm_output_dir)
+strlen(outFile)+49 > PATH_MAX)
{
-#ifdef DEBUG
ErrorF("compiler command for keymap (%s) exceeds max length\n",
names->keymap);
-#endif
return False;
}
sprintf(cmd,"xkbcomp -w %d -xkm %s%s -em1 %s -emp %s -eml %s keymap/%s %s%s.xkm",
@@ -237,6 +233,10 @@ int i;
sprintf(keymap,"server-%s",display);
}
else {
+ if (strlen(names->keymap) > PATH_MAX - 1) {
+ ErrorF("name of keymap (%s) exceeds max length\n", names->keymap);
+ return False;
+ }
strcpy(keymap,names->keymap);
}
@@ -255,10 +255,8 @@ int i;
+strlen(POST_ERROR_MSG1)+strlen(xkm_output_dir)
+strlen(keymap)+48 > PATH_MAX)
{
-#ifdef DEBUG
ErrorF("compiler command for keymap (%s) exceeds max length\n",
names->keymap);
-#endif
return False;
}
#ifndef WIN32
@@ -295,10 +293,8 @@ int i;
+strlen(ERROR_PREFIX)+strlen(POST_ERROR_MSG1)
+strlen(xkm_output_dir)+strlen(keymap)+44 > PATH_MAX)
{
-#ifdef DEBUG
ErrorF("compiler command for keymap (%s) exceeds max length\n",
names->keymap);
-#endif
return False;
}
#ifndef WIN32
diff --git a/xc/programs/Xserver/xkb/xkb.c b/xc/programs/Xserver/xkb/xkb.c
index 8628eccbe..ee5c32fb7 100644
--- a/xc/programs/Xserver/xkb/xkb.c
+++ b/xc/programs/Xserver/xkb/xkb.c
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/xkb.c,v 3.12 1997/06/22 10:16:59 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkb.c,v 3.13 2000/04/04 19:25:22 dawes Exp $ */
#include <stdio.h>
#include "X.h"
@@ -2397,13 +2397,13 @@ unsigned first,last;
server->behaviors[wire->key].type= wire->type;
server->behaviors[wire->key].data= wire->data;
if ((wire->type==XkbKB_RadioGroup)&&(((int)wire->data)>maxRG))
- maxRG= wire->data;
+ maxRG= wire->data + 1;
}
wire++;
}
if (maxRG>(int)xkbi->nRadioGroups) {
- int sz = (maxRG+1)*sizeof(XkbRadioGroupRec);
+ int sz = maxRG*sizeof(XkbRadioGroupRec);
if (xkbi->radioGroups)
xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz);
else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz);
@@ -2411,7 +2411,7 @@ unsigned first,last;
if (xkbi->nRadioGroups)
bzero(&xkbi->radioGroups[xkbi->nRadioGroups],
(maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec));
- xkbi->nRadioGroups= maxRG+1;
+ xkbi->nRadioGroups= maxRG;
}
else xkbi->nRadioGroups= 0;
/* should compute members here */
diff --git a/xc/programs/Xserver/xkb/xkbActions.c b/xc/programs/Xserver/xkb/xkbActions.c
index be184e893..f136bc832 100644
--- a/xc/programs/Xserver/xkb/xkbActions.c
+++ b/xc/programs/Xserver/xkb/xkbActions.c
@@ -1,5 +1,4 @@
/* $XConsortium: xkbActions.c /main/3 1996/03/01 14:31:12 kaleb $ */
-/* $XFree86: xc/programs/Xserver/xkb/xkbActions.c,v 3.2 2000/02/09 13:30:47 dawes Exp $ */
/************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
@@ -25,6 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
+/* $XFree86: xc/programs/Xserver/xkb/xkbActions.c,v 3.3 2000/04/04 19:25:23 dawes Exp $ */
#include <stdio.h>
#include <math.h>
@@ -845,7 +845,7 @@ XkbEventCauseRec cause;
filter->keycode= 0;
filter->active= 0;
}
- return 0;
+ return 1;
}
static int
@@ -929,7 +929,7 @@ XkbStateRec old;
unsigned mods,mask,oldCoreState,oldCorePrevState;
if ((filter->keycode!=0)&&(filter->keycode!=keycode))
- return 0;
+ return 1;
GetSpritePosition(&x,&y);
ev.u.keyButtonPointer.time = GetTimeInMillis();
@@ -983,8 +983,6 @@ unsigned mods,mask,oldCoreState,oldCorePrevState;
xkbi->device->key->prev_state= oldCorePrevState;
xkbi->state= old;
}
-
- return 0;
}
else if (filter->keycode==keycode) {
@@ -1019,9 +1017,8 @@ unsigned mods,mask,oldCoreState,oldCorePrevState;
filter->keycode= 0;
filter->active= 0;
- return 0;
}
- return 0;
+ return 1;
}
#ifdef XINPUT
diff --git a/xc/programs/Xserver/xkb/xkbEvents.c b/xc/programs/Xserver/xkb/xkbEvents.c
index cc18dd974..77141fca2 100644
--- a/xc/programs/Xserver/xkb/xkbEvents.c
+++ b/xc/programs/Xserver/xkb/xkbEvents.c
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/xkbEvents.c,v 3.4 1997/12/14 02:55:42 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbEvents.c,v 3.5 2000/06/13 23:15:52 dawes Exp $ */
#include <stdio.h>
#define NEED_EVENTS 1
@@ -895,7 +895,7 @@ XkbFilterEvents(pClient,nEvents,xE)
xEvent *xE;
#endif
{
-int i;
+int i, button_mask;
DeviceIntPtr pXDev = (DeviceIntPtr)LookupKeyboardDevice();
XkbSrvInfoPtr xkbi;
@@ -946,6 +946,19 @@ XkbSrvInfoPtr xkbi;
state= xkbi->state.compat_lookup_mods;
xE[0].u.keyButtonPointer.state= state;
}
+ button_mask = 1 << xE[0].u.u.detail;
+ if (xE[0].u.u.type == ButtonPress &&
+ ((xE[0].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
+ (xkbi->lockedPtrButtons & button_mask) == button_mask) {
+#ifdef DEBUG
+ /* If the MouseKeys is pressed, and the "real" mouse is also pressed
+ * when the mouse is released, the server does not behave properly.
+ * Faking a release of the button here solves the problem.
+ */
+ ErrorF("Faking release of button %d\n", xE[0].u.u.detail);
+#endif
+ XkbDDXFakePointerButton(ButtonRelease, xE[0].u.u.detail);
+ }
}
else {
register CARD8 type;
@@ -980,6 +993,15 @@ XkbSrvInfoPtr xkbi;
xE->u.enterLeave.state&= 0x1F00;
xE->u.enterLeave.state|= xkbi->state.compat_grab_mods;
}
+ button_mask = 1 << xE[i].u.u.detail;
+ if (type == ButtonPress &&
+ ((xE[i].u.keyButtonPointer.state >> 7) & button_mask) == button_mask &&
+ (xkbi->lockedPtrButtons & button_mask) == button_mask) {
+#ifdef DEBUG
+ ErrorF("Faking release of button %d\n", xE[i].u.u.detail);
+#endif
+ XkbDDXFakePointerButton(ButtonRelease, xE[i].u.u.detail);
+ }
}
}
return True;
diff --git a/xc/programs/Xserver/xkb/xkbInit.c b/xc/programs/Xserver/xkb/xkbInit.c
index 61204c1d0..d8bae6905 100644
--- a/xc/programs/Xserver/xkb/xkbInit.c
+++ b/xc/programs/Xserver/xkb/xkbInit.c
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/xkbInit.c,v 3.15 1998/10/04 09:39:55 dawes Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbInit.c,v 3.17 2000/06/15 20:50:03 dawes Exp $ */
#include <stdio.h>
#include <stdlib.h>
@@ -684,7 +684,7 @@ XkbFileInfo finfo;
KeySymsRec tmpSyms,*pSyms;
CARD8 tmpMods[XkbMaxLegalKeyCode+1],*pMods;
char name[PATH_MAX],*rules;
-Bool ok;
+Bool ok=False;
XPointer config;
XkbComponentNamesRec cfgNames;
XkbRF_VarDefsRec defs;
@@ -702,12 +702,18 @@ XkbRF_VarDefsRec defs;
XkbComponentNamesRec rNames;
bzero(&rNames,sizeof(XkbComponentNamesRec));
if (XkbDDXNamesFromRules(dev,rules,&defs,&rNames)) {
- if (rNames.keymap) names->keymap= rNames.keymap;
- if (rNames.keycodes) names->keycodes= rNames.keycodes;
- if (rNames.types) names->types= rNames.types;
- if (rNames.compat) names->compat= rNames.compat;
- if (rNames.symbols) names->symbols= rNames.symbols;
- if (rNames.geometry) names->geometry= rNames.geometry;
+ if (rNames.keymap && !names->keymap)
+ names->keymap = rNames.keymap;
+ if (rNames.keycodes && !names->keycodes)
+ names->keycodes = rNames.keycodes;
+ if (rNames.types && !names->types)
+ names->types = rNames.types;
+ if (rNames.compat && !names->compat)
+ names->compat = rNames.compat;
+ if (rNames.symbols && !names->symbols)
+ names->symbols = rNames.symbols;
+ if (rNames.geometry && !names->geometry)
+ names->geometry = rNames.geometry;
XkbSetRulesUsed(&defs);
}
}
@@ -718,9 +724,18 @@ XkbRF_VarDefsRec defs;
if (cfgNames.symbols) names->symbols= cfgNames.symbols;
if (cfgNames.geometry) names->geometry= cfgNames.geometry;
- if ((XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0,
- &finfo,name,PATH_MAX))&&
- (finfo.xkb!=NULL)) {
+ if (names->keymap) {
+ XkbComponentNamesRec tmpNames;
+ bzero(&tmpNames,sizeof(XkbComponentNamesRec));
+ tmpNames.keymap = names->keymap;
+ ok = (Bool) XkbDDXLoadKeymapByNames(dev,&tmpNames,XkmAllIndicesMask,0,
+ &finfo,name,PATH_MAX);
+ }
+ if (!(ok && (finfo.xkb!=NULL)))
+ ok = (Bool) XkbDDXLoadKeymapByNames(dev,names,XkmAllIndicesMask,0,
+ &finfo,name,PATH_MAX);
+
+ if (ok && (finfo.xkb!=NULL)) {
XkbDescPtr xkb;
int minKC,maxKC;
@@ -911,8 +926,13 @@ XkbProcessArguments(argc,argv,i)
}
else if (strncmp(argv[i], "-xkbmap", 7) == 0) {
if(++i < argc) {
- XkbInitialMap= argv[i];
- return 2;
+ if (strlen(argv[i]) < PATH_MAX) {
+ XkbInitialMap= argv[i];
+ return 2;
+ } else {
+ ErrorF("-xkbmap pathname too long\n");
+ return -1;
+ }
}
else {
return -1;
@@ -920,8 +940,13 @@ XkbProcessArguments(argc,argv,i)
}
else if (strncmp(argv[i], "-xkbdb", 7) == 0) {
if(++i < argc) {
- XkbDB= argv[i];
- return 2;
+ if (strlen(argv[i]) < PATH_MAX) {
+ XkbDB= argv[i];
+ return 2;
+ } else {
+ ErrorF("-xkbdb pathname too long\n");
+ return -1;
+ }
}
else {
return -1;
diff --git a/xc/programs/Xserver/xkb/xkbPrKeyEv.c b/xc/programs/Xserver/xkb/xkbPrKeyEv.c
index e52bfda72..d73cf4c1c 100644
--- a/xc/programs/Xserver/xkb/xkbPrKeyEv.c
+++ b/xc/programs/Xserver/xkb/xkbPrKeyEv.c
@@ -24,7 +24,7 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
-/* $XFree86: xc/programs/Xserver/xkb/xkbPrKeyEv.c,v 3.6 1997/07/12 12:09:42 hohndel Exp $ */
+/* $XFree86: xc/programs/Xserver/xkb/xkbPrKeyEv.c,v 3.7 2000/04/04 19:25:24 dawes Exp $ */
#include <stdio.h>
#include <math.h>
@@ -54,6 +54,7 @@ KeyClassPtr keyc = keybd->key;
XkbSrvInfoPtr xkbi;
int key;
XkbBehavior behavior;
+unsigned ndx;
xkbi= keyc->xkbInfo;
key= xE->u.u.detail;
@@ -107,34 +108,33 @@ XkbBehavior behavior;
}
break;
case XkbKB_RadioGroup:
- if ( xE->u.u.type == KeyRelease )
- return;
- else {
- unsigned ndx= (behavior.data&(~XkbKB_RGAllowNone));
- if ( ndx<xkbi->nRadioGroups ) {
- XkbRadioGroupPtr rg;
-
- rg = &xkbi->radioGroups[ndx];
- if ( rg->currentDown == xE->u.u.detail ) {
- if (behavior.data&XkbKB_RGAllowNone) {
- xE->u.u.type = KeyRelease;
- XkbHandleActions(keybd,keybd,xE,count);
- rg->currentDown= 0;
- }
- return;
- }
- if ( rg->currentDown!=0 ) {
- int key = xE->u.u.detail;
- xE->u.u.type= KeyRelease;
- xE->u.u.detail= rg->currentDown;
+ ndx= (behavior.data&(~XkbKB_RGAllowNone));
+ if ( ndx<xkbi->nRadioGroups ) {
+ XkbRadioGroupPtr rg;
+
+ if ( xE->u.u.type == KeyRelease )
+ return;
+
+ rg = &xkbi->radioGroups[ndx];
+ if ( rg->currentDown == xE->u.u.detail ) {
+ if (behavior.data&XkbKB_RGAllowNone) {
+ xE->u.u.type = KeyRelease;
XkbHandleActions(keybd,keybd,xE,count);
- xE->u.u.type= KeyPress;
- xE->u.u.detail= key;
- }
- rg->currentDown= key;
+ rg->currentDown= 0;
+ }
+ return;
+ }
+ if ( rg->currentDown!=0 ) {
+ int key = xE->u.u.detail;
+ xE->u.u.type= KeyRelease;
+ xE->u.u.detail= rg->currentDown;
+ XkbHandleActions(keybd,keybd,xE,count);
+ xE->u.u.type= KeyPress;
+ xE->u.u.detail= key;
}
- else ErrorF("InternalError! Illegal radio group %d\n",ndx);
+ rg->currentDown= key;
}
+ else ErrorF("InternalError! Illegal radio group %d\n",ndx);
break;
case XkbKB_Overlay1: case XkbKB_Overlay2:
{
diff --git a/xc/util/memleak/fmalloc.c b/xc/util/memleak/fmalloc.c
index 473fa8bfe..0c030d943 100644
--- a/xc/util/memleak/fmalloc.c
+++ b/xc/util/memleak/fmalloc.c
@@ -22,7 +22,7 @@ in this Software without prior written authorization from The Open Group.
* Author: Keith Packard, MIT X Consortium
*/
-/* $XFree86: xc/util/memleak/fmalloc.c,v 3.6 2000/02/12 03:40:07 dawes Exp $ */
+/* $XFree86: xc/util/memleak/fmalloc.c,v 3.8 2000/06/15 01:26:22 dawes Exp $ */
/*
@@ -157,6 +157,7 @@ unsigned long FindLeakAllocBreakpoint = ~0;
unsigned long FindLeakFreeBreakpoint = ~0;
unsigned long FindLeakTime;
int FindLeakCheckAlways = 0;
+int FindLeakValidateAlways = 0;
static void MarkActiveBlock ();
static int tree_insert (), tree_delete ();
@@ -550,6 +551,11 @@ malloc (desiredsize)
endOfStaticMemory = (mem *) sbrk(0);
if (FindLeakCheckAlways)
CheckMemory ();
+ else if (FindLeakValidateAlways)
+ {
+ ValidateActiveMemory ();
+ ValidateFreedMemory ();
+ }
size = RoundUp(desiredsize);
totalsize = TotalSize (size);
@@ -631,6 +637,11 @@ free (p)
AddFreedBlock (h);
if (FindLeakCheckAlways)
CheckMemory ();
+ else if (FindLeakValidateAlways)
+ {
+ ValidateActiveMemory ();
+ ValidateFreedMemory ();
+ }
}
char *
@@ -645,6 +656,8 @@ realloc (old, desiredsize)
new = malloc (desiredsize);
if (!new)
return NULL;
+ if (!old)
+ return new;
SEARCH(activeMemory, h, old);
if (!h)
{